brw/vec4: Don't convert tex dest type to glsl_type
We were using nir_tex_instr::dest_type to a glsl_type, then passing it to emit_texture(), only to just check the number of components. Just pass the number of components directly. This lets us delete brw_glsl_base_type_for_nir_type, which was asserting with nir_texop_all_samples_equal because it didn't handle bool32. Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7989>
This commit is contained in:
@@ -1482,42 +1482,6 @@ brw_type_for_nir_type(const struct gen_device_info *devinfo, nir_alu_type type)
|
|||||||
return BRW_REGISTER_TYPE_F;
|
return BRW_REGISTER_TYPE_F;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the glsl_base_type corresponding to a nir_alu_type.
|
|
||||||
* This is used by both brw_vec4_nir and brw_fs_nir.
|
|
||||||
*/
|
|
||||||
enum glsl_base_type
|
|
||||||
brw_glsl_base_type_for_nir_type(nir_alu_type type)
|
|
||||||
{
|
|
||||||
switch (type) {
|
|
||||||
case nir_type_float:
|
|
||||||
case nir_type_float32:
|
|
||||||
return GLSL_TYPE_FLOAT;
|
|
||||||
|
|
||||||
case nir_type_float16:
|
|
||||||
return GLSL_TYPE_FLOAT16;
|
|
||||||
|
|
||||||
case nir_type_float64:
|
|
||||||
return GLSL_TYPE_DOUBLE;
|
|
||||||
|
|
||||||
case nir_type_int:
|
|
||||||
case nir_type_int32:
|
|
||||||
return GLSL_TYPE_INT;
|
|
||||||
|
|
||||||
case nir_type_uint:
|
|
||||||
case nir_type_uint32:
|
|
||||||
return GLSL_TYPE_UINT;
|
|
||||||
|
|
||||||
case nir_type_int16:
|
|
||||||
return GLSL_TYPE_INT16;
|
|
||||||
|
|
||||||
case nir_type_uint16:
|
|
||||||
return GLSL_TYPE_UINT16;
|
|
||||||
|
|
||||||
default:
|
|
||||||
unreachable("bad type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nir_shader *
|
nir_shader *
|
||||||
brw_nir_create_passthrough_tcs(void *mem_ctx, const struct brw_compiler *compiler,
|
brw_nir_create_passthrough_tcs(void *mem_ctx, const struct brw_compiler *compiler,
|
||||||
const nir_shader_compiler_options *options,
|
const nir_shader_compiler_options *options,
|
||||||
|
@@ -156,8 +156,6 @@ uint32_t brw_aop_for_nir_intrinsic(const nir_intrinsic_instr *atomic);
|
|||||||
enum brw_reg_type brw_type_for_nir_type(const struct gen_device_info *devinfo,
|
enum brw_reg_type brw_type_for_nir_type(const struct gen_device_info *devinfo,
|
||||||
nir_alu_type type);
|
nir_alu_type type);
|
||||||
|
|
||||||
enum glsl_base_type brw_glsl_base_type_for_nir_type(nir_alu_type type);
|
|
||||||
|
|
||||||
void brw_nir_setup_glsl_uniforms(void *mem_ctx, nir_shader *shader,
|
void brw_nir_setup_glsl_uniforms(void *mem_ctx, nir_shader *shader,
|
||||||
const struct gl_program *prog,
|
const struct gl_program *prog,
|
||||||
struct brw_stage_prog_data *stage_prog_data,
|
struct brw_stage_prog_data *stage_prog_data,
|
||||||
|
@@ -254,7 +254,7 @@ public:
|
|||||||
|
|
||||||
void emit_texture(ir_texture_opcode op,
|
void emit_texture(ir_texture_opcode op,
|
||||||
dst_reg dest,
|
dst_reg dest,
|
||||||
const glsl_type *dest_type,
|
int dest_components,
|
||||||
src_reg coordinate,
|
src_reg coordinate,
|
||||||
int coord_components,
|
int coord_components,
|
||||||
src_reg shadow_comparator,
|
src_reg shadow_comparator,
|
||||||
|
@@ -1950,14 +1950,6 @@ ir_texture_opcode_for_nir_texop(nir_texop texop)
|
|||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const glsl_type *
|
|
||||||
glsl_type_for_nir_alu_type(nir_alu_type alu_type,
|
|
||||||
unsigned components)
|
|
||||||
{
|
|
||||||
return glsl_type::get_instance(brw_glsl_base_type_for_nir_type(alu_type),
|
|
||||||
components, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
||||||
{
|
{
|
||||||
@@ -1973,9 +1965,6 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
|||||||
src_reg sample_index;
|
src_reg sample_index;
|
||||||
src_reg mcs;
|
src_reg mcs;
|
||||||
|
|
||||||
const glsl_type *dest_type =
|
|
||||||
glsl_type_for_nir_alu_type(instr->dest_type,
|
|
||||||
nir_tex_instr_dest_size(instr));
|
|
||||||
dst_reg dest = get_nir_dest(instr->dest, instr->dest_type);
|
dst_reg dest = get_nir_dest(instr->dest, instr->dest_type);
|
||||||
|
|
||||||
/* The hardware requires a LOD for buffer textures */
|
/* The hardware requires a LOD for buffer textures */
|
||||||
@@ -2102,7 +2091,8 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)
|
|||||||
|
|
||||||
ir_texture_opcode op = ir_texture_opcode_for_nir_texop(instr->op);
|
ir_texture_opcode op = ir_texture_opcode_for_nir_texop(instr->op);
|
||||||
|
|
||||||
emit_texture(op, dest, dest_type, coordinate, instr->coord_components,
|
emit_texture(op, dest, nir_tex_instr_dest_size(instr),
|
||||||
|
coordinate, instr->coord_components,
|
||||||
shadow_comparator,
|
shadow_comparator,
|
||||||
lod, lod2, sample_index,
|
lod, lod2, sample_index,
|
||||||
constant_offset, offset_value, mcs,
|
constant_offset, offset_value, mcs,
|
||||||
|
@@ -827,7 +827,7 @@ vec4_visitor::is_high_sampler(src_reg sampler)
|
|||||||
void
|
void
|
||||||
vec4_visitor::emit_texture(ir_texture_opcode op,
|
vec4_visitor::emit_texture(ir_texture_opcode op,
|
||||||
dst_reg dest,
|
dst_reg dest,
|
||||||
const glsl_type *dest_type,
|
int dest_components,
|
||||||
src_reg coordinate,
|
src_reg coordinate,
|
||||||
int coord_components,
|
int coord_components,
|
||||||
src_reg shadow_comparator,
|
src_reg shadow_comparator,
|
||||||
@@ -964,7 +964,7 @@ vec4_visitor::emit_texture(ir_texture_opcode op,
|
|||||||
emit(MOV(dst_reg(MRF, param_base + 1, type, WRITEMASK_YW), lod2));
|
emit(MOV(dst_reg(MRF, param_base + 1, type, WRITEMASK_YW), lod2));
|
||||||
inst->mlen++;
|
inst->mlen++;
|
||||||
|
|
||||||
if (dest_type->vector_elements == 3 || shadow_comparator.file != BAD_FILE) {
|
if (dest_components == 3 || shadow_comparator.file != BAD_FILE) {
|
||||||
lod.swizzle = BRW_SWIZZLE_ZZZZ;
|
lod.swizzle = BRW_SWIZZLE_ZZZZ;
|
||||||
lod2.swizzle = BRW_SWIZZLE_ZZZZ;
|
lod2.swizzle = BRW_SWIZZLE_ZZZZ;
|
||||||
emit(MOV(dst_reg(MRF, param_base + 2, type, WRITEMASK_X), lod));
|
emit(MOV(dst_reg(MRF, param_base + 2, type, WRITEMASK_X), lod));
|
||||||
|
Reference in New Issue
Block a user