From 76a34f5d3f63e2c672dcd66681040ce6fd95a51c Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Tue, 7 Jan 2020 08:45:24 +0100 Subject: [PATCH] spirv: add support for SpvOpFragment{Mask}FetchAMD operations nir_tex_src_ms_index is re-used for the fragment index with nir_texop_fragment_fetch to avoid introducing a new texture source type. Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- src/compiler/spirv/spirv_to_nir.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/compiler/spirv/spirv_to_nir.c b/src/compiler/spirv/spirv_to_nir.c index 5e2ed6c27eb..abf27d5e6b0 100644 --- a/src/compiler/spirv/spirv_to_nir.c +++ b/src/compiler/spirv/spirv_to_nir.c @@ -2346,6 +2346,14 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, dest_type = nir_type_int; break; + case SpvOpFragmentFetchAMD: + texop = nir_texop_fragment_fetch; + break; + + case SpvOpFragmentMaskFetchAMD: + texop = nir_texop_fragment_mask_fetch; + break; + default: vtn_fail_with_opcode("Unhandled opcode", opcode); } @@ -2377,6 +2385,8 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, case nir_texop_query_levels: case nir_texop_texture_samples: case nir_texop_samples_identical: + case nir_texop_fragment_fetch: + case nir_texop_fragment_mask_fetch: /* These don't */ break; case nir_texop_txf_ms_fb: @@ -2404,7 +2414,9 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, case SpvOpImageFetch: case SpvOpImageGather: case SpvOpImageDrefGather: - case SpvOpImageQueryLod: { + case SpvOpImageQueryLod: + case SpvOpFragmentFetchAMD: + case SpvOpFragmentMaskFetchAMD: { /* All these types have the coordinate as their first real argument */ switch (sampler_dim) { case GLSL_SAMPLER_DIM_1D: @@ -2414,6 +2426,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, case GLSL_SAMPLER_DIM_2D: case GLSL_SAMPLER_DIM_RECT: case GLSL_SAMPLER_DIM_MS: + case GLSL_SAMPLER_DIM_SUBPASS_MS: coord_components = 2; break; case GLSL_SAMPLER_DIM_3D: @@ -2482,6 +2495,10 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode, if (opcode == SpvOpImageQuerySizeLod) (*p++) = vtn_tex_src(b, w[idx++], nir_tex_src_lod); + /* For OpFragmentFetchAMD, we always have a multisample index */ + if (opcode == SpvOpFragmentFetchAMD) + (*p++) = vtn_tex_src(b, w[idx++], nir_tex_src_ms_index); + /* Now we need to handle some number of optional arguments */ struct vtn_value *gather_offsets = NULL; if (idx < count) { @@ -4797,6 +4814,11 @@ vtn_handle_body_instruction(struct vtn_builder *b, SpvOp opcode, break; } + case SpvOpFragmentMaskFetchAMD: + case SpvOpFragmentFetchAMD: + vtn_handle_texture(b, opcode, w, count); + break; + case SpvOpAtomicLoad: case SpvOpAtomicExchange: case SpvOpAtomicCompareExchange: -- 2.30.2