From: Dave Airlie <airl...@redhat.com>

This fixes the layout issue for the blit path as well.

This fixes:
dEQP-VK.api.copy_and_blit.core.blit_image.all_formats.depth_stencil.d32_sfloat_s8_uint_d32_sfloat_s8_uint*

Signed-off-by: Dave Airlie <airl...@redhat.com>
---
 src/amd/vulkan/radv_meta_blit.c | 537 +++++++++++++++++++++-------------------
 src/amd/vulkan/radv_private.h   |  18 +-
 2 files changed, 286 insertions(+), 269 deletions(-)

diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c
index bbbd38173f..b4b0c065f0 100644
--- a/src/amd/vulkan/radv_meta_blit.c
+++ b/src/amd/vulkan/radv_meta_blit.c
@@ -265,10 +265,12 @@ static void
 meta_emit_blit(struct radv_cmd_buffer *cmd_buffer,
                struct radv_image *src_image,
                struct radv_image_view *src_iview,
+              VkImageLayout src_image_layout,
                VkOffset3D src_offset_0,
                VkOffset3D src_offset_1,
                struct radv_image *dest_image,
                struct radv_image_view *dest_iview,
+              VkImageLayout dest_image_layout,
                VkOffset2D dest_offset_0,
                VkOffset2D dest_offset_1,
                VkRect2D dest_box,
@@ -351,11 +353,12 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer,
                }
                break;
        }
-       case VK_IMAGE_ASPECT_DEPTH_BIT:
+       case VK_IMAGE_ASPECT_DEPTH_BIT: {
+               int idx = radv_meta_blit_ds_to_type(dest_image_layout);
                radv_CmdBeginRenderPass(radv_cmd_buffer_to_handle(cmd_buffer),
                                              &(VkRenderPassBeginInfo) {
                                                      .sType = 
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
-                                                             .renderPass = 
device->meta_state.blit.depth_only_rp,
+                                                             .renderPass = 
device->meta_state.blit.depth_only_rp[idx],
                                                              .framebuffer = fb,
                                                              .renderArea = {
                                                              .offset = { 
dest_box.offset.x, dest_box.offset.y },
@@ -366,23 +369,25 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer,
                                                       }, 
VK_SUBPASS_CONTENTS_INLINE);
                switch (src_image->type) {
                case VK_IMAGE_TYPE_1D:
-                       pipeline = 
device->meta_state.blit.depth_only_1d_pipeline;
+                       pipeline = 
device->meta_state.blit.depth_only_1d_pipeline[idx];
                        break;
                case VK_IMAGE_TYPE_2D:
-                       pipeline = 
device->meta_state.blit.depth_only_2d_pipeline;
+                       pipeline = 
device->meta_state.blit.depth_only_2d_pipeline[idx];
                        break;
                case VK_IMAGE_TYPE_3D:
-                       pipeline = 
device->meta_state.blit.depth_only_3d_pipeline;
+                       pipeline = 
device->meta_state.blit.depth_only_3d_pipeline[idx];
                        break;
                default:
                        unreachable(!"bad VkImageType");
                }
                break;
-       case VK_IMAGE_ASPECT_STENCIL_BIT:
+       }
+       case VK_IMAGE_ASPECT_STENCIL_BIT: {
+               int idx = radv_meta_blit_ds_to_type(dest_image_layout);
                radv_CmdBeginRenderPass(radv_cmd_buffer_to_handle(cmd_buffer),
                                              &(VkRenderPassBeginInfo) {
                                                      .sType = 
VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
-                                                             .renderPass = 
device->meta_state.blit.stencil_only_rp,
+                                                             .renderPass = 
device->meta_state.blit.stencil_only_rp[idx],
                                                              .framebuffer = fb,
                                                              .renderArea = {
                                                              .offset = { 
dest_box.offset.x, dest_box.offset.y },
@@ -393,18 +398,19 @@ meta_emit_blit(struct radv_cmd_buffer *cmd_buffer,
                                                       }, 
VK_SUBPASS_CONTENTS_INLINE);
                switch (src_image->type) {
                case VK_IMAGE_TYPE_1D:
-                       pipeline = 
device->meta_state.blit.stencil_only_1d_pipeline;
+                       pipeline = 
device->meta_state.blit.stencil_only_1d_pipeline[idx];
                        break;
                case VK_IMAGE_TYPE_2D:
-                       pipeline = 
device->meta_state.blit.stencil_only_2d_pipeline;
+                       pipeline = 
device->meta_state.blit.stencil_only_2d_pipeline[idx];
                        break;
                case VK_IMAGE_TYPE_3D:
-                       pipeline = 
device->meta_state.blit.stencil_only_3d_pipeline;
+                       pipeline = 
device->meta_state.blit.stencil_only_3d_pipeline[idx];
                        break;
                default:
                        unreachable(!"bad VkImageType");
                }
                break;
+       }
        default:
                unreachable(!"bad VkImageType");
        }
@@ -620,9 +626,9 @@ void radv_CmdBlitImage(
                                                },
                                        });
                        meta_emit_blit(cmd_buffer,
-                                      src_image, &src_iview,
+                                      src_image, &src_iview, srcImageLayout,
                                       src_offset_0, src_offset_1,
-                                      dest_image, &dest_iview,
+                                      dest_image, &dest_iview, destImageLayout,
                                       dest_offset_0, dest_offset_1,
                                       dest_box,
                                       filter);
@@ -652,26 +658,28 @@ radv_device_finish_meta_blit_state(struct radv_device 
*device)
                                     &state->alloc);
        }
 
-       radv_DestroyRenderPass(radv_device_to_handle(device),
-                              state->blit.depth_only_rp, &state->alloc);
-       radv_DestroyPipeline(radv_device_to_handle(device),
-                            state->blit.depth_only_1d_pipeline, &state->alloc);
-       radv_DestroyPipeline(radv_device_to_handle(device),
-                            state->blit.depth_only_2d_pipeline, &state->alloc);
-       radv_DestroyPipeline(radv_device_to_handle(device),
-                            state->blit.depth_only_3d_pipeline, &state->alloc);
-
-       radv_DestroyRenderPass(radv_device_to_handle(device),
-                              state->blit.stencil_only_rp, &state->alloc);
-       radv_DestroyPipeline(radv_device_to_handle(device),
-                            state->blit.stencil_only_1d_pipeline,
-                            &state->alloc);
-       radv_DestroyPipeline(radv_device_to_handle(device),
-                            state->blit.stencil_only_2d_pipeline,
-                            &state->alloc);
-       radv_DestroyPipeline(radv_device_to_handle(device),
-                            state->blit.stencil_only_3d_pipeline,
-                            &state->alloc);
+       for (unsigned i = 0; i < RADV_BLIT_DS_NUM_LAYOUTS; ++i) {
+               radv_DestroyRenderPass(radv_device_to_handle(device),
+                                      state->blit.depth_only_rp[i], 
&state->alloc);
+               radv_DestroyPipeline(radv_device_to_handle(device),
+                                    state->blit.depth_only_1d_pipeline[i], 
&state->alloc);
+               radv_DestroyPipeline(radv_device_to_handle(device),
+                                    state->blit.depth_only_2d_pipeline[i], 
&state->alloc);
+               radv_DestroyPipeline(radv_device_to_handle(device),
+                                    state->blit.depth_only_3d_pipeline[i], 
&state->alloc);
+
+               radv_DestroyRenderPass(radv_device_to_handle(device),
+                                      state->blit.stencil_only_rp[i], 
&state->alloc);
+               radv_DestroyPipeline(radv_device_to_handle(device),
+                                    state->blit.stencil_only_1d_pipeline[i],
+                                    &state->alloc);
+               radv_DestroyPipeline(radv_device_to_handle(device),
+                                    state->blit.stencil_only_2d_pipeline[i],
+                                    &state->alloc);
+               radv_DestroyPipeline(radv_device_to_handle(device),
+                                    state->blit.stencil_only_3d_pipeline[i],
+                                    &state->alloc);
+       }
 
        radv_DestroyPipelineLayout(radv_device_to_handle(device),
                                   state->blit.pipeline_layout, &state->alloc);
