mirror of
https://github.com/vortexgpgpu/vortex.git
synced 2025-04-23 21:39:10 -04:00
minor update
This commit is contained in:
parent
8add5efe66
commit
f6d210b67a
8 changed files with 505 additions and 516 deletions
|
@ -62,10 +62,7 @@ struct ColorARGB {
|
|||
this->value = rhs.value;
|
||||
}
|
||||
|
||||
uint32_t toRGBA() const {
|
||||
// swap B/R channels
|
||||
return (this->value & 0xff00ff00)
|
||||
| ((this->value >> 16) & 0xff)
|
||||
| ((this->value & 0xff) << 16);
|
||||
operator uint32_t() const {
|
||||
return this->value;
|
||||
}
|
||||
};
|
Binary file not shown.
Binary file not shown.
|
@ -20,11 +20,10 @@ void kernel_body(int task_id, void* arg) {
|
|||
uint32_t yoffset = task_id * _arg->tile_height;
|
||||
uint8_t* dst_ptr = (uint8_t*)(_arg->karg.dst_ptr + xoffset * _arg->karg.dst_stride + yoffset * _arg->karg.dst_pitch);
|
||||
|
||||
float fu = xoffset * _arg->deltaX;
|
||||
float fv = yoffset * _arg->deltaY;
|
||||
|
||||
for (uint32_t y = 0; y < _arg->tile_height; ++y) {
|
||||
uint32_t* dst_row = (uint32_t*)dst_ptr;
|
||||
float fu = xoffset * _arg->deltaX;
|
||||
for (uint32_t x = 0; x < _arg->tile_width; ++x) {
|
||||
int32_t u = (int32_t)(fu * (1<<20));
|
||||
int32_t v = (int32_t)(fv * (1<<20));
|
||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 16 KiB |
|
@ -81,7 +81,7 @@ int LoadTGA(const char *filename,
|
|||
default:
|
||||
std::abort();
|
||||
}
|
||||
*dst_bytes++ = color.toRGBA();
|
||||
*dst_bytes++ = color;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -108,6 +108,11 @@ int SaveTGA(const char *filename,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (bpp < 2 || bpp > 4) {
|
||||
std::cerr << "unsupported pixel stride: " << bpp << "!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tga_header_t header;
|
||||
header.idlength = 0;
|
||||
header.colormaptype = 0; // no palette
|
||||
|
@ -131,20 +136,7 @@ int SaveTGA(const char *filename,
|
|||
for (uint32_t y = 0; y < height; ++y) {
|
||||
const uint8_t* pixel_row = pixel_bytes;
|
||||
for (uint32_t x = 0; x < width; ++x) {
|
||||
// swap R/B color channels
|
||||
if (bpp == 4) {
|
||||
ofs.write((const char*)pixel_row + 2, 1);
|
||||
ofs.write((const char*)pixel_row + 1, 1);
|
||||
ofs.write((const char*)pixel_row + 0, 1);
|
||||
ofs.write((const char*)pixel_row + 3, 1);
|
||||
} else if (bpp == 3) {
|
||||
ofs.write((const char*)pixel_row + 2, 1);
|
||||
ofs.write((const char*)pixel_row + 1, 1);
|
||||
ofs.write((const char*)pixel_row + 0, 1);
|
||||
} else{
|
||||
std::cerr << "unsupported TGA bitsperpixel!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
ofs.write((const char*)pixel_row, bpp);
|
||||
pixel_row += bpp;
|
||||
}
|
||||
pixel_bytes -= pitch;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue