diff options
author | Samuel Pitoiset <[email protected]> | 2017-05-17 10:51:59 +0200 |
---|---|---|
committer | Samuel Pitoiset <[email protected]> | 2017-05-18 21:48:16 +0200 |
commit | 5cb2eee5573b69311da95454be1431e536212fbb (patch) | |
tree | de5809f80ab973e510c624679b45d9c4a06e6c7b /src/mesa/state_tracker | |
parent | ac3f6bf608a10f661ac177d63d5fbdcd11b6c1c2 (diff) |
tgsi: store the sampler view type directly in the instruction
RadeonSI needs to do a special lowering for Gather4 with integer
formats, but with bindless samplers we just can't access the index.
Instead, store the return type in the instruction like the target.
Signed-off-by: Samuel Pitoiset <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atifs_to_tgsi.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 17 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_mesa_to_tgsi.c | 21 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_mesa_to_tgsi.h | 4 |
4 files changed, 28 insertions, 16 deletions
diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c b/src/mesa/state_tracker/st_atifs_to_tgsi.c index 8b9c332feb7..338ced56edc 100644 --- a/src/mesa/state_tracker/st_atifs_to_tgsi.c +++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c @@ -334,7 +334,7 @@ compile_setupinst(struct st_translate *t, src[1] = t->samplers[r]; /* the texture target is still unknown, it will be fixed in the draw call */ ureg_tex_insn(t->ureg, TGSI_OPCODE_TEX, dst, 1, TGSI_TEXTURE_2D, - NULL, 0, src, 2); + TGSI_RETURN_TYPE_FLOAT, NULL, 0, src, 2); } else if (texinst->Opcode == ATI_FRAGMENT_SHADER_PASS_OP) { ureg_insn(t->ureg, TGSI_OPCODE_MOV, dst, 1, src, 1); } diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 54bc70f57b5..9620ef760f3 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5877,6 +5877,7 @@ compile_tgsi_instruction(struct st_translate *t, inst->op, dst, num_dst, tex_target, + st_translate_texture_type(inst->tex_type), texoffsets, inst->tex_offset_num_offset, src, num_src); return; @@ -6570,24 +6571,10 @@ st_translate_program( /* texture samplers */ for (i = 0; i < frag_const->MaxTextureImageUnits; i++) { if (program->samplers_used & (1u << i)) { - unsigned type; + unsigned type = st_translate_texture_type(program->sampler_types[i]); t->samplers[i] = ureg_DECL_sampler(ureg, i); - switch (program->sampler_types[i]) { - case GLSL_TYPE_INT: - type = TGSI_RETURN_TYPE_SINT; - break; - case GLSL_TYPE_UINT: - type = TGSI_RETURN_TYPE_UINT; - break; - case GLSL_TYPE_FLOAT: - type = TGSI_RETURN_TYPE_FLOAT; - break; - default: - unreachable("not reached"); - } - ureg_DECL_sampler_view( ureg, i, program->sampler_targets[i], type, type, type, type ); } diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index b3721d8703b..aad3c5b04ca 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -223,6 +223,26 @@ st_translate_texture_target(GLuint textarget, GLboolean shadow) /** + * Map GLSL base type to TGSI return type. + */ +unsigned +st_translate_texture_type(enum glsl_base_type type) +{ + switch (type) { + case GLSL_TYPE_INT: + return TGSI_RETURN_TYPE_SINT; + case GLSL_TYPE_UINT: + return TGSI_RETURN_TYPE_UINT; + case GLSL_TYPE_FLOAT: + return TGSI_RETURN_TYPE_FLOAT; + default: + assert(!"unexpected texture type"); + return TGSI_RETURN_TYPE_UNKNOWN; + } +} + + +/** * Translate a (1 << TEXTURE_x_INDEX) bit into a TGSI_TEXTURE_x enum. */ static unsigned @@ -536,6 +556,7 @@ compile_instruction( dst, num_dst, st_translate_texture_target( inst->TexSrcTarget, inst->TexShadow ), + TGSI_RETURN_TYPE_FLOAT, NULL, 0, src, num_src ); return; diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h index b4d9af635a8..106cf85a3e6 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -34,6 +34,8 @@ #include "pipe/p_compiler.h" #include "pipe/p_defines.h" +#include "compiler/glsl_types.h" + #if defined __cplusplus extern "C" { #endif @@ -63,6 +65,8 @@ st_translate_mesa_program( unsigned st_translate_texture_target(GLuint textarget, GLboolean shadow); +unsigned +st_translate_texture_type(enum glsl_base_type type); #if defined __cplusplus } /* extern "C" */ |