From 4cdd85517d48c9aec51e7be0e2f69224602efc9c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sat, 8 Apr 2023 16:31:41 -0400 Subject: [PATCH] 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 Reviewed-by: Asahi Lina Part-of: --- src/compiler/nir/nir_gather_info.c | 4 ++++ src/compiler/nir/nir_intrinsics.py | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index e4e355e185a..c89ea09df90 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -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) { diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index 9c431708562..e56a9827d8d 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -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.