minor update

This commit is contained in:
Blaise Tine 2021-03-31 14:07:12 -04:00
parent 7b2f96bc6d
commit 1332fd1b67
8 changed files with 631 additions and 623 deletions

Binary file not shown.

Binary file not shown.

View file

@ -52,8 +52,8 @@ int main() {
targ.karg = *arg;
targ.tile_width = arg->dst_width;
targ.tile_height = (arg->dst_height + arg->num_tasks - 1) / arg->num_tasks;
targ.deltaX = 1.0f / (((float)arg->src_width) / arg->dst_width);
targ.deltaY = 1.0f / (((float)arg->src_height) / arg->dst_height);
targ.deltaX = 1.0f / arg->dst_width;
targ.deltaY = 1.0f / arg->dst_height;
vx_spawn_tasks(arg->num_tasks, kernel_body, &targ);
}

File diff suppressed because it is too large Load diff

Binary file not shown.

View file

@ -20,7 +20,7 @@
///////////////////////////////////////////////////////////////////////////////
const char* kernel_file = "kernel.bin";
const char* input_file = "palette.tga";
const char* input_file = "toad.tga";
const char* output_file = "output.tga";
float scale = 1.0f;

View file

@ -63,11 +63,13 @@ int LoadTGA(const char *filename,
return -1;
}
// Because the TGA is BGR instead of RGB, we must swap RG components
for (int i = 0; i < pitch; i += stride) {
auto tmp = line[i];
line[i] = line[i + 2];
line[i + 2] = tmp;
// TGA uses BGR instead of RGB, we must swap RG components
if (stride >= 3) {
for (int i = 0; i < pitch; i += stride) {
auto tmp = line[i];
line[i] = line[i + 2];
line[i + 2] = tmp;
}
}
}
break;
@ -116,7 +118,19 @@ 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) {
ofs.write((const char*)pixel_row, bpp);
// TGA uses BGR instead of RGB, we must swap RG components
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{
ofs.write((const char*)pixel_row, bpp);
}
pixel_row += bpp;
}
pixel_bytes -= pitch;

View file

@ -46,7 +46,7 @@ module VX_tex_sampler #(
VX_tex_format #(
.CORE_ID (CORE_ID),
.NUM_TEXELS (4)
) tex_format_texel (
) tex_format (
.texel_data (req_texels[i]),
.format (req_format),