• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2016 Intel Corporation
3  *
4  * SPDX-License-Identifier: MIT
5  */
6 
7 #include <assert.h>
8 #include <stdbool.h>
9 
10 #include "radv_meta.h"
11 #include "sid.h"
12 
13 static nir_shader *
build_expand_depth_stencil_compute_shader(struct radv_device * dev)14 build_expand_depth_stencil_compute_shader(struct radv_device *dev)
15 {
16    const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_2D, false, GLSL_TYPE_FLOAT);
17 
18    nir_builder b = radv_meta_init_shader(dev, MESA_SHADER_COMPUTE, "expand_depth_stencil_compute");
19 
20    /* We need at least 8/8/1 to cover an entire HTILE block in a single workgroup. */
21    b.shader->info.workgroup_size[0] = 8;
22    b.shader->info.workgroup_size[1] = 8;
23    nir_variable *input_img = nir_variable_create(b.shader, nir_var_image, img_type, "in_img");
24    input_img->data.descriptor_set = 0;
25    input_img->data.binding = 0;
26 
27    nir_variable *output_img = nir_variable_create(b.shader, nir_var_image, img_type, "out_img");
28    output_img->data.descriptor_set = 0;
29    output_img->data.binding = 1;
30 
31    nir_def *invoc_id = nir_load_local_invocation_id(&b);
32    nir_def *wg_id = nir_load_workgroup_id(&b);
33    nir_def *block_size = nir_imm_ivec4(&b, b.shader->info.workgroup_size[0], b.shader->info.workgroup_size[1],
34                                        b.shader->info.workgroup_size[2], 0);
35 
36    nir_def *global_id = nir_iadd(&b, nir_imul(&b, wg_id, block_size), invoc_id);
37 
38    nir_def *data = nir_image_deref_load(&b, 4, 32, &nir_build_deref_var(&b, input_img)->def, global_id,
39                                         nir_undef(&b, 1, 32), nir_imm_int(&b, 0), .image_dim = GLSL_SAMPLER_DIM_2D);
40 
41    /* We need a SCOPE_DEVICE memory_scope because ACO will avoid
42     * creating a vmcnt(0) because it expects the L1 cache to keep memory
43     * operations in-order for the same workgroup. The vmcnt(0) seems
44     * necessary however. */
45    nir_barrier(&b, .execution_scope = SCOPE_WORKGROUP, .memory_scope = SCOPE_DEVICE,
46                .memory_semantics = NIR_MEMORY_ACQ_REL, .memory_modes = nir_var_mem_ssbo);
47 
48    nir_image_deref_store(&b, &nir_build_deref_var(&b, output_img)->def, global_id, nir_undef(&b, 1, 32), data,
49                          nir_imm_int(&b, 0), .image_dim = GLSL_SAMPLER_DIM_2D);
50    return b.shader;
51 }
52 
53 static VkResult
get_pipeline_gfx(struct radv_device * device,struct radv_image * image,VkPipeline * pipeline_out,VkPipelineLayout * layout_out)54 get_pipeline_gfx(struct radv_device *device, struct radv_image *image, VkPipeline *pipeline_out, VkPipelineLayout *layout_out)
55 {
56    const uint32_t samples = image->vk.samples;
57    char key_data[64];
58    VkResult result;
59 
60    result = radv_meta_get_noop_pipeline_layout(device, layout_out);
61    if (result != VK_SUCCESS)
62       return result;
63 
64    snprintf(key_data, sizeof(key_data), "radv-htile-expand-gfx-%d", samples);
65 
66    VkPipeline pipeline_from_cache = vk_meta_lookup_pipeline(&device->meta_state.device, key_data, strlen(key_data));
67    if (pipeline_from_cache != VK_NULL_HANDLE) {
68       *pipeline_out = pipeline_from_cache;
69       return VK_SUCCESS;
70    }
71 
72    nir_shader *vs_module = radv_meta_build_nir_vs_generate_vertices(device);
73    nir_shader *fs_module = radv_meta_build_nir_fs_noop(device);
74 
75    const VkPipelineSampleLocationsStateCreateInfoEXT sample_locs_create_info = {
76       .sType = VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT,
77       .sampleLocationsEnable = false,
78    };
79 
80    const VkGraphicsPipelineCreateInfoRADV radv_info = {
81       .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO_RADV,
82       .depth_compress_disable = true,
83       .stencil_compress_disable = true,
84    };
85 
86    const VkGraphicsPipelineCreateInfo pipeline_create_info = {
87       .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
88       .pNext = &radv_info,
89       .stageCount = 2,
90       .pStages =
91          (VkPipelineShaderStageCreateInfo[]){
92             {
93                .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
94                .stage = VK_SHADER_STAGE_VERTEX_BIT,
95                .module = vk_shader_module_handle_from_nir(vs_module),
96                .pName = "main",
97             },
98             {
99                .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
100                .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
101                .module = vk_shader_module_handle_from_nir(fs_module),
102                .pName = "main",
103             },
104          },
105       .pVertexInputState =
106          &(VkPipelineVertexInputStateCreateInfo){
107             .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
108             .vertexBindingDescriptionCount = 0,
109             .vertexAttributeDescriptionCount = 0,
110          },
111       .pInputAssemblyState =
112          &(VkPipelineInputAssemblyStateCreateInfo){
113             .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
114             .topology = VK_PRIMITIVE_TOPOLOGY_META_RECT_LIST_MESA,
115             .primitiveRestartEnable = false,
116          },
117       .pViewportState =
118          &(VkPipelineViewportStateCreateInfo){
119             .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
120             .viewportCount = 1,
121             .scissorCount = 1,
122          },
123       .pRasterizationState =
124          &(VkPipelineRasterizationStateCreateInfo){
125             .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
126             .depthClampEnable = false,
127             .rasterizerDiscardEnable = false,
128             .polygonMode = VK_POLYGON_MODE_FILL,
129             .cullMode = VK_CULL_MODE_NONE,
130             .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE,
131          },
132       .pMultisampleState =
133          &(VkPipelineMultisampleStateCreateInfo){
134             .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
135             .pNext = &sample_locs_create_info,
136             .rasterizationSamples = samples,
137             .sampleShadingEnable = false,
138             .pSampleMask = NULL,
139             .alphaToCoverageEnable = false,
140             .alphaToOneEnable = false,
141          },
142       .pColorBlendState =
143          &(VkPipelineColorBlendStateCreateInfo){
144             .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
145             .logicOpEnable = false,
146             .attachmentCount = 0,
147             .pAttachments = NULL,
148          },
149       .pDepthStencilState =
150          &(VkPipelineDepthStencilStateCreateInfo){
151             .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
152             .depthTestEnable = false,
153             .depthWriteEnable = false,
154             .depthBoundsTestEnable = false,
155             .stencilTestEnable = false,
156          },
157       .pDynamicState =
158          &(VkPipelineDynamicStateCreateInfo){
159             .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
160             .dynamicStateCount = 3,
161             .pDynamicStates =
162                (VkDynamicState[]){
163                   VK_DYNAMIC_STATE_VIEWPORT,
164                   VK_DYNAMIC_STATE_SCISSOR,
165                   VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT,
166                },
167          },
168       .layout = *layout_out,
169    };
170 
171    struct vk_meta_rendering_info render = {
172        .depth_attachment_format = VK_FORMAT_D32_SFLOAT_S8_UINT,
173        .stencil_attachment_format = VK_FORMAT_D32_SFLOAT_S8_UINT,
174     };
175 
176    result = vk_meta_create_graphics_pipeline(&device->vk, &device->meta_state.device, &pipeline_create_info, &render,
177                                              key_data, strlen(key_data), pipeline_out);
178 
179    ralloc_free(vs_module);
180    ralloc_free(fs_module);
181 
182    return result;
183 }
184 
185 static void
radv_process_depth_image_layer(struct radv_cmd_buffer * cmd_buffer,struct radv_image * image,const VkImageSubresourceRange * range,int level,int layer)186 radv_process_depth_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image,
187                                const VkImageSubresourceRange *range, int level, int layer)
188 {
189    struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
190    struct radv_image_view iview;
191    uint32_t width, height;
192 
193    width = u_minify(image->vk.extent.width, range->baseMipLevel + level);
194    height = u_minify(image->vk.extent.height, range->baseMipLevel + level);
195 
196    radv_image_view_init(&iview, device,
197                         &(VkImageViewCreateInfo){
198                            .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
199                            .image = radv_image_to_handle(image),
200                            .viewType = radv_meta_get_view_type(image),
201                            .format = image->vk.format,
202                            .subresourceRange =
203                               {
204                                  .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT,
205                                  .baseMipLevel = range->baseMipLevel + level,
206                                  .levelCount = 1,
207                                  .baseArrayLayer = range->baseArrayLayer + layer,
208                                  .layerCount = 1,
209                               },
210                         },
211                         NULL);
212 
213    const VkRenderingAttachmentInfo depth_att = {
214       .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
215       .imageView = radv_image_view_to_handle(&iview),
216       .imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
217       .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
218       .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
219    };
220 
221    const VkRenderingAttachmentInfo stencil_att = {
222       .sType = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO,
223       .imageView = radv_image_view_to_handle(&iview),
224       .imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL,
225       .loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
226       .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
227    };
228 
229    const VkRenderingInfo rendering_info = {
230       .sType = VK_STRUCTURE_TYPE_RENDERING_INFO,
231       .flags = VK_RENDERING_INPUT_ATTACHMENT_NO_CONCURRENT_WRITES_BIT_MESA,
232       .renderArea = {.offset = {0, 0}, .extent = {width, height}},
233       .layerCount = 1,
234       .pDepthAttachment = &depth_att,
235       .pStencilAttachment = &stencil_att,
236    };
237 
238    radv_CmdBeginRendering(radv_cmd_buffer_to_handle(cmd_buffer), &rendering_info);
239 
240    radv_CmdDraw(radv_cmd_buffer_to_handle(cmd_buffer), 3, 1, 0, 0);
241 
242    radv_CmdEndRendering(radv_cmd_buffer_to_handle(cmd_buffer));
243 
244    radv_image_view_finish(&iview);
245 }
246 
247 static void
radv_process_depth_stencil(struct radv_cmd_buffer * cmd_buffer,struct radv_image * image,const VkImageSubresourceRange * subresourceRange,struct radv_sample_locations_state * sample_locs)248 radv_process_depth_stencil(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image,
249                            const VkImageSubresourceRange *subresourceRange,
250                            struct radv_sample_locations_state *sample_locs)
251 {
252    struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
253    struct radv_meta_saved_state saved_state;
254    VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer);
255    VkPipelineLayout layout;
256    VkPipeline pipeline;
257    VkResult result;
258 
259    result = get_pipeline_gfx(device, image, &pipeline, &layout);
260    if (result != VK_SUCCESS) {
261       vk_command_buffer_set_error(&cmd_buffer->vk, result);
262       return;
263    }
264 
265    radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_RENDER);
266 
267    radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline);
268 
269    if (sample_locs) {
270       assert(image->vk.create_flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT);
271 
272       /* Set the sample locations specified during explicit or
273        * automatic layout transitions, otherwise the depth decompress
274        * pass uses the default HW locations.
275        */
276       radv_CmdSetSampleLocationsEXT(cmd_buffer_h, &(VkSampleLocationsInfoEXT){
277                                                      .sampleLocationsPerPixel = sample_locs->per_pixel,
278                                                      .sampleLocationGridSize = sample_locs->grid_size,
279                                                      .sampleLocationsCount = sample_locs->count,
280                                                      .pSampleLocations = sample_locs->locations,
281                                                   });
282    }
283 
284    for (uint32_t l = 0; l < vk_image_subresource_level_count(&image->vk, subresourceRange); ++l) {
285 
286       /* Do not decompress levels without HTILE. */
287       if (!radv_htile_enabled(image, subresourceRange->baseMipLevel + l))
288          continue;
289 
290       uint32_t width = u_minify(image->vk.extent.width, subresourceRange->baseMipLevel + l);
291       uint32_t height = u_minify(image->vk.extent.height, subresourceRange->baseMipLevel + l);
292 
293       radv_CmdSetViewport(
294          cmd_buffer_h, 0, 1,
295          &(VkViewport){.x = 0, .y = 0, .width = width, .height = height, .minDepth = 0.0f, .maxDepth = 1.0f});
296 
297       radv_CmdSetScissor(cmd_buffer_h, 0, 1,
298                          &(VkRect2D){
299                             .offset = {0, 0},
300                             .extent = {width, height},
301                          });
302 
303       for (uint32_t s = 0; s < vk_image_subresource_layer_count(&image->vk, subresourceRange); s++) {
304          radv_process_depth_image_layer(cmd_buffer, image, subresourceRange, l, s);
305       }
306    }
307 
308    radv_meta_restore(&saved_state, cmd_buffer);
309 }
310 
311 static VkResult
get_pipeline_cs(struct radv_device * device,VkPipeline * pipeline_out,VkPipelineLayout * layout_out)312 get_pipeline_cs(struct radv_device *device, VkPipeline *pipeline_out, VkPipelineLayout *layout_out)
313 {
314    const char *key_data = "radv-htile-expand-cs";
315    VkResult result;
316 
317    const VkDescriptorSetLayoutBinding bindings[] = {
318       {
319          .binding = 0,
320          .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
321          .descriptorCount = 1,
322          .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
323       },
324       {
325          .binding = 1,
326          .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
327          .descriptorCount = 1,
328          .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
329       },
330 
331    };
332 
333    const VkDescriptorSetLayoutCreateInfo desc_info = {
334       .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
335       .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT,
336       .bindingCount = 2,
337       .pBindings = bindings,
338    };
339 
340    result = vk_meta_get_pipeline_layout(&device->vk, &device->meta_state.device, &desc_info, NULL, key_data,
341                                         strlen(key_data), layout_out);
342    if (result != VK_SUCCESS)
343       return result;
344 
345    VkPipeline pipeline_from_cache = vk_meta_lookup_pipeline(&device->meta_state.device, key_data, strlen(key_data));
346    if (pipeline_from_cache != VK_NULL_HANDLE) {
347       *pipeline_out = pipeline_from_cache;
348       return VK_SUCCESS;
349    }
350 
351    nir_shader *cs = build_expand_depth_stencil_compute_shader(device);
352 
353    const VkPipelineShaderStageCreateInfo stage_info = {
354       .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
355       .stage = VK_SHADER_STAGE_COMPUTE_BIT,
356       .module = vk_shader_module_handle_from_nir(cs),
357       .pName = "main",
358       .pSpecializationInfo = NULL,
359    };
360 
361    const VkComputePipelineCreateInfo pipeline_info = {
362       .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
363       .stage = stage_info,
364       .flags = 0,
365       .layout = *layout_out,
366    };
367 
368    result = vk_meta_create_compute_pipeline(&device->vk, &device->meta_state.device, &pipeline_info, key_data,
369                                             strlen(key_data), pipeline_out);
370 
371    ralloc_free(cs);
372    return result;
373 }
374 
375 static void
radv_expand_depth_stencil_compute(struct radv_cmd_buffer * cmd_buffer,struct radv_image * image,const VkImageSubresourceRange * subresourceRange)376 radv_expand_depth_stencil_compute(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image,
377                                   const VkImageSubresourceRange *subresourceRange)
378 {
379    struct radv_device *device = radv_cmd_buffer_device(cmd_buffer);
380    struct radv_meta_saved_state saved_state;
381    struct radv_image_view load_iview = {0};
382    struct radv_image_view store_iview = {0};
383    VkPipelineLayout layout;
384    VkPipeline pipeline;
385    VkResult result;
386 
387    assert(radv_image_is_tc_compat_htile(image));
388 
389    result = get_pipeline_cs(device, &pipeline, &layout);
390    if (result != VK_SUCCESS) {
391       vk_command_buffer_set_error(&cmd_buffer->vk, result);
392       return;
393    }
394 
395    radv_meta_save(&saved_state, cmd_buffer, RADV_META_SAVE_DESCRIPTORS | RADV_META_SAVE_COMPUTE_PIPELINE);
396 
397    radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE, pipeline);
398 
399    for (uint32_t l = 0; l < vk_image_subresource_level_count(&image->vk, subresourceRange); l++) {
400       uint32_t width, height;
401 
402       /* Do not decompress levels without HTILE. */
403       if (!radv_htile_enabled(image, subresourceRange->baseMipLevel + l))
404          continue;
405 
406       width = u_minify(image->vk.extent.width, subresourceRange->baseMipLevel + l);
407       height = u_minify(image->vk.extent.height, subresourceRange->baseMipLevel + l);
408 
409       for (uint32_t s = 0; s < vk_image_subresource_layer_count(&image->vk, subresourceRange); s++) {
410          radv_image_view_init(&load_iview, device,
411                               &(VkImageViewCreateInfo){
412                                  .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
413                                  .image = radv_image_to_handle(image),
414                                  .viewType = VK_IMAGE_VIEW_TYPE_2D,
415                                  .format = image->vk.format,
416                                  .subresourceRange = {.aspectMask = subresourceRange->aspectMask,
417                                                       .baseMipLevel = subresourceRange->baseMipLevel + l,
418                                                       .levelCount = 1,
419                                                       .baseArrayLayer = subresourceRange->baseArrayLayer + s,
420                                                       .layerCount = 1},
421                               },
422                               &(struct radv_image_view_extra_create_info){.enable_compression = true});
423          radv_image_view_init(&store_iview, device,
424                               &(VkImageViewCreateInfo){
425                                  .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
426                                  .image = radv_image_to_handle(image),
427                                  .viewType = VK_IMAGE_VIEW_TYPE_2D,
428                                  .format = image->vk.format,
429                                  .subresourceRange = {.aspectMask = subresourceRange->aspectMask,
430                                                       .baseMipLevel = subresourceRange->baseMipLevel + l,
431                                                       .levelCount = 1,
432                                                       .baseArrayLayer = subresourceRange->baseArrayLayer + s,
433                                                       .layerCount = 1},
434                               },
435                               &(struct radv_image_view_extra_create_info){.disable_compression = true});
436 
437          radv_meta_push_descriptor_set(
438             cmd_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, layout, 0, 2,
439             (VkWriteDescriptorSet[]){{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
440                                       .dstBinding = 0,
441                                       .dstArrayElement = 0,
442                                       .descriptorCount = 1,
443                                       .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
444                                       .pImageInfo =
445                                          (VkDescriptorImageInfo[]){
446                                             {
447                                                .sampler = VK_NULL_HANDLE,
448                                                .imageView = radv_image_view_to_handle(&load_iview),
449                                                .imageLayout = VK_IMAGE_LAYOUT_GENERAL,
450                                             },
451                                          }},
452                                      {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
453                                       .dstBinding = 1,
454                                       .dstArrayElement = 0,
455                                       .descriptorCount = 1,
456                                       .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
457                                       .pImageInfo = (VkDescriptorImageInfo[]){
458                                          {
459                                             .sampler = VK_NULL_HANDLE,
460                                             .imageView = radv_image_view_to_handle(&store_iview),
461                                             .imageLayout = VK_IMAGE_LAYOUT_GENERAL,
462                                          },
463                                       }}});
464 
465          radv_unaligned_dispatch(cmd_buffer, width, height, 1);
466 
467          radv_image_view_finish(&load_iview);
468          radv_image_view_finish(&store_iview);
469       }
470    }
471 
472    radv_meta_restore(&saved_state, cmd_buffer);
473 
474    cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_CS_PARTIAL_FLUSH | RADV_CMD_FLAG_INV_VCACHE |
475                                    radv_src_access_flush(cmd_buffer, VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT,
476                                                          VK_ACCESS_2_SHADER_WRITE_BIT, image, subresourceRange);
477 
478    /* Initialize the HTILE metadata as "fully expanded". */
479    uint32_t htile_value = radv_get_htile_initial_value(device, image);
480 
481    cmd_buffer->state.flush_bits |= radv_clear_htile(cmd_buffer, image, subresourceRange, htile_value, false);
482 }
483 
484 void
radv_expand_depth_stencil(struct radv_cmd_buffer * cmd_buffer,struct radv_image * image,const VkImageSubresourceRange * subresourceRange,struct radv_sample_locations_state * sample_locs)485 radv_expand_depth_stencil(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image,
486                           const VkImageSubresourceRange *subresourceRange,
487                           struct radv_sample_locations_state *sample_locs)
488 {
489    struct radv_barrier_data barrier = {0};
490 
491    barrier.layout_transitions.depth_stencil_expand = 1;
492    radv_describe_layout_transition(cmd_buffer, &barrier);
493 
494    if (cmd_buffer->qf == RADV_QUEUE_GENERAL) {
495       radv_process_depth_stencil(cmd_buffer, image, subresourceRange, sample_locs);
496    } else {
497       radv_expand_depth_stencil_compute(cmd_buffer, image, subresourceRange);
498    }
499 }
500