instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
instruction_texture.NumOffsets = 0;
+ instruction_texture.ReturnType = TGSI_RETURN_TYPE_UNKNOWN;
instruction_texture.Padding = 0;
return instruction_texture;
tgsi_build_instruction_texture(
unsigned texture,
unsigned num_offsets,
+ unsigned return_type,
struct tgsi_token *prev_token,
struct tgsi_instruction *instruction,
struct tgsi_header *header )
instruction_texture.Texture = texture;
instruction_texture.NumOffsets = num_offsets;
+ instruction_texture.ReturnType = return_type;
instruction_texture.Padding = 0;
instruction->Texture = 1;
*instruction_texture = tgsi_build_instruction_texture(
full_inst->Texture.Texture,
- full_inst->Texture.NumOffsets,
+ full_inst->Texture.NumOffsets,
+ full_inst->Texture.ReturnType,
prev_token,
instruction,
header );
void
ureg_emit_texture(struct ureg_program *ureg,
unsigned extended_token,
- unsigned target, unsigned num_offsets)
+ unsigned target, unsigned return_type, unsigned num_offsets)
{
union tgsi_any_token *out, *insn;
out[0].value = 0;
out[0].insn_texture.Texture = target;
out[0].insn_texture.NumOffsets = num_offsets;
+ out[0].insn_texture.ReturnType = return_type;
}
void
const struct ureg_dst *dst,
unsigned nr_dst,
unsigned target,
+ unsigned return_type,
const struct tgsi_texture_offset *texoffsets,
unsigned nr_offset,
const struct ureg_src *src,
nr_dst,
nr_src);
- ureg_emit_texture( ureg, insn.extended_token, target, nr_offset );
+ ureg_emit_texture( ureg, insn.extended_token, target, return_type,
+ nr_offset );
for (i = 0; i < nr_offset; i++)
ureg_emit_texture_offset( ureg, &texoffsets[i]);
const struct ureg_dst *dst,
unsigned nr_dst,
unsigned target,
+ unsigned return_type,
const struct tgsi_texture_offset *texoffsets,
unsigned nr_offset,
const struct ureg_src *src,
void
ureg_emit_texture(struct ureg_program *ureg,
unsigned insn_token,
- unsigned target, unsigned num_offsets);
+ unsigned target, unsigned return_type, unsigned num_offsets);
void
ureg_emit_texture_offset(struct ureg_program *ureg,
struct ureg_src src1 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
+ unsigned return_type = TGSI_RETURN_TYPE_UNKNOWN; \
struct ureg_emit_insn_result insn; \
if (ureg_dst_is_empty(dst)) \
return; \
dst.Saturate, \
1, \
2); \
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \
+ ureg_emit_texture( ureg, insn.extended_token, target, \
+ return_type, 0 ); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
struct ureg_src src3 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
+ unsigned return_type = TGSI_RETURN_TYPE_UNKNOWN; \
struct ureg_emit_insn_result insn; \
if (ureg_dst_is_empty(dst)) \
return; \
dst.Saturate, \
1, \
4); \
- ureg_emit_texture( ureg, insn.extended_token, target, 0 ); \
+ ureg_emit_texture( ureg, insn.extended_token, target, \
+ return_type, 0 ); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
TGSI_RETURN_TYPE_SINT,
TGSI_RETURN_TYPE_UINT,
TGSI_RETURN_TYPE_FLOAT,
+ TGSI_RETURN_TYPE_UNKNOWN,
TGSI_RETURN_TYPE_COUNT
};
{
unsigned Texture : 8; /* TGSI_TEXTURE_ */
unsigned NumOffsets : 4;
- unsigned Padding : 20;
+ unsigned ReturnType : 3; /* TGSI_RETURN_TYPE_x */
+ unsigned Padding : 17;
};
/* for texture offsets in GLSL and DirectX.
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);
}
inst->op,
dst, num_dst,
tex_target,
+ st_translate_texture_type(inst->tex_type),
texoffsets, inst->tex_offset_num_offset,
src, num_src);
return;
/* 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 );
}
}
+/**
+ * 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.
*/
dst, num_dst,
st_translate_texture_target( inst->TexSrcTarget,
inst->TexShadow ),
+ TGSI_RETURN_TYPE_FLOAT,
NULL, 0,
src, num_src );
return;
#include "pipe/p_compiler.h"
#include "pipe/p_defines.h"
+#include "compiler/glsl_types.h"
+
#if defined __cplusplus
extern "C" {
#endif
unsigned
st_translate_texture_target(GLuint textarget, GLboolean shadow);
+unsigned
+st_translate_texture_type(enum glsl_base_type type);
#if defined __cplusplus
} /* extern "C" */