Texture format rework (#21)
continuous-integration/drone/push Build is passing Details

- Adds number format information to the texture format names
- Adds several unsigned integer texture formats

Reviewed-on: #21
pull/22/head
cosmonaut 2022-09-13 20:51:41 +00:00
parent 764de140cc
commit f49c0ab190
3 changed files with 79 additions and 44 deletions

View File

@ -115,28 +115,38 @@ typedef enum Refresh_IndexElementSize
typedef enum Refresh_TextureFormat
{
/* Color Formats */
/* Unsigned Normalized Float Color Formats */
REFRESH_TEXTUREFORMAT_R8G8B8A8,
REFRESH_TEXTUREFORMAT_B8G8R8A8,
REFRESH_TEXTUREFORMAT_R5G6B5,
REFRESH_TEXTUREFORMAT_A1R5G5B5,
REFRESH_TEXTUREFORMAT_B4G4R4A4,
REFRESH_TEXTUREFORMAT_BC1,
REFRESH_TEXTUREFORMAT_BC2,
REFRESH_TEXTUREFORMAT_BC3,
REFRESH_TEXTUREFORMAT_BC7,
REFRESH_TEXTUREFORMAT_R8G8_SNORM,
REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM,
REFRESH_TEXTUREFORMAT_A2R10G10B10,
REFRESH_TEXTUREFORMAT_R16G16,
REFRESH_TEXTUREFORMAT_R16G16B16A16,
REFRESH_TEXTUREFORMAT_R8,
REFRESH_TEXTUREFORMAT_R32_SFLOAT,
REFRESH_TEXTUREFORMAT_R32G32_SFLOAT,
REFRESH_TEXTUREFORMAT_R32G32B32A32_SFLOAT,
/* Compressed Unsigned Normalized Float Color Formats */
REFRESH_TEXTUREFORMAT_BC1,
REFRESH_TEXTUREFORMAT_BC2,
REFRESH_TEXTUREFORMAT_BC3,
REFRESH_TEXTUREFORMAT_BC7,
/* Signed Normalized Float Color Formats */
REFRESH_TEXTUREFORMAT_R8G8_SNORM,
REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM,
/* Signed Float Color Formats */
REFRESH_TEXTUREFORMAT_R16_SFLOAT,
REFRESH_TEXTUREFORMAT_R16G16_SFLOAT,
REFRESH_TEXTUREFORMAT_R16G16B16A16_SFLOAT,
REFRESH_TEXTUREFORMAT_R32_SFLOAT,
REFRESH_TEXTUREFORMAT_R32G32_SFLOAT,
REFRESH_TEXTUREFORMAT_R32G32B32A32_SFLOAT,
/* Unsigned Integer Color Formats */
REFRESH_TEXTUREFORMAT_R8_UINT,
REFRESH_TEXTUREFORMAT_R8G8_UINT,
REFRESH_TEXTUREFORMAT_R8G8B8A8_UINT,
REFRESH_TEXTUREFORMAT_R16_UINT,
REFRESH_TEXTUREFORMAT_R16G16_UINT,
REFRESH_TEXTUREFORMAT_R16G16B16A16_UINT,
/* Depth Formats */
REFRESH_TEXTUREFORMAT_D16_UNORM,
REFRESH_TEXTUREFORMAT_D32_SFLOAT,

View File

@ -60,22 +60,28 @@ static inline uint32_t Texture_GetFormatSize(
case REFRESH_TEXTUREFORMAT_BC7:
return 16;
case REFRESH_TEXTUREFORMAT_R8:
case REFRESH_TEXTUREFORMAT_R8_UINT:
return 1;
case REFRESH_TEXTUREFORMAT_R5G6B5:
case REFRESH_TEXTUREFORMAT_B4G4R4A4:
case REFRESH_TEXTUREFORMAT_A1R5G5B5:
case REFRESH_TEXTUREFORMAT_R16_SFLOAT:
case REFRESH_TEXTUREFORMAT_R8G8_SNORM:
case REFRESH_TEXTUREFORMAT_R8G8_UINT:
case REFRESH_TEXTUREFORMAT_R16_UINT:
return 2;
case REFRESH_TEXTUREFORMAT_R8G8B8A8:
case REFRESH_TEXTUREFORMAT_R32_SFLOAT:
case REFRESH_TEXTUREFORMAT_R16G16_SFLOAT:
case REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM:
case REFRESH_TEXTUREFORMAT_A2R10G10B10:
case REFRESH_TEXTUREFORMAT_R8G8B8A8_UINT:
case REFRESH_TEXTUREFORMAT_R16G16_UINT:
return 4;
case REFRESH_TEXTUREFORMAT_R16G16B16A16_SFLOAT:
case REFRESH_TEXTUREFORMAT_R16G16B16A16:
case REFRESH_TEXTUREFORMAT_R32G32_SFLOAT:
case REFRESH_TEXTUREFORMAT_R16G16B16A16_UINT:
return 8;
case REFRESH_TEXTUREFORMAT_R32G32B32A32_SFLOAT:
return 16;

View File

@ -185,31 +185,37 @@ static const uint8_t DEVICE_PRIORITY[] =
static VkFormat RefreshToVK_SurfaceFormat[] =
{
VK_FORMAT_R8G8B8A8_UNORM, /* R8G8B8A8 */
VK_FORMAT_B8G8R8A8_UNORM, /* B8G8R8A8 */
VK_FORMAT_R5G6B5_UNORM_PACK16, /* R5G6B5 */
VK_FORMAT_A1R5G5B5_UNORM_PACK16, /* A1R5G5B5 */
VK_FORMAT_B4G4R4A4_UNORM_PACK16, /* B4G4R4A4 */
VK_FORMAT_BC1_RGBA_UNORM_BLOCK, /* BC1 */
VK_FORMAT_BC2_UNORM_BLOCK, /* BC3 */
VK_FORMAT_BC3_UNORM_BLOCK, /* BC5 */
VK_FORMAT_BC7_UNORM_BLOCK, /* BC7 */
VK_FORMAT_R8G8B8A8_UNORM, /* R8G8B8A8_UNORM */
VK_FORMAT_B8G8R8A8_UNORM, /* B8G8R8A8_UNORM */
VK_FORMAT_R5G6B5_UNORM_PACK16, /* R5G6B5_UNORM */
VK_FORMAT_A1R5G5B5_UNORM_PACK16, /* A1R5G5B5_UNORM */
VK_FORMAT_B4G4R4A4_UNORM_PACK16, /* B4G4R4A4_UNORM */
VK_FORMAT_A2R10G10B10_UNORM_PACK32, /* A2R10G10B10_UNORM */
VK_FORMAT_R16G16_UNORM, /* R16G16_UNORM */
VK_FORMAT_R16G16B16A16_UNORM, /* R16G16B16A16_UNORM */
VK_FORMAT_R8_UNORM, /* R8_UNORM */
VK_FORMAT_BC1_RGBA_UNORM_BLOCK, /* BC1_UNORM */
VK_FORMAT_BC2_UNORM_BLOCK, /* BC2_UNORM */
VK_FORMAT_BC3_UNORM_BLOCK, /* BC3_UNORM */
VK_FORMAT_BC7_UNORM_BLOCK, /* BC7_UNORM */
VK_FORMAT_R8G8_SNORM, /* R8G8_SNORM */
VK_FORMAT_R8G8B8A8_SNORM, /* R8G8B8A8_SNORM */
VK_FORMAT_A2R10G10B10_UNORM_PACK32, /* A2R10G10B10 */
VK_FORMAT_R16G16_UNORM, /* R16G16 */
VK_FORMAT_R16G16B16A16_UNORM, /* R16G16B16A16 */
VK_FORMAT_R8_UNORM, /* R8 */
VK_FORMAT_R32_SFLOAT, /* R32_SFLOAT */
VK_FORMAT_R32G32_SFLOAT, /* R32G32_SFLOAT */
VK_FORMAT_R32G32B32A32_SFLOAT, /* R32G32B32A32_SFLOAT */
VK_FORMAT_R16_SFLOAT, /* R16_SFLOAT */
VK_FORMAT_R16G16_SFLOAT, /* R16G16_SFLOAT */
VK_FORMAT_R16G16B16A16_SFLOAT, /* R16G16B16A16_SFLOAT */
VK_FORMAT_D16_UNORM, /* D16 */
VK_FORMAT_D32_SFLOAT, /* D32 */
VK_FORMAT_D16_UNORM_S8_UINT, /* D16S8 */
VK_FORMAT_D32_SFLOAT_S8_UINT /* D32S8 */
VK_FORMAT_R32_SFLOAT, /* R32_SFLOAT */
VK_FORMAT_R32G32_SFLOAT, /* R32G32_SFLOAT */
VK_FORMAT_R32G32B32A32_SFLOAT, /* R32G32B32A32_SFLOAT */
VK_FORMAT_R8_UINT, /* R8_UINT */
VK_FORMAT_R8G8_UINT, /* R8G8_UINT */
VK_FORMAT_R8G8B8A8_UINT, /* R8G8B8A8_UINT */
VK_FORMAT_R16_UINT, /* R16_UINT */
VK_FORMAT_R16G16_UINT, /* R16G16_UINT */
VK_FORMAT_R16G16B16A16_UINT, /* R16G16B16A16_UINT */
VK_FORMAT_D16_UNORM, /* D16_UNORM */
VK_FORMAT_D32_SFLOAT, /* D32_SFLOAT */
VK_FORMAT_D16_UNORM_S8_UINT, /* D16_UNORM_S8_UINT */
VK_FORMAT_D32_SFLOAT_S8_UINT /* D32_SFLOAT_S8_UINT */
};
static VkFormat RefreshToVK_VertexFormat[] =
@ -1908,6 +1914,7 @@ static inline uint32_t VULKAN_INTERNAL_BytesPerPixel(VkFormat format)
case VK_FORMAT_BC2_UNORM_BLOCK:
case VK_FORMAT_BC3_UNORM_BLOCK:
case VK_FORMAT_BC7_UNORM_BLOCK:
case VK_FORMAT_R16G16B16A16_UINT:
return 16;
case VK_FORMAT_R8G8B8A8_UNORM:
@ -1917,6 +1924,8 @@ static inline uint32_t VULKAN_INTERNAL_BytesPerPixel(VkFormat format)
case VK_FORMAT_R16G16_SFLOAT:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_D32_SFLOAT:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R16G16_UINT:
return 4;
case VK_FORMAT_R5G6B5_UNORM_PACK16:
@ -1925,12 +1934,15 @@ static inline uint32_t VULKAN_INTERNAL_BytesPerPixel(VkFormat format)
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R16_SFLOAT:
case VK_FORMAT_D16_UNORM:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R16_UINT:
return 2;
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R16G16B16A16_SFLOAT:
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
case VK_FORMAT_R8_UINT:
return 8;
case VK_FORMAT_R8_UNORM:
@ -1975,6 +1987,12 @@ static inline uint32_t VULKAN_INTERNAL_GetTextureBlockSize(
case VK_FORMAT_R16_SFLOAT:
case VK_FORMAT_R16G16_SFLOAT:
case VK_FORMAT_R16G16B16A16_SFLOAT:
case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R16_UINT:
case VK_FORMAT_R16G16_UINT:
case VK_FORMAT_R16G16B16A16_UINT:
return 1;
default:
Refresh_LogError("Unrecognized texture format!");
@ -10396,6 +10414,7 @@ static uint8_t VULKAN_INTERNAL_CreateLogicalDevice(
SDL_zero(deviceFeatures);
deviceFeatures.occlusionQueryPrecise = VK_TRUE;
deviceFeatures.fillModeNonSolid = VK_TRUE;
deviceFeatures.depthClamp = VK_TRUE;
/* creating the logical device */