@@ -866,35 +874,38 @@ radv_device_init_meta_blit_depth(struct radv_device 
*device,
        fs_2d.nir = build_nir_copy_fragment_shader_depth(GLSL_SAMPLER_DIM_2D);
        fs_3d.nir = build_nir_copy_fragment_shader_depth(GLSL_SAMPLER_DIM_3D);
 
-       result = radv_CreateRenderPass(radv_device_to_handle(device),
-                                      &(VkRenderPassCreateInfo) {
-                                              .sType = 
VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
+       for (unsigned i = 0; i < RADV_BLIT_DS_NUM_LAYOUTS; i++) {
+               VkImageLayout layout = radv_meta_blit_ds_to_layout(i);
+               result = radv_CreateRenderPass(radv_device_to_handle(device),
+                                              &(VkRenderPassCreateInfo) {
+                                                      .sType = 
VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
                                                       .attachmentCount = 1,
                                                       .pAttachments = 
&(VkAttachmentDescription) {
-                                                      .format = 
VK_FORMAT_D32_SFLOAT,
-                                                      .loadOp = 
VK_ATTACHMENT_LOAD_OP_LOAD,
-                                                      .storeOp = 
VK_ATTACHMENT_STORE_OP_STORE,
-                                                      .initialLayout = 
VK_IMAGE_LAYOUT_GENERAL,
-                                                      .finalLayout = 
VK_IMAGE_LAYOUT_GENERAL,
-                                              },
-                                                      .subpassCount = 1,
-                                               .pSubpasses = 
&(VkSubpassDescription) {
-                                                      .pipelineBindPoint = 
VK_PIPELINE_BIND_POINT_GRAPHICS,
-                                                      .inputAttachmentCount = 
0,
-                                                      .colorAttachmentCount = 
0,
-                                                      .pColorAttachments = 
NULL,
-                                                      .pResolveAttachments = 
NULL,
-                                                      .pDepthStencilAttachment 
= &(VkAttachmentReference) {
-                                                              .attachment = 0,
-                                                              .layout = 
VK_IMAGE_LAYOUT_GENERAL,
+                                                              .format = 
VK_FORMAT_D32_SFLOAT,
+                                                              .loadOp = 
VK_ATTACHMENT_LOAD_OP_LOAD,
+                                                              .storeOp = 
VK_ATTACHMENT_STORE_OP_STORE,
+                                                              .initialLayout = 
layout,
+                                                              .finalLayout = 
layout,
                                                       },
-                                                      .preserveAttachmentCount 
= 1,
-                                                      .pPreserveAttachments = 
(uint32_t[]) { 0 },
-                                              },
-                                               .dependencyCount = 0,
-                                        }, &device->meta_state.alloc, 
&device->meta_state.blit.depth_only_rp);
-       if (result != VK_SUCCESS)
-               goto fail;
+                                                      .subpassCount = 1,
+                                                      .pSubpasses = 
&(VkSubpassDescription) {
+                                                              
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
+                                                              
.inputAttachmentCount = 0,
+                                                              
.colorAttachmentCount = 0,
+                                                              
.pColorAttachments = NULL,
+                                                              
.pResolveAttachments = NULL,
+                                                              
.pDepthStencilAttachment = &(VkAttachmentReference) {
+                                                                      
.attachment = 0,
+                                                                      .layout 
= layout,
+                                                               },
+                                                              
.preserveAttachmentCount = 1,
+                                                              
.pPreserveAttachments = (uint32_t[]) { 0 },
+                                                       },
+                                                       .dependencyCount = 0,
+                                               }, &device->meta_state.alloc, 
&device->meta_state.blit.depth_only_rp[i]);
+               if (result != VK_SUCCESS)
+                       goto fail;
+       }
 
        VkPipelineVertexInputStateCreateInfo vi_create_info = {
                .sType = 
VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
@@ -918,93 +929,95 @@ radv_device_init_meta_blit_depth(struct radv_device 
*device,
                },
        };
 
-       const VkGraphicsPipelineCreateInfo vk_pipeline_info = {
-               .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
-               .stageCount = ARRAY_SIZE(pipeline_shader_stages),
-               .pStages = pipeline_shader_stages,
-               .pVertexInputState = &vi_create_info,
-               .pInputAssemblyState = 
&(VkPipelineInputAssemblyStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
-                       .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
-                       .primitiveRestartEnable = false,
-               },
-               .pViewportState = &(VkPipelineViewportStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
-                       .viewportCount = 1,
-                       .scissorCount = 1,
-               },
-               .pRasterizationState = 
&(VkPipelineRasterizationStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
-                       .rasterizerDiscardEnable = false,
-                       .polygonMode = VK_POLYGON_MODE_FILL,
-                       .cullMode = VK_CULL_MODE_NONE,
-                       .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE
-               },
-               .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
-                       .rasterizationSamples = 1,
-                       .sampleShadingEnable = false,
-                       .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
-               },
-               .pColorBlendState = &(VkPipelineColorBlendStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
-                       .attachmentCount = 0,
-                       .pAttachments = NULL,
-               },
-               .pDepthStencilState = &(VkPipelineDepthStencilStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
-                       .depthTestEnable = true,
-                       .depthWriteEnable = true,
-                       .depthCompareOp = VK_COMPARE_OP_ALWAYS,
-               },
-               .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
-                       .dynamicStateCount = 9,
-                       .pDynamicStates = (VkDynamicState[]) {
-                               VK_DYNAMIC_STATE_VIEWPORT,
-                               VK_DYNAMIC_STATE_SCISSOR,
-                               VK_DYNAMIC_STATE_LINE_WIDTH,
-                               VK_DYNAMIC_STATE_DEPTH_BIAS,
-                               VK_DYNAMIC_STATE_BLEND_CONSTANTS,
-                               VK_DYNAMIC_STATE_DEPTH_BOUNDS,
-                               VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK,
-                               VK_DYNAMIC_STATE_STENCIL_WRITE_MASK,
-                               VK_DYNAMIC_STATE_STENCIL_REFERENCE,
+       for (unsigned i = 0; i < RADV_BLIT_DS_NUM_LAYOUTS; i++) {
+               const VkGraphicsPipelineCreateInfo vk_pipeline_info = {
+                       .sType = 
VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
+                       .stageCount = ARRAY_SIZE(pipeline_shader_stages),
+                       .pStages = pipeline_shader_stages,
+                       .pVertexInputState = &vi_create_info,
+                       .pInputAssemblyState = 
&(VkPipelineInputAssemblyStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
+                               .topology = 
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
+                               .primitiveRestartEnable = false,
                        },
-               },
-               .flags = 0,
-               .layout = device->meta_state.blit.pipeline_layout,
-               .renderPass = device->meta_state.blit.depth_only_rp,
-               .subpass = 0,
-       };
+                       .pViewportState = &(VkPipelineViewportStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
+                               .viewportCount = 1,
+                               .scissorCount = 1,
+                       },
+                       .pRasterizationState = 
&(VkPipelineRasterizationStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
+                               .rasterizerDiscardEnable = false,
+                               .polygonMode = VK_POLYGON_MODE_FILL,
+                               .cullMode = VK_CULL_MODE_NONE,
+                               .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE
+                       },
+                       .pMultisampleState = 
&(VkPipelineMultisampleStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
+                               .rasterizationSamples = 1,
+                               .sampleShadingEnable = false,
+                               .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
+                       },
+                       .pColorBlendState = 
&(VkPipelineColorBlendStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
+                               .attachmentCount = 0,
+                               .pAttachments = NULL,
+                       },
+                       .pDepthStencilState = 
&(VkPipelineDepthStencilStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
+                               .depthTestEnable = true,
+                               .depthWriteEnable = true,
+                               .depthCompareOp = VK_COMPARE_OP_ALWAYS,
+                       },
+                       .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
+                               .dynamicStateCount = 9,
+                               .pDynamicStates = (VkDynamicState[]) {
+                                       VK_DYNAMIC_STATE_VIEWPORT,
+                                       VK_DYNAMIC_STATE_SCISSOR,
+                                       VK_DYNAMIC_STATE_LINE_WIDTH,
+                                       VK_DYNAMIC_STATE_DEPTH_BIAS,
+                                       VK_DYNAMIC_STATE_BLEND_CONSTANTS,
+                                       VK_DYNAMIC_STATE_DEPTH_BOUNDS,
+                                       VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK,
+                                       VK_DYNAMIC_STATE_STENCIL_WRITE_MASK,
+                                       VK_DYNAMIC_STATE_STENCIL_REFERENCE,
+                               },
+                       },
+                       .flags = 0,
+                       .layout = device->meta_state.blit.pipeline_layout,
+                       .renderPass = device->meta_state.blit.depth_only_rp[i],
+                       .subpass = 0,
+               };
 
