summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c71
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c56
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.c91
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_build.h18
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c13
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump_c.c16
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c107
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.h3
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_info.c11
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h31
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.c8
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_parse.h5
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_sse2.c67
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_text.c102
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.c133
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ureg.h82
-rw-r--r--src/gallium/auxiliary/util/u_simple_shaders.c10
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c8
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c55
-rw-r--r--src/gallium/auxiliary/vl/vl_shader_build.c41
-rw-r--r--src/gallium/auxiliary/vl/vl_shader_build.h11
21 files changed, 467 insertions, 472 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 77cf2c709a7..4585dcdb48a 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -122,10 +122,8 @@ struct aa_transform_context {
struct tgsi_transform_context base;
uint tempsUsed; /**< bitmask */
int colorOutput; /**< which output is the primary color */
- uint samplersUsed; /**< bitfield of samplers used */
- int freeSampler; /**< an available sampler for the aaline */
- uint resourcesUsed; /**< bitfield of resource used */
- uint freeResource; /**< an available resource for the aaline */
+ uint samplersUsed; /**< bitfield of samplers used */
+ int freeSampler; /** an available sampler for the pstipple */
int maxInput, maxGeneric; /**< max input index found */
int colorTemp, texTemp; /**< temp registers */
boolean firstInstruction;
@@ -141,38 +139,33 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
struct tgsi_full_declaration *decl)
{
struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
- uint i;
- switch (decl->Declaration.File) {
- case TGSI_FILE_OUTPUT:
- if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
- decl->Semantic.Index == 0) {
- aactx->colorOutput = decl->Range.First;
- }
- break;
- case TGSI_FILE_SAMPLER:
- for (i = decl->Range.First; i <= decl->Range.Last; i++) {
+ if (decl->Declaration.File == TGSI_FILE_OUTPUT &&
+ decl->Semantic.Name == TGSI_SEMANTIC_COLOR &&
+ decl->Semantic.Index == 0) {
+ aactx->colorOutput = decl->Range.First;
+ }
+ else if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
+ uint i;
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
aactx->samplersUsed |= 1 << i;
}
- break;
- case TGSI_FILE_RESOURCE:
- for (i = decl->Range.First; i <= decl->Range.Last; i++) {
- aactx->resourcesUsed |= 1 << i;
- }
- break;
- case TGSI_FILE_INPUT:
+ }
+ else if (decl->Declaration.File == TGSI_FILE_INPUT) {
if ((int) decl->Range.Last > aactx->maxInput)
aactx->maxInput = decl->Range.Last;
if (decl->Semantic.Name == TGSI_SEMANTIC_GENERIC &&
(int) decl->Semantic.Index > aactx->maxGeneric) {
aactx->maxGeneric = decl->Semantic.Index;
}
- break;
- case TGSI_FILE_TEMPORARY:
- for (i = decl->Range.First; i <= decl->Range.Last; i++) {
+ }
+ else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
+ uint i;
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
aactx->tempsUsed |= (1 << i);
}
- break;
}
ctx->emit_declaration(ctx, decl);
@@ -216,11 +209,6 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
if (aactx->freeSampler >= PIPE_MAX_SAMPLERS)
aactx->freeSampler = PIPE_MAX_SAMPLERS - 1;
- /* find free resource */
- aactx->freeResource = free_bit(aactx->resourcesUsed);
- if (aactx->freeResource >= PIPE_MAX_SHADER_RESOURCES)
- aactx->freeResource = PIPE_MAX_SHADER_RESOURCES - 1;
-
/* find two free temp regs */
for (i = 0; i < 32; i++) {
if ((aactx->tempsUsed & (1 << i)) == 0) {
@@ -255,15 +243,6 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
decl.Range.Last = aactx->freeSampler;
ctx->emit_declaration(ctx, &decl);
- /* declare new resource */
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_RESOURCE;
- decl.Declaration.Resource = 1;
- decl.Resource.Texture = TGSI_TEXTURE_2D;
- decl.Range.First =
- decl.Range.Last = aactx->freeResource;
- ctx->emit_declaration(ctx, &decl);
-
/* declare new temp regs */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
@@ -290,13 +269,13 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
newInst.Instruction.NumDstRegs = 1;
newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
newInst.Dst[0].Register.Index = aactx->texTemp;
- newInst.Instruction.NumSrcRegs = 3;
- newInst.Src[0].Register.File = TGSI_FILE_RESOURCE;
- newInst.Src[0].Register.Index = aactx->freeResource;
- newInst.Src[1].Register.File = TGSI_FILE_INPUT;
- newInst.Src[1].Register.Index = aactx->maxInput + 1;
- newInst.Src[2].Register.File = TGSI_FILE_SAMPLER;
- newInst.Src[2].Register.Index = aactx->freeSampler;
+ newInst.Instruction.NumSrcRegs = 2;
+ newInst.Instruction.Texture = TRUE;
+ newInst.Texture.Texture = TGSI_TEXTURE_2D;
+ newInst.Src[0].Register.File = TGSI_FILE_INPUT;
+ newInst.Src[0].Register.Index = aactx->maxInput + 1;
+ newInst.Src[1].Register.File = TGSI_FILE_SAMPLER;
+ newInst.Src[1].Register.Index = aactx->freeSampler;
ctx->emit_instruction(ctx, &newInst);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index 869dc943fdd..0cc2b718641 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -116,8 +116,6 @@ struct pstip_transform_context {
int maxInput;
uint samplersUsed; /**< bitfield of samplers used */
int freeSampler; /** an available sampler for the pstipple */
- uint resourcesUsed; /**< bitfield of resources used */
- uint freeResource; /**< an available resource for the pstipple */
int texTemp; /**< temp registers */
int numImmed;
boolean firstInstruction;
@@ -133,29 +131,25 @@ pstip_transform_decl(struct tgsi_transform_context *ctx,
struct tgsi_full_declaration *decl)
{
struct pstip_transform_context *pctx = (struct pstip_transform_context *) ctx;
- uint i;
- switch (decl->Declaration.File) {
- case TGSI_FILE_SAMPLER:
- for (i = decl->Range.First; i <= decl->Range.Last; i++) {
+ if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
+ uint i;
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
pctx->samplersUsed |= 1 << i;
}
- break;
- case TGSI_FILE_RESOURCE:
- for (i = decl->Range.First; i <= decl->Range.Last; i++) {
- pctx->resourcesUsed |= 1 << i;
- }
- break;
- case TGSI_FILE_INPUT:
+ }
+ else if (decl->Declaration.File == TGSI_FILE_INPUT) {
pctx->maxInput = MAX2(pctx->maxInput, (int) decl->Range.Last);
if (decl->Semantic.Name == TGSI_SEMANTIC_POSITION)
pctx->wincoordInput = (int) decl->Range.First;
- break;
- case TGSI_FILE_TEMPORARY:
- for (i = decl->Range.First; i <= decl->Range.Last; i++) {
+ }
+ else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
+ uint i;
+ for (i = decl->Range.First;
+ i <= decl->Range.Last; i++) {
pctx->tempsUsed |= (1 << i);
}
- break;
}
ctx->emit_declaration(ctx, decl);
@@ -210,11 +204,6 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
if (pctx->freeSampler >= PIPE_MAX_SAMPLERS)
pctx->freeSampler = PIPE_MAX_SAMPLERS - 1;
- /* find free resource */
- pctx->freeResource = free_bit(pctx->resourcesUsed);
- if (pctx->freeResource >= PIPE_MAX_SHADER_RESOURCES)
- pctx->freeResource = PIPE_MAX_SHADER_RESOURCES - 1;
-
if (pctx->wincoordInput < 0)
wincoordInput = pctx->maxInput + 1;
else
@@ -252,15 +241,6 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
decl.Range.Last = pctx->freeSampler;
ctx->emit_declaration(ctx, &decl);
- /* declare new resource */
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_RESOURCE;
- decl.Declaration.Resource = 1;
- decl.Resource.Texture = TGSI_TEXTURE_2D;
- decl.Range.First =
- decl.Range.Last = pctx->freeResource;
- ctx->emit_declaration(ctx, &decl);
-
/* declare new temp regs */
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
@@ -316,13 +296,13 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
newInst.Instruction.NumDstRegs = 1;
newInst.Dst[0].Register.File = TGSI_FILE_TEMPORARY;
newInst.Dst[0].Register.Index = pctx->texTemp;
- newInst.Instruction.NumSrcRegs = 3;
- newInst.Src[0].Register.File = TGSI_FILE_RESOURCE;
- newInst.Src[0].Register.Index = pctx->freeResource;
- newInst.Src[1].Register.File = TGSI_FILE_TEMPORARY;
- newInst.Src[1].Register.Index = pctx->texTemp;
- newInst.Src[2].Register.File = TGSI_FILE_SAMPLER;
- newInst.Src[2].Register.Index = pctx->freeSampler;
+ newInst.Instruction.NumSrcRegs = 2;
+ newInst.Instruction.Texture = TRUE;
+ newInst.Texture.Texture = TGSI_TEXTURE_2D;
+ newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY;
+ newInst.Src[0].Register.Index = pctx->texTemp;
+ newInst.Src[1].Register.File = TGSI_FILE_SAMPLER;
+ newInst.Src[1].Register.Index = pctx->freeSampler;
ctx->emit_instruction(ctx, &newInst);
/* KIL -texTemp; # if -texTemp < 0, KILL fragment */
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.c b/src/gallium/auxiliary/tgsi/tgsi_build.c
index 426f708c3d5..de9cbc86305 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -106,7 +106,6 @@ tgsi_default_declaration( void )
declaration.Semantic = 0;
declaration.Centroid = 0;
declaration.Invariant = 0;
- declaration.Resource = 0;
declaration.Padding = 0;
return declaration;
@@ -134,7 +133,6 @@ tgsi_build_declaration(
declaration.Semantic = semantic;
declaration.Centroid = centroid;
declaration.Invariant = invariant;
- declaration.Resource = file == TGSI_FILE_RESOURCE;
header_bodysize_grow( header );
@@ -161,7 +159,6 @@ tgsi_default_full_declaration( void )
full_declaration.Declaration = tgsi_default_declaration();
full_declaration.Range = tgsi_default_declaration_range();
full_declaration.Semantic = tgsi_default_declaration_semantic();
- full_declaration.Resource = tgsi_default_declaration_resource();
return full_declaration;
}
@@ -217,20 +214,6 @@ tgsi_build_full_declaration(
header );
}
- if (full_decl->Declaration.Resource) {
- struct tgsi_declaration_resource *dr;
-
- if (maxsize <= size) {
- return 0;
- }
- dr = (struct tgsi_declaration_resource *)&tokens[size];
- size++;
-
- *dr = tgsi_build_declaration_resource(full_decl->Resource.Texture,
- declaration,
- header);
- }
-
return size;
}
@@ -299,32 +282,6 @@ tgsi_build_declaration_semantic(
return ds;
}
-struct tgsi_declaration_resource
-tgsi_default_declaration_resource(void)
-{
- struct tgsi_declaration_resource declaration_resource;
-
- declaration_resource.Texture = TGSI_TEXTURE_UNKNOWN;
- declaration_resource.Padding = 0;
-
- return declaration_resource;
-}
-
-struct tgsi_declaration_resource
-tgsi_build_declaration_resource(unsigned texture,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header)
-{
- struct tgsi_declaration_resource declaration_resource;
-
- declaration_resource = tgsi_default_declaration_resource();
- declaration_resource.Texture = texture;
-
- declaration_grow(declaration, header);
-
- return declaration_resource;
-}
-
/*
* immediate
*/
@@ -449,6 +406,7 @@ tgsi_default_instruction( void )
instruction.NumDstRegs = 1;
instruction.NumSrcRegs = 1;
instruction.Label = 0;
+ instruction.Texture = 0;
instruction.Padding = 0;
return instruction;
@@ -502,6 +460,7 @@ tgsi_default_full_instruction( void )
full_instruction.Instruction = tgsi_default_instruction();
full_instruction.Predicate = tgsi_default_instruction_predicate();
full_instruction.Label = tgsi_default_instruction_label();
+ full_instruction.Texture = tgsi_default_instruction_texture();
for( i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++ ) {
full_instruction.Dst[i] = tgsi_default_full_dst_register();
}
@@ -574,6 +533,23 @@ tgsi_build_full_instruction(
prev_token = (struct tgsi_token *) instruction_label;
}
+ if (full_inst->Instruction.Texture) {
+ struct tgsi_instruction_texture *instruction_texture;
+
+ if( maxsize <= size )
+ return 0;
+ instruction_texture =
+ (struct tgsi_instruction_texture *) &tokens[size];
+ size++;
+
+ *instruction_texture = tgsi_build_instruction_texture(
+ full_inst->Texture.Texture,
+ prev_token,
+ instruction,
+ header );
+ prev_token = (struct tgsi_token *) instruction_texture;
+ }
+
for( i = 0; i < full_inst->Instruction.NumDstRegs; i++ ) {
const struct tgsi_full_dst_register *reg = &full_inst->Dst[i];
struct tgsi_dst_register *dst_register;
@@ -779,6 +755,35 @@ tgsi_build_instruction_label(
return instruction_label;
}
+struct tgsi_instruction_texture
+tgsi_default_instruction_texture( void )
+{
+ struct tgsi_instruction_texture instruction_texture;
+
+ instruction_texture.Texture = TGSI_TEXTURE_UNKNOWN;
+ instruction_texture.Padding = 0;
+
+ return instruction_texture;
+}
+
+struct tgsi_instruction_texture
+tgsi_build_instruction_texture(
+ unsigned texture,
+ struct tgsi_token *prev_token,
+ struct tgsi_instruction *instruction,
+ struct tgsi_header *header )
+{
+ struct tgsi_instruction_texture instruction_texture;
+
+ instruction_texture = tgsi_default_instruction_texture();
+ instruction_texture.Texture = texture;
+ instruction->Texture = 1;
+
+ instruction_grow( instruction, header );
+
+ return instruction_texture;
+}
+
struct tgsi_src_register
tgsi_default_src_register( void )
{
diff --git a/src/gallium/auxiliary/tgsi/tgsi_build.h b/src/gallium/auxiliary/tgsi/tgsi_build.h
index 1532e81d32d..9de2757fe40 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.h
@@ -99,14 +99,6 @@ tgsi_build_declaration_semantic(
struct tgsi_declaration *declaration,
struct tgsi_header *header );
-struct tgsi_declaration_resource
-tgsi_default_declaration_resource(void);
-
-struct tgsi_declaration_resource
-tgsi_build_declaration_resource(unsigned texture,
- struct tgsi_declaration *declaration,
- struct tgsi_header *header);
-
/*
* immediate
*/
@@ -211,6 +203,16 @@ tgsi_build_instruction_label(
struct tgsi_instruction *instruction,
struct tgsi_header *header );
+struct tgsi_instruction_texture
+tgsi_default_instruction_texture( void );
+
+struct tgsi_instruction_texture
+tgsi_build_instruction_texture(
+ unsigned texture,
+ struct tgsi_token *prev_token,
+ struct tgsi_instruction *instruction,
+ struct tgsi_header *header );
+
struct tgsi_src_register
tgsi_default_src_register( void );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index 69ab1b44016..e2e5394f86f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -102,8 +102,7 @@ static const char *file_names[TGSI_FILE_COUNT] =
"IMM",
"LOOP",
"PRED",
- "SV",
- "RES"
+ "SV"
};
static const char *interpolate_names[] =
@@ -320,11 +319,6 @@ iter_declaration(
}
}
- if (decl->Declaration.Resource) {
- TXT(", ");
- ENM(decl->Resource.Texture, texture_names);
- }
-
if (iter->processor.Processor == TGSI_PROCESSOR_FRAGMENT &&
decl->Declaration.File == TGSI_FILE_INPUT)
{
@@ -543,6 +537,11 @@ iter_instruction(
first_reg = FALSE;
}
+ if (inst->Instruction.Texture) {
+ TXT( ", " );
+ ENM( inst->Texture.Texture, texture_names );
+ }
+
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_IF:
case TGSI_OPCODE_ELSE:
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
index 1b3f4852f7f..47fd1dd590e 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
@@ -278,6 +278,10 @@ dump_instruction_verbose(
TXT("\nLabel : ");
UID(inst->Instruction.Label);
}
+ if (deflt || fi->Instruction.Texture != inst->Instruction.Texture) {
+ TXT("\nTexture : ");
+ UID(inst->Instruction.Texture);
+ }
if( ignored ) {
TXT( "\nPadding : " );
UIX( inst->Instruction.Padding );
@@ -295,6 +299,18 @@ dump_instruction_verbose(
}
}
+ if (deflt || inst->Instruction.Texture) {
+ EOL();
+ if (deflt || fi->Texture.Texture != inst->Texture.Texture) {
+ TXT( "\nTexture : " );
+ ENM(inst->Texture.Texture, TGSI_TEXTURES);
+ }
+ if( ignored ) {
+ TXT( "\nPadding : " );
+ UIX(inst->Texture.Padding);
+ }
+ }
+
for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
struct tgsi_full_dst_register *dst = &inst->Dst[i];
struct tgsi_full_dst_register *fd = &fi->Dst[i];
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index c3d79c91368..2bcb33392a8 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -52,6 +52,8 @@
*/
#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_dump.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
@@ -1539,15 +1541,14 @@ exec_tex(struct tgsi_exec_machine *mach,
const struct tgsi_full_instruction *inst,
uint modifier)
{
- const uint image_unit = inst->Src[0].Register.Index;
- const uint sampler_unit = inst->Src[2].Register.Index;
+ const uint unit = inst->Src[1].Register.Index;
union tgsi_exec_channel r[4];
const union tgsi_exec_channel *lod = &ZeroVec;
enum tgsi_sampler_control control;
- uint chan;
+ uint chan_index;
if (modifier != TEX_MODIFIER_NONE) {
- fetch_source(mach, &r[3], &inst->Src[1], CHAN_W, TGSI_EXEC_DATA_FLOAT);
+ FETCH(&r[3], 0, CHAN_W);
if (modifier != TEX_MODIFIER_PROJECTED) {
lod = &r[3];
}
@@ -1559,16 +1560,16 @@ exec_tex(struct tgsi_exec_machine *mach,
control = tgsi_sampler_lod_bias;
}
- switch (mach->Resources[image_unit].Texture) {
+ switch (inst->Texture.Texture) {
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_SHADOW1D:
- fetch_source(mach, &r[0], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
+ FETCH(&r[0], 0, CHAN_X);
if (modifier == TEX_MODIFIER_PROJECTED) {
micro_div(&r[0], &r[0], &r[3]);
}
- fetch_texel(mach->Samplers[sampler_unit],
+ fetch_texel(mach->Samplers[unit],
&r[0], &ZeroVec, &ZeroVec, lod, /* S, T, P, LOD */
control,
&r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
@@ -1578,9 +1579,9 @@ exec_tex(struct tgsi_exec_machine *mach,
case TGSI_TEXTURE_RECT:
case TGSI_TEXTURE_SHADOW2D:
case TGSI_TEXTURE_SHADOWRECT:
- fetch_source(mach, &r[0], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
- fetch_source(mach, &r[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
- fetch_source(mach, &r[2], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT);
+ FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[1], 0, CHAN_Y);
+ FETCH(&r[2], 0, CHAN_Z);
if (modifier == TEX_MODIFIER_PROJECTED) {
micro_div(&r[0], &r[0], &r[3]);
@@ -1588,7 +1589,7 @@ exec_tex(struct tgsi_exec_machine *mach,
micro_div(&r[2], &r[2], &r[3]);
}
- fetch_texel(mach->Samplers[sampler_unit],
+ fetch_texel(mach->Samplers[unit],
&r[0], &r[1], &r[2], lod, /* S, T, P, LOD */
control,
&r[0], &r[1], &r[2], &r[3]); /* outputs */
@@ -1596,9 +1597,9 @@ exec_tex(struct tgsi_exec_machine *mach,
case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_CUBE:
- fetch_source(mach, &r[0], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
- fetch_source(mach, &r[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
- fetch_source(mach, &r[2], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT);
+ FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[1], 0, CHAN_Y);
+ FETCH(&r[2], 0, CHAN_Z);
if (modifier == TEX_MODIFIER_PROJECTED) {
micro_div(&r[0], &r[0], &r[3]);
@@ -1606,7 +1607,7 @@ exec_tex(struct tgsi_exec_machine *mach,
micro_div(&r[2], &r[2], &r[3]);
}
- fetch_texel(mach->Samplers[sampler_unit],
+ fetch_texel(mach->Samplers[unit],
&r[0], &r[1], &r[2], lod,
control,
&r[0], &r[1], &r[2], &r[3]);
@@ -1616,10 +1617,8 @@ exec_tex(struct tgsi_exec_machine *mach,
assert(0);
}
- for (chan = 0; chan < NUM_CHANNELS; chan++) {
- if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
- store_dest(mach, &r[chan], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
- }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&r[chan_index], 0, chan_index);
}
}
@@ -1627,21 +1626,21 @@ static void
exec_txd(struct tgsi_exec_machine *mach,
const struct tgsi_full_instruction *inst)
{
- const uint image_unit = inst->Src[0].Register.Index;
- const uint sampler_unit = inst->Src[2].Register.Index;
+ const uint unit = inst->Src[3].Register.Index;
union tgsi_exec_channel r[4];
- uint chan;
+ uint chan_index;
/*
* XXX: This is fake TXD -- the derivatives are not taken into account, yet.
*/
- switch (mach->Resources[image_unit].Texture) {
+ switch (inst->Texture.Texture) {
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_SHADOW1D:
- fetch_source(mach, &r[0], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
- fetch_texel(mach->Samplers[sampler_unit],
+ FETCH(&r[0], 0, CHAN_X);
+
+ fetch_texel(mach->Samplers[unit],
&r[0], &ZeroVec, &ZeroVec, &ZeroVec, /* S, T, P, BIAS */
tgsi_sampler_lod_bias,
&r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
@@ -1651,11 +1650,12 @@ exec_txd(struct tgsi_exec_machine *mach,
case TGSI_TEXTURE_RECT:
case TGSI_TEXTURE_SHADOW2D:
case TGSI_TEXTURE_SHADOWRECT:
- fetch_source(mach, &r[0], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
- fetch_source(mach, &r[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
- fetch_source(mach, &r[2], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT);
- fetch_texel(mach->Samplers[sampler_unit],
+ FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[1], 0, CHAN_Y);
+ FETCH(&r[2], 0, CHAN_Z);
+
+ fetch_texel(mach->Samplers[unit],
&r[0], &r[1], &r[2], &ZeroVec, /* inputs */
tgsi_sampler_lod_bias,
&r[0], &r[1], &r[2], &r[3]); /* outputs */
@@ -1663,11 +1663,12 @@ exec_txd(struct tgsi_exec_machine *mach,
case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_CUBE:
- fetch_source(mach, &r[0], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
- fetch_source(mach, &r[1], &inst->Src[1], CHAN_Y, TGSI_EXEC_DATA_FLOAT);
- fetch_source(mach, &r[2], &inst->Src[1], CHAN_Z, TGSI_EXEC_DATA_FLOAT);
- fetch_texel(mach->Samplers[sampler_unit],
+ FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[1], 0, CHAN_Y);
+ FETCH(&r[2], 0, CHAN_Z);
+
+ fetch_texel(mach->Samplers[unit],
&r[0], &r[1], &r[2], &ZeroVec,
tgsi_sampler_lod_bias,
&r[0], &r[1], &r[2], &r[3]);
@@ -1677,10 +1678,8 @@ exec_txd(struct tgsi_exec_machine *mach,
assert(0);
}
- for (chan = 0; chan < NUM_CHANNELS; chan++) {
- if (inst->Dst[0].Register.WriteMask & (1 << chan)) {
- store_dest(mach, &r[chan], &inst->Dst[0], inst, chan, TGSI_EXEC_DATA_FLOAT);
- }
+ FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(&r[chan_index], 0, chan_index);
}
}
@@ -1756,11 +1755,6 @@ static void
exec_declaration(struct tgsi_exec_machine *mach,
const struct tgsi_full_declaration *decl)
{
- if (decl->Declaration.File == TGSI_FILE_RESOURCE) {
- mach->Resources[decl->Range.First] = decl->Resource;
- return;
- }
-
if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
if (decl->Declaration.File == TGSI_FILE_INPUT ||
decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE) {
@@ -2846,43 +2840,38 @@ exec_instruction(
case TGSI_OPCODE_TEX:
/* simple texture lookup */
- /* src[0] = resource */
- /* src[1] = texcoord */
- /* src[2] = sampler */
+ /* src[0] = texcoord */
+ /* src[1] = sampler unit */
exec_tex(mach, inst, TEX_MODIFIER_NONE);
break;
case TGSI_OPCODE_TXB:
/* Texture lookup with lod bias */
- /* src[0] = resource */
- /* src[1] = texcoord (src[1].w = LOD bias) */
- /* src[2] = sampler */
+ /* src[0] = texcoord (src[0].w = LOD bias) */
+ /* src[1] = sampler unit */
exec_tex(mach, inst, TEX_MODIFIER_LOD_BIAS);
break;
case TGSI_OPCODE_TXD:
/* Texture lookup with explict partial derivatives */
- /* src[0] = resource */
- /* src[1] = texcoord */
- /* src[2] = sampler */
- /* src[3] = d[strq]/dx */
- /* src[4] = d[strq]/dy */
+ /* src[0] = texcoord */
+ /* src[1] = d[strq]/dx */
+ /* src[2] = d[strq]/dy */
+ /* src[3] = sampler unit */
exec_txd(mach, inst);
break;
case TGSI_OPCODE_TXL:
/* Texture lookup with explit LOD */
- /* src[0] = resource */
- /* src[1] = texcoord (src[1].w = LOD) */
- /* src[2] = sampler */
+ /* src[0] = texcoord (src[0].w = LOD) */
+ /* src[1] = sampler unit */
exec_tex(mach, inst, TEX_MODIFIER_EXPLICIT_LOD);
break;
case TGSI_OPCODE_TXP:
/* Texture lookup with projection */
- /* src[0] = resource */
- /* src[1] = texcoord (src[0].w = projection) */
- /* src[2] = sampler */
+ /* src[0] = texcoord (src[0].w = projection) */
+ /* src[1] = sampler unit */
exec_tex(mach, inst, TEX_MODIFIER_PROJECTED);
break;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index 61189fe5cb7..59e3b445cc3 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -31,7 +31,6 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
-#include "pipe/p_shader_tokens.h"
#if defined __cplusplus
extern "C" {
@@ -330,8 +329,6 @@ struct tgsi_exec_machine
uint NumDeclarations;
struct tgsi_exec_labels Labels;
-
- struct tgsi_declaration_resource Resources[PIPE_MAX_SHADER_RESOURCES];
};
struct tgsi_exec_machine *
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info.c b/src/gallium/auxiliary/tgsi/tgsi_info.c
index 46d1809dcb5..de0e09cdbae 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -2,7 +2,6 @@
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
- * Copyright 2009-2010 VMware, Inc. All rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -84,9 +83,9 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
{ 1, 2, 0, 0, 0, 0, "SLE", TGSI_OPCODE_SLE },
{ 1, 2, 0, 0, 0, 0, "SNE", TGSI_OPCODE_SNE },
{ 1, 2, 0, 0, 0, 0, "STR", TGSI_OPCODE_STR },
- { 1, 3, 1, 0, 0, 0, "TEX", TGSI_OPCODE_TEX },
- { 1, 5, 1, 0, 0, 0, "TXD", TGSI_OPCODE_TXD },
- { 1, 3, 1, 0, 0, 0, "TXP", TGSI_OPCODE_TXP },
+ { 1, 2, 1, 0, 0, 0, "TEX", TGSI_OPCODE_TEX },
+ { 1, 4, 1, 0, 0, 0, "TXD", TGSI_OPCODE_TXD },
+ { 1, 2, 1, 0, 0, 0, "TXP", TGSI_OPCODE_TXP },
{ 1, 1, 0, 0, 0, 0, "UP2H", TGSI_OPCODE_UP2H },
{ 1, 1, 0, 0, 0, 0, "UP2US", TGSI_OPCODE_UP2US },
{ 1, 1, 0, 0, 0, 0, "UP4B", TGSI_OPCODE_UP4B },
@@ -100,11 +99,11 @@ static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
{ 1, 1, 0, 0, 0, 0, "SSG", TGSI_OPCODE_SSG },
{ 1, 3, 0, 0, 0, 0, "CMP", TGSI_OPCODE_CMP },
{ 1, 1, 0, 0, 0, 0, "SCS", TGSI_OPCODE_SCS },
- { 1, 3, 1, 0, 0, 0, "TXB", TGSI_OPCODE_TXB },
+ { 1, 2, 1, 0, 0, 0, "TXB", TGSI_OPCODE_TXB },
{ 1, 1, 0, 0, 0, 0, "NRM", TGSI_OPCODE_NRM },
{ 1, 2, 0, 0, 0, 0, "DIV", TGSI_OPCODE_DIV },
{ 1, 2, 0, 0, 0, 0, "DP2", TGSI_OPCODE_DP2 },
- { 1, 3, 1, 0, 0, 0, "TXL", TGSI_OPCODE_TXL },
+ { 1, 2, 1, 0, 0, 0, "TXL", TGSI_OPCODE_TXL },
{ 0, 0, 0, 0, 0, 0, "BRK", TGSI_OPCODE_BRK },
{ 0, 1, 0, 1, 0, 1, "IF", TGSI_OPCODE_IF },
{ 1, 1, 0, 0, 0, 1, "BGNFOR", TGSI_OPCODE_BGNFOR },
diff --git a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
index c8f7a3a77b2..e4af15c156f 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
@@ -2,7 +2,6 @@
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
- * Copyright 2009-2010 VMware, Inc. All rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
@@ -25,6 +24,13 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
+#ifndef OP12_TEX
+#define OP12_TEX(a) OP12(a)
+#endif
+
+#ifndef OP14_TEX
+#define OP14_TEX(a) OP14(a)
+#endif
#ifndef OP00_LBL
#define OP00_LBL(a) OP00(a)
@@ -82,9 +88,9 @@ OP11(SIN)
OP12(SLE)
OP12(SNE)
OP12(STR)
-OP13(TEX)
-OP15(TXD)
-OP13(TXP)
+OP12_TEX(TEX)
+OP14_TEX(TXD)
+OP12_TEX(TXP)
OP11(UP2H)
OP11(UP2US)
OP11(UP4B)
@@ -98,11 +104,11 @@ OP00(RET)
OP11(SSG)
OP13(CMP)
OP11(SCS)
-OP13(TXB)
+OP12_TEX(TXB)
OP11(NRM)
OP12(DIV)
OP12(DP2)
-OP13(TXL)
+OP12_TEX(TXL)
OP00(BRK)
OP01_LBL(IF)
OP11(BGNFOR)
@@ -123,8 +129,8 @@ OP12(OR)
OP12(MOD)
OP12(XOR)
OP13(SAD)
-OP12(TXF)
-OP13(TXQ)
+OP12_TEX(TXF)
+OP12_TEX(TXQ)
OP00(CONT)
OP00(EMIT)
OP00(ENDPRIM)
@@ -169,7 +175,14 @@ OP12(USNE)
#undef OP11
#undef OP12
#undef OP13
-#undef OP15
+
+#ifdef OP14
+#undef OP14
+#endif
#undef OP00_LBL
#undef OP01_LBL
+
+#undef OP12_TEX
+#undef OP14_TEX
+
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.c b/src/gallium/auxiliary/tgsi/tgsi_parse.c
index e46df700688..8c7062d850c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c
@@ -113,10 +113,6 @@ tgsi_parse_token(
next_token( ctx, &decl->Semantic );
}
- if (decl->Declaration.Resource) {
- next_token(ctx, &decl->Resource);
- }
-
break;
}
@@ -171,6 +167,10 @@ tgsi_parse_token(
next_token( ctx, &inst->Label);
}
+ if (inst->Instruction.Texture) {
+ next_token( ctx, &inst->Texture);
+ }
+
assert( inst->Instruction.NumDstRegs <= TGSI_FULL_MAX_DST_REGISTERS );
for( i = 0; i < inst->Instruction.NumDstRegs; i++ ) {
diff --git a/src/gallium/auxiliary/tgsi/tgsi_parse.h b/src/gallium/auxiliary/tgsi/tgsi_parse.h
index 7ab2d018824..439a57269b7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.h
@@ -1,7 +1,6 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * Copyright 2009-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -60,7 +59,6 @@ struct tgsi_full_declaration
struct tgsi_declaration Declaration;
struct tgsi_declaration_range Range;
struct tgsi_declaration_semantic Semantic;
- struct tgsi_declaration_resource Resource;
};
struct tgsi_full_immediate
@@ -76,13 +74,14 @@ struct tgsi_full_property
};
#define TGSI_FULL_MAX_DST_REGISTERS 2
-#define TGSI_FULL_MAX_SRC_REGISTERS 5 /* TXD has 5 */
+#define TGSI_FULL_MAX_SRC_REGISTERS 4 /* TXD has 4 */
struct tgsi_full_instruction
{
struct tgsi_instruction Instruction;
struct tgsi_instruction_predicate Predicate;
struct tgsi_instruction_label Label;
+ struct tgsi_instruction_texture Texture;
struct tgsi_full_dst_register Dst[TGSI_FULL_MAX_DST_REGISTERS];
struct tgsi_full_src_register Src[TGSI_FULL_MAX_SRC_REGISTERS];
};
diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
index 853d2771165..2e13a7aaf9d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -55,11 +55,6 @@
#define FAST_MATH 1
-struct tgsi_sse_info {
- struct tgsi_declaration_resource resources[PIPE_MAX_SHADER_RESOURCES];
-};
-
-
#define FOR_EACH_CHANNEL( CHAN )\
for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
@@ -1462,19 +1457,18 @@ fetch_texel( struct tgsi_sampler **sampler,
*/
static void
-emit_tex(struct tgsi_sse_info *info,
- struct x86_function *func,
- const struct tgsi_full_instruction *inst,
- boolean lodbias,
- boolean projected)
-{
- const uint image_unit = inst->Src[0].Register.Index;
- const uint sampler_unit = inst->Src[2].Register.Index;
+emit_tex( struct x86_function *func,
+ const struct tgsi_full_instruction *inst,
+ boolean lodbias,
+ boolean projected)
+{
+ const uint unit = inst->Src[1].Register.Index;
struct x86_reg args[2];
unsigned count;
unsigned i;
- switch (info->resources[image_unit].Texture) {
+ assert(inst->Instruction.Texture);
+ switch (inst->Texture.Texture) {
case TGSI_TEXTURE_1D:
count = 1;
break;
@@ -1495,7 +1489,7 @@ emit_tex(struct tgsi_sse_info *info,
}
if (lodbias) {
- FETCH( func, *inst, 3, 1, 3 );
+ FETCH( func, *inst, 3, 0, 3 );
}
else {
emit_tempf(
@@ -1515,13 +1509,13 @@ emit_tex(struct tgsi_sse_info *info,
if (projected) {
- FETCH( func, *inst, 3, 1, 3 );
+ FETCH( func, *inst, 3, 0, 3 );
emit_rcp( func, 3, 3 );
}
for (i = 0; i < count; i++) {
- FETCH( func, *inst, i, 1, i );
+ FETCH( func, *inst, i, 0, i );
if (projected) {
sse_mulps(
@@ -1539,7 +1533,7 @@ emit_tex(struct tgsi_sse_info *info,
}
args[0] = get_temp( TEMP_R0, 0 );
- args[1] = get_sampler_ptr( sampler_unit );
+ args[1] = get_sampler_ptr( unit );
emit_func_call( func,
@@ -1745,9 +1739,9 @@ indirect_temp_reference(const struct tgsi_full_instruction *inst)
static int
-emit_instruction(struct tgsi_sse_info *info,
- struct x86_function *func,
- struct tgsi_full_instruction *inst)
+emit_instruction(
+ struct x86_function *func,
+ struct tgsi_full_instruction *inst )
{
unsigned chan_index;
@@ -2309,7 +2303,7 @@ emit_instruction(struct tgsi_sse_info *info,
break;
case TGSI_OPCODE_TEX:
- emit_tex(info, func, inst, FALSE, FALSE);
+ emit_tex( func, inst, FALSE, FALSE );
break;
case TGSI_OPCODE_TXD:
@@ -2406,7 +2400,7 @@ emit_instruction(struct tgsi_sse_info *info,
break;
case TGSI_OPCODE_TXB:
- emit_tex(info, func, inst, TRUE, FALSE);
+ emit_tex( func, inst, TRUE, FALSE );
break;
case TGSI_OPCODE_NRM:
@@ -2518,7 +2512,7 @@ emit_instruction(struct tgsi_sse_info *info,
break;
case TGSI_OPCODE_TXP:
- emit_tex(info, func, inst, FALSE, TRUE);
+ emit_tex( func, inst, FALSE, TRUE );
break;
case TGSI_OPCODE_BRK:
@@ -2638,15 +2632,10 @@ emit_instruction(struct tgsi_sse_info *info,
}
static void
-emit_declaration(struct tgsi_sse_info *info,
- struct x86_function *func,
- struct tgsi_full_declaration *decl)
+emit_declaration(
+ struct x86_function *func,
+ struct tgsi_full_declaration *decl )
{
- if (decl->Declaration.File == TGSI_FILE_RESOURCE) {
- info->resources[decl->Range.First] = decl->Resource;
- return;
- }
-
if( decl->Declaration.File == TGSI_FILE_INPUT ||
decl->Declaration.File == TGSI_FILE_SYSTEM_VALUE ) {
unsigned first, last, mask;
@@ -2850,7 +2839,6 @@ tgsi_emit_sse2(
boolean do_swizzles )
{
struct tgsi_parse_context parse;
- struct tgsi_sse_info info;
unsigned ok = 1;
uint num_immediates = 0;
@@ -2903,7 +2891,6 @@ tgsi_emit_sse2(
x86_make_disp( get_machine_base(),
Offset( struct tgsi_exec_machine, Samplers ) ) );
- memset(&info, 0, sizeof(info));
while( !tgsi_parse_end_of_tokens( &parse ) && ok ) {
tgsi_parse_token( &parse );
@@ -2911,16 +2898,16 @@ tgsi_emit_sse2(
switch( parse.FullToken.Token.Type ) {
case TGSI_TOKEN_TYPE_DECLARATION:
if (parse.FullHeader.Processor.Processor == TGSI_PROCESSOR_FRAGMENT) {
- emit_declaration(&info,
- func,
- &parse.FullToken.FullDeclaration);
+ emit_declaration(
+ func,
+ &parse.FullToken.FullDeclaration );
}
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
- ok = emit_instruction(&info,
- func,
- &parse.FullToken.FullInstruction );
+ ok = emit_instruction(
+ func,
+ &parse.FullToken.FullInstruction );
if (!ok) {
uint opcode = parse.FullToken.FullInstruction.Instruction.Opcode;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_text.c b/src/gallium/auxiliary/tgsi/tgsi_text.c
index 86cab4218a0..9fcffeda368 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -280,8 +280,7 @@ static const char *file_names[TGSI_FILE_COUNT] =
"IMM",
"LOOP",
"PRED",
- "SV",
- "RES"
+ "SV"
};
static boolean
@@ -827,7 +826,7 @@ parse_instruction(
else if (str_match_no_case( &cur, "_SAT" ))
saturate = TGSI_SAT_ZERO_ONE;
- if (info->num_dst + info->num_src == 0) {
+ if (info->num_dst + info->num_src + info->is_tex == 0) {
if (!is_digit_alpha_underscore( cur )) {
ctx->cur = cur;
break;
@@ -855,7 +854,7 @@ parse_instruction(
/* Parse instruction operands.
*/
- for (i = 0; i < info->num_dst + info->num_src; i++) {
+ for (i = 0; i < info->num_dst + info->num_src + info->is_tex; i++) {
if (i > 0) {
eat_opt_white( &ctx->cur );
if (*ctx->cur != ',') {
@@ -869,10 +868,28 @@ parse_instruction(
if (i < info->num_dst) {
if (!parse_dst_operand( ctx, &inst.Dst[i] ))
return FALSE;
- } else {
+ }
+ else if (i < info->num_dst + info->num_src) {
if (!parse_src_operand( ctx, &inst.Src[i - info->num_dst] ))
return FALSE;
}
+ else {
+ uint j;
+
+ for (j = 0; j < TGSI_TEXTURE_COUNT; j++) {
+ if (str_match_no_case( &ctx->cur, texture_names[j] )) {
+ if (!is_digit_alpha_underscore( ctx->cur )) {
+ inst.Instruction.Texture = 1;
+ inst.Texture.Texture = j;
+ break;
+ }
+ }
+ }
+ if (j == TGSI_TEXTURE_COUNT) {
+ report_error( ctx, "Expected texture target" );
+ return FALSE;
+ }
+ }
}
if (info->is_branch) {
@@ -961,61 +978,40 @@ static boolean parse_declaration( struct translate_ctx *ctx )
cur++;
eat_opt_white( &cur );
- if (file == TGSI_FILE_RESOURCE) {
- for (i = 0; i < TGSI_TEXTURE_COUNT; i++) {
- if (str_match_no_case(&cur, texture_names[i])) {
- if (!is_digit_alpha_underscore(cur)) {
- decl.Declaration.Resource = 1;
- decl.Resource.Texture = i;
- break;
+ for (i = 0; i < TGSI_SEMANTIC_COUNT; i++) {
+ if (str_match_no_case( &cur, semantic_names[i] )) {
+ const char *cur2 = cur;
+ uint index;
+
+ if (is_digit_alpha_underscore( cur ))
+ continue;
+ eat_opt_white( &cur2 );
+ if (*cur2 == '[') {
+ cur2++;
+ eat_opt_white( &cur2 );
+ if (!parse_uint( &cur2, &index )) {
+ report_error( ctx, "Expected literal integer" );
+ return FALSE;
}
- }
- }
- if (i == TGSI_TEXTURE_COUNT) {
- report_error(ctx, "Expected texture target");
- return FALSE;
- }
- } else {
- for (i = 0; i < TGSI_SEMANTIC_COUNT; i++) {
- if (str_match_no_case(&cur, semantic_names[i])) {
- const char *cur2 = cur;
- uint index;
-
- if (is_digit_alpha_underscore(cur))
- continue;
- eat_opt_white(&cur2);
- if (*cur2 == '[') {
- cur2++;
- eat_opt_white(&cur2);
- if (!parse_uint(&cur2, &index)) {
- report_error(ctx, "Expected literal integer");
- return FALSE;
- }
- eat_opt_white(&cur2);
- if (*cur2 != ']') {
- report_error(ctx, "Expected `]'");
- return FALSE;
- }
- cur2++;
-
- decl.Semantic.Index = index;
-
- cur = cur2;
+ eat_opt_white( &cur2 );
+ if (*cur2 != ']') {
+ report_error( ctx, "Expected `]'" );
+ return FALSE;
}
+ cur2++;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = i;
+ decl.Semantic.Index = index;
- ctx->cur = cur;
- break;
+ cur = cur2;
}
+
+ decl.Declaration.Semantic = 1;
+ decl.Semantic.Name = i;
+
+ ctx->cur = cur;
+ break;
}
}
- } else {
- if (file == TGSI_FILE_RESOURCE) {
- report_error(ctx, "Expected `,'");
- return FALSE;
- }
}
cur = ctx->cur;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
index ac2455a201e..e64e2b731df 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2009-2010 VMware, Inc.
+ * Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -43,12 +43,12 @@ union tgsi_any_token {
struct tgsi_declaration decl;
struct tgsi_declaration_range decl_range;
struct tgsi_declaration_semantic decl_semantic;
- struct tgsi_declaration_resource decl_resource;
struct tgsi_immediate imm;
union tgsi_immediate_data imm_data;
struct tgsi_instruction insn;
struct tgsi_instruction_predicate insn_predicate;
struct tgsi_instruction_label insn_label;
+ struct tgsi_instruction_texture insn_texture;
struct tgsi_src_register src;
struct tgsi_dimension dim;
struct tgsi_dst_register dst;
@@ -114,12 +114,6 @@ struct ureg_program
struct ureg_src sampler[PIPE_MAX_SAMPLERS];
unsigned nr_samplers;
- struct {
- unsigned index;
- unsigned target;
- } resource[PIPE_MAX_SHADER_RESOURCES];
- unsigned nr_resources;
-
unsigned temps_active[UREG_MAX_TEMP / 32];
unsigned nr_temps;
@@ -496,33 +490,6 @@ struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg,
return ureg->sampler[0];
}
-/* Allocate a new shader resource.
- */
-struct ureg_src
-ureg_DECL_resource(struct ureg_program *ureg,
- unsigned index,
- unsigned target)
-{
- struct ureg_src reg = ureg_src_register(TGSI_FILE_RESOURCE, index);
- uint i;
-
- for (i = 0; i < ureg->nr_resources; i++) {
- if (ureg->resource[i].index == index) {
- return reg;
- }
- }
-
- if (i < PIPE_MAX_SHADER_RESOURCES) {
- ureg->resource[i].index = index;
- ureg->resource[i].target = target;
- ureg->nr_resources++;
- return reg;
- }
-
- assert(0);
- return reg;
-}
-
static int
match_or_expand_immediate( const unsigned *v,
@@ -711,7 +678,6 @@ ureg_emit_dst( struct ureg_program *ureg,
assert(dst.File != TGSI_FILE_CONSTANT);
assert(dst.File != TGSI_FILE_INPUT);
assert(dst.File != TGSI_FILE_SAMPLER);
- assert(dst.File != TGSI_FILE_RESOURCE);
assert(dst.File != TGSI_FILE_IMMEDIATE);
assert(dst.File < TGSI_FILE_COUNT);
@@ -839,6 +805,23 @@ ureg_fixup_label(struct ureg_program *ureg,
void
+ureg_emit_texture(struct ureg_program *ureg,
+ unsigned extended_token,
+ unsigned target )
+{
+ union tgsi_any_token *out, *insn;
+
+ out = get_tokens( ureg, DOMAIN_INSN, 1 );
+ insn = retrieve_token( ureg, DOMAIN_INSN, extended_token );
+
+ insn->insn.Texture = 1;
+
+ out[0].value = 0;
+ out[0].insn_texture.Texture = target;
+}
+
+
+void
ureg_fixup_insn_size(struct ureg_program *ureg,
unsigned insn )
{
@@ -895,6 +878,55 @@ ureg_insn(struct ureg_program *ureg,
ureg_fixup_insn_size( ureg, insn.insn_token );
}
+void
+ureg_tex_insn(struct ureg_program *ureg,
+ unsigned opcode,
+ const struct ureg_dst *dst,
+ unsigned nr_dst,
+ unsigned target,
+ const struct ureg_src *src,
+ unsigned nr_src )
+{
+ struct ureg_emit_insn_result insn;
+ unsigned i;
+ boolean saturate;
+ boolean predicate;
+ boolean negate = FALSE;
+ unsigned swizzle[4] = { 0 };
+
+ saturate = nr_dst ? dst[0].Saturate : FALSE;
+ predicate = nr_dst ? dst[0].Predicate : FALSE;
+ if (predicate) {
+ negate = dst[0].PredNegate;
+ swizzle[0] = dst[0].PredSwizzleX;
+ swizzle[1] = dst[0].PredSwizzleY;
+ swizzle[2] = dst[0].PredSwizzleZ;
+ swizzle[3] = dst[0].PredSwizzleW;
+ }
+
+ insn = ureg_emit_insn(ureg,
+ opcode,
+ saturate,
+ predicate,
+ negate,
+ swizzle[0],
+ swizzle[1],
+ swizzle[2],
+ swizzle[3],
+ nr_dst,
+ nr_src);
+
+ ureg_emit_texture( ureg, insn.extended_token, target );
+
+ for (i = 0; i < nr_dst; i++)
+ ureg_emit_dst( ureg, dst[i] );
+
+ for (i = 0; i < nr_src; i++)
+ ureg_emit_src( ureg, src[i] );
+
+ ureg_fixup_insn_size( ureg, insn.insn_token );
+}
+
void
ureg_label_insn(struct ureg_program *ureg,
@@ -977,29 +1009,6 @@ static void emit_decl_range( struct ureg_program *ureg,
}
static void
-emit_decl_resource(struct ureg_program *ureg,
- unsigned index,
- unsigned target)
-{
- union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 3);
-
- out[0].value = 0;
- out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION;
- out[0].decl.NrTokens = 3;
- out[0].decl.File = TGSI_FILE_RESOURCE;
- out[0].decl.UsageMask = 0xf;
- out[0].decl.Interpolate = TGSI_INTERPOLATE_CONSTANT;
- out[0].decl.Resource = 1;
-
- out[1].value = 0;
- out[1].decl_range.First = index;
- out[1].decl_range.Last = index;
-
- out[2].value = 0;
- out[2].decl_resource.Texture = target;
-}
-
-static void
emit_immediate( struct ureg_program *ureg,
const unsigned *v,
unsigned type )
@@ -1064,12 +1073,6 @@ static void emit_decls( struct ureg_program *ureg )
ureg->sampler[i].Index, 1 );
}
- for (i = 0; i < ureg->nr_resources; i++) {
- emit_decl_resource(ureg,
- ureg->resource[i].index,
- ureg->resource[i].target);
- }
-
if (ureg->nr_constant_ranges) {
for (i = 0; i < ureg->nr_constant_ranges; i++)
emit_decl_range( ureg,
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
index d49dc21e8cc..6f11273320a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2009-2010 VMware, Inc.
+ * Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -186,11 +186,6 @@ struct ureg_src
ureg_DECL_sampler( struct ureg_program *,
unsigned index );
-struct ureg_src
-ureg_DECL_resource(struct ureg_program *,
- unsigned index,
- unsigned target);
-
static INLINE struct ureg_src
ureg_imm4f( struct ureg_program *ureg,
@@ -358,6 +353,16 @@ ureg_insn(struct ureg_program *ureg,
void
+ureg_tex_insn(struct ureg_program *ureg,
+ unsigned opcode,
+ const struct ureg_dst *dst,
+ unsigned nr_dst,
+ unsigned target,
+ const struct ureg_src *src,
+ unsigned nr_src );
+
+
+void
ureg_label_insn(struct ureg_program *ureg,
unsigned opcode,
const struct ureg_src *src,
@@ -392,6 +397,11 @@ ureg_emit_label(struct ureg_program *ureg,
unsigned insn_token,
unsigned *label_token );
+void
+ureg_emit_texture(struct ureg_program *ureg,
+ unsigned insn_token,
+ unsigned target );
+
void
ureg_emit_dst( struct ureg_program *ureg,
struct ureg_dst dst );
@@ -554,6 +564,33 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
ureg_fixup_insn_size( ureg, insn ); \
}
+#define OP12_TEX( op ) \
+static INLINE void ureg_##op( struct ureg_program *ureg, \
+ struct ureg_dst dst, \
+ unsigned target, \
+ struct ureg_src src0, \
+ struct ureg_src src1 ) \
+{ \
+ unsigned opcode = TGSI_OPCODE_##op; \
+ struct ureg_emit_insn_result insn; \
+ insn = ureg_emit_insn(ureg, \
+ opcode, \
+ dst.Saturate, \
+ dst.Predicate, \
+ dst.PredNegate, \
+ dst.PredSwizzleX, \
+ dst.PredSwizzleY, \
+ dst.PredSwizzleZ, \
+ dst.PredSwizzleW, \
+ 1, \
+ 2); \
+ ureg_emit_texture( ureg, insn.extended_token, target ); \
+ ureg_emit_dst( ureg, dst ); \
+ ureg_emit_src( ureg, src0 ); \
+ ureg_emit_src( ureg, src1 ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
+}
+
#define OP13( op ) \
static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_dst dst, \
@@ -580,34 +617,35 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
ureg_fixup_insn_size( ureg, insn ); \
}
-#define OP15( op ) \
+#define OP14_TEX( op ) \
static INLINE void ureg_##op( struct ureg_program *ureg, \
struct ureg_dst dst, \
+ unsigned target, \
struct ureg_src src0, \
struct ureg_src src1, \
struct ureg_src src2, \
- struct ureg_src src3, \
- struct ureg_src src4 ) \
+ struct ureg_src src3 ) \
{ \
unsigned opcode = TGSI_OPCODE_##op; \
- unsigned insn = ureg_emit_insn(ureg, \
- opcode, \
- dst.Saturate, \
- dst.Predicate, \
- dst.PredNegate, \
- dst.PredSwizzleX, \
- dst.PredSwizzleY, \
- dst.PredSwizzleZ, \
- dst.PredSwizzleW, \
- 1, \
- 5).insn_token; \
+ struct ureg_emit_insn_result insn; \
+ insn = ureg_emit_insn(ureg, \
+ opcode, \
+ dst.Saturate, \
+ dst.Predicate, \
+ dst.PredNegate, \
+ dst.PredSwizzleX, \
+ dst.PredSwizzleY, \
+ dst.PredSwizzleZ, \
+ dst.PredSwizzleW, \
+ 1, \
+ 4); \
+ ureg_emit_texture( ureg, insn.extended_token, target ); \
ureg_emit_dst( ureg, dst ); \
ureg_emit_src( ureg, src0 ); \
ureg_emit_src( ureg, src1 ); \
ureg_emit_src( ureg, src2 ); \
ureg_emit_src( ureg, src3 ); \
- ureg_emit_src( ureg, src4 ); \
- ureg_fixup_insn_size( ureg, insn ); \
+ ureg_fixup_insn_size( ureg, insn.insn_token ); \
}
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index ae890c25518..b751e29ab62 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -94,7 +94,6 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
{
struct ureg_program *ureg;
struct ureg_src sampler;
- struct ureg_src resource;
struct ureg_src tex;
struct ureg_dst out;
@@ -104,8 +103,6 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
sampler = ureg_DECL_sampler( ureg, 0 );
- resource = ureg_DECL_resource( ureg, 0, tex_target );
-
tex = ureg_DECL_fs_input( ureg,
TGSI_SEMANTIC_GENERIC, 0,
TGSI_INTERPOLATE_PERSPECTIVE );
@@ -122,7 +119,7 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
ureg_TEX( ureg,
ureg_writemask(out, writemask),
- resource, tex, sampler );
+ tex_target, tex, sampler );
ureg_END( ureg );
return ureg_create_shader_and_destroy( ureg, pipe );
@@ -153,7 +150,6 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
{
struct ureg_program *ureg;
struct ureg_src sampler;
- struct ureg_src resource;
struct ureg_src tex;
struct ureg_dst out, depth;
struct ureg_src imm;
@@ -164,8 +160,6 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
sampler = ureg_DECL_sampler( ureg, 0 );
- resource = ureg_DECL_resource( ureg, 0, tex_target );
-
tex = ureg_DECL_fs_input( ureg,
TGSI_SEMANTIC_GENERIC, 0,
TGSI_INTERPOLATE_PERSPECTIVE );
@@ -184,7 +178,7 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
ureg_TEX( ureg,
ureg_writemask(depth, TGSI_WRITEMASK_Z),
- resource, tex, sampler );
+ tex_target, tex, sampler );
ureg_END( ureg );
return ureg_create_shader_and_destroy( ureg, pipe );
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
index 2f594c48dd5..fc2a1c59a6b 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -199,12 +199,8 @@ create_frag_shader(struct vl_compositor *c)
decl = vl_decl_samplers(0, 0);
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- /* decl r0, 2D ; Resource containing picture to display */
- decl = vl_decl_resource(0, TGSI_TEXTURE_2D);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* tex t0, r0, i0, s0 ; Read src pixel */
- inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_RESOURCE, 0, TGSI_FILE_INPUT, 0, TGSI_FILE_SAMPLER, 0);
+ /* tex2d t0, i0, s0 ; Read src pixel */
+ inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_INPUT, 0, TGSI_FILE_SAMPLER, 0);
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
/*
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
index 9e72c5f32ed..caf581aca60 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -215,30 +215,24 @@ create_intra_frag_shader(struct vl_mpeg12_mc_renderer *r)
/*
* decl s0 ; Sampler for luma texture
- * decl r0, 2D
* decl s1 ; Sampler for chroma Cb texture
- * decl r1, 2D
* decl s2 ; Sampler for chroma Cr texture
- * decl r2, 2D
*/
for (i = 0; i < 3; ++i) {
decl = vl_decl_samplers(i, i);
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- decl = vl_decl_resource(i, TGSI_TEXTURE_2D);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
}
/*
- * tex t1, r0, i0, s0 ; Read texel from luma texture
+ * tex2d t1, i0, s0 ; Read texel from luma texture
* mov t0.x, t1.x ; Move luma sample into .x component
- * tex t1, r1, i1, s1 ; Read texel from chroma Cb texture
+ * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
* mov t0.y, t1.x ; Move Cb sample into .y component
- * tex t1, r2, i2, s2 ; Read texel from chroma Cr texture
+ * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
* mov t0.z, t1.x ; Move Cr sample into .z component
*/
for (i = 0; i < 3; ++i) {
- inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_RESOURCE, i, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
+ inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
@@ -398,32 +392,25 @@ create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
/*
* decl s0 ; Sampler for luma texture
- * decl r0, 2D
* decl s1 ; Sampler for chroma Cb texture
- * decl r1, 2D
* decl s2 ; Sampler for chroma Cr texture
- * decl r2, 2D
* decl s3 ; Sampler for ref surface texture
- * decl r3, 2D
*/
for (i = 0; i < 4; ++i) {
decl = vl_decl_samplers(i, i);
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- decl = vl_decl_resource(i, TGSI_TEXTURE_2D);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
}
/*
- * tex t1, r0, i0, s0 ; Read texel from luma texture
+ * tex2d t1, i0, s0 ; Read texel from luma texture
* mov t0.x, t1.x ; Move luma sample into .x component
- * tex t1, r1, i1, s1 ; Read texel from chroma Cb texture
+ * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
* mov t0.y, t1.x ; Move Cb sample into .y component
- * tex t1, r2, i2, s2 ; Read texel from chroma Cr texture
+ * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
* mov t0.z, t1.x ; Move Cr sample into .z component
*/
for (i = 0; i < 3; ++i) {
- inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_RESOURCE, i, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
+ inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
@@ -438,8 +425,8 @@ create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
inst = vl_inst3(TGSI_OPCODE_MUL, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 0);
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- /* tex t1, r3, i3, s3 ; Read texel from ref macroblock */
- inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_RESOURCE, 3, TGSI_FILE_INPUT, 3, TGSI_FILE_SAMPLER, 3);
+ /* tex2d t1, i3, s3 ; Read texel from ref macroblock */
+ inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, 3, TGSI_FILE_SAMPLER, 3);
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
/* add o0, t0, t1 ; Add ref and differential to form final output */
@@ -611,34 +598,26 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
/*
* decl s0 ; Sampler for luma texture
- * decl r0, 2D
* decl s1 ; Sampler for chroma Cb texture
- * decl r1, 2D
* decl s2 ; Sampler for chroma Cr texture
- * decl r2, 2D
* decl s3 ; Sampler for first ref surface texture
- * decl r3, 2D
* decl s4 ; Sampler for second ref surface texture
- * decl r4, 2D
*/
for (i = 0; i < 5; ++i) {
decl = vl_decl_samplers(i, i);
ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- decl = vl_decl_resource(i, TGSI_TEXTURE_2D);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
}
/*
- * tex t1, r0, i0, s0 ; Read texel from luma texture
+ * tex2d t1, i0, s0 ; Read texel from luma texture
* mov t0.x, t1.x ; Move luma sample into .x component
- * tex t1, r1, i1, s1 ; Read texel from chroma Cb texture
+ * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
* mov t0.y, t1.x ; Move Cb sample into .y component
- * tex t1, r2, i2, s2 ; Read texel from chroma Cr texture
+ * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
* mov t0.z, t1.x ; Move Cr sample into .z component
*/
for (i = 0; i < 3; ++i) {
- inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_RESOURCE, i, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
+ inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
@@ -654,11 +633,11 @@ create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
/*
- * tex t1, r3, i3, s3 ; Read texel from first ref macroblock
- * tex t2, r4, i4, s4 ; Read texel from second ref macroblock
+ * tex2d t1, i3, s3 ; Read texel from first ref macroblock
+ * tex2d t2, i4, s4 ; Read texel from second ref macroblock
*/
for (i = 0; i < 2; ++i) {
- inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, i + 1, TGSI_FILE_RESOURCE, i + 3, TGSI_FILE_INPUT, i + 3, TGSI_FILE_SAMPLER, i + 3);
+ inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, i + 1, TGSI_FILE_INPUT, i + 3, TGSI_FILE_SAMPLER, i + 3);
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
}
diff --git a/src/gallium/auxiliary/vl/vl_shader_build.c b/src/gallium/auxiliary/vl/vl_shader_build.c
index 30cd823383b..d011ef97bd6 100644
--- a/src/gallium/auxiliary/vl/vl_shader_build.c
+++ b/src/gallium/auxiliary/vl/vl_shader_build.c
@@ -125,19 +125,6 @@ struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int l
return decl;
}
-struct tgsi_full_declaration vl_decl_resource(unsigned int index, unsigned int target)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl.Declaration.File = TGSI_FILE_RESOURCE;
- decl.Declaration.Resource = 1;
- decl.Range.First = index;
- decl.Range.Last = index;
- decl.Resource.Texture = target;
-
- return decl;
-}
-
struct tgsi_full_instruction vl_inst2
(
int opcode,
@@ -186,6 +173,34 @@ struct tgsi_full_instruction vl_inst3
return inst;
}
+struct tgsi_full_instruction vl_tex
+(
+ int tex,
+ enum tgsi_file_type dst_file,
+ unsigned int dst_index,
+ enum tgsi_file_type src1_file,
+ unsigned int src1_index,
+ enum tgsi_file_type src2_file,
+ unsigned int src2_index
+)
+{
+ struct tgsi_full_instruction inst = tgsi_default_full_instruction();
+
+ inst.Instruction.Opcode = TGSI_OPCODE_TEX;
+ inst.Instruction.NumDstRegs = 1;
+ inst.Dst[0].Register.File = dst_file;
+ inst.Dst[0].Register.Index = dst_index;
+ inst.Instruction.NumSrcRegs = 2;
+ inst.Instruction.Texture = 1;
+ inst.Texture.Texture = tex;
+ inst.Src[0].Register.File = src1_file;
+ inst.Src[0].Register.Index = src1_index;
+ inst.Src[1].Register.File = src2_file;
+ inst.Src[1].Register.Index = src2_index;
+
+ return inst;
+}
+
struct tgsi_full_instruction vl_inst4
(
int opcode,
diff --git a/src/gallium/auxiliary/vl/vl_shader_build.h b/src/gallium/auxiliary/vl/vl_shader_build.h
index c3fb7c6110b..5da71f8e136 100644
--- a/src/gallium/auxiliary/vl/vl_shader_build.h
+++ b/src/gallium/auxiliary/vl/vl_shader_build.h
@@ -43,7 +43,6 @@ struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int i
struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last);
struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_resource(unsigned int index, unsigned int target);
struct tgsi_full_instruction vl_inst2
(
int opcode,
@@ -62,6 +61,16 @@ struct tgsi_full_instruction vl_inst3
enum tgsi_file_type src2_file,
unsigned int src2_index
);
+struct tgsi_full_instruction vl_tex
+(
+ int tex,
+ enum tgsi_file_type dst_file,
+ unsigned int dst_index,
+ enum tgsi_file_type src1_file,
+ unsigned int src1_index,
+ enum tgsi_file_type src2_file,
+ unsigned int src2_index
+);
struct tgsi_full_instruction vl_inst4
(
int opcode,