diff --git a/docs/features.txt b/docs/features.txt index 2b66f2768db..1a2bafbad43 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -532,6 +532,7 @@ Khronos extensions that are not part of any Vulkan version: VK_KHR_win32_surface DONE (dzn, lvp) VK_KHR_xcb_surface DONE (anv, dzn, lvp, radv, tu, v3dv, vn) VK_KHR_xlib_surface DONE (anv, dzn, lvp, radv, tu, v3dv, vn) + VK_EXT_attachment_feedback_loop_layout DONE (radv, tu) VK_EXT_border_color_swizzle DONE (anv, lvp, tu, radv/gfx10+) VK_EXT_buffer_device_address DONE (anv/gen8+, radv) VK_EXT_calibrated_timestamps DONE (anv, lvp, radv, vn) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 27e28692cf7..4003c69b3a7 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -2561,6 +2561,25 @@ tu_CmdBindPipeline(VkCommandBuffer commandBuffer, cmd->state.dirty |= TU_CMD_DIRTY_DESC_SETS_LOAD | TU_CMD_DIRTY_SHADER_CONSTS | TU_CMD_DIRTY_LRZ | TU_CMD_DIRTY_VS_PARAMS; + if (pipeline->feedback_loop_may_involve_textures) { + /* VK_EXT_attachment_feedback_loop_layout allows feedback loop to involve + * not only input attachments but also sampled images or image resources. + * But we cannot just patch gmem for image in the descriptors. + * + * At the moment, in context of DXVK, it is expected that only a few + * drawcalls in a frame would use feedback loop and they would be wrapped + * in their own renderpasses, so it should be ok to force sysmem. + * + * However, there are two further possible optimizations if need would + * arise for other translation layer: + * - Tiling could be enabled if we ensure that there is no barrier in + * the renderpass; + * - Check that both pipeline and attachments agree that feedback loop + * is needed. + */ + cmd->state.rp.disable_gmem = true; + } + struct tu_cs *cs = &cmd->draw_cs; /* note: this also avoids emitting draw states before renderpass clears, diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 4e6a66f79f7..4a44526b113 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -213,6 +213,7 @@ get_device_extensions(const struct tu_physical_device *device, .EXT_pipeline_creation_feedback = true, .EXT_pipeline_creation_cache_control = true, .EXT_vertex_input_dynamic_state = true, + .EXT_attachment_feedback_loop_layout = true, #ifndef TU_USE_KGSL .EXT_physical_device_drm = true, #endif @@ -926,6 +927,12 @@ tu_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, features->nonSeamlessCubeMap = true; break; } + case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT: { + VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT *features = + (VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT*)ext; + features->attachmentFeedbackLoopLayout = true; + break; + } default: break; diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index bf1862cef61..b768fd84dbc 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -270,6 +270,7 @@ struct tu_pipeline_builder bool subpass_raster_order_attachment_access; bool subpass_feedback_loop_color; bool subpass_feedback_loop_ds; + bool feedback_loop_may_involve_textures; }; static bool @@ -3438,6 +3439,9 @@ tu_pipeline_builder_parse_rasterization(struct tu_pipeline_builder *builder, const VkPipelineRasterizationStateCreateInfo *rast_info = builder->create_info->pRasterizationState; + pipeline->feedback_loop_may_involve_textures = + builder->feedback_loop_may_involve_textures; + enum a6xx_polygon_mode mode = tu6_polygon_mode(rast_info->polygonMode); builder->depth_clip_disable = rast_info->depthClampEnable; @@ -4053,6 +4057,15 @@ tu_pipeline_builder_init_graphics( } } + if (builder->create_info->flags & VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT) { + builder->subpass_feedback_loop_color = true; + builder->feedback_loop_may_involve_textures = true; + } + + if (builder->create_info->flags & VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT) { + builder->subpass_feedback_loop_ds = true; + builder->feedback_loop_may_involve_textures = true; + } if (builder->rasterizer_discard) { builder->samples = VK_SAMPLE_COUNT_1_BIT; diff --git a/src/freedreno/vulkan/tu_pipeline.h b/src/freedreno/vulkan/tu_pipeline.h index b6e5247beeb..00c843cc332 100644 --- a/src/freedreno/vulkan/tu_pipeline.h +++ b/src/freedreno/vulkan/tu_pipeline.h @@ -191,6 +191,7 @@ struct tu_pipeline /* In other words - framebuffer fetch support */ bool raster_order_attachment_access; bool subpass_feedback_loop_ds; + bool feedback_loop_may_involve_textures; bool z_negative_one_to_one;