From: Roland Scheidegger Date: Tue, 5 Sep 2017 15:59:37 +0000 (+0200) Subject: llvmpipe, tgsi: hook up dx10 gather4 opcode X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d9d6071ee961acc82543b321764a0ffec8cd39a;p=mesa.git llvmpipe, tgsi: hook up dx10 gather4 opcode Trivial. We already support tg4 for legacy tex opcodes, so the actual texture sampling code already handles it. (Just like TG4, we don't handle additional capabilities and always sample red channel.) Reviewed-by: Jose Fonseca --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index b7f11401355..f16c579f38d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -2232,6 +2232,7 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, const struct tgsi_full_instruction *inst, enum lp_build_tex_modifier modifier, boolean compare, + enum lp_sampler_op_type sample_type, LLVMValueRef *texel) { struct gallivm_state *gallivm = bld->bld_base.base.gallivm; @@ -2245,7 +2246,7 @@ emit_sample(struct lp_build_tgsi_soa_context *bld, unsigned num_offsets, num_derivs, i; unsigned layer_coord = 0; - unsigned sample_key = LP_SAMPLER_OP_TEXTURE << LP_SAMPLER_OP_TYPE_SHIFT; + unsigned sample_key = sample_type << LP_SAMPLER_OP_TYPE_SHIFT; memset(¶ms, 0, sizeof(params)); @@ -3186,7 +3187,7 @@ sample_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_sample(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_NONE, - FALSE, emit_data->output); + FALSE, LP_SAMPLER_OP_TEXTURE, emit_data->output); } static void @@ -3198,7 +3199,7 @@ sample_b_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_sample(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_LOD_BIAS, - FALSE, emit_data->output); + FALSE, LP_SAMPLER_OP_TEXTURE, emit_data->output); } static void @@ -3210,7 +3211,7 @@ sample_c_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_sample(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_NONE, - TRUE, emit_data->output); + TRUE, LP_SAMPLER_OP_TEXTURE, emit_data->output); } static void @@ -3222,7 +3223,7 @@ sample_c_lz_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_sample(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_LOD_ZERO, - TRUE, emit_data->output); + TRUE, LP_SAMPLER_OP_TEXTURE, emit_data->output); } static void @@ -3234,7 +3235,7 @@ sample_d_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_sample(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_EXPLICIT_DERIV, - FALSE, emit_data->output); + FALSE, LP_SAMPLER_OP_TEXTURE, emit_data->output); } static void @@ -3246,7 +3247,19 @@ sample_l_emit( struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); emit_sample(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_EXPLICIT_LOD, - FALSE, emit_data->output); + FALSE, LP_SAMPLER_OP_TEXTURE, emit_data->output); +} + +static void +gather4_emit( + const struct lp_build_tgsi_action * action, + struct lp_build_tgsi_context * bld_base, + struct lp_build_emit_data * emit_data) +{ + struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); + + emit_sample(bld, emit_data->inst, LP_BLD_TEX_MODIFIER_NONE, + FALSE, LP_SAMPLER_OP_GATHER, emit_data->output); } static void @@ -3871,6 +3884,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, bld.bld_base.op_actions[TGSI_OPCODE_SAMPLE_I].emit = sample_i_emit; bld.bld_base.op_actions[TGSI_OPCODE_SAMPLE_I_MS].emit = sample_i_emit; bld.bld_base.op_actions[TGSI_OPCODE_SAMPLE_L].emit = sample_l_emit; + bld.bld_base.op_actions[TGSI_OPCODE_GATHER4].emit = gather4_emit; bld.bld_base.op_actions[TGSI_OPCODE_SVIEWINFO].emit = sviewinfo_emit; if (gs_iface) { diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index c58ea6ad09c..1264df0c622 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -2631,6 +2631,9 @@ exec_sample(struct tgsi_exec_machine *mach, lod = &c1; control = TGSI_SAMPLER_LOD_EXPLICIT; } + else if (modifier == TEX_MODIFIER_GATHER) { + control = TGSI_SAMPLER_GATHER; + } else { assert(modifier == TEX_MODIFIER_LEVEL_ZERO); control = TGSI_SAMPLER_LOD_ZERO; @@ -5687,7 +5690,7 @@ exec_instruction( break; case TGSI_OPCODE_GATHER4: - assert(0); + exec_sample(mach, inst, TEX_MODIFIER_GATHER, FALSE); break; case TGSI_OPCODE_SVIEWINFO: