nir: Add intrinsics for multisampling on AGX
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 8 Apr 2023 20:31:41 +0000 (16:31 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 25 May 2023 17:41:33 +0000 (17:41 +0000)
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>

src/compiler/nir/nir_gather_info.c
src/compiler/nir/nir_intrinsics.py

index e4e355e..c89ea09 100644 (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) {
index 9c43170..e56a982 100644 (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.