3737
3838uint32_t lvk::VulkanPipelineBuilder::numPipelinesCreated_ = 0 ;
3939
40- static_assert (lvk::HWDeviceDesc::LVK_MAX_PHYSICAL_DEVICE_NAME_SIZE == VK_MAX_PHYSICAL_DEVICE_NAME_SIZE);
41- static_assert (lvk::Swizzle_Default == (uint32_t )VK_COMPONENT_SWIZZLE_IDENTITY);
42- static_assert (lvk::Swizzle_0 == (uint32_t )VK_COMPONENT_SWIZZLE_ZERO);
43- static_assert (lvk::Swizzle_1 == (uint32_t )VK_COMPONENT_SWIZZLE_ONE);
44- static_assert (lvk::Swizzle_R == (uint32_t )VK_COMPONENT_SWIZZLE_R);
45- static_assert (lvk::Swizzle_G == (uint32_t )VK_COMPONENT_SWIZZLE_G);
46- static_assert (lvk::Swizzle_B == (uint32_t )VK_COMPONENT_SWIZZLE_B);
47- static_assert (lvk::Swizzle_A == (uint32_t )VK_COMPONENT_SWIZZLE_A);
4840static_assert (sizeof (lvk::AccelStructInstance) == sizeof (VkAccelerationStructureInstanceKHR));
4941static_assert (sizeof (lvk::mat3x4) == sizeof (VkTransformMatrixKHR));
5042
5143namespace {
5244
53- const char * kDefaultValidationLayers [] = {" VK_LAYER_KHRONOS_validation" };
45+ const char * kDefaultValidationLayers [] = {
46+ " VK_LAYER_KHRONOS_validation" ,
47+ };
5448
5549// These bindings should match GLSL declarations injected into shaders in VulkanContext::createShaderModule().
5650enum Bindings {
@@ -73,6 +67,11 @@ uint64_t getAlignedAddress(uint64_t addr, uint64_t align) {
7367 return offs ? addr + (align - offs) : addr;
7468}
7569
70+ bool isIdentityMapping (const VkComponentMapping& m) {
71+ return m.r == VK_COMPONENT_SWIZZLE_IDENTITY && m.g == VK_COMPONENT_SWIZZLE_IDENTITY && m.b == VK_COMPONENT_SWIZZLE_IDENTITY &&
72+ m.a == VK_COMPONENT_SWIZZLE_IDENTITY;
73+ }
74+
7675VKAPI_ATTR VkBool32 VKAPI_CALL vulkanDebugCallback (VkDebugUtilsMessageSeverityFlagBitsEXT msgSeverity,
7776 [[maybe_unused]] VkDebugUtilsMessageTypeFlagsEXT msgType,
7877 const VkDebugUtilsMessengerCallbackDataEXT* cbData,
@@ -4111,20 +4110,13 @@ lvk::Holder<lvk::TextureHandle> lvk::VulkanContext::createTexture(const TextureD
41114110 aspect = VK_IMAGE_ASPECT_COLOR_BIT;
41124111 }
41134112
4114- const VkComponentMapping components = {
4115- .r = VkComponentSwizzle (desc.components .r ),
4116- .g = VkComponentSwizzle (desc.components .g ),
4117- .b = VkComponentSwizzle (desc.components .b ),
4118- .a = VkComponentSwizzle (desc.components .a ),
4119- };
4120-
41214113 const VkSamplerYcbcrConversionInfo* ycbcrInfo = isDisjoint ? getOrCreateYcbcrConversionInfo (desc.format ) : nullptr ;
41224114
41234115 image.imageView_ = image.createImageView (
4124- vkDevice_, vkImageViewType, vkFormat, aspect, 0 , VK_REMAINING_MIP_LEVELS, 0 , numLayers, components, ycbcrInfo, debugNameImageView);
4116+ vkDevice_, vkImageViewType, vkFormat, aspect, 0 , VK_REMAINING_MIP_LEVELS, 0 , numLayers, desc. components , ycbcrInfo, debugNameImageView);
41254117
41264118 if (image.vkUsageFlags_ & VK_IMAGE_USAGE_STORAGE_BIT) {
4127- if (!desc.components . identity ( )) {
4119+ if (!isIdentityMapping ( desc.components )) {
41284120 // use identity swizzle for storage images
41294121 image.imageViewStorage_ = image.createImageView (
41304122 vkDevice_, vkImageViewType, vkFormat, aspect, 0 , VK_REMAINING_MIP_LEVELS, 0 , numLayers, {}, ycbcrInfo, debugNameImageView);
@@ -4206,13 +4198,6 @@ lvk::Holder<lvk::TextureHandle> lvk::VulkanContext::createTextureView(lvk::Textu
42064198 return {};
42074199 }
42084200
4209- const VkComponentMapping components = {
4210- .r = VkComponentSwizzle (desc.components .r ),
4211- .g = VkComponentSwizzle (desc.components .g ),
4212- .b = VkComponentSwizzle (desc.components .b ),
4213- .a = VkComponentSwizzle (desc.components .a ),
4214- };
4215-
42164201 LVK_ASSERT_MSG (lvk::getNumImagePlanes (image.vkImageFormat_ ) == 1 , " Unsupported multiplanar image" );
42174202
42184203 image.imageView_ = image.createImageView (vkDevice_,
@@ -4223,7 +4208,7 @@ lvk::Holder<lvk::TextureHandle> lvk::VulkanContext::createTextureView(lvk::Textu
42234208 desc.numMipLevels ,
42244209 desc.layer ,
42254210 desc.numLayers ,
4226- components,
4211+ desc. components ,
42274212 nullptr ,
42284213 debugName);
42294214
@@ -4233,7 +4218,7 @@ lvk::Holder<lvk::TextureHandle> lvk::VulkanContext::createTextureView(lvk::Textu
42334218 }
42344219
42354220 if (image.vkUsageFlags_ & VK_IMAGE_USAGE_STORAGE_BIT) {
4236- if (!desc.components . identity ( )) {
4221+ if (!isIdentityMapping ( desc.components )) {
42374222 // use identity swizzle for storage images
42384223 image.imageViewStorage_ = image.createImageView (vkDevice_,
42394224 vkImageViewType,
0 commit comments