VK_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF
} VkImageViewType;
-typedef enum {
- VK_CHANNEL_SWIZZLE_ZERO = 0,
- VK_CHANNEL_SWIZZLE_ONE = 1,
- VK_CHANNEL_SWIZZLE_R = 2,
- VK_CHANNEL_SWIZZLE_G = 3,
- VK_CHANNEL_SWIZZLE_B = 4,
- VK_CHANNEL_SWIZZLE_A = 5,
- VK_CHANNEL_SWIZZLE_BEGIN_RANGE = VK_CHANNEL_SWIZZLE_ZERO,
- VK_CHANNEL_SWIZZLE_END_RANGE = VK_CHANNEL_SWIZZLE_A,
- VK_CHANNEL_SWIZZLE_NUM = (VK_CHANNEL_SWIZZLE_A - VK_CHANNEL_SWIZZLE_ZERO + 1),
- VK_CHANNEL_SWIZZLE_MAX_ENUM = 0x7FFFFFFF
-} VkChannelSwizzle;
+typedef enum VkComponentSwizzle {
+ VK_COMPONENT_SWIZZLE_IDENTITY = 0,
+ VK_COMPONENT_SWIZZLE_ZERO = 1,
+ VK_COMPONENT_SWIZZLE_ONE = 2,
+ VK_COMPONENT_SWIZZLE_R = 3,
+ VK_COMPONENT_SWIZZLE_G = 4,
+ VK_COMPONENT_SWIZZLE_B = 5,
+ VK_COMPONENT_SWIZZLE_A = 6,
+ VK_COMPONENT_SWIZZLE_BEGIN_RANGE = VK_COMPONENT_SWIZZLE_IDENTITY,
+ VK_COMPONENT_SWIZZLE_END_RANGE = VK_COMPONENT_SWIZZLE_A,
+ VK_COMPONENT_SWIZZLE_RANGE_SIZE = (VK_COMPONENT_SWIZZLE_A - VK_COMPONENT_SWIZZLE_IDENTITY + 1),
+ VK_COMPONENT_SWIZZLE_MAX_ENUM = 0x7FFFFFFF
+} VkComponentSwizzle;
typedef enum {
VK_SHADER_STAGE_VERTEX = 0,
VkDeviceSize depthPitch;
} VkSubresourceLayout;
-typedef struct {
- VkChannelSwizzle r;
- VkChannelSwizzle g;
- VkChannelSwizzle b;
- VkChannelSwizzle a;
-} VkChannelMapping;
+typedef struct VkComponentMapping {
+ VkComponentSwizzle r;
+ VkComponentSwizzle g;
+ VkComponentSwizzle b;
+ VkComponentSwizzle a;
+} VkComponentMapping;
typedef struct {
VkImageAspectFlags aspectMask;
VkImage image;
VkImageViewType viewType;
VkFormat format;
- VkChannelMapping channels;
+ VkComponentMapping components;
VkImageSubresourceRange subresourceRange;
VkImageViewCreateFlags flags;
} VkImageViewCreateInfo;
view_format_info = anv_format_for_vk_format(pCreateInfo->format);
/* Validate channel swizzles. */
- assert(pCreateInfo->channels.r >= VK_CHANNEL_SWIZZLE_BEGIN_RANGE);
- assert(pCreateInfo->channels.r <= VK_CHANNEL_SWIZZLE_END_RANGE);
- assert(pCreateInfo->channels.g >= VK_CHANNEL_SWIZZLE_BEGIN_RANGE);
- assert(pCreateInfo->channels.g <= VK_CHANNEL_SWIZZLE_END_RANGE);
- assert(pCreateInfo->channels.b >= VK_CHANNEL_SWIZZLE_BEGIN_RANGE);
- assert(pCreateInfo->channels.b <= VK_CHANNEL_SWIZZLE_END_RANGE);
- assert(pCreateInfo->channels.a >= VK_CHANNEL_SWIZZLE_BEGIN_RANGE);
- assert(pCreateInfo->channels.a <= VK_CHANNEL_SWIZZLE_END_RANGE);
+ assert(pCreateInfo->components.r >= VK_COMPONENT_SWIZZLE_BEGIN_RANGE);
+ assert(pCreateInfo->components.r <= VK_COMPONENT_SWIZZLE_END_RANGE);
+ assert(pCreateInfo->components.g >= VK_COMPONENT_SWIZZLE_BEGIN_RANGE);
+ assert(pCreateInfo->components.g <= VK_COMPONENT_SWIZZLE_END_RANGE);
+ assert(pCreateInfo->components.b >= VK_COMPONENT_SWIZZLE_BEGIN_RANGE);
+ assert(pCreateInfo->components.b <= VK_COMPONENT_SWIZZLE_END_RANGE);
+ assert(pCreateInfo->components.a >= VK_COMPONENT_SWIZZLE_BEGIN_RANGE);
+ assert(pCreateInfo->components.a <= VK_COMPONENT_SWIZZLE_END_RANGE);
/* Validate subresource. */
assert(subresource->aspectMask != 0);
.image = src_image,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = copy_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = 0,
.image = dest_image,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = copy_format,
- .channels = {
- .r = VK_CHANNEL_SWIZZLE_R,
- .g = VK_CHANNEL_SWIZZLE_G,
- .b = VK_CHANNEL_SWIZZLE_B,
- .a = VK_CHANNEL_SWIZZLE_A,
- },
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = 0,
.image = srcImage,
.viewType = src_iview_type,
.format = src_image->format->vk_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = 1 << pRegions[r].srcSubresource.aspect,
.baseMipLevel = pRegions[r].srcSubresource.mipLevel,
.image = destImage,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = dest_image->format->vk_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = pRegions[r].destSubresource.mipLevel,
.image = srcImage,
.viewType = src_iview_type,
.format = src_image->format->vk_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = 1 << pRegions[r].srcSubresource.aspect,
.baseMipLevel = pRegions[r].srcSubresource.mipLevel,
.image = destImage,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = dest_image->format->vk_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = pRegions[r].destSubresource.mipLevel,
.image = anv_image_to_handle(src_image),
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = proxy_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = 1 << proxy_aspect,
.baseMipLevel = 0,
.image = anv_image_to_handle(dest_image),
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = proxy_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = pRegions[r].imageSubresource.mipLevel,
.image = srcImage,
.viewType = src_iview_type,
.format = src_image->format->vk_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = 1 << pRegions[r].imageSubresource.aspect,
.baseMipLevel = pRegions[r].imageSubresource.mipLevel,
.image = anv_image_to_handle(dest_image),
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = dest_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = 0,
.image = _image,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = image->format->vk_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = pRanges[r].baseMipLevel + l,
[4] = VALIGN_4,
};
-static const uint32_t vk_to_gen_swizzle[] = {
- [VK_CHANNEL_SWIZZLE_ZERO] = SCS_ZERO,
- [VK_CHANNEL_SWIZZLE_ONE] = SCS_ONE,
- [VK_CHANNEL_SWIZZLE_R] = SCS_RED,
- [VK_CHANNEL_SWIZZLE_G] = SCS_GREEN,
- [VK_CHANNEL_SWIZZLE_B] = SCS_BLUE,
- [VK_CHANNEL_SWIZZLE_A] = SCS_ALPHA
+static const uint32_t vk_to_gen_swizzle_map[] = {
+ [VK_COMPONENT_SWIZZLE_ZERO] = SCS_ZERO,
+ [VK_COMPONENT_SWIZZLE_ONE] = SCS_ONE,
+ [VK_COMPONENT_SWIZZLE_R] = SCS_RED,
+ [VK_COMPONENT_SWIZZLE_G] = SCS_GREEN,
+ [VK_COMPONENT_SWIZZLE_B] = SCS_BLUE,
+ [VK_COMPONENT_SWIZZLE_A] = SCS_ALPHA
};
+static 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];
+}
+
GENX_FUNC(GEN7, GEN75) void
genX(image_view_init)(struct anv_image_view *iview,
struct anv_device *device,
.MCSEnable = false,
# if (ANV_IS_HASWELL)
- .ShaderChannelSelectR = vk_to_gen_swizzle[pCreateInfo->channels.r],
- .ShaderChannelSelectG = vk_to_gen_swizzle[pCreateInfo->channels.g],
- .ShaderChannelSelectB = vk_to_gen_swizzle[pCreateInfo->channels.b],
- .ShaderChannelSelectA = vk_to_gen_swizzle[pCreateInfo->channels.a],
+ .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),
# else /* XXX: Seriously? */
.RedClearColor = 0,
.GreenClearColor = 0,
}
}
+static const uint32_t vk_to_gen_swizzle_map[] = {
+ [VK_COMPONENT_SWIZZLE_ZERO] = SCS_ZERO,
+ [VK_COMPONENT_SWIZZLE_ONE] = SCS_ONE,
+ [VK_COMPONENT_SWIZZLE_R] = SCS_RED,
+ [VK_COMPONENT_SWIZZLE_G] = SCS_GREEN,
+ [VK_COMPONENT_SWIZZLE_B] = SCS_BLUE,
+ [VK_COMPONENT_SWIZZLE_A] = SCS_ALPHA
+};
+
+static 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];
+}
+
void
genX(image_view_init)(struct anv_image_view *iview,
struct anv_device *device,
unreachable(!"bad VkImageType");
}
- static const uint32_t vk_to_gen_swizzle[] = {
- [VK_CHANNEL_SWIZZLE_ZERO] = SCS_ZERO,
- [VK_CHANNEL_SWIZZLE_ONE] = SCS_ONE,
- [VK_CHANNEL_SWIZZLE_R] = SCS_RED,
- [VK_CHANNEL_SWIZZLE_G] = SCS_GREEN,
- [VK_CHANNEL_SWIZZLE_B] = SCS_BLUE,
- [VK_CHANNEL_SWIZZLE_A] = SCS_ALPHA
- };
-
static const uint8_t isl_to_gen_tiling[] = {
[ISL_TILING_LINEAR] = LINEAR,
[ISL_TILING_X] = XMAJOR,
.GreenClearColor = 0,
.BlueClearColor = 0,
.AlphaClearColor = 0,
- .ShaderChannelSelectRed = vk_to_gen_swizzle[pCreateInfo->channels.r],
- .ShaderChannelSelectGreen = vk_to_gen_swizzle[pCreateInfo->channels.g],
- .ShaderChannelSelectBlue = vk_to_gen_swizzle[pCreateInfo->channels.b],
- .ShaderChannelSelectAlpha = vk_to_gen_swizzle[pCreateInfo->channels.a],
+ .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),
.ResourceMinLOD = 0.0,
.SurfaceBaseAddress = { NULL, iview->offset },
};