nir: Add intrinsics for multisampling on AGX

sample_mask_agx maps to the AGX instruction used to write out a sample mask.

api_sample_mask_agx is a system value that returns the value of glSampleMask
(or its Vulkan equivalent), used to lower glSampleMask (etc).
This is distinct from sample_mask_in, which we map to the hardware thing and
AND with this as a lowering.

sample_positions_agx is a system value returning the sample positions in a
packed fixed-point format matching the hardware register, used to lower
gl_SamplePositions.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Asahi Lina <lina@asahilina.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23040>
This commit is contained in:
Alyssa Rosenzweig
2023-04-08 16:31:41 -04:00
committed by Marge Bot
parent 170e2fa11e
commit 4cdd85517d
2 changed files with 15 additions and 0 deletions

View File

@@ -777,6 +777,10 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
BITFIELD64_BIT(FRAG_RESULT_STENCIL);
break;
case nir_intrinsic_sample_mask_agx:
shader->info.outputs_written |= BITFIELD64_BIT(FRAG_RESULT_SAMPLE_MASK);
break;
case nir_intrinsic_launch_mesh_workgroups:
case nir_intrinsic_launch_mesh_workgroups_with_payload_deref: {
for (unsigned i = 0; i < 3; ++i) {

View File

@@ -1696,6 +1696,17 @@ intrinsic("load_ubo_base_agx", src_comp=[1], dest_comp=1, bit_sizes=[64],
intrinsic("load_vbo_base_agx", src_comp=[1], dest_comp=1, bit_sizes=[64],
flags=[CAN_ELIMINATE, CAN_REORDER])
# Write out a sample mask for a targeted subset of samples, specified in the two
# masks. Maps to the corresponding AGX instruction, the actual workings are
# documented elsewhere as they are too complicated for this comment.
intrinsic("sample_mask_agx", src_comp=[1, 1])
# The fixed-function sample mask specified in the API (e.g. glSampleMask)
system_value("api_sample_mask_agx", 1, bit_sizes=[16])
# Loads the sample position array as fixed point packed into a 32-bit word
system_value("sample_positions_agx", 1, bit_sizes=[32])
# Intel-specific query for loading from the brw_image_param struct passed
# into the shader as a uniform. The variable is a deref to the image
# variable. The const index specifies which of the six parameters to load.