mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[vulkan] Allow QFV_ImageFormat to select unorm or srgb
This is definitely something that should be selectable per image and not hard-coded into the engine.
This commit is contained in:
parent
1dff24dbd0
commit
e62b7d7b05
3 changed files with 9 additions and 8 deletions
|
@ -104,11 +104,12 @@ int QFV_MipLevels (int width, int height) __attribute__((const));
|
|||
/** Convert QFFormat to VkFormat
|
||||
*
|
||||
* \param format The format to convert.
|
||||
* \param srgb Select SRGB formats (non-zero) or UNORM (0).
|
||||
* \return The corresponding VkFormat.
|
||||
*
|
||||
* \note For tex_palette, VK_FORMAT_R8_UINT is returned. If \a format is
|
||||
* not a valid QFFormat, then VK_FORMAT_R8_SRGB is returned.
|
||||
*/
|
||||
VkFormat QFV_ImageFormat (QFFormat format);
|
||||
VkFormat QFV_ImageFormat (QFFormat format, int srgb);
|
||||
|
||||
#endif//__QF_Vulkan_image_h
|
||||
|
|
|
@ -107,7 +107,7 @@ vulkan_iqm_init_image (iqm_t *iqm, int meshnum, qfv_resobj_t *image)
|
|||
.type = qfv_res_image,
|
||||
.image = {
|
||||
.type = VK_IMAGE_TYPE_2D,
|
||||
.format = QFV_ImageFormat (tex->format),
|
||||
.format = QFV_ImageFormat (tex->format, 0),
|
||||
.extent = {
|
||||
.width = tex->width,
|
||||
.height = tex->height,
|
||||
|
@ -127,7 +127,7 @@ vulkan_iqm_init_image (iqm_t *iqm, int meshnum, qfv_resobj_t *image)
|
|||
.type = qfv_res_image,
|
||||
.image = {
|
||||
.type = VK_IMAGE_TYPE_2D,
|
||||
.format = QFV_ImageFormat (tex_rgba),
|
||||
.format = QFV_ImageFormat (tex_rgba, 0),
|
||||
.extent = {
|
||||
.width = 2,
|
||||
.height = 2,
|
||||
|
|
|
@ -267,20 +267,20 @@ QFV_MipLevels (int width, int height)
|
|||
}
|
||||
|
||||
VkFormat
|
||||
QFV_ImageFormat (QFFormat format)
|
||||
QFV_ImageFormat (QFFormat format, int srgb)
|
||||
{
|
||||
switch (format) {
|
||||
case tex_palette:
|
||||
return VK_FORMAT_R8_UINT;
|
||||
case tex_l:
|
||||
case tex_a:
|
||||
return VK_FORMAT_R8_UNORM;
|
||||
return srgb ? VK_FORMAT_R8_SRGB : VK_FORMAT_R8_UNORM;
|
||||
case tex_la:
|
||||
return VK_FORMAT_R8G8_UNORM;
|
||||
return srgb ? VK_FORMAT_R8G8_SRGB : VK_FORMAT_R8G8_UNORM;
|
||||
case tex_rgb:
|
||||
return VK_FORMAT_R8G8B8_UNORM; // SRGB?
|
||||
return srgb ? VK_FORMAT_R8G8B8_SRGB : VK_FORMAT_R8G8B8_UNORM;
|
||||
case tex_rgba:
|
||||
return VK_FORMAT_R8G8B8A8_UNORM;// SRGB?
|
||||
return srgb ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM;
|
||||
case tex_frgba:
|
||||
return VK_FORMAT_R32G32B32A32_SFLOAT;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue