101e04c3fSmrg/* 201e04c3fSmrg * Copyright © 2016 Intel Corporation 301e04c3fSmrg * 401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 501e04c3fSmrg * copy of this software and associated documentation files (the "Software"), 601e04c3fSmrg * to deal in the Software without restriction, including without limitation 701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the 901e04c3fSmrg * Software is furnished to do so, subject to the following conditions: 1001e04c3fSmrg * 1101e04c3fSmrg * The above copyright notice and this permission notice (including the next 1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the 1301e04c3fSmrg * Software. 1401e04c3fSmrg * 1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 2101e04c3fSmrg * IN THE SOFTWARE. 2201e04c3fSmrg */ 2301e04c3fSmrg 2401e04c3fSmrg#include <assert.h> 2501e04c3fSmrg#include <stdbool.h> 2601e04c3fSmrg 2701e04c3fSmrg#include "radv_meta.h" 2801e04c3fSmrg#include "radv_private.h" 2901e04c3fSmrg#include "sid.h" 3001e04c3fSmrg 317ec681f3Smrgenum radv_depth_op { 327ec681f3Smrg DEPTH_DECOMPRESS, 337ec681f3Smrg DEPTH_RESUMMARIZE, 347ec681f3Smrg}; 357ec681f3Smrg 367ec681f3Smrgstatic nir_shader * 377ec681f3Smrgbuild_expand_depth_stencil_compute_shader(struct radv_device *dev) 387ec681f3Smrg{ 397ec681f3Smrg const struct glsl_type *img_type = glsl_image_type(GLSL_SAMPLER_DIM_2D, false, GLSL_TYPE_FLOAT); 407ec681f3Smrg 417ec681f3Smrg nir_builder b = 427ec681f3Smrg nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, NULL, "expand_depth_stencil_compute"); 437ec681f3Smrg 447ec681f3Smrg /* We need at least 8/8/1 to cover an entire HTILE block in a single workgroup. */ 457ec681f3Smrg b.shader->info.workgroup_size[0] = 8; 467ec681f3Smrg b.shader->info.workgroup_size[1] = 8; 477ec681f3Smrg b.shader->info.workgroup_size[2] = 1; 487ec681f3Smrg nir_variable *input_img = nir_variable_create(b.shader, nir_var_uniform, img_type, "in_img"); 497ec681f3Smrg input_img->data.descriptor_set = 0; 507ec681f3Smrg input_img->data.binding = 0; 517ec681f3Smrg 527ec681f3Smrg nir_variable *output_img = nir_variable_create(b.shader, nir_var_uniform, img_type, "out_img"); 537ec681f3Smrg output_img->data.descriptor_set = 0; 547ec681f3Smrg output_img->data.binding = 1; 557ec681f3Smrg 567ec681f3Smrg nir_ssa_def *invoc_id = nir_load_local_invocation_id(&b); 577ec681f3Smrg nir_ssa_def *wg_id = nir_load_workgroup_id(&b, 32); 587ec681f3Smrg nir_ssa_def *block_size = 597ec681f3Smrg nir_imm_ivec4(&b, b.shader->info.workgroup_size[0], b.shader->info.workgroup_size[1], 607ec681f3Smrg b.shader->info.workgroup_size[2], 0); 617ec681f3Smrg 627ec681f3Smrg nir_ssa_def *global_id = nir_iadd(&b, nir_imul(&b, wg_id, block_size), invoc_id); 637ec681f3Smrg 647ec681f3Smrg nir_ssa_def *data = nir_image_deref_load( 657ec681f3Smrg &b, 4, 32, &nir_build_deref_var(&b, input_img)->dest.ssa, global_id, nir_ssa_undef(&b, 1, 32), 667ec681f3Smrg nir_imm_int(&b, 0), .image_dim = GLSL_SAMPLER_DIM_2D); 677ec681f3Smrg 687ec681f3Smrg /* We need a NIR_SCOPE_DEVICE memory_scope because ACO will avoid 697ec681f3Smrg * creating a vmcnt(0) because it expects the L1 cache to keep memory 707ec681f3Smrg * operations in-order for the same workgroup. The vmcnt(0) seems 717ec681f3Smrg * necessary however. */ 727ec681f3Smrg nir_scoped_barrier(&b, .execution_scope = NIR_SCOPE_WORKGROUP, .memory_scope = NIR_SCOPE_DEVICE, 737ec681f3Smrg .memory_semantics = NIR_MEMORY_ACQ_REL, .memory_modes = nir_var_mem_ssbo); 747ec681f3Smrg 757ec681f3Smrg nir_image_deref_store(&b, &nir_build_deref_var(&b, output_img)->dest.ssa, global_id, 767ec681f3Smrg nir_ssa_undef(&b, 1, 32), data, nir_imm_int(&b, 0), 777ec681f3Smrg .image_dim = GLSL_SAMPLER_DIM_2D); 787ec681f3Smrg return b.shader; 797ec681f3Smrg} 807ec681f3Smrg 817ec681f3Smrgstatic VkResult 827ec681f3Smrgcreate_expand_depth_stencil_compute(struct radv_device *device) 837ec681f3Smrg{ 847ec681f3Smrg VkResult result = VK_SUCCESS; 857ec681f3Smrg nir_shader *cs = build_expand_depth_stencil_compute_shader(device); 867ec681f3Smrg 877ec681f3Smrg VkDescriptorSetLayoutCreateInfo ds_create_info = { 887ec681f3Smrg .sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, 897ec681f3Smrg .flags = VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR, 907ec681f3Smrg .bindingCount = 2, 917ec681f3Smrg .pBindings = (VkDescriptorSetLayoutBinding[]){ 927ec681f3Smrg {.binding = 0, 937ec681f3Smrg .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 947ec681f3Smrg .descriptorCount = 1, 957ec681f3Smrg .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT, 967ec681f3Smrg .pImmutableSamplers = NULL}, 977ec681f3Smrg {.binding = 1, 987ec681f3Smrg .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 997ec681f3Smrg .descriptorCount = 1, 1007ec681f3Smrg .stageFlags = VK_SHADER_STAGE_COMPUTE_BIT, 1017ec681f3Smrg .pImmutableSamplers = NULL}, 1027ec681f3Smrg }}; 1037ec681f3Smrg 1047ec681f3Smrg result = radv_CreateDescriptorSetLayout( 1057ec681f3Smrg radv_device_to_handle(device), &ds_create_info, &device->meta_state.alloc, 1067ec681f3Smrg &device->meta_state.expand_depth_stencil_compute_ds_layout); 1077ec681f3Smrg if (result != VK_SUCCESS) 1087ec681f3Smrg goto cleanup; 1097ec681f3Smrg 1107ec681f3Smrg VkPipelineLayoutCreateInfo pl_create_info = { 1117ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, 1127ec681f3Smrg .setLayoutCount = 1, 1137ec681f3Smrg .pSetLayouts = &device->meta_state.expand_depth_stencil_compute_ds_layout, 1147ec681f3Smrg .pushConstantRangeCount = 0, 1157ec681f3Smrg .pPushConstantRanges = NULL, 1167ec681f3Smrg }; 1177ec681f3Smrg 1187ec681f3Smrg result = radv_CreatePipelineLayout( 1197ec681f3Smrg radv_device_to_handle(device), &pl_create_info, &device->meta_state.alloc, 1207ec681f3Smrg &device->meta_state.expand_depth_stencil_compute_p_layout); 1217ec681f3Smrg if (result != VK_SUCCESS) 1227ec681f3Smrg goto cleanup; 1237ec681f3Smrg 1247ec681f3Smrg /* compute shader */ 1257ec681f3Smrg 1267ec681f3Smrg VkPipelineShaderStageCreateInfo pipeline_shader_stage = { 1277ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, 1287ec681f3Smrg .stage = VK_SHADER_STAGE_COMPUTE_BIT, 1297ec681f3Smrg .module = vk_shader_module_handle_from_nir(cs), 1307ec681f3Smrg .pName = "main", 1317ec681f3Smrg .pSpecializationInfo = NULL, 1327ec681f3Smrg }; 1337ec681f3Smrg 1347ec681f3Smrg VkComputePipelineCreateInfo vk_pipeline_info = { 1357ec681f3Smrg .sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO, 1367ec681f3Smrg .stage = pipeline_shader_stage, 1377ec681f3Smrg .flags = 0, 1387ec681f3Smrg .layout = device->meta_state.expand_depth_stencil_compute_p_layout, 1397ec681f3Smrg }; 1407ec681f3Smrg 1417ec681f3Smrg result = radv_CreateComputePipelines( 1427ec681f3Smrg radv_device_to_handle(device), radv_pipeline_cache_to_handle(&device->meta_state.cache), 1, 1437ec681f3Smrg &vk_pipeline_info, NULL, 1447ec681f3Smrg &device->meta_state.expand_depth_stencil_compute_pipeline); 1457ec681f3Smrg if (result != VK_SUCCESS) 1467ec681f3Smrg goto cleanup; 1477ec681f3Smrg 1487ec681f3Smrgcleanup: 1497ec681f3Smrg ralloc_free(cs); 1507ec681f3Smrg return result; 1517ec681f3Smrg} 1527ec681f3Smrg 15301e04c3fSmrgstatic VkResult 1547ec681f3Smrgcreate_pass(struct radv_device *device, uint32_t samples, VkRenderPass *pass) 15501e04c3fSmrg{ 1567ec681f3Smrg VkResult result; 1577ec681f3Smrg VkDevice device_h = radv_device_to_handle(device); 1587ec681f3Smrg const VkAllocationCallbacks *alloc = &device->meta_state.alloc; 1597ec681f3Smrg VkAttachmentDescription2 attachment; 1607ec681f3Smrg 1617ec681f3Smrg attachment.sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2; 1627ec681f3Smrg attachment.pNext = NULL; 1637ec681f3Smrg attachment.flags = 0; 1647ec681f3Smrg attachment.format = VK_FORMAT_D32_SFLOAT_S8_UINT; 1657ec681f3Smrg attachment.samples = samples; 1667ec681f3Smrg attachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; 1677ec681f3Smrg attachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE; 1687ec681f3Smrg attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_LOAD; 1697ec681f3Smrg attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE; 1707ec681f3Smrg attachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; 1717ec681f3Smrg attachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; 1727ec681f3Smrg 1737ec681f3Smrg result = radv_CreateRenderPass2( 1747ec681f3Smrg device_h, 1757ec681f3Smrg &(VkRenderPassCreateInfo2){ 1767ec681f3Smrg .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2, 1777ec681f3Smrg .attachmentCount = 1, 1787ec681f3Smrg .pAttachments = &attachment, 1797ec681f3Smrg .subpassCount = 1, 1807ec681f3Smrg .pSubpasses = 1817ec681f3Smrg &(VkSubpassDescription2){ 1827ec681f3Smrg .sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2, 1837ec681f3Smrg .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS, 1847ec681f3Smrg .inputAttachmentCount = 0, 1857ec681f3Smrg .colorAttachmentCount = 0, 1867ec681f3Smrg .pColorAttachments = NULL, 1877ec681f3Smrg .pResolveAttachments = NULL, 1887ec681f3Smrg .pDepthStencilAttachment = 1897ec681f3Smrg &(VkAttachmentReference2){ 1907ec681f3Smrg .sType = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2, 1917ec681f3Smrg .attachment = 0, 1927ec681f3Smrg .layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, 1937ec681f3Smrg }, 1947ec681f3Smrg .preserveAttachmentCount = 0, 1957ec681f3Smrg .pPreserveAttachments = NULL, 1967ec681f3Smrg }, 1977ec681f3Smrg .dependencyCount = 2, 1987ec681f3Smrg .pDependencies = 1997ec681f3Smrg (VkSubpassDependency2[]){{.sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2, 2007ec681f3Smrg .srcSubpass = VK_SUBPASS_EXTERNAL, 2017ec681f3Smrg .dstSubpass = 0, 2027ec681f3Smrg .srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 2037ec681f3Smrg .dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 2047ec681f3Smrg .srcAccessMask = 0, 2057ec681f3Smrg .dstAccessMask = 0, 2067ec681f3Smrg .dependencyFlags = 0}, 2077ec681f3Smrg {.sType = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2, 2087ec681f3Smrg .srcSubpass = 0, 2097ec681f3Smrg .dstSubpass = VK_SUBPASS_EXTERNAL, 2107ec681f3Smrg .srcStageMask = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 2117ec681f3Smrg .dstStageMask = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 2127ec681f3Smrg .srcAccessMask = 0, 2137ec681f3Smrg .dstAccessMask = 0, 2147ec681f3Smrg .dependencyFlags = 0}}, 2157ec681f3Smrg }, 2167ec681f3Smrg alloc, pass); 2177ec681f3Smrg 2187ec681f3Smrg return result; 21901e04c3fSmrg} 22001e04c3fSmrg 22101e04c3fSmrgstatic VkResult 22201e04c3fSmrgcreate_pipeline_layout(struct radv_device *device, VkPipelineLayout *layout) 22301e04c3fSmrg{ 2247ec681f3Smrg VkPipelineLayoutCreateInfo pl_create_info = { 2257ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, 2267ec681f3Smrg .setLayoutCount = 0, 2277ec681f3Smrg .pSetLayouts = NULL, 2287ec681f3Smrg .pushConstantRangeCount = 0, 2297ec681f3Smrg .pPushConstantRanges = NULL, 2307ec681f3Smrg }; 2317ec681f3Smrg 2327ec681f3Smrg return radv_CreatePipelineLayout(radv_device_to_handle(device), &pl_create_info, 2337ec681f3Smrg &device->meta_state.alloc, layout); 23401e04c3fSmrg} 23501e04c3fSmrg 23601e04c3fSmrgstatic VkResult 2377ec681f3Smrgcreate_pipeline(struct radv_device *device, uint32_t samples, VkRenderPass pass, 2387ec681f3Smrg VkPipelineLayout layout, enum radv_depth_op op, VkPipeline *pipeline) 23901e04c3fSmrg{ 2407ec681f3Smrg VkResult result; 2417ec681f3Smrg VkDevice device_h = radv_device_to_handle(device); 2427ec681f3Smrg 2437ec681f3Smrg mtx_lock(&device->meta_state.mtx); 2447ec681f3Smrg if (*pipeline) { 2457ec681f3Smrg mtx_unlock(&device->meta_state.mtx); 2467ec681f3Smrg return VK_SUCCESS; 2477ec681f3Smrg } 2487ec681f3Smrg 2497ec681f3Smrg nir_shader *vs_module = radv_meta_build_nir_vs_generate_vertices(); 2507ec681f3Smrg nir_shader *fs_module = radv_meta_build_nir_fs_noop(); 2517ec681f3Smrg 2527ec681f3Smrg if (!vs_module || !fs_module) { 2537ec681f3Smrg /* XXX: Need more accurate error */ 2547ec681f3Smrg result = VK_ERROR_OUT_OF_HOST_MEMORY; 2557ec681f3Smrg goto cleanup; 2567ec681f3Smrg } 2577ec681f3Smrg 2587ec681f3Smrg const VkPipelineSampleLocationsStateCreateInfoEXT sample_locs_create_info = { 2597ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT, 2607ec681f3Smrg .sampleLocationsEnable = false, 2617ec681f3Smrg }; 2627ec681f3Smrg 2637ec681f3Smrg const VkGraphicsPipelineCreateInfo pipeline_create_info = { 2647ec681f3Smrg .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO, 2657ec681f3Smrg .stageCount = 2, 2667ec681f3Smrg .pStages = 2677ec681f3Smrg (VkPipelineShaderStageCreateInfo[]){ 2687ec681f3Smrg { 2697ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, 2707ec681f3Smrg .stage = VK_SHADER_STAGE_VERTEX_BIT, 2717ec681f3Smrg .module = vk_shader_module_handle_from_nir(vs_module), 2727ec681f3Smrg .pName = "main", 2737ec681f3Smrg }, 2747ec681f3Smrg { 2757ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO, 2767ec681f3Smrg .stage = VK_SHADER_STAGE_FRAGMENT_BIT, 2777ec681f3Smrg .module = vk_shader_module_handle_from_nir(fs_module), 2787ec681f3Smrg .pName = "main", 2797ec681f3Smrg }, 2807ec681f3Smrg }, 2817ec681f3Smrg .pVertexInputState = 2827ec681f3Smrg &(VkPipelineVertexInputStateCreateInfo){ 2837ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, 2847ec681f3Smrg .vertexBindingDescriptionCount = 0, 2857ec681f3Smrg .vertexAttributeDescriptionCount = 0, 2867ec681f3Smrg }, 2877ec681f3Smrg .pInputAssemblyState = 2887ec681f3Smrg &(VkPipelineInputAssemblyStateCreateInfo){ 2897ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, 2907ec681f3Smrg .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, 2917ec681f3Smrg .primitiveRestartEnable = false, 2927ec681f3Smrg }, 2937ec681f3Smrg .pViewportState = 2947ec681f3Smrg &(VkPipelineViewportStateCreateInfo){ 2957ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, 2967ec681f3Smrg .viewportCount = 1, 2977ec681f3Smrg .scissorCount = 1, 2987ec681f3Smrg }, 2997ec681f3Smrg .pRasterizationState = 3007ec681f3Smrg &(VkPipelineRasterizationStateCreateInfo){ 3017ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, 3027ec681f3Smrg .depthClampEnable = false, 3037ec681f3Smrg .rasterizerDiscardEnable = false, 3047ec681f3Smrg .polygonMode = VK_POLYGON_MODE_FILL, 3057ec681f3Smrg .cullMode = VK_CULL_MODE_NONE, 3067ec681f3Smrg .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE, 3077ec681f3Smrg }, 3087ec681f3Smrg .pMultisampleState = 3097ec681f3Smrg &(VkPipelineMultisampleStateCreateInfo){ 3107ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO, 3117ec681f3Smrg .pNext = &sample_locs_create_info, 3127ec681f3Smrg .rasterizationSamples = samples, 3137ec681f3Smrg .sampleShadingEnable = false, 3147ec681f3Smrg .pSampleMask = NULL, 3157ec681f3Smrg .alphaToCoverageEnable = false, 3167ec681f3Smrg .alphaToOneEnable = false, 3177ec681f3Smrg }, 3187ec681f3Smrg .pColorBlendState = 3197ec681f3Smrg &(VkPipelineColorBlendStateCreateInfo){ 3207ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, 3217ec681f3Smrg .logicOpEnable = false, 3227ec681f3Smrg .attachmentCount = 0, 3237ec681f3Smrg .pAttachments = NULL, 3247ec681f3Smrg }, 3257ec681f3Smrg .pDepthStencilState = 3267ec681f3Smrg &(VkPipelineDepthStencilStateCreateInfo){ 3277ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, 3287ec681f3Smrg .depthTestEnable = false, 3297ec681f3Smrg .depthWriteEnable = false, 3307ec681f3Smrg .depthBoundsTestEnable = false, 3317ec681f3Smrg .stencilTestEnable = false, 3327ec681f3Smrg }, 3337ec681f3Smrg .pDynamicState = 3347ec681f3Smrg &(VkPipelineDynamicStateCreateInfo){ 3357ec681f3Smrg .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, 3367ec681f3Smrg .dynamicStateCount = 3, 3377ec681f3Smrg .pDynamicStates = 3387ec681f3Smrg (VkDynamicState[]){ 3397ec681f3Smrg VK_DYNAMIC_STATE_VIEWPORT, 3407ec681f3Smrg VK_DYNAMIC_STATE_SCISSOR, 3417ec681f3Smrg VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, 3427ec681f3Smrg }, 3437ec681f3Smrg }, 3447ec681f3Smrg .layout = layout, 3457ec681f3Smrg .renderPass = pass, 3467ec681f3Smrg .subpass = 0, 3477ec681f3Smrg }; 3487ec681f3Smrg 3497ec681f3Smrg struct radv_graphics_pipeline_create_info extra = { 3507ec681f3Smrg .use_rectlist = true, 3517ec681f3Smrg .depth_compress_disable = true, 3527ec681f3Smrg .stencil_compress_disable = true, 3537ec681f3Smrg .resummarize_enable = op == DEPTH_RESUMMARIZE, 3547ec681f3Smrg }; 3557ec681f3Smrg 3567ec681f3Smrg result = radv_graphics_pipeline_create( 3577ec681f3Smrg device_h, radv_pipeline_cache_to_handle(&device->meta_state.cache), &pipeline_create_info, 3587ec681f3Smrg &extra, &device->meta_state.alloc, pipeline); 35901e04c3fSmrg 36001e04c3fSmrgcleanup: 3617ec681f3Smrg ralloc_free(fs_module); 3627ec681f3Smrg ralloc_free(vs_module); 3637ec681f3Smrg mtx_unlock(&device->meta_state.mtx); 3647ec681f3Smrg return result; 36501e04c3fSmrg} 36601e04c3fSmrg 36701e04c3fSmrgvoid 36801e04c3fSmrgradv_device_finish_meta_depth_decomp_state(struct radv_device *device) 36901e04c3fSmrg{ 3707ec681f3Smrg struct radv_meta_state *state = &device->meta_state; 3717ec681f3Smrg 3727ec681f3Smrg for (uint32_t i = 0; i < ARRAY_SIZE(state->depth_decomp); ++i) { 3737ec681f3Smrg radv_DestroyRenderPass(radv_device_to_handle(device), state->depth_decomp[i].pass, 3747ec681f3Smrg &state->alloc); 3757ec681f3Smrg radv_DestroyPipelineLayout(radv_device_to_handle(device), state->depth_decomp[i].p_layout, 3767ec681f3Smrg &state->alloc); 3777ec681f3Smrg 3787ec681f3Smrg radv_DestroyPipeline(radv_device_to_handle(device), 3797ec681f3Smrg state->depth_decomp[i].decompress_pipeline, &state->alloc); 3807ec681f3Smrg radv_DestroyPipeline(radv_device_to_handle(device), 3817ec681f3Smrg state->depth_decomp[i].resummarize_pipeline, &state->alloc); 3827ec681f3Smrg } 3837ec681f3Smrg 3847ec681f3Smrg radv_DestroyPipeline(radv_device_to_handle(device), 3857ec681f3Smrg state->expand_depth_stencil_compute_pipeline, &state->alloc); 3867ec681f3Smrg radv_DestroyPipelineLayout(radv_device_to_handle(device), 3877ec681f3Smrg state->expand_depth_stencil_compute_p_layout, &state->alloc); 3887ec681f3Smrg radv_DestroyDescriptorSetLayout(radv_device_to_handle(device), 3897ec681f3Smrg state->expand_depth_stencil_compute_ds_layout, &state->alloc); 39001e04c3fSmrg} 39101e04c3fSmrg 39201e04c3fSmrgVkResult 39301e04c3fSmrgradv_device_init_meta_depth_decomp_state(struct radv_device *device, bool on_demand) 39401e04c3fSmrg{ 3957ec681f3Smrg struct radv_meta_state *state = &device->meta_state; 3967ec681f3Smrg VkResult res = VK_SUCCESS; 39701e04c3fSmrg 3987ec681f3Smrg for (uint32_t i = 0; i < ARRAY_SIZE(state->depth_decomp); ++i) { 3997ec681f3Smrg uint32_t samples = 1 << i; 40001e04c3fSmrg 4017ec681f3Smrg res = create_pass(device, samples, &state->depth_decomp[i].pass); 4027ec681f3Smrg if (res != VK_SUCCESS) 4037ec681f3Smrg goto fail; 40401e04c3fSmrg 4057ec681f3Smrg res = create_pipeline_layout(device, &state->depth_decomp[i].p_layout); 4067ec681f3Smrg if (res != VK_SUCCESS) 4077ec681f3Smrg goto fail; 40801e04c3fSmrg 4097ec681f3Smrg if (on_demand) 4107ec681f3Smrg continue; 41101e04c3fSmrg 4127ec681f3Smrg res = create_pipeline(device, samples, state->depth_decomp[i].pass, 4137ec681f3Smrg state->depth_decomp[i].p_layout, DEPTH_DECOMPRESS, 4147ec681f3Smrg &state->depth_decomp[i].decompress_pipeline); 4157ec681f3Smrg if (res != VK_SUCCESS) 4167ec681f3Smrg goto fail; 41701e04c3fSmrg 4187ec681f3Smrg res = create_pipeline(device, samples, state->depth_decomp[i].pass, 4197ec681f3Smrg state->depth_decomp[i].p_layout, DEPTH_RESUMMARIZE, 4207ec681f3Smrg &state->depth_decomp[i].resummarize_pipeline); 4217ec681f3Smrg if (res != VK_SUCCESS) 4227ec681f3Smrg goto fail; 4237ec681f3Smrg } 42401e04c3fSmrg 4257ec681f3Smrg res = create_expand_depth_stencil_compute(device); 4267ec681f3Smrg if (res != VK_SUCCESS) 4277ec681f3Smrg goto fail; 42801e04c3fSmrg 4297ec681f3Smrg return VK_SUCCESS; 43001e04c3fSmrg 43101e04c3fSmrgfail: 4327ec681f3Smrg radv_device_finish_meta_depth_decomp_state(device); 4337ec681f3Smrg return res; 4347ec681f3Smrg} 43501e04c3fSmrg 4367ec681f3Smrgstatic VkPipeline * 4377ec681f3Smrgradv_get_depth_pipeline(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, 4387ec681f3Smrg const VkImageSubresourceRange *subresourceRange, enum radv_depth_op op) 4397ec681f3Smrg{ 4407ec681f3Smrg struct radv_meta_state *state = &cmd_buffer->device->meta_state; 4417ec681f3Smrg uint32_t samples = image->info.samples; 4427ec681f3Smrg uint32_t samples_log2 = ffs(samples) - 1; 4437ec681f3Smrg VkPipeline *pipeline; 4447ec681f3Smrg 4457ec681f3Smrg if (!state->depth_decomp[samples_log2].decompress_pipeline) { 4467ec681f3Smrg VkResult ret; 4477ec681f3Smrg 4487ec681f3Smrg ret = create_pipeline(cmd_buffer->device, samples, state->depth_decomp[samples_log2].pass, 4497ec681f3Smrg state->depth_decomp[samples_log2].p_layout, DEPTH_DECOMPRESS, 4507ec681f3Smrg &state->depth_decomp[samples_log2].decompress_pipeline); 4517ec681f3Smrg if (ret != VK_SUCCESS) { 4527ec681f3Smrg cmd_buffer->record_result = ret; 4537ec681f3Smrg return NULL; 4547ec681f3Smrg } 4557ec681f3Smrg 4567ec681f3Smrg ret = create_pipeline(cmd_buffer->device, samples, state->depth_decomp[samples_log2].pass, 4577ec681f3Smrg state->depth_decomp[samples_log2].p_layout, DEPTH_RESUMMARIZE, 4587ec681f3Smrg &state->depth_decomp[samples_log2].resummarize_pipeline); 4597ec681f3Smrg if (ret != VK_SUCCESS) { 4607ec681f3Smrg cmd_buffer->record_result = ret; 4617ec681f3Smrg return NULL; 4627ec681f3Smrg } 4637ec681f3Smrg } 4647ec681f3Smrg 4657ec681f3Smrg switch (op) { 4667ec681f3Smrg case DEPTH_DECOMPRESS: 4677ec681f3Smrg pipeline = &state->depth_decomp[samples_log2].decompress_pipeline; 4687ec681f3Smrg break; 4697ec681f3Smrg case DEPTH_RESUMMARIZE: 4707ec681f3Smrg pipeline = &state->depth_decomp[samples_log2].resummarize_pipeline; 4717ec681f3Smrg break; 4727ec681f3Smrg default: 4737ec681f3Smrg unreachable("unknown operation"); 4747ec681f3Smrg } 4757ec681f3Smrg 4767ec681f3Smrg return pipeline; 4777ec681f3Smrg} 47801e04c3fSmrg 4797ec681f3Smrgstatic void 4807ec681f3Smrgradv_process_depth_image_layer(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, 4817ec681f3Smrg const VkImageSubresourceRange *range, int level, int layer) 4827ec681f3Smrg{ 4837ec681f3Smrg struct radv_device *device = cmd_buffer->device; 4847ec681f3Smrg struct radv_meta_state *state = &device->meta_state; 4857ec681f3Smrg uint32_t samples_log2 = ffs(image->info.samples) - 1; 4867ec681f3Smrg struct radv_image_view iview; 4877ec681f3Smrg uint32_t width, height; 4887ec681f3Smrg 4897ec681f3Smrg width = radv_minify(image->info.width, range->baseMipLevel + level); 4907ec681f3Smrg height = radv_minify(image->info.height, range->baseMipLevel + level); 4917ec681f3Smrg 4927ec681f3Smrg radv_image_view_init(&iview, device, 4937ec681f3Smrg &(VkImageViewCreateInfo){ 4947ec681f3Smrg .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, 4957ec681f3Smrg .image = radv_image_to_handle(image), 4967ec681f3Smrg .viewType = radv_meta_get_view_type(image), 4977ec681f3Smrg .format = image->vk_format, 4987ec681f3Smrg .subresourceRange = 4997ec681f3Smrg { 5007ec681f3Smrg .aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT, 5017ec681f3Smrg .baseMipLevel = range->baseMipLevel + level, 5027ec681f3Smrg .levelCount = 1, 5037ec681f3Smrg .baseArrayLayer = range->baseArrayLayer + layer, 5047ec681f3Smrg .layerCount = 1, 5057ec681f3Smrg }, 5067ec681f3Smrg }, 5077ec681f3Smrg NULL); 5087ec681f3Smrg 5097ec681f3Smrg VkFramebuffer fb_h; 5107ec681f3Smrg radv_CreateFramebuffer( 5117ec681f3Smrg radv_device_to_handle(device), 5127ec681f3Smrg &(VkFramebufferCreateInfo){.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, 5137ec681f3Smrg .attachmentCount = 1, 5147ec681f3Smrg .pAttachments = (VkImageView[]){radv_image_view_to_handle(&iview)}, 5157ec681f3Smrg .width = width, 5167ec681f3Smrg .height = height, 5177ec681f3Smrg .layers = 1}, 5187ec681f3Smrg &cmd_buffer->pool->alloc, &fb_h); 5197ec681f3Smrg 5207ec681f3Smrg radv_cmd_buffer_begin_render_pass(cmd_buffer, 5217ec681f3Smrg &(VkRenderPassBeginInfo){ 5227ec681f3Smrg .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, 5237ec681f3Smrg .renderPass = state->depth_decomp[samples_log2].pass, 5247ec681f3Smrg .framebuffer = fb_h, 5257ec681f3Smrg .renderArea = {.offset = 5267ec681f3Smrg { 5277ec681f3Smrg 0, 5287ec681f3Smrg 0, 5297ec681f3Smrg }, 5307ec681f3Smrg .extent = 5317ec681f3Smrg { 5327ec681f3Smrg width, 5337ec681f3Smrg height, 5347ec681f3Smrg }}, 5357ec681f3Smrg .clearValueCount = 0, 5367ec681f3Smrg .pClearValues = NULL, 5377ec681f3Smrg }, 5387ec681f3Smrg NULL); 5397ec681f3Smrg radv_cmd_buffer_set_subpass(cmd_buffer, &cmd_buffer->state.pass->subpasses[0]); 5407ec681f3Smrg 5417ec681f3Smrg radv_CmdDraw(radv_cmd_buffer_to_handle(cmd_buffer), 3, 1, 0, 0); 5427ec681f3Smrg radv_cmd_buffer_end_render_pass(cmd_buffer); 5437ec681f3Smrg 5447ec681f3Smrg radv_image_view_finish(&iview); 5457ec681f3Smrg radv_DestroyFramebuffer(radv_device_to_handle(device), fb_h, &cmd_buffer->pool->alloc); 54601e04c3fSmrg} 54701e04c3fSmrg 5487ec681f3Smrgstatic void 5497ec681f3Smrgradv_process_depth_stencil(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, 5507ec681f3Smrg const VkImageSubresourceRange *subresourceRange, 5517ec681f3Smrg struct radv_sample_locations_state *sample_locs, enum radv_depth_op op) 5527ec681f3Smrg{ 5537ec681f3Smrg struct radv_meta_saved_state saved_state; 5547ec681f3Smrg VkCommandBuffer cmd_buffer_h = radv_cmd_buffer_to_handle(cmd_buffer); 5557ec681f3Smrg VkPipeline *pipeline; 5567ec681f3Smrg 5577ec681f3Smrg radv_meta_save( 5587ec681f3Smrg &saved_state, cmd_buffer, 5597ec681f3Smrg RADV_META_SAVE_GRAPHICS_PIPELINE | RADV_META_SAVE_SAMPLE_LOCATIONS | RADV_META_SAVE_PASS); 5607ec681f3Smrg 5617ec681f3Smrg pipeline = radv_get_depth_pipeline(cmd_buffer, image, subresourceRange, op); 5627ec681f3Smrg 5637ec681f3Smrg radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_GRAPHICS, 5647ec681f3Smrg *pipeline); 5657ec681f3Smrg 5667ec681f3Smrg if (sample_locs) { 5677ec681f3Smrg assert(image->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT); 5687ec681f3Smrg 5697ec681f3Smrg /* Set the sample locations specified during explicit or 5707ec681f3Smrg * automatic layout transitions, otherwise the depth decompress 5717ec681f3Smrg * pass uses the default HW locations. 5727ec681f3Smrg */ 5737ec681f3Smrg radv_CmdSetSampleLocationsEXT(cmd_buffer_h, 5747ec681f3Smrg &(VkSampleLocationsInfoEXT){ 5757ec681f3Smrg .sampleLocationsPerPixel = sample_locs->per_pixel, 5767ec681f3Smrg .sampleLocationGridSize = sample_locs->grid_size, 5777ec681f3Smrg .sampleLocationsCount = sample_locs->count, 5787ec681f3Smrg .pSampleLocations = sample_locs->locations, 5797ec681f3Smrg }); 5807ec681f3Smrg } 5817ec681f3Smrg 5827ec681f3Smrg for (uint32_t l = 0; l < radv_get_levelCount(image, subresourceRange); ++l) { 5837ec681f3Smrg 5847ec681f3Smrg /* Do not decompress levels without HTILE. */ 5857ec681f3Smrg if (!radv_htile_enabled(image, subresourceRange->baseMipLevel + l)) 5867ec681f3Smrg continue; 5877ec681f3Smrg 5887ec681f3Smrg uint32_t width = radv_minify(image->info.width, subresourceRange->baseMipLevel + l); 5897ec681f3Smrg uint32_t height = radv_minify(image->info.height, subresourceRange->baseMipLevel + l); 5907ec681f3Smrg 5917ec681f3Smrg radv_CmdSetViewport(cmd_buffer_h, 0, 1, 5927ec681f3Smrg &(VkViewport){.x = 0, 5937ec681f3Smrg .y = 0, 5947ec681f3Smrg .width = width, 5957ec681f3Smrg .height = height, 5967ec681f3Smrg .minDepth = 0.0f, 5977ec681f3Smrg .maxDepth = 1.0f}); 5987ec681f3Smrg 5997ec681f3Smrg radv_CmdSetScissor(cmd_buffer_h, 0, 1, 6007ec681f3Smrg &(VkRect2D){ 6017ec681f3Smrg .offset = {0, 0}, 6027ec681f3Smrg .extent = {width, height}, 6037ec681f3Smrg }); 6047ec681f3Smrg 6057ec681f3Smrg for (uint32_t s = 0; s < radv_get_layerCount(image, subresourceRange); s++) { 6067ec681f3Smrg radv_process_depth_image_layer(cmd_buffer, image, subresourceRange, l, s); 6077ec681f3Smrg } 6087ec681f3Smrg } 6097ec681f3Smrg 6107ec681f3Smrg radv_meta_restore(&saved_state, cmd_buffer); 6117ec681f3Smrg} 61201e04c3fSmrg 6137ec681f3Smrgstatic void 6147ec681f3Smrgradv_expand_depth_stencil_compute(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, 6157ec681f3Smrg const VkImageSubresourceRange *subresourceRange) 61601e04c3fSmrg{ 6177ec681f3Smrg struct radv_meta_saved_state saved_state; 6187ec681f3Smrg struct radv_image_view load_iview = {0}; 6197ec681f3Smrg struct radv_image_view store_iview = {0}; 6207ec681f3Smrg struct radv_device *device = cmd_buffer->device; 6217ec681f3Smrg 6227ec681f3Smrg assert(radv_image_is_tc_compat_htile(image)); 6237ec681f3Smrg 6247ec681f3Smrg cmd_buffer->state.flush_bits |= 6257ec681f3Smrg radv_dst_access_flush(cmd_buffer, VK_ACCESS_SHADER_WRITE_BIT, image); 6267ec681f3Smrg 6277ec681f3Smrg radv_meta_save(&saved_state, cmd_buffer, 6287ec681f3Smrg RADV_META_SAVE_DESCRIPTORS | RADV_META_SAVE_COMPUTE_PIPELINE); 6297ec681f3Smrg 6307ec681f3Smrg radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer), VK_PIPELINE_BIND_POINT_COMPUTE, 6317ec681f3Smrg device->meta_state.expand_depth_stencil_compute_pipeline); 6327ec681f3Smrg 6337ec681f3Smrg for (uint32_t l = 0; l < radv_get_levelCount(image, subresourceRange); l++) { 6347ec681f3Smrg uint32_t width, height; 6357ec681f3Smrg 6367ec681f3Smrg /* Do not decompress levels without HTILE. */ 6377ec681f3Smrg if (!radv_htile_enabled(image, subresourceRange->baseMipLevel + l)) 6387ec681f3Smrg continue; 6397ec681f3Smrg 6407ec681f3Smrg width = radv_minify(image->info.width, subresourceRange->baseMipLevel + l); 6417ec681f3Smrg height = radv_minify(image->info.height, subresourceRange->baseMipLevel + l); 6427ec681f3Smrg 6437ec681f3Smrg for (uint32_t s = 0; s < radv_get_layerCount(image, subresourceRange); s++) { 6447ec681f3Smrg radv_image_view_init( 6457ec681f3Smrg &load_iview, cmd_buffer->device, 6467ec681f3Smrg &(VkImageViewCreateInfo){ 6477ec681f3Smrg .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, 6487ec681f3Smrg .image = radv_image_to_handle(image), 6497ec681f3Smrg .viewType = VK_IMAGE_VIEW_TYPE_2D, 6507ec681f3Smrg .format = image->vk_format, 6517ec681f3Smrg .subresourceRange = {.aspectMask = subresourceRange->aspectMask, 6527ec681f3Smrg .baseMipLevel = subresourceRange->baseMipLevel + l, 6537ec681f3Smrg .levelCount = 1, 6547ec681f3Smrg .baseArrayLayer = subresourceRange->baseArrayLayer + s, 6557ec681f3Smrg .layerCount = 1}, 6567ec681f3Smrg }, 6577ec681f3Smrg &(struct radv_image_view_extra_create_info){.enable_compression = true}); 6587ec681f3Smrg radv_image_view_init( 6597ec681f3Smrg &store_iview, cmd_buffer->device, 6607ec681f3Smrg &(VkImageViewCreateInfo){ 6617ec681f3Smrg .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, 6627ec681f3Smrg .image = radv_image_to_handle(image), 6637ec681f3Smrg .viewType = VK_IMAGE_VIEW_TYPE_2D, 6647ec681f3Smrg .format = image->vk_format, 6657ec681f3Smrg .subresourceRange = {.aspectMask = subresourceRange->aspectMask, 6667ec681f3Smrg .baseMipLevel = subresourceRange->baseMipLevel + l, 6677ec681f3Smrg .levelCount = 1, 6687ec681f3Smrg .baseArrayLayer = subresourceRange->baseArrayLayer + s, 6697ec681f3Smrg .layerCount = 1}, 6707ec681f3Smrg }, 6717ec681f3Smrg &(struct radv_image_view_extra_create_info){.disable_compression = true}); 6727ec681f3Smrg 6737ec681f3Smrg radv_meta_push_descriptor_set( 6747ec681f3Smrg cmd_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, 6757ec681f3Smrg device->meta_state.expand_depth_stencil_compute_p_layout, 0, /* set */ 6767ec681f3Smrg 2, /* descriptorWriteCount */ 6777ec681f3Smrg (VkWriteDescriptorSet[]){{.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, 6787ec681f3Smrg .dstBinding = 0, 6797ec681f3Smrg .dstArrayElement = 0, 6807ec681f3Smrg .descriptorCount = 1, 6817ec681f3Smrg .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 6827ec681f3Smrg .pImageInfo = 6837ec681f3Smrg (VkDescriptorImageInfo[]){ 6847ec681f3Smrg { 6857ec681f3Smrg .sampler = VK_NULL_HANDLE, 6867ec681f3Smrg .imageView = radv_image_view_to_handle(&load_iview), 6877ec681f3Smrg .imageLayout = VK_IMAGE_LAYOUT_GENERAL, 6887ec681f3Smrg }, 6897ec681f3Smrg }}, 6907ec681f3Smrg {.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, 6917ec681f3Smrg .dstBinding = 1, 6927ec681f3Smrg .dstArrayElement = 0, 6937ec681f3Smrg .descriptorCount = 1, 6947ec681f3Smrg .descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, 6957ec681f3Smrg .pImageInfo = (VkDescriptorImageInfo[]){ 6967ec681f3Smrg { 6977ec681f3Smrg .sampler = VK_NULL_HANDLE, 6987ec681f3Smrg .imageView = radv_image_view_to_handle(&store_iview), 6997ec681f3Smrg .imageLayout = VK_IMAGE_LAYOUT_GENERAL, 7007ec681f3Smrg }, 7017ec681f3Smrg }}}); 7027ec681f3Smrg 7037ec681f3Smrg radv_unaligned_dispatch(cmd_buffer, width, height, 1); 7047ec681f3Smrg 7057ec681f3Smrg radv_image_view_finish(&load_iview); 7067ec681f3Smrg radv_image_view_finish(&store_iview); 7077ec681f3Smrg } 7087ec681f3Smrg } 7097ec681f3Smrg 7107ec681f3Smrg radv_meta_restore(&saved_state, cmd_buffer); 7117ec681f3Smrg 7127ec681f3Smrg cmd_buffer->state.flush_bits |= 7137ec681f3Smrg RADV_CMD_FLAG_CS_PARTIAL_FLUSH | RADV_CMD_FLAG_INV_VCACHE | 7147ec681f3Smrg radv_src_access_flush(cmd_buffer, VK_ACCESS_SHADER_WRITE_BIT, image); 7157ec681f3Smrg 7167ec681f3Smrg /* Initialize the HTILE metadata as "fully expanded". */ 7177ec681f3Smrg uint32_t htile_value = radv_get_htile_initial_value(cmd_buffer->device, image); 7187ec681f3Smrg 7197ec681f3Smrg cmd_buffer->state.flush_bits |= radv_clear_htile(cmd_buffer, image, subresourceRange, htile_value); 72001e04c3fSmrg} 72101e04c3fSmrg 7227ec681f3Smrgvoid 7237ec681f3Smrgradv_expand_depth_stencil(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, 7247ec681f3Smrg const VkImageSubresourceRange *subresourceRange, 7257ec681f3Smrg struct radv_sample_locations_state *sample_locs) 72601e04c3fSmrg{ 7277ec681f3Smrg struct radv_barrier_data barrier = {0}; 7287ec681f3Smrg 7297ec681f3Smrg barrier.layout_transitions.depth_stencil_expand = 1; 7307ec681f3Smrg radv_describe_layout_transition(cmd_buffer, &barrier); 7317ec681f3Smrg 7327ec681f3Smrg if (cmd_buffer->queue_family_index == RADV_QUEUE_GENERAL) { 7337ec681f3Smrg radv_process_depth_stencil(cmd_buffer, image, subresourceRange, sample_locs, DEPTH_DECOMPRESS); 7347ec681f3Smrg } else { 7357ec681f3Smrg radv_expand_depth_stencil_compute(cmd_buffer, image, subresourceRange); 7367ec681f3Smrg } 73701e04c3fSmrg} 73801e04c3fSmrg 7397ec681f3Smrgvoid 7407ec681f3Smrgradv_resummarize_depth_stencil(struct radv_cmd_buffer *cmd_buffer, struct radv_image *image, 7417ec681f3Smrg const VkImageSubresourceRange *subresourceRange, 7427ec681f3Smrg struct radv_sample_locations_state *sample_locs) 74301e04c3fSmrg{ 7447ec681f3Smrg struct radv_barrier_data barrier = {0}; 7457ec681f3Smrg 7467ec681f3Smrg barrier.layout_transitions.depth_stencil_resummarize = 1; 7477ec681f3Smrg radv_describe_layout_transition(cmd_buffer, &barrier); 7487ec681f3Smrg 7497ec681f3Smrg assert(cmd_buffer->queue_family_index == RADV_QUEUE_GENERAL); 7507ec681f3Smrg radv_process_depth_stencil(cmd_buffer, image, subresourceRange, sample_locs, DEPTH_RESUMMARIZE); 75101e04c3fSmrg} 752