-       const struct radv_graphics_pipeline_create_info radv_pipeline_info = {
-               .use_rectlist = true
-       };
+               const struct radv_graphics_pipeline_create_info 
radv_pipeline_info = {
+                       .use_rectlist = true
+               };
 
-       pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_1d);
-       result = radv_graphics_pipeline_create(radv_device_to_handle(device),
-                                              
radv_pipeline_cache_to_handle(&device->meta_state.cache),
-                                              &vk_pipeline_info, 
&radv_pipeline_info,
-                                              &device->meta_state.alloc, 
&device->meta_state.blit.depth_only_1d_pipeline);
-       if (result != VK_SUCCESS)
-               goto fail;
+               pipeline_shader_stages[1].module = 
radv_shader_module_to_handle(&fs_1d);
+               result = 
radv_graphics_pipeline_create(radv_device_to_handle(device),
+                                                      
radv_pipeline_cache_to_handle(&device->meta_state.cache),
+                                                      &vk_pipeline_info, 
&radv_pipeline_info,
+                                                      
&device->meta_state.alloc, &device->meta_state.blit.depth_only_1d_pipeline[i]);
+               if (result != VK_SUCCESS)
+                       goto fail;
 
-       pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_2d);
-       result = radv_graphics_pipeline_create(radv_device_to_handle(device),
-                                              
radv_pipeline_cache_to_handle(&device->meta_state.cache),
-                                              &vk_pipeline_info, 
&radv_pipeline_info,
-                                              &device->meta_state.alloc, 
&device->meta_state.blit.depth_only_2d_pipeline);
-       if (result != VK_SUCCESS)
-               goto fail;
+               pipeline_shader_stages[1].module = 
radv_shader_module_to_handle(&fs_2d);
+               result = 
radv_graphics_pipeline_create(radv_device_to_handle(device),
+                                                      
radv_pipeline_cache_to_handle(&device->meta_state.cache),
+                                                      &vk_pipeline_info, 
&radv_pipeline_info,
+                                                      
&device->meta_state.alloc, &device->meta_state.blit.depth_only_2d_pipeline[i]);
+               if (result != VK_SUCCESS)
+                       goto fail;
 
