diff --git a/lvk/HelpersImGui.cpp b/lvk/HelpersImGui.cpp index 6e76432a37..e7fe506e15 100644 --- a/lvk/HelpersImGui.cpp +++ b/lvk/HelpersImGui.cpp @@ -124,7 +124,7 @@ ImGuiRenderer::ImGuiRenderer(igl::IDevice& device, const char* defaultFontTTF, f int width, height; io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); fontTexture_ = device.createTexture({.type = igl::TextureType::TwoD, - .format = igl::TextureFormat::RGBA_UNorm8, + .format = igl::TextureFormat::RGBA_UN8, .width = (uint32_t)width, .height = (uint32_t)height, .usage = igl::TextureUsageBits_Sampled}, diff --git a/lvk/LVK.h b/lvk/LVK.h index 1390327bf8..a5afe506ba 100644 --- a/lvk/LVK.h +++ b/lvk/LVK.h @@ -374,45 +374,35 @@ enum class VertexFormat { enum TextureFormat : uint8_t { Invalid = 0, - - R_UNorm8, - + R_UN8, + R_UI16, + R_UN16, R_F16, - R_UInt16, - R_UNorm16, - RG_UNorm8, - - RGBA_UNorm8, - BGRA_UNorm8, - RGBA_SRGB, - BGRA_SRGB, - RG_F16, - RG_UInt16, - RG_UNorm16, - RGB10_A2_UNorm_Rev, - RGB10_A2_Uint_Rev, - BGR10_A2_Unorm, R_F32, - RGBA_F16, + RG_UN8, + RG_UI16, + RG_UN16, + RG_F16, + RG_F32, - RGBA_UInt32, + RGBA_UN8, + RGBA_UI32, + RGBA_F16, RGBA_F32, + RGBA_SRGB8, + + BGRA_UN8, + BGRA_SRGB8, + + ETC2_RGB8, + ETC2_SRGB8, + BC7_RGBA, - RGB8_ETC2, - SRGB8_ETC2, - RGB8_Punchthrough_A1_ETC2, - SRGB8_Punchthrough_A1_ETC2, - RG_EAC_UNorm, - RG_EAC_SNorm, - R_EAC_UNorm, - R_EAC_SNorm, - RGBA_BC7_UNORM_4x4, - - Z_UNorm16, - Z_UNorm24, - Z_UNorm32, - S8_UInt_Z24_UNorm, + Z_UN16, + Z_UN24, + Z_F32, + Z_UN24_S_UI8, }; enum LoadOp : uint8_t { diff --git a/samples/Tiny_Mesh.cpp b/samples/Tiny_Mesh.cpp index 89fea77d18..bd1588a0dd 100644 --- a/samples/Tiny_Mesh.cpp +++ b/samples/Tiny_Mesh.cpp @@ -213,7 +213,7 @@ static void initIGL() { texture0_ = device_->createTexture( { .type = TextureType::TwoD, - .format = igl::TextureFormat::BGRA_UNorm8, + .format = igl::TextureFormat::BGRA_UN8, .width = texWidth, .height = texHeight, .usage = igl::TextureUsageBits_Sampled, @@ -257,7 +257,7 @@ static void initIGL() { texture1_ = device_->createTexture( { .type = TextureType::TwoD, - .format = igl::TextureFormat::RGBA_UNorm8, + .format = igl::TextureFormat::RGBA_UN8, .width = (uint32_t)texWidth, .height = (uint32_t)texHeight, .usage = igl::TextureUsageBits_Sampled, diff --git a/samples/Tiny_MeshLarge.cpp b/samples/Tiny_MeshLarge.cpp index 0f4c8a0571..a06628dda7 100644 --- a/samples/Tiny_MeshLarge.cpp +++ b/samples/Tiny_MeshLarge.cpp @@ -584,7 +584,7 @@ void initIGL() { textureDummyWhite_ = device_->createTexture( { .type = igl::TextureType::TwoD, - .format = igl::TextureFormat::RGBA_UNorm8, + .format = igl::TextureFormat::RGBA_UN8, .width = 1, .height = 1, .usage = igl::TextureUsageBits_Sampled, @@ -1033,7 +1033,7 @@ void createShadowMap() { const uint32_t h = 4096; const TextureDesc desc = { .type = TextureType::TwoD, - .format = igl::TextureFormat::Z_UNorm16, + .format = igl::TextureFormat::Z_UN16, .width = w, .height = h, .usage = igl::TextureUsageBits_Attachment | igl::TextureUsageBits_Sampled, @@ -1050,7 +1050,7 @@ void createOffscreenFramebuffer() { const uint32_t h = height_; TextureDesc descDepth = { .type = TextureType::TwoD, - .format = igl::TextureFormat::Z_UNorm24, + .format = igl::TextureFormat::Z_UN24, .width = w, .height = h, .usage = igl::TextureUsageBits_Attachment | igl::TextureUsageBits_Sampled, @@ -1066,7 +1066,7 @@ void createOffscreenFramebuffer() { const uint8_t usage = TextureUsageBits_Attachment | TextureUsageBits_Sampled | TextureUsageBits_Storage; - const TextureFormat format = igl::TextureFormat::RGBA_UNorm8; + const TextureFormat format = igl::TextureFormat::RGBA_UN8; TextureDesc descColor = { .type = TextureType::TwoD, @@ -1344,7 +1344,7 @@ igl::TextureFormat gli2iglTextureFormat(gli::texture2d::format_type format) { return igl::TextureFormat::RG_F16; } IGL_ASSERT_MSG(false, "Code should NOT be reached"); - return igl::TextureFormat::RGBA_UNorm8; + return igl::TextureFormat::RGBA_UN8; } LoadedImage loadImage(const char* fileName, int channels) { @@ -1622,12 +1622,11 @@ void loadSkyboxTexture() { igl::TextureFormat formatFromChannels(uint32_t channels) { if (channels == 1) { - return igl::TextureFormat::R_UNorm8; + return igl::TextureFormat::R_UN8; } if (channels == 4) { - return kEnableCompression ? igl::TextureFormat::RGBA_BC7_UNORM_4x4 - : igl::TextureFormat::RGBA_UNorm8; + return kEnableCompression ? igl::TextureFormat::BC7_RGBA : igl::TextureFormat::RGBA_UN8; } return igl::TextureFormat::Invalid; diff --git a/src/igl/IGL.cpp b/src/igl/IGL.cpp index 9b493c34be..50e7aa75c5 100644 --- a/src/igl/IGL.cpp +++ b/src/igl/IGL.cpp @@ -82,40 +82,33 @@ size_t getTextureBytesPerRow(size_t texWidth, TextureFormat texFormat, size_t mi #define STENCIL(fmt, bpb) PROPERTIES(fmt, bpb, 1, 1, 1, 1, 1, 1, Flags::Stencil) TextureFormatProperties TextureFormatProperties::fromTextureFormat(TextureFormat format) { + switch (format) { INVALID(Invalid) - COLOR(R_UNorm8, 1) + COLOR(R_UN8, 1) + COLOR(R_UI16, 2) + COLOR(R_UN16, 2) COLOR(R_F16, 2) - COLOR(R_UInt16, 2) - COLOR(R_UNorm16, 2) - COLOR(RG_UNorm8, 2) - COLOR(RGBA_UNorm8, 4) - COLOR(BGRA_UNorm8, 4) - COLOR(RGBA_SRGB, 4) - COLOR(BGRA_SRGB, 4) - COLOR(RG_F16, 4) - COLOR(RG_UInt16, 4) - COLOR(RG_UNorm16, 4) - COLOR(RGB10_A2_UNorm_Rev, 4) - COLOR(RGB10_A2_Uint_Rev, 4) - COLOR(BGR10_A2_Unorm, 4) COLOR(R_F32, 4) + COLOR(RG_UN8, 2) + COLOR(RG_UI16, 4) + COLOR(RG_UN16, 4) + COLOR(RG_F16, 4) + COLOR(RG_F32, 8) + COLOR(RGBA_UN8, 4) + COLOR(RGBA_UI32, 16) COLOR(RGBA_F16, 8) - COLOR(RGBA_UInt32, 16) COLOR(RGBA_F32, 16) - COMPRESSED(RGB8_ETC2, 8, 4, 4, 1, 1, 1, 1) - COMPRESSED(SRGB8_ETC2, 8, 4, 4, 1, 1, 1, 1) - COMPRESSED(RGB8_Punchthrough_A1_ETC2, 8, 4, 4, 1, 1, 1, 1) - COMPRESSED(SRGB8_Punchthrough_A1_ETC2, 8, 4, 4, 1, 1, 1, 1) - COMPRESSED(RG_EAC_UNorm, 16, 4, 4, 1, 1, 1, 1) - COMPRESSED(RG_EAC_SNorm, 16, 4, 4, 1, 1, 1, 1) - COMPRESSED(R_EAC_UNorm, 8, 4, 4, 1, 1, 1, 1) - COMPRESSED(R_EAC_SNorm, 8, 4, 4, 1, 1, 1, 1) - COMPRESSED(RGBA_BC7_UNORM_4x4, 16, 4, 4, 1, 1, 1, 1) - DEPTH(Z_UNorm16, 2) - DEPTH(Z_UNorm24, 3) - DEPTH(Z_UNorm32, 4) - DEPTH_STENCIL(S8_UInt_Z24_UNorm, 4) + COLOR(RGBA_SRGB8, 4) + COLOR(BGRA_UN8, 4) + COLOR(BGRA_SRGB8, 4) + COMPRESSED(ETC2_RGB8, 8, 4, 4, 1, 1, 1, 1) + COMPRESSED(ETC2_SRGB8, 8, 4, 4, 1, 1, 1, 1) + COMPRESSED(BC7_RGBA, 16, 4, 4, 1, 1, 1, 1) + DEPTH(Z_UN16, 2) + DEPTH(Z_UN24, 3) + DEPTH(Z_F32, 4) + DEPTH_STENCIL(Z_UN24_S_UI8, 4) } #if defined(_MSC_VER) return TextureFormatProperties{}; diff --git a/src/igl/vulkan/Common.cpp b/src/igl/vulkan/Common.cpp index 03ec441a72..20bd95980f 100644 --- a/src/igl/vulkan/Common.cpp +++ b/src/igl/vulkan/Common.cpp @@ -53,69 +53,53 @@ VkFormat textureFormatToVkFormat(igl::TextureFormat format) { switch (format) { case TextureFormat::Invalid: return VK_FORMAT_UNDEFINED; - case TextureFormat::R_UNorm8: + case TextureFormat::R_UN8: return VK_FORMAT_R8_UNORM; - case TextureFormat::R_UNorm16: + case TextureFormat::R_UN16: return VK_FORMAT_R16_UNORM; case TextureFormat::R_F16: return VK_FORMAT_R16_SFLOAT; - case TextureFormat::R_UInt16: + case TextureFormat::R_UI16: return VK_FORMAT_R16_UINT; - case TextureFormat::RG_UNorm8: + case TextureFormat::RG_UN8: return VK_FORMAT_R8G8_UNORM; - case TextureFormat::RG_UNorm16: + case TextureFormat::RG_UN16: return VK_FORMAT_R16G16_UNORM; - case TextureFormat::BGRA_UNorm8: + case TextureFormat::BGRA_UN8: return VK_FORMAT_B8G8R8A8_UNORM; - case TextureFormat::RGBA_UNorm8: + case TextureFormat::RGBA_UN8: return VK_FORMAT_R8G8B8A8_UNORM; - case TextureFormat::RGBA_SRGB: + case TextureFormat::RGBA_SRGB8: return VK_FORMAT_R8G8B8A8_SRGB; - case TextureFormat::BGRA_SRGB: + case TextureFormat::BGRA_SRGB8: return VK_FORMAT_B8G8R8A8_SRGB; case TextureFormat::RG_F16: return VK_FORMAT_R16G16_SFLOAT; - case TextureFormat::RG_UInt16: + case TextureFormat::RG_F32: + return VK_FORMAT_R32G32_SFLOAT; + case TextureFormat::RG_UI16: return VK_FORMAT_R16G16_UINT; - case TextureFormat::RGB10_A2_UNorm_Rev: - return VK_FORMAT_A2R10G10B10_UNORM_PACK32; - case TextureFormat::RGB10_A2_Uint_Rev: - return VK_FORMAT_A2R10G10B10_UINT_PACK32; - case TextureFormat::BGR10_A2_Unorm: - return VK_FORMAT_A2B10G10R10_UNORM_PACK32; case TextureFormat::R_F32: return VK_FORMAT_R32_SFLOAT; case TextureFormat::RGBA_F16: return VK_FORMAT_R16G16B16A16_SFLOAT; - case TextureFormat::RGBA_UInt32: + case TextureFormat::RGBA_UI32: return VK_FORMAT_R32G32B32A32_UINT; case TextureFormat::RGBA_F32: return VK_FORMAT_R32G32B32A32_SFLOAT; - case TextureFormat::RGB8_ETC2: + case TextureFormat::ETC2_RGB8: return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK; - case TextureFormat::SRGB8_ETC2: + case TextureFormat::ETC2_SRGB8: return VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK; - case TextureFormat::RGB8_Punchthrough_A1_ETC2: - return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK; - case TextureFormat::SRGB8_Punchthrough_A1_ETC2: - return VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK; - case TextureFormat::RG_EAC_UNorm: - return VK_FORMAT_EAC_R11G11_UNORM_BLOCK; - case TextureFormat::RG_EAC_SNorm: - return VK_FORMAT_EAC_R11G11_SNORM_BLOCK; - case TextureFormat::R_EAC_UNorm: - return VK_FORMAT_EAC_R11_UNORM_BLOCK; - case TextureFormat::R_EAC_SNorm: - return VK_FORMAT_EAC_R11_SNORM_BLOCK; - case TextureFormat::RGBA_BC7_UNORM_4x4: + case TextureFormat::BC7_RGBA: return VK_FORMAT_BC7_UNORM_BLOCK; - case TextureFormat::Z_UNorm16: + case TextureFormat::Z_UN16: return VK_FORMAT_D16_UNORM; - case TextureFormat::Z_UNorm24: + case TextureFormat::Z_UN24: return VK_FORMAT_D24_UNORM_S8_UINT; - case TextureFormat::Z_UNorm32: + case TextureFormat::Z_F32: return VK_FORMAT_D32_SFLOAT; - case TextureFormat::S8_UInt_Z24_UNorm: + case TextureFormat::Z_UN24_S_UI8: return VK_FORMAT_D24_UNORM_S8_UINT; default: IGL_ASSERT_MSG(false, "TextureFormat value not handled: %d", (int)format); @@ -131,70 +115,54 @@ igl::TextureFormat vkFormatToTextureFormat(VkFormat format) { case VK_FORMAT_UNDEFINED: return TextureFormat::Invalid; case VK_FORMAT_R8_UNORM: - return TextureFormat::R_UNorm8; + return TextureFormat::R_UN8; case VK_FORMAT_R16_UNORM: - return TextureFormat::R_UNorm16; + return TextureFormat::R_UN16; case VK_FORMAT_R16_SFLOAT: return TextureFormat::R_F16; case VK_FORMAT_R16_UINT: - return TextureFormat::R_UInt16; + return TextureFormat::R_UI16; case VK_FORMAT_R8G8_UNORM: - return TextureFormat::RG_UNorm8; + return TextureFormat::RG_UN8; case VK_FORMAT_B8G8R8A8_UNORM: - return TextureFormat::BGRA_UNorm8; + return TextureFormat::BGRA_UN8; case VK_FORMAT_R8G8B8A8_UNORM: - return TextureFormat::RGBA_UNorm8; + return TextureFormat::RGBA_UN8; case VK_FORMAT_R8G8B8A8_SRGB: - return TextureFormat::RGBA_SRGB; + return TextureFormat::RGBA_SRGB8; case VK_FORMAT_B8G8R8A8_SRGB: - return TextureFormat::BGRA_SRGB; + return TextureFormat::BGRA_SRGB8; case VK_FORMAT_R16G16_UNORM: - return TextureFormat::RG_UNorm16; + return TextureFormat::RG_UN16; case VK_FORMAT_R16G16_SFLOAT: return TextureFormat::RG_F16; + case VK_FORMAT_R32G32_SFLOAT: + return TextureFormat::RG_F32; case VK_FORMAT_R16G16_UINT: - return TextureFormat::RG_UInt16; - case VK_FORMAT_A2R10G10B10_UNORM_PACK32: - return TextureFormat::RGB10_A2_UNorm_Rev; - case VK_FORMAT_A2R10G10B10_UINT_PACK32: - return TextureFormat::RGB10_A2_Uint_Rev; - case VK_FORMAT_A2B10G10R10_UNORM_PACK32: - return TextureFormat::BGR10_A2_Unorm; + return TextureFormat::RG_UI16; case VK_FORMAT_R32_SFLOAT: return TextureFormat::R_F32; case VK_FORMAT_R16G16B16A16_SFLOAT: return TextureFormat::RGBA_F16; case VK_FORMAT_R32G32B32A32_UINT: - return TextureFormat::RGBA_UInt32; + return TextureFormat::RGBA_UI32; case VK_FORMAT_R32G32B32A32_SFLOAT: return TextureFormat::RGBA_F32; case VK_FORMAT_ASTC_4x4_SRGB_BLOCK: case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK: - return TextureFormat::RGB8_ETC2; + return TextureFormat::ETC2_RGB8; case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK: - return TextureFormat::SRGB8_ETC2; - case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK: - return TextureFormat::RGB8_Punchthrough_A1_ETC2; - case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK: - return TextureFormat::SRGB8_Punchthrough_A1_ETC2; - case VK_FORMAT_EAC_R11G11_UNORM_BLOCK: - return TextureFormat::RG_EAC_UNorm; - case VK_FORMAT_EAC_R11G11_SNORM_BLOCK: - return TextureFormat::RG_EAC_SNorm; - case VK_FORMAT_EAC_R11_UNORM_BLOCK: - return TextureFormat::R_EAC_UNorm; - case VK_FORMAT_EAC_R11_SNORM_BLOCK: - return TextureFormat::R_EAC_SNorm; + return TextureFormat::ETC2_SRGB8; case VK_FORMAT_D16_UNORM: - return TextureFormat::Z_UNorm16; + return TextureFormat::Z_UN16; case VK_FORMAT_BC7_UNORM_BLOCK: - return TextureFormat::RGBA_BC7_UNORM_4x4; + return TextureFormat::BC7_RGBA; case VK_FORMAT_X8_D24_UNORM_PACK32: - return TextureFormat::Z_UNorm24; + return TextureFormat::Z_UN24; case VK_FORMAT_D24_UNORM_S8_UINT: - return TextureFormat::S8_UInt_Z24_UNorm; + return TextureFormat::Z_UN24_S_UI8; case VK_FORMAT_D32_SFLOAT: - return TextureFormat::Z_UNorm32; + return TextureFormat::Z_F32; default: IGL_ASSERT_MSG(false, "VkFormat value not handled: %d", (int)format); } diff --git a/src/igl/vulkan/VulkanContext.cpp b/src/igl/vulkan/VulkanContext.cpp index 98bc6d86b7..89b4eee4a1 100644 --- a/src/igl/vulkan/VulkanContext.cpp +++ b/src/igl/vulkan/VulkanContext.cpp @@ -94,16 +94,16 @@ vulkanDebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT msgSeverity, std::vector getCompatibleDepthStencilFormats(igl::TextureFormat format) { switch (format) { - case igl::TextureFormat::Z_UNorm16: + case igl::TextureFormat::Z_UN16: return {VK_FORMAT_D16_UNORM, VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT}; - case igl::TextureFormat::Z_UNorm24: + case igl::TextureFormat::Z_UN24: return {VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT, VK_FORMAT_D16_UNORM_S8_UINT}; - case igl::TextureFormat::Z_UNorm32: + case igl::TextureFormat::Z_F32: return {VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT}; - case igl::TextureFormat::S8_UInt_Z24_UNorm: + case igl::TextureFormat::Z_UN24_S_UI8: return {VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D16_UNORM_S8_UINT}; default: return {VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT}; @@ -111,20 +111,6 @@ std::vector getCompatibleDepthStencilFormats(igl::TextureFormat format return {VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT}; } -VkQueueFlagBits getQueueTypeFlag(igl::CommandQueueType type) { - switch (type) { - case igl::CommandQueueType::Compute: - return VK_QUEUE_COMPUTE_BIT; - case igl::CommandQueueType::Graphics: - return VK_QUEUE_GRAPHICS_BIT; - case igl::CommandQueueType::Transfer: - return VK_QUEUE_TRANSFER_BIT; - } -#if defined(_MSC_VER) - return VK_QUEUE_GRAPHICS_BIT; -#endif // _MSC_VER -} - bool validateImageLimits(VkImageType imageType, VkSampleCountFlagBits samples, const VkExtent3D& extent,