[image] Add support for float rgba for vulkan

This commit is contained in:
Bill Currie 2021-01-20 01:18:47 +09:00
parent 82889a2c52
commit 2de1c02f61
4 changed files with 18 additions and 0 deletions

View file

@ -38,6 +38,7 @@ typedef enum QFFormat {
tex_la = 2,
tex_rgb = 3,
tex_rgba = 4,
tex_frgba = 5,
} QFFormat;
// could not use texture_t as that is used for models.

View file

@ -130,6 +130,15 @@ convert_tex (tex_t *tex)
for (i = 0; i < pixels; i++)
new->data[i] = convert_color (tex->data + i * bpp);
break;
case tex_frgba:
for (i = 0; i < pixels; i++) {
byte col[3];
col[0] = ((float *)tex->data)[i * 4 + 0] * 255;
col[1] = ((float *)tex->data)[i * 4 + 1] * 255;
col[2] = ((float *)tex->data)[i * 4 + 2] * 255;
new->data[i] = convert_color (col);
}
break;
}
return new;
}

View file

@ -100,6 +100,10 @@ QFV_CreateScrap (qfv_device_t *device, int size, QFFormat format)
bpp = 4;
fmt = VK_FORMAT_R8G8B8A8_UNORM;
break;
case tex_frgba:
bpp = 16;
fmt = VK_FORMAT_R32G32B32A32_SFLOAT;
break;
}
scrap_t *scrap = malloc (sizeof (scrap_t));

View file

@ -118,6 +118,10 @@ Vulkan_LoadTex (vulkan_ctx_t *ctx, tex_t *tex, int mip)
format = VK_FORMAT_R8G8B8A8_UNORM;
bpp = 4;
break;
case tex_frgba:
format = VK_FORMAT_R32G32B32A32_SFLOAT;
bpp = 16;
break;
}
if (format == VK_FORMAT_UNDEFINED) {
return 0;