device->info.gen >= 9);
}
+static VkComponentSwizzle
+remap_swizzle(VkComponentSwizzle swizzle, VkComponentSwizzle component)
+{
+ if (swizzle == VK_COMPONENT_SWIZZLE_IDENTITY)
+ return component;
+ else
+ return swizzle;
+}
+
void
anv_image_view_init(struct anv_image_view *iview,
struct anv_device *device,
iview->vk_format = pCreateInfo->format;
iview->format = anv_get_isl_format(pCreateInfo->format, iview->aspect_mask,
image->tiling);
+ iview->swizzle.r = remap_swizzle(pCreateInfo->components.r,
+ VK_COMPONENT_SWIZZLE_R);
+ iview->swizzle.g = remap_swizzle(pCreateInfo->components.g,
+ VK_COMPONENT_SWIZZLE_G);
+ iview->swizzle.b = remap_swizzle(pCreateInfo->components.b,
+ VK_COMPONENT_SWIZZLE_B);
+ iview->swizzle.a = remap_swizzle(pCreateInfo->components.a,
+ VK_COMPONENT_SWIZZLE_A);
iview->base_layer = range->baseArrayLayer;
iview->base_mip = range->baseMipLevel;
VkImageAspectFlags aspect_mask;
VkFormat vk_format;
+ VkComponentMapping swizzle;
enum isl_format format;
uint32_t base_layer;
uint32_t base_mip;
.MCSEnable = false,
# if (ANV_IS_HASWELL)
- .ShaderChannelSelectR = vk_to_gen_swizzle(pCreateInfo->components.r,
- VK_COMPONENT_SWIZZLE_R),
- .ShaderChannelSelectG = vk_to_gen_swizzle(pCreateInfo->components.g,
- VK_COMPONENT_SWIZZLE_G),
- .ShaderChannelSelectB = vk_to_gen_swizzle(pCreateInfo->components.b,
- VK_COMPONENT_SWIZZLE_B),
- .ShaderChannelSelectA = vk_to_gen_swizzle(pCreateInfo->components.a,
- VK_COMPONENT_SWIZZLE_A),
+ .ShaderChannelSelectR = vk_to_gen_swizzle[iview->swizzle.r],
+ .ShaderChannelSelectG = vk_to_gen_swizzle[iview->swizzle.g],
+ .ShaderChannelSelectB = vk_to_gen_swizzle[iview->swizzle.b],
+ .ShaderChannelSelectA = vk_to_gen_swizzle[iview->swizzle.a],
# else /* XXX: Seriously? */
.RedClearColor = 0,
.GreenClearColor = 0,
.GreenClearColor = 0,
.BlueClearColor = 0,
.AlphaClearColor = 0,
- .ShaderChannelSelectRed = vk_to_gen_swizzle(pCreateInfo->components.r,
- VK_COMPONENT_SWIZZLE_R),
- .ShaderChannelSelectGreen = vk_to_gen_swizzle(pCreateInfo->components.g,
- VK_COMPONENT_SWIZZLE_G),
- .ShaderChannelSelectBlue = vk_to_gen_swizzle(pCreateInfo->components.b,
- VK_COMPONENT_SWIZZLE_B),
- .ShaderChannelSelectAlpha = vk_to_gen_swizzle(pCreateInfo->components.a,
- VK_COMPONENT_SWIZZLE_A),
+ .ShaderChannelSelectRed = vk_to_gen_swizzle[iview->swizzle.r],
+ .ShaderChannelSelectGreen = vk_to_gen_swizzle[iview->swizzle.g],
+ .ShaderChannelSelectBlue = vk_to_gen_swizzle[iview->swizzle.b],
+ .ShaderChannelSelectAlpha = vk_to_gen_swizzle[iview->swizzle.a],
.ResourceMinLOD = 0.0,
.SurfaceBaseAddress = { NULL, iview->offset },
};
}
#if ANV_GEN > 7 || ANV_IS_HASWELL
-static const uint32_t vk_to_gen_swizzle_map[] = {
+static const uint32_t vk_to_gen_swizzle[] = {
[VK_COMPONENT_SWIZZLE_ZERO] = SCS_ZERO,
[VK_COMPONENT_SWIZZLE_ONE] = SCS_ONE,
[VK_COMPONENT_SWIZZLE_R] = SCS_RED,
[VK_COMPONENT_SWIZZLE_B] = SCS_BLUE,
[VK_COMPONENT_SWIZZLE_A] = SCS_ALPHA
};
-
-static inline uint32_t
-vk_to_gen_swizzle(VkComponentSwizzle swizzle, VkComponentSwizzle component)
-{
- if (swizzle == VK_COMPONENT_SWIZZLE_IDENTITY)
- return vk_to_gen_swizzle_map[component];
- else
- return vk_to_gen_swizzle_map[swizzle];
-}
#endif
static inline uint32_t