Module: Mesa Branch: master Commit: 519eb735a3085d30042201bbb9a637d0b8796a7a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=519eb735a3085d30042201bbb9a637d0b8796a7a
Author: Danylo Piliaiev <[email protected]> Date: Thu Mar 11 16:22:38 2021 +0200 turnip: implement variableMultisampleRate If subpass doesn't have depth/color attachments - samples count is devised from VkPipelineMultisampleStateCreateInfo::rasterizationSamples. Without variableMultisampleRate enabled all pipelines in such subpass should have the same samples count; variableMultisampleRate allows to have pipelines with different number of samples in one subpass, given that it doesn't have depth/color attachments. Blob doesn't have it enabled but there is no known reason for this. Passes: dEQP-VK.pipeline.multisample.variable_rate.* Fixes test: dEQP-VK.pipeline.framebuffer_attachment.no_attachments_ms Signed-off-by: Danylo Piliaiev <[email protected]> Reviewed-by: Hyunjun Ko <[email protected]> Reviewed-by: Eric Anholt <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9556> --- src/freedreno/vulkan/tu_cmd_buffer.c | 6 ++++-- src/freedreno/vulkan/tu_device.c | 2 +- src/freedreno/vulkan/tu_pass.c | 2 -- src/freedreno/vulkan/tu_pipeline.c | 13 ++++++++++++- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 0de7c7dfd33..26391605f23 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -2964,7 +2964,8 @@ tu_CmdBeginRenderPass2(VkCommandBuffer commandBuffer, tu6_emit_zs(cmd, cmd->state.subpass, &cmd->draw_cs); tu6_emit_mrt(cmd, cmd->state.subpass, &cmd->draw_cs); - tu6_emit_msaa(&cmd->draw_cs, cmd->state.subpass->samples); + if (cmd->state.subpass->samples) + tu6_emit_msaa(&cmd->draw_cs, cmd->state.subpass->samples); tu6_emit_render_cntl(cmd, cmd->state.subpass, &cmd->draw_cs, false); tu_set_input_attachments(cmd, cmd->state.subpass); @@ -3029,7 +3030,8 @@ tu_CmdNextSubpass2(VkCommandBuffer commandBuffer, /* emit mrt/zs/msaa/ubwc state for the subpass that is starting */ tu6_emit_zs(cmd, cmd->state.subpass, cs); tu6_emit_mrt(cmd, cmd->state.subpass, cs); - tu6_emit_msaa(cs, cmd->state.subpass->samples); + if (cmd->state.subpass->samples) + tu6_emit_msaa(cs, cmd->state.subpass->samples); tu6_emit_render_cntl(cmd, cmd->state.subpass, cs, false); tu_set_input_attachments(cmd, cmd->state.subpass); diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 5fe163be27d..04e74982af2 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -386,7 +386,7 @@ tu_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, .shaderInt64 = false, .shaderInt16 = false, .sparseBinding = false, - .variableMultisampleRate = false, + .variableMultisampleRate = true, .inheritedQueries = true, }; diff --git a/src/freedreno/vulkan/tu_pass.c b/src/freedreno/vulkan/tu_pass.c index 0bbc089c536..e63ee0c33a9 100644 --- a/src/freedreno/vulkan/tu_pass.c +++ b/src/freedreno/vulkan/tu_pass.c @@ -630,8 +630,6 @@ tu_CreateRenderPass2(VkDevice _device, pass->attachments[a].gmem_offset = 0; update_samples(subpass, pCreateInfo->pAttachments[a].samples); } - - subpass->samples = subpass->samples ?: 1; } /* disable unused attachments */ diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index d0d5b5ca6b5..78a568172cb 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -259,6 +259,7 @@ struct tu_pipeline_builder bool rasterizer_discard; /* these states are affectd by rasterizer_discard */ + bool emit_msaa_state; VkSampleCountFlagBits samples; bool use_color_attachments; bool use_dual_src_blend; @@ -2559,7 +2560,8 @@ tu_pipeline_builder_parse_rasterization(struct tu_pipeline_builder *builder, depth_clip_disable = !depth_clip_state->depthClipEnable; struct tu_cs cs; - pipeline->rast_state = tu_cs_draw_state(&pipeline->cs, &cs, 13); + uint32_t cs_size = 13 + (builder->emit_msaa_state ? 11 : 0); + pipeline->rast_state = tu_cs_draw_state(&pipeline->cs, &cs, cs_size); tu_cs_emit_regs(&cs, A6XX_GRAS_CL_CNTL( @@ -2591,6 +2593,12 @@ tu_pipeline_builder_parse_rasterization(struct tu_pipeline_builder *builder, tu_cs_emit_regs(&cs, A6XX_VPC_UNKNOWN_9107(.raster_discard = rast_info->rasterizerDiscardEnable)); + /* If samples count couldn't be devised from the subpass, we should emit it here. + * It happens when subpass doesn't use any color/depth attachment. + */ + if (builder->emit_msaa_state) + tu6_emit_msaa(&cs, builder->samples); + pipeline->gras_su_cntl = tu6_gras_su_cntl(rast_info, builder->samples, builder->multiview_mask != 0); @@ -2969,6 +2977,9 @@ tu_pipeline_builder_init_graphics( builder->rasterizer_discard = create_info->pRasterizationState->rasterizerDiscardEnable; + /* variableMultisampleRate support */ + builder->emit_msaa_state = (subpass->samples == 0) && !builder->rasterizer_discard; + if (builder->rasterizer_discard) { builder->samples = VK_SAMPLE_COUNT_1_BIT; } else { _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
