diff options
Diffstat (limited to 'lib/mesa/src/amd/vulkan/radv_meta_resolve.c')
-rw-r--r-- | lib/mesa/src/amd/vulkan/radv_meta_resolve.c | 107 |
1 files changed, 64 insertions, 43 deletions
diff --git a/lib/mesa/src/amd/vulkan/radv_meta_resolve.c b/lib/mesa/src/amd/vulkan/radv_meta_resolve.c index 52f7246f6..da813eb56 100644 --- a/lib/mesa/src/amd/vulkan/radv_meta_resolve.c +++ b/lib/mesa/src/amd/vulkan/radv_meta_resolve.c @@ -33,6 +33,7 @@ */ struct vertex_attrs { float position[2]; /**< 3DPRIM_RECTLIST */ + float tex_position[2]; }; /* passthrough vertex shader */ @@ -44,9 +45,11 @@ build_nir_vs(void) nir_builder b; nir_variable *a_position; nir_variable *v_position; + nir_variable *a_tex_position; + nir_variable *v_tex_position; nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL); - b.shader->info->name = ralloc_strdup(b.shader, "meta_resolve_vs"); + b.shader->info.name = ralloc_strdup(b.shader, "meta_resolve_vs"); a_position = nir_variable_create(b.shader, nir_var_shader_in, vec4, "a_position"); @@ -56,7 +59,16 @@ build_nir_vs(void) "gl_Position"); v_position->data.location = VARYING_SLOT_POS; + a_tex_position = nir_variable_create(b.shader, nir_var_shader_in, vec4, + "a_tex_position"); + a_tex_position->data.location = VERT_ATTRIB_GENERIC1; + + v_tex_position = nir_variable_create(b.shader, nir_var_shader_out, vec4, + "v_tex_position"); + v_tex_position->data.location = VARYING_SLOT_VAR0; + nir_copy_var(&b, v_position, a_position); + nir_copy_var(&b, v_tex_position, a_tex_position); return b.shader; } @@ -67,16 +79,22 @@ build_nir_fs(void) { const struct glsl_type *vec4 = glsl_vec4_type(); nir_builder b; + nir_variable *v_tex_position; /* vec4, varying texture coordinate */ nir_variable *f_color; /* vec4, fragment output color */ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL); - b.shader->info->name = ralloc_asprintf(b.shader, - "meta_resolve_fs"); + b.shader->info.name = ralloc_asprintf(b.shader, + "meta_resolve_fs"); + + v_tex_position = nir_variable_create(b.shader, nir_var_shader_in, vec4, + "v_tex_position"); + v_tex_position->data.location = VARYING_SLOT_VAR0; f_color = nir_variable_create(b.shader, nir_var_shader_out, vec4, "f_color"); f_color->data.location = FRAG_RESULT_DATA0; - nir_store_var(&b, f_color, nir_imm_vec4(&b, 0.0, 0.0, 0.0, 1.0), 0xf); + + nir_copy_var(&b, f_color, v_tex_position); return b.shader; } @@ -95,11 +113,9 @@ create_pass(struct radv_device *device) attachments[i].samples = 1; attachments[i].loadOp = VK_ATTACHMENT_LOAD_OP_LOAD; attachments[i].storeOp = VK_ATTACHMENT_STORE_OP_STORE; + attachments[i].initialLayout = VK_IMAGE_LAYOUT_GENERAL; + attachments[i].finalLayout = VK_IMAGE_LAYOUT_GENERAL; } - attachments[0].initialLayout = VK_IMAGE_LAYOUT_GENERAL; - attachments[0].finalLayout = VK_IMAGE_LAYOUT_GENERAL; - attachments[1].initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; - attachments[1].finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; result = radv_CreateRenderPass(device_h, &(VkRenderPassCreateInfo) { @@ -118,7 +134,7 @@ create_pass(struct radv_device *device) }, { .attachment = 1, - .layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, + .layout = VK_IMAGE_LAYOUT_GENERAL, }, }, .pResolveAttachments = NULL, @@ -182,7 +198,7 @@ create_pipeline(struct radv_device *device, .inputRate = VK_VERTEX_INPUT_RATE_VERTEX }, }, - .vertexAttributeDescriptionCount = 1, + .vertexAttributeDescriptionCount = 2, .pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) { { /* Position */ @@ -191,6 +207,13 @@ create_pipeline(struct radv_device *device, .format = VK_FORMAT_R32G32_SFLOAT, .offset = offsetof(struct vertex_attrs, position), }, + { + /* Texture Coordinate */ + .location = 1, + .binding = 0, + .format = VK_FORMAT_R32G32_SFLOAT, + .offset = offsetof(struct vertex_attrs, tex_position), + }, }, }, .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) { @@ -200,8 +223,8 @@ create_pipeline(struct radv_device *device, }, .pViewportState = &(VkPipelineViewportStateCreateInfo) { .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO, - .viewportCount = 1, - .scissorCount = 1, + .viewportCount = 0, + .scissorCount = 0, }, .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) { .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, @@ -236,14 +259,7 @@ create_pipeline(struct radv_device *device, } }, }, - .pDynamicState = &(VkPipelineDynamicStateCreateInfo) { - .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO, - .dynamicStateCount = 2, - .pDynamicStates = (VkDynamicState[]) { - VK_DYNAMIC_STATE_VIEWPORT, - VK_DYNAMIC_STATE_SCISSOR, - }, - }, + .pDynamicState = NULL, .renderPass = device->meta_state.resolve.pass, .subpass = 0, }, @@ -317,6 +333,7 @@ cleanup: static void emit_resolve(struct radv_cmd_buffer *cmd_buffer, + const VkOffset2D *src_offset, const VkOffset2D *dest_offset, const VkExtent2D *resolve_extent) { @@ -326,20 +343,32 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer, const struct vertex_attrs vertex_data[3] = { { .position = { - -1.0, - -1.0, + dest_offset->x, + dest_offset->y, + }, + .tex_position = { + src_offset->x, + src_offset->y, }, }, { .position = { - -1.0, - 1.0, + dest_offset->x, + dest_offset->y + resolve_extent->height, + }, + .tex_position = { + src_offset->x, + src_offset->y + resolve_extent->height, }, }, { .position = { - 1.0, - -1.0, + dest_offset->x + resolve_extent->width, + dest_offset->y, + }, + .tex_position = { + src_offset->x + resolve_extent->width, + src_offset->y, }, }, }; @@ -369,22 +398,9 @@ emit_resolve(struct radv_cmd_buffer *cmd_buffer, pipeline_h); } - radv_CmdSetViewport(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkViewport) { - .x = dest_offset->x, - .y = dest_offset->y, - .width = resolve_extent->width, - .height = resolve_extent->height, - .minDepth = 0.0f, - .maxDepth = 1.0f - }); - - radv_CmdSetScissor(radv_cmd_buffer_to_handle(cmd_buffer), 0, 1, &(VkRect2D) { - .offset = *dest_offset, - .extent = *resolve_extent, - }); - radv_CmdDraw(cmd_buffer_h, 3, 1, 0, 0); cmd_buffer->state.flush_bits |= RADV_CMD_FLAG_FLUSH_AND_INV_CB; + si_emit_cache_flush(cmd_buffer); } void radv_CmdResolveImage( @@ -424,6 +440,7 @@ void radv_CmdResolveImage( if (use_compute_resolve) { + radv_fast_clear_flush_image_inplace(cmd_buffer, src_image); radv_meta_resolve_compute_image(cmd_buffer, src_image, src_image_layout, @@ -449,9 +466,6 @@ void radv_CmdResolveImage( if (src_image->array_size > 1) radv_finishme("vkCmdResolveImage: multisample array images"); - if (dest_image->surface.dcc_size) { - radv_initialize_dcc(cmd_buffer, dest_image, 0xffffffff); - } for (uint32_t r = 0; r < region_count; ++r) { const VkImageResolve *region = ®ions[r]; @@ -491,6 +505,8 @@ void radv_CmdResolveImage( */ const struct VkExtent3D extent = radv_sanitize_image_extent(src_image->type, region->extent); + const struct VkOffset3D srcOffset = + radv_sanitize_image_offset(src_image->type, region->srcOffset); const struct VkOffset3D dstOffset = radv_sanitize_image_offset(dest_image->type, region->dstOffset); @@ -572,6 +588,10 @@ void radv_CmdResolveImage( emit_resolve(cmd_buffer, &(VkOffset2D) { + .x = srcOffset.x, + .y = srcOffset.y, + }, + &(VkOffset2D) { .x = dstOffset.x, .y = dstOffset.y, }, @@ -643,6 +663,7 @@ radv_cmd_buffer_resolve_subpass(struct radv_cmd_buffer *cmd_buffer) */ emit_resolve(cmd_buffer, &(VkOffset2D) { 0, 0 }, + &(VkOffset2D) { 0, 0 }, &(VkExtent2D) { fb->width, fb->height }); } |