Skip to content

radv: Move most of DB_SHADER_CONTROL to PS, more precise GFX11 blend WA

This change moves most of the fields of DB_SHADER_CONTROL from the pipeline to the pixel shader, and also makes its fields that are based on the current state, as opposed to purely the shader, configured more granularly through a new internal dynamic state atom.

It is needed for two features:

  • VK_EXT_shader_object;
  • VK_EXT_fragment_shader_interlock — originally, this commit was a part of the merge request implementing it, !22250 (merged), but it was requested that it was moved to a separate merge request.

With fragment shader interlock, it's extremely highly desirable that if the shader requests a SampleInterlock execution mode (as opposed to PixelInterlock), the POPS_OVERLAP_NUM_SAMPLES/OVERRIDE_INTRINSIC_RATE field of DB_SHADER_CONTROL is set to the number of coverage samples, because PixelInterlock is hugely slower on AMD hardware with MSAA due to adjacent primitives sharing covered pixels along the common edge and thus overlapping and being interlocked. That requires access to the up-to-date dynamic rasterization sample count.

Additionally, the condition for applying the GFX11 blending performance issue OVERRIDE_INTRINSIC_RATE(log2(4)) workaround is now more precise (same as in PAL): multisampling is not used, and blending is enabled for at least one render target. Previously, if multisample or blending state was dynamic, RADV simply always assumed the worst and enabled the workaround unconditionally. Now, since the exact sample count will be needed for another purpose in DB_SHADER_CONTROL setup later anyway (for fragment shader interlock), it can be also used to apply the workaround correctly.

The new state atom is named unambiguously, DB_SHADER_CONTROL. Previously, DB_SHADER_CONTROL was emitted from the attachment feedback loop state when it became dynamic (after having been emitted for the pipeline earlier), but since then, line rasterization mode has also started being taken into account, so it started doing more than it would be expected from its name.

Merge request reports