-       pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_3d);
-       result = radv_graphics_pipeline_create(radv_device_to_handle(device),
-                                              
radv_pipeline_cache_to_handle(&device->meta_state.cache),
-                                              &vk_pipeline_info, 
&radv_pipeline_info,
-                                              &device->meta_state.alloc, 
&device->meta_state.blit.depth_only_3d_pipeline);
-       if (result != VK_SUCCESS)
-               goto fail;
+               pipeline_shader_stages[1].module = 
radv_shader_module_to_handle(&fs_3d);
+               result = 
radv_graphics_pipeline_create(radv_device_to_handle(device),
+                                                      
radv_pipeline_cache_to_handle(&device->meta_state.cache),
+                                                      &vk_pipeline_info, 
&radv_pipeline_info,
+                                                      
&device->meta_state.alloc, &device->meta_state.blit.depth_only_3d_pipeline[i]);
+               if (result != VK_SUCCESS)
+                       goto fail;
+       }
 
 fail:
        ralloc_free(fs_1d.nir);
@@ -1024,33 +1037,36 @@ radv_device_init_meta_blit_stencil(struct radv_device 
*device,
        fs_2d.nir = build_nir_copy_fragment_shader_stencil(GLSL_SAMPLER_DIM_2D);
        fs_3d.nir = build_nir_copy_fragment_shader_stencil(GLSL_SAMPLER_DIM_3D);
 
-       result = radv_CreateRenderPass(radv_device_to_handle(device),
-                                      &(VkRenderPassCreateInfo) {
-                                              .sType = 
VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
+       for (unsigned i = 0; i < RADV_BLIT_DS_NUM_LAYOUTS; i++) {
+               VkImageLayout layout = radv_meta_blit_ds_to_layout(i);
+               result = radv_CreateRenderPass(radv_device_to_handle(device),
+                                              &(VkRenderPassCreateInfo) {
+                                                      .sType = 
VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
                                                       .attachmentCount = 1,
                                                       .pAttachments = 
&(VkAttachmentDescription) {
-                                                      .format = 
VK_FORMAT_S8_UINT,
-                                                      .loadOp = 
VK_ATTACHMENT_LOAD_OP_LOAD,
-                                                      .storeOp = 
VK_ATTACHMENT_STORE_OP_STORE,
-                                                      .initialLayout = 
VK_IMAGE_LAYOUT_GENERAL,
-                                                      .finalLayout = 
VK_IMAGE_LAYOUT_GENERAL,
-                                              },
+                                                              .format = 
VK_FORMAT_S8_UINT,
+                                                              .loadOp = 
VK_ATTACHMENT_LOAD_OP_LOAD,
+                                                              .storeOp = 
VK_ATTACHMENT_STORE_OP_STORE,
+                                                              .initialLayout = 
layout,
+                                                              .finalLayout = 
layout,
+                                                      },
                                                       .subpassCount = 1,
-                                               .pSubpasses = 
&(VkSubpassDescription) {
-                                                      .pipelineBindPoint = 
VK_PIPELINE_BIND_POINT_GRAPHICS,
-                                                      .inputAttachmentCount = 
0,
-                                                      .colorAttachmentCount = 
0,
-                                                      .pColorAttachments = 
NULL,
-                                                      .pResolveAttachments = 
NULL,
-                                                      .pDepthStencilAttachment 
= &(VkAttachmentReference) {
-                                                              .attachment = 0,
-                                                              .layout = 
VK_IMAGE_LAYOUT_GENERAL,
+                                                      .pSubpasses = 
&(VkSubpassDescription) {
+                                                              
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
+                                                              
.inputAttachmentCount = 0,
+                                                              
.colorAttachmentCount = 0,
+                                                              
.pColorAttachments = NULL,
+                                                              
.pResolveAttachments = NULL,
+                                                              
.pDepthStencilAttachment = &(VkAttachmentReference) {
+                                                                      
.attachment = 0,
+                                                                      .layout 
= layout,
+                                                              },
+                                                              
.preserveAttachmentCount = 1,
+                                                              
.pPreserveAttachments = (uint32_t[]) { 0 },
                                                       },
-                                                      .preserveAttachmentCount 
= 1,
-                                                      .pPreserveAttachments = 
(uint32_t[]) { 0 },
-                                              },
-                                               .dependencyCount = 0,
-                                        }, &device->meta_state.alloc, 
&device->meta_state.blit.stencil_only_rp);
+                                                      .dependencyCount = 0,
+                                        }, &device->meta_state.alloc, 
&device->meta_state.blit.stencil_only_rp[i]);
+       }
        if (result != VK_SUCCESS)
                goto fail;
 
@@ -1076,110 +1092,111 @@ radv_device_init_meta_blit_stencil(struct radv_device 
*device,
                },
        };
 
-       const VkGraphicsPipelineCreateInfo vk_pipeline_info = {
-               .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
-               .stageCount = ARRAY_SIZE(pipeline_shader_stages),
-               .pStages = pipeline_shader_stages,
-               .pVertexInputState = &vi_create_info,
-               .pInputAssemblyState = 
&(VkPipelineInputAssemblyStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
-                       .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
-                       .primitiveRestartEnable = false,
-               },
-               .pViewportState = &(VkPipelineViewportStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
-                       .viewportCount = 1,
-                       .scissorCount = 1,
-               },
-               .pRasterizationState = 
&(VkPipelineRasterizationStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
-                       .rasterizerDiscardEnable = false,
-                       .polygonMode = VK_POLYGON_MODE_FILL,
-                       .cullMode = VK_CULL_MODE_NONE,
-                       .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE
-               },
-               .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
-                       .rasterizationSamples = 1,
-                       .sampleShadingEnable = false,
-                       .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
-               },
-               .pColorBlendState = &(VkPipelineColorBlendStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
-                       .attachmentCount = 0,
-                       .pAttachments = NULL,
-               },
-               .pDepthStencilState = &(VkPipelineDepthStencilStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
-                       .depthTestEnable = false,
-                       .depthWriteEnable = false,
-                       .stencilTestEnable = true,
-                       .front = {
-                               .failOp = VK_STENCIL_OP_REPLACE,
-                               .passOp = VK_STENCIL_OP_REPLACE,
-                               .depthFailOp = VK_STENCIL_OP_REPLACE,
-                               .compareOp = VK_COMPARE_OP_ALWAYS,
-                               .compareMask = 0xff,
-                               .writeMask = 0xff,
-                               .reference = 0
+       for (unsigned i = 0; i < RADV_BLIT_DS_NUM_LAYOUTS; i++) {
+               const VkGraphicsPipelineCreateInfo vk_pipeline_info = {
+                       .sType = 
VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
+                       .stageCount = ARRAY_SIZE(pipeline_shader_stages),
+                       .pStages = pipeline_shader_stages,
+                       .pVertexInputState = &vi_create_info,
+                       .pInputAssemblyState = 
&(VkPipelineInputAssemblyStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
+                               .topology = 
VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
+                               .primitiveRestartEnable = false,
                        },
-                       .back = {
-                               .failOp = VK_STENCIL_OP_REPLACE,
-                               .passOp = VK_STENCIL_OP_REPLACE,
-                               .depthFailOp = VK_STENCIL_OP_REPLACE,
-                               .compareOp = VK_COMPARE_OP_ALWAYS,
-                               .compareMask = 0xff,
-                               .writeMask = 0xff,
-                               .reference = 0
+                       .pViewportState = &(VkPipelineViewportStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
+                               .viewportCount = 1,
+                               .scissorCount = 1,
                        },
-                       .depthCompareOp = VK_COMPARE_OP_ALWAYS,
-               },
-
-               .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
-                       .sType = 
VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
-                       .dynamicStateCount = 6,
-                       .pDynamicStates = (VkDynamicState[]) {
-                               VK_DYNAMIC_STATE_VIEWPORT,
-                               VK_DYNAMIC_STATE_SCISSOR,
-                               VK_DYNAMIC_STATE_LINE_WIDTH,
-                               VK_DYNAMIC_STATE_DEPTH_BIAS,
-                               VK_DYNAMIC_STATE_BLEND_CONSTANTS,
-                               VK_DYNAMIC_STATE_DEPTH_BOUNDS,
+                       .pRasterizationState = 
&(VkPipelineRasterizationStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
+                               .rasterizerDiscardEnable = false,
+                               .polygonMode = VK_POLYGON_MODE_FILL,
+                               .cullMode = VK_CULL_MODE_NONE,
+                               .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE
                        },
-               },
-               .flags = 0,
-               .layout = device->meta_state.blit.pipeline_layout,
-               .renderPass = device->meta_state.blit.stencil_only_rp,
-               .subpass = 0,
-       };
+                       .pMultisampleState = 
&(VkPipelineMultisampleStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
+                               .rasterizationSamples = 1,
+                               .sampleShadingEnable = false,
+                               .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
+                       },
+                       .pColorBlendState = 
&(VkPipelineColorBlendStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
+                               .attachmentCount = 0,
+                               .pAttachments = NULL,
+                       },
+                       .pDepthStencilState = 
&(VkPipelineDepthStencilStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
+                               .depthTestEnable = false,
+                               .depthWriteEnable = false,
+                               .stencilTestEnable = true,
+                               .front = {
+                                       .failOp = VK_STENCIL_OP_REPLACE,
+                                       .passOp = VK_STENCIL_OP_REPLACE,
+                                       .depthFailOp = VK_STENCIL_OP_REPLACE,
+                                       .compareOp = VK_COMPARE_OP_ALWAYS,
+                                       .compareMask = 0xff,
+                                       .writeMask = 0xff,
+                                       .reference = 0
+                               },
+                               .back = {
+                                       .failOp = VK_STENCIL_OP_REPLACE,
+                                       .passOp = VK_STENCIL_OP_REPLACE,
+                                       .depthFailOp = VK_STENCIL_OP_REPLACE,
+                                       .compareOp = VK_COMPARE_OP_ALWAYS,
+                                       .compareMask = 0xff,
+                                       .writeMask = 0xff,
+                                       .reference = 0
+                               },
+                               .depthCompareOp = VK_COMPARE_OP_ALWAYS,
+                       },
+                       .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
+                               .sType = 
VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
+                               .dynamicStateCount = 6,
+                               .pDynamicStates = (VkDynamicState[]) {
+                                       VK_DYNAMIC_STATE_VIEWPORT,
+                                       VK_DYNAMIC_STATE_SCISSOR,
+                                       VK_DYNAMIC_STATE_LINE_WIDTH,
+                                       VK_DYNAMIC_STATE_DEPTH_BIAS,
+                                       VK_DYNAMIC_STATE_BLEND_CONSTANTS,
+                                       VK_DYNAMIC_STATE_DEPTH_BOUNDS,
+                               },
+                       },
+                       .flags = 0,
+                       .layout = device->meta_state.blit.pipeline_layout,
+                       .renderPass = 
device->meta_state.blit.stencil_only_rp[i],
+                       .subpass = 0,
+               };
 
-       const struct radv_graphics_pipeline_create_info radv_pipeline_info = {
-               .use_rectlist = true
-       };
+               const struct radv_graphics_pipeline_create_info 
radv_pipeline_info = {
+                       .use_rectlist = true
+               };
 
-       pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_1d);
-       result = radv_graphics_pipeline_create(radv_device_to_handle(device),
-                                              
radv_pipeline_cache_to_handle(&device->meta_state.cache),
-                                              &vk_pipeline_info, 
&radv_pipeline_info,
-                                              &device->meta_state.alloc, 
&device->meta_state.blit.stencil_only_1d_pipeline);
-       if (result != VK_SUCCESS)
-               goto fail;
+               pipeline_shader_stages[1].module = 
radv_shader_module_to_handle(&fs_1d);
+               result = 
radv_graphics_pipeline_create(radv_device_to_handle(device),
+                                                      
radv_pipeline_cache_to_handle(&device->meta_state.cache),
+                                                      &vk_pipeline_info, 
&radv_pipeline_info,
+                                                      
&device->meta_state.alloc, 
&device->meta_state.blit.stencil_only_1d_pipeline[i]);
+               if (result != VK_SUCCESS)
+                       goto fail;
 
