r300: delete backend shadow lowering code

Signed-off-by: Pavel Ondračka <pavel.ondracka@gmail.com>
Reviewed-by: Filip Gawin <None>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33066>
This commit is contained in:
Pavel Ondračka
2024-06-27 13:59:04 +02:00
committed by Marge Bot
parent d1c7244b6f
commit 14fe3e9886
4 changed files with 12 additions and 191 deletions
+8 -19
View File
@@ -743,32 +743,20 @@ ntr_setup_outputs(struct ntr_compile *c)
}
static enum tgsi_texture_type
tgsi_texture_type_from_sampler_dim(enum glsl_sampler_dim dim, bool is_array, bool is_shadow)
tgsi_texture_type_from_sampler_dim(enum glsl_sampler_dim dim, bool is_array)
{
switch (dim) {
case GLSL_SAMPLER_DIM_1D:
if (is_shadow)
return is_array ? TGSI_TEXTURE_SHADOW1D_ARRAY : TGSI_TEXTURE_SHADOW1D;
else
return is_array ? TGSI_TEXTURE_1D_ARRAY : TGSI_TEXTURE_1D;
return is_array ? TGSI_TEXTURE_1D_ARRAY : TGSI_TEXTURE_1D;
case GLSL_SAMPLER_DIM_2D:
case GLSL_SAMPLER_DIM_EXTERNAL:
if (is_shadow)
return is_array ? TGSI_TEXTURE_SHADOW2D_ARRAY : TGSI_TEXTURE_SHADOW2D;
else
return is_array ? TGSI_TEXTURE_2D_ARRAY : TGSI_TEXTURE_2D;
return is_array ? TGSI_TEXTURE_2D_ARRAY : TGSI_TEXTURE_2D;
case GLSL_SAMPLER_DIM_3D:
return TGSI_TEXTURE_3D;
case GLSL_SAMPLER_DIM_CUBE:
if (is_shadow)
return is_array ? TGSI_TEXTURE_SHADOWCUBE_ARRAY : TGSI_TEXTURE_SHADOWCUBE;
else
return is_array ? TGSI_TEXTURE_CUBE_ARRAY : TGSI_TEXTURE_CUBE;
return is_array ? TGSI_TEXTURE_CUBE_ARRAY : TGSI_TEXTURE_CUBE;
case GLSL_SAMPLER_DIM_RECT:
if (is_shadow)
return TGSI_TEXTURE_SHADOWRECT;
else
return TGSI_TEXTURE_RECT;
return TGSI_TEXTURE_RECT;
case GLSL_SAMPLER_DIM_MS:
return is_array ? TGSI_TEXTURE_2D_ARRAY_MSAA : TGSI_TEXTURE_2D_MSAA;
case GLSL_SAMPLER_DIM_BUF:
@@ -807,7 +795,7 @@ ntr_setup_uniforms(struct ntr_compile *c)
const struct glsl_type *stype = glsl_without_array(var->type);
enum tgsi_texture_type target = tgsi_texture_type_from_sampler_dim(
glsl_get_sampler_dim(stype), glsl_sampler_type_is_array(stype), false);
glsl_get_sampler_dim(stype), glsl_sampler_type_is_array(stype));
enum tgsi_return_type ret_type =
tgsi_return_type_from_base_type(glsl_get_sampler_result_type(stype));
for (int i = 0; i < size; i++) {
@@ -1617,8 +1605,9 @@ static void
ntr_emit_texture(struct ntr_compile *c, nir_tex_instr *instr)
{
struct ureg_dst dst = ntr_get_dest(c, &instr->def);
assert(!instr->is_shadow);
enum tgsi_texture_type target =
tgsi_texture_type_from_sampler_dim(instr->sampler_dim, instr->is_array, instr->is_shadow);
tgsi_texture_type_from_sampler_dim(instr->sampler_dim, instr->is_array);
unsigned tex_opcode;
int tex_handle_src = nir_tex_instr_src_index(instr, nir_tex_src_texture_handle);
@@ -135,7 +135,6 @@ struct rc_program {
* actually used very often. */
uint32_t InputsRead;
uint32_t OutputsWritten;
uint32_t ShadowSamplers; /**< Texture units used for shadow sampling. */
struct rc_constant_list Constants;
};
@@ -10,26 +10,6 @@
/* Series of transformations to be done on textures. */
static struct rc_src_register
shadow_fail_value(struct r300_fragment_program_compiler *compiler, int tmu)
{
struct rc_src_register reg = {0, 0, 0, 0, 0, 0};
reg.File = RC_FILE_NONE;
reg.Swizzle = combine_swizzles(RC_SWIZZLE_0000, compiler->state.unit[tmu].texture_swizzle);
return reg;
}
static struct rc_src_register
shadow_pass_value(struct r300_fragment_program_compiler *compiler, int tmu)
{
struct rc_src_register reg = {0, 0, 0, 0, 0, 0};
reg.File = RC_FILE_NONE;
reg.Swizzle = combine_swizzles(RC_SWIZZLE_1111, compiler->state.unit[tmu].texture_swizzle);
return reg;
}
static void
scale_texcoords(struct r300_fragment_program_compiler *compiler, struct rc_instruction *inst,
unsigned state_constant)
@@ -105,124 +85,6 @@ radeonTransformTEX(struct radeon_compiler *c, struct rc_instruction *inst, void
inst->U.I.Opcode != RC_OPCODE_TXL && inst->U.I.Opcode != RC_OPCODE_KIL)
return 0;
/* ARB_shadow & EXT_shadow_funcs */
if (inst->U.I.Opcode != RC_OPCODE_KIL &&
((c->Program.ShadowSamplers & (1U << inst->U.I.TexSrcUnit)) ||
(compiler->state.unit[inst->U.I.TexSrcUnit].compare_mode_enabled))) {
rc_compare_func comparefunc = compiler->state.unit[inst->U.I.TexSrcUnit].texture_compare_func;
if (comparefunc == RC_COMPARE_FUNC_NEVER || comparefunc == RC_COMPARE_FUNC_ALWAYS) {
inst->U.I.Opcode = RC_OPCODE_MOV;
if (comparefunc == RC_COMPARE_FUNC_ALWAYS) {
inst->U.I.SrcReg[0] = shadow_pass_value(compiler, inst->U.I.TexSrcUnit);
} else {
inst->U.I.SrcReg[0] = shadow_fail_value(compiler, inst->U.I.TexSrcUnit);
}
return 1;
} else {
struct rc_instruction *inst_rcp = NULL;
struct rc_instruction *inst_mul, *inst_add, *inst_cmp;
unsigned tmp_texsample;
unsigned tmp_sum;
int pass, fail;
/* Save the output register. */
struct rc_dst_register output_reg = inst->U.I.DstReg;
unsigned saturate_mode = inst->U.I.SaturateMode;
/* Redirect TEX to a new temp. */
tmp_texsample = rc_find_free_temporary(c);
inst->U.I.SaturateMode = 0;
inst->U.I.DstReg.File = RC_FILE_TEMPORARY;
inst->U.I.DstReg.Index = tmp_texsample;
inst->U.I.DstReg.WriteMask = RC_MASK_XYZW;
tmp_sum = rc_find_free_temporary(c);
if (inst->U.I.Opcode == RC_OPCODE_TXP) {
/* Compute 1/W. */
inst_rcp = rc_insert_new_instruction(c, inst);
inst_rcp->U.I.Opcode = RC_OPCODE_RCP;
inst_rcp->U.I.DstReg.File = RC_FILE_TEMPORARY;
inst_rcp->U.I.DstReg.Index = tmp_sum;
inst_rcp->U.I.DstReg.WriteMask = RC_MASK_W;
inst_rcp->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
inst_rcp->U.I.SrcReg[0].Swizzle =
RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 3));
}
/* Divide Z by W (if it's TXP) and saturate. */
inst_mul = rc_insert_new_instruction(c, inst_rcp ? inst_rcp : inst);
inst_mul->U.I.Opcode = inst->U.I.Opcode == RC_OPCODE_TXP ? RC_OPCODE_MUL : RC_OPCODE_MOV;
inst_mul->U.I.DstReg.File = RC_FILE_TEMPORARY;
inst_mul->U.I.DstReg.Index = tmp_sum;
inst_mul->U.I.DstReg.WriteMask = RC_MASK_W;
inst_mul->U.I.SaturateMode = RC_SATURATE_ZERO_ONE;
inst_mul->U.I.SrcReg[0] = inst->U.I.SrcReg[0];
inst_mul->U.I.SrcReg[0].Swizzle =
RC_MAKE_SWIZZLE_SMEAR(GET_SWZ(inst->U.I.SrcReg[0].Swizzle, 2));
if (inst->U.I.Opcode == RC_OPCODE_TXP) {
inst_mul->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
inst_mul->U.I.SrcReg[1].Index = tmp_sum;
inst_mul->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_WWWW;
}
/* Add the depth texture value. */
inst_add = rc_insert_new_instruction(c, inst_mul);
inst_add->U.I.Opcode = RC_OPCODE_ADD;
inst_add->U.I.DstReg.File = RC_FILE_TEMPORARY;
inst_add->U.I.DstReg.Index = tmp_sum;
inst_add->U.I.DstReg.WriteMask = RC_MASK_W;
inst_add->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
inst_add->U.I.SrcReg[0].Index = tmp_sum;
inst_add->U.I.SrcReg[0].Swizzle = RC_SWIZZLE_WWWW;
inst_add->U.I.SrcReg[1].File = RC_FILE_TEMPORARY;
inst_add->U.I.SrcReg[1].Index = tmp_texsample;
inst_add->U.I.SrcReg[1].Swizzle = RC_SWIZZLE_XXXX;
/* Note that SrcReg[0] is r, SrcReg[1] is tex and:
* LESS: r < tex <=> -tex+r < 0
* GEQUAL: r >= tex <=> not (-tex+r < 0)
* GREATER: r > tex <=> tex-r < 0
* LEQUAL: r <= tex <=> not ( tex-r < 0)
* EQUAL: GEQUAL
* NOTEQUAL:LESS
*/
/* This negates either r or tex: */
if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GEQUAL ||
comparefunc == RC_COMPARE_FUNC_EQUAL || comparefunc == RC_COMPARE_FUNC_NOTEQUAL)
inst_add->U.I.SrcReg[1].Negate = inst_add->U.I.SrcReg[1].Negate ^ RC_MASK_XYZW;
else
inst_add->U.I.SrcReg[0].Negate = inst_add->U.I.SrcReg[0].Negate ^ RC_MASK_XYZW;
/* This negates the whole expression: */
if (comparefunc == RC_COMPARE_FUNC_LESS || comparefunc == RC_COMPARE_FUNC_GREATER ||
comparefunc == RC_COMPARE_FUNC_NOTEQUAL) {
pass = 1;
fail = 2;
} else {
pass = 2;
fail = 1;
}
inst_cmp = rc_insert_new_instruction(c, inst_add);
inst_cmp->U.I.Opcode = RC_OPCODE_CMP;
inst_cmp->U.I.SaturateMode = saturate_mode;
inst_cmp->U.I.DstReg = output_reg;
inst_cmp->U.I.SrcReg[0].File = RC_FILE_TEMPORARY;
inst_cmp->U.I.SrcReg[0].Index = tmp_sum;
inst_cmp->U.I.SrcReg[0].Swizzle = combine_swizzles(
RC_SWIZZLE_WWWW, compiler->state.unit[inst->U.I.TexSrcUnit].texture_swizzle);
inst_cmp->U.I.SrcReg[pass] = shadow_pass_value(compiler, inst->U.I.TexSrcUnit);
inst_cmp->U.I.SrcReg[fail] = shadow_fail_value(compiler, inst->U.I.TexSrcUnit);
assert(tmp_texsample != tmp_sum);
}
}
/* R300 cannot sample from rectangles and the wrap mode fallback needs
* normalized coordinates anyway. */
if (inst->U.I.Opcode != RC_OPCODE_KIL && is_rect && (!c->is_r500 || wrapmode != RC_WRAP_NONE)) {
+4 -33
View File
@@ -141,8 +141,7 @@ static void transform_srcreg(
dst->Negate = src->Register.Negate ? RC_MASK_XYZW : 0;
}
static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src,
uint32_t *shadowSamplers)
static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src)
{
switch(src.Texture) {
case TGSI_TEXTURE_1D:
@@ -160,41 +159,14 @@ static void transform_texture(struct rc_instruction * dst, struct tgsi_instructi
case TGSI_TEXTURE_RECT:
dst->U.I.TexSrcTarget = RC_TEXTURE_RECT;
break;
case TGSI_TEXTURE_SHADOW1D:
dst->U.I.TexSrcTarget = RC_TEXTURE_1D;
dst->U.I.TexShadow = 1;
*shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
break;
case TGSI_TEXTURE_SHADOW2D:
dst->U.I.TexSrcTarget = RC_TEXTURE_2D;
dst->U.I.TexShadow = 1;
*shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
break;
case TGSI_TEXTURE_SHADOWRECT:
dst->U.I.TexSrcTarget = RC_TEXTURE_RECT;
dst->U.I.TexShadow = 1;
*shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
break;
case TGSI_TEXTURE_1D_ARRAY:
dst->U.I.TexSrcTarget = RC_TEXTURE_1D_ARRAY;
break;
case TGSI_TEXTURE_2D_ARRAY:
dst->U.I.TexSrcTarget = RC_TEXTURE_2D_ARRAY;
break;
case TGSI_TEXTURE_SHADOW1D_ARRAY:
dst->U.I.TexSrcTarget = RC_TEXTURE_1D_ARRAY;
dst->U.I.TexShadow = 1;
*shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
break;
case TGSI_TEXTURE_SHADOW2D_ARRAY:
dst->U.I.TexSrcTarget = RC_TEXTURE_2D_ARRAY;
dst->U.I.TexShadow = 1;
*shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
break;
case TGSI_TEXTURE_SHADOWCUBE:
dst->U.I.TexSrcTarget = RC_TEXTURE_CUBE;
dst->U.I.TexShadow = 1;
*shadowSamplers |= 1U << dst->U.I.TexSrcUnit;
default:
unreachable();
break;
}
dst->U.I.TexSwizzle = RC_SWIZZLE_XYZW;
@@ -230,8 +202,7 @@ static void transform_instruction(struct tgsi_to_rc * ttr, struct tgsi_full_inst
/* Texturing. */
if (src->Instruction.Texture)
transform_texture(dst, src->Texture,
&ttr->compiler->Program.ShadowSamplers);
transform_texture(dst, src->Texture);
}
static void handle_immediate(struct tgsi_to_rc * ttr,