From fe6f7b526563cc64ed59004f8a108d994a349bf7 Mon Sep 17 00:00:00 2001 From: Jesse Natalie Date: Fri, 14 Jan 2022 17:33:05 -0800 Subject: [PATCH] microsoft/compiler: Handle tex texture/sampler offset srcs Note that these offsets are 0-based, so to make them binding IDs we need to explicitly add the base ID to them. Reviewed-by: Sil Vilerino Part-of: --- src/microsoft/compiler/nir_to_dxil.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/microsoft/compiler/nir_to_dxil.c b/src/microsoft/compiler/nir_to_dxil.c index 494544cd0d0..c3a5c781bab 100644 --- a/src/microsoft/compiler/nir_to_dxil.c +++ b/src/microsoft/compiler/nir_to_dxil.c @@ -4386,6 +4386,26 @@ emit_tex(struct ntd_context *ctx, nir_tex_instr *instr) params.sampler = get_src_ssa(ctx, instr->src[i].src.ssa, 0); break; + case nir_tex_src_texture_offset: + params.tex = emit_createhandle_call(ctx, DXIL_RESOURCE_CLASS_SRV, + get_resource_id(ctx, DXIL_RESOURCE_CLASS_SRV, 0, instr->texture_index), + dxil_emit_binop(&ctx->mod, DXIL_BINOP_ADD, + get_src_ssa(ctx, instr->src[i].src.ssa, 0), + dxil_module_get_int32_const(&ctx->mod, instr->texture_index), 0), + instr->texture_non_uniform); + break; + + case nir_tex_src_sampler_offset: + if (nir_tex_instr_need_sampler(instr)) { + params.sampler = emit_createhandle_call(ctx, DXIL_RESOURCE_CLASS_SAMPLER, + get_resource_id(ctx, DXIL_RESOURCE_CLASS_SAMPLER, 0, instr->sampler_index), + dxil_emit_binop(&ctx->mod, DXIL_BINOP_ADD, + get_src_ssa(ctx, instr->src[i].src.ssa, 0), + dxil_module_get_int32_const(&ctx->mod, instr->sampler_index), 0), + instr->sampler_non_uniform); + } + break; + case nir_tex_src_projector: unreachable("Texture projector should have been lowered");