-       pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_2d);
-       result = radv_graphics_pipeline_create(radv_device_to_handle(device),
-                                              
radv_pipeline_cache_to_handle(&device->meta_state.cache),
-                                              &vk_pipeline_info, 
&radv_pipeline_info,
-                                              &device->meta_state.alloc, 
&device->meta_state.blit.stencil_only_2d_pipeline);
-       if (result != VK_SUCCESS)
-               goto fail;
+               pipeline_shader_stages[1].module = 
radv_shader_module_to_handle(&fs_2d);
+               result = 
radv_graphics_pipeline_create(radv_device_to_handle(device),
+                                                      
radv_pipeline_cache_to_handle(&device->meta_state.cache),
+                                                      &vk_pipeline_info, 
&radv_pipeline_info,
+                                                      
&device->meta_state.alloc, 
&device->meta_state.blit.stencil_only_2d_pipeline[i]);
+               if (result != VK_SUCCESS)
+                       goto fail;
 
-       pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_3d);
-       result = radv_graphics_pipeline_create(radv_device_to_handle(device),
-                                              
radv_pipeline_cache_to_handle(&device->meta_state.cache),
-                                              &vk_pipeline_info, 
&radv_pipeline_info,
-                                              &device->meta_state.alloc, 
&device->meta_state.blit.stencil_only_3d_pipeline);
-       if (result != VK_SUCCESS)
-               goto fail;
+               pipeline_shader_stages[1].module = 
radv_shader_module_to_handle(&fs_3d);
+               result = 
radv_graphics_pipeline_create(radv_device_to_handle(device),
+                                                      
radv_pipeline_cache_to_handle(&device->meta_state.cache),
+                                                      &vk_pipeline_info, 
&radv_pipeline_info,
+                                                      
&device->meta_state.alloc, 
&device->meta_state.blit.stencil_only_3d_pipeline[i]);
+               if (result != VK_SUCCESS)
+                       goto fail;
+       }
 
 fail:
        ralloc_free(fs_1d.nir);
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 36fd461fc7..006e00ae75 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -399,15 +399,15 @@ struct radv_meta_state {
                /** Pipeline that blits from a 3D image. */
                VkPipeline pipeline_3d_src[NUM_META_FS_KEYS];
 
-               VkRenderPass depth_only_rp;
-               VkPipeline depth_only_1d_pipeline;
-               VkPipeline depth_only_2d_pipeline;
-               VkPipeline depth_only_3d_pipeline;
-
-               VkRenderPass stencil_only_rp;
-               VkPipeline stencil_only_1d_pipeline;
-               VkPipeline stencil_only_2d_pipeline;
-               VkPipeline stencil_only_3d_pipeline;
+               VkRenderPass depth_only_rp[RADV_BLIT_DS_NUM_LAYOUTS];
+               VkPipeline depth_only_1d_pipeline[RADV_BLIT_DS_NUM_LAYOUTS];
+               VkPipeline depth_only_2d_pipeline[RADV_BLIT_DS_NUM_LAYOUTS];
+               VkPipeline depth_only_3d_pipeline[RADV_BLIT_DS_NUM_LAYOUTS];
+
+               VkRenderPass stencil_only_rp[RADV_BLIT_DS_NUM_LAYOUTS];
+               VkPipeline stencil_only_1d_pipeline[RADV_BLIT_DS_NUM_LAYOUTS];
+               VkPipeline stencil_only_2d_pipeline[RADV_BLIT_DS_NUM_LAYOUTS];
+               VkPipeline stencil_only_3d_pipeline[RADV_BLIT_DS_NUM_LAYOUTS];
                VkPipelineLayout                          pipeline_layout;
                VkDescriptorSetLayout                     ds_layout;
        } blit;
-- 
2.14.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to