@@ -3942,10 +3942,12 @@ uint32_t d3d12_graphics_pipeline_state_get_dynamic_state_flags(struct d3d12_pipe
3942
3942
if (d3d12_device_supports_variable_shading_rate_tier_1 (state -> device ) && graphics -> rt_count )
3943
3943
{
3944
3944
/* If sample rate shading or ROVs are used, force default VRS state. Do this by not enabling the dynamic state.
3945
- * This forces default static pipeline state to be used instead, which is what we want. */
3945
+ * This forces default static pipeline state to be used instead, which is what we want.
3946
+ * For force VRS 2x2, we want to remove the dynamic shading rate, and use static pipeline struct instead. */
3946
3947
const uint32_t disable_flags =
3947
3948
VKD3D_SHADER_META_FLAG_USES_SAMPLE_RATE_SHADING |
3948
- VKD3D_SHADER_META_FLAG_USES_RASTERIZER_ORDERED_VIEWS ;
3949
+ VKD3D_SHADER_META_FLAG_USES_RASTERIZER_ORDERED_VIEWS |
3950
+ VKD3D_SHADER_META_FLAG_FORCE_VRS_2X2 ;
3949
3951
bool allow_vrs_combiners = true;
3950
3952
3951
3953
for (i = 0 ; allow_vrs_combiners && i < graphics -> stage_count ; i ++ )
@@ -5275,12 +5277,26 @@ static void d3d12_pipeline_state_log_graphics_state(const struct d3d12_pipeline_
5275
5277
ERR ("Dynamic state: %#x (explicit: %#x)\n" , graphics -> pipeline_dynamic_states , graphics -> explicit_dynamic_states );
5276
5278
}
5277
5279
5280
+ static bool d3d12_pipeline_state_forces_vrs_2x2 (struct d3d12_pipeline_state * state )
5281
+ {
5282
+ struct d3d12_graphics_pipeline_state * graphics = & state -> graphics ;
5283
+ bool use_vrs_2x2 = false;
5284
+ uint32_t i ;
5285
+
5286
+ if (d3d12_device_supports_variable_shading_rate_tier_1 (state -> device ) && graphics -> rt_count )
5287
+ for (i = 0 ; i < graphics -> stage_count && !use_vrs_2x2 ; i ++ )
5288
+ use_vrs_2x2 = !!(graphics -> code [i ].meta .flags & VKD3D_SHADER_META_FLAG_FORCE_VRS_2X2 );
5289
+
5290
+ return use_vrs_2x2 ;
5291
+ }
5292
+
5278
5293
static VkResult d3d12_pipeline_state_link_pipeline_variant (struct d3d12_pipeline_state * state ,
5279
5294
const struct vkd3d_pipeline_key * key , const struct vkd3d_format * dsv_format , VkPipelineCache vk_cache ,
5280
5295
uint32_t dynamic_state_flags , VkPipeline * vk_pipeline )
5281
5296
{
5282
5297
const struct vkd3d_vk_device_procs * vk_procs = & state -> device -> vk_procs ;
5283
5298
struct d3d12_graphics_pipeline_state * graphics = & state -> graphics ;
5299
+ VkPipelineFragmentShadingRateStateCreateInfoKHR shading_rate_info ;
5284
5300
struct vkd3d_fragment_output_pipeline_desc fragment_output_desc ;
5285
5301
struct vkd3d_vertex_input_pipeline_desc vertex_input_desc ;
5286
5302
VkPipelineLibraryCreateInfoKHR library_info ;
@@ -5315,6 +5331,18 @@ static VkResult d3d12_pipeline_state_link_pipeline_variant(struct d3d12_pipeline
5315
5331
create_info .layout = graphics -> pipeline_layout ;
5316
5332
create_info .basePipelineIndex = -1 ;
5317
5333
5334
+ if (d3d12_pipeline_state_forces_vrs_2x2 (state ))
5335
+ {
5336
+ memset (& shading_rate_info , 0 , sizeof (shading_rate_info ));
5337
+ shading_rate_info .sType = VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR ;
5338
+ shading_rate_info .combinerOps [0 ] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR ;
5339
+ shading_rate_info .combinerOps [1 ] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR ;
5340
+ shading_rate_info .fragmentSize .width = 2 ;
5341
+ shading_rate_info .fragmentSize .height = 2 ;
5342
+
5343
+ vk_prepend_struct (& create_info , & shading_rate_info );
5344
+ }
5345
+
5318
5346
if (d3d12_device_uses_descriptor_buffers (state -> device ))
5319
5347
create_info .flags |= VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT ;
5320
5348
@@ -5344,6 +5372,7 @@ VkPipeline d3d12_pipeline_state_create_pipeline_variant(struct d3d12_pipeline_st
5344
5372
{
5345
5373
const struct vkd3d_vk_device_procs * vk_procs = & state -> device -> vk_procs ;
5346
5374
VkDynamicState dynamic_state_buffer [ARRAY_SIZE (vkd3d_dynamic_state_list )];
5375
+ VkPipelineFragmentShadingRateStateCreateInfoKHR shading_rate_info ;
5347
5376
struct d3d12_graphics_pipeline_state * graphics = & state -> graphics ;
5348
5377
VkPipelineCreationFeedbackEXT feedbacks [VKD3D_MAX_SHADER_STAGES ];
5349
5378
struct vkd3d_fragment_output_pipeline_desc fragment_output_desc ;
@@ -5512,6 +5541,18 @@ VkPipeline d3d12_pipeline_state_create_pipeline_variant(struct d3d12_pipeline_st
5512
5541
else
5513
5542
feedback_info .pipelineStageCreationFeedbackCount = 0 ;
5514
5543
5544
+ if (d3d12_pipeline_state_forces_vrs_2x2 (state ))
5545
+ {
5546
+ memset (& shading_rate_info , 0 , sizeof (shading_rate_info ));
5547
+ shading_rate_info .sType = VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR ;
5548
+ shading_rate_info .combinerOps [0 ] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR ;
5549
+ shading_rate_info .combinerOps [1 ] = VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR ;
5550
+ shading_rate_info .fragmentSize .width = 2 ;
5551
+ shading_rate_info .fragmentSize .height = 2 ;
5552
+
5553
+ vk_prepend_struct (& pipeline_desc , & shading_rate_info );
5554
+ }
5555
+
5515
5556
vr = VK_CALL (vkCreateGraphicsPipelines (device -> vk_device , vk_cache , 1 , & pipeline_desc , NULL , & vk_pipeline ));
5516
5557
5517
5558
if (vkd3d_config_flags & VKD3D_CONFIG_FLAG_PIPELINE_LIBRARY_LOG )
0 commit comments