summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2010-01-26 11:56:21 +0100
committerMichal Krol <michal@vmware.com>2010-01-26 11:56:21 +0100
commit2f3d85ac4d463142cc171f9f4d036f5831967489 (patch)
tree044c976c62f4189a1f5977f847c0dcef3ba25fb7
parentdd3f800aea0c4a8739112aff581cdcc2d8c775c1 (diff)
Revert "gallium: Replace texture target with resource operand in TGSI texture opcodes."gallium-gpu4-texture-opcodes
-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
-rw-r--r--src/gallium/drivers/cell/ppu/cell_gen_fp.c16
-rw-r--r--src/gallium/drivers/cell/spu/spu_exec.c67
-rw-r--r--src/gallium/drivers/cell/spu/spu_exec.h2
-rw-r--r--src/gallium/drivers/i915/i915_fpc.h2
-rw-r--r--src/gallium/drivers/i915/i915_fpc_translate.c12
-rw-r--r--src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c18
-rw-r--r--src/gallium/drivers/nv30/nv30_fragprog.c8
-rw-r--r--src/gallium/drivers/nv40/nv40_fragprog.c8
-rw-r--r--src/gallium/drivers/nv50/nv50_program.c34
-rw-r--r--src/gallium/drivers/r300/r300_tgsi_to_rc.c27
-rw-r--r--src/gallium/drivers/r300/r300_tgsi_to_rc.h2
-rw-r--r--src/gallium/drivers/svga/svga_tgsi_insn.c32
-rw-r--r--src/gallium/include/pipe/p_shader_tokens.h44
-rw-r--r--src/gallium/include/pipe/p_state.h1
35 files changed, 584 insertions, 628 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 77cf2c709a..4585dcdb48 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 869dc943fd..0cc2b71864 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 426f708c3d..de9cbc8630 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 1532e81d32..9de2757fe4 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 69ab1b4401..e2e5394f86 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 1b3f4852f7..47fd1dd590 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 c3d79c9136..2bcb33392a 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 61189fe5cb..59e3b445cc 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 46d1809dcb..de0e09cdba 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 c8f7a3a77b..e4af15c156 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 e46df70068..8c7062d850 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 7ab2d01882..439a57269b 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 853d277116..2e13a7aaf9 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 86cab4218a..9fcffeda36 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 ac2455a201..e64e2b731d 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 d49dc21e8c..6f11273320 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 ae890c2551..b751e29ab6 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 2f594c48dd..fc2a1c59a6 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 9e72c5f32e..caf581aca6 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 30cd823383..d011ef97bd 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 c3fb7c6110..5da71f8e13 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,
diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fp.c b/src/gallium/drivers/cell/ppu/cell_gen_fp.c
index c7f9818a51..1d8a11a4ac 100644
--- a/src/gallium/drivers/cell/ppu/cell_gen_fp.c
+++ b/src/gallium/drivers/cell/ppu/cell_gen_fp.c
@@ -71,7 +71,6 @@ struct codegen
int constants_reg; /**< 3rd function parameter */
int temp_regs[MAX_TEMPS][4]; /**< maps TGSI temps to SPE registers */
int imm_regs[MAX_IMMED][4]; /**< maps TGSI immediates to SPE registers */
- struct tgsi_declaration_resource resources[PIPE_MAX_SHADER_RESOURCES];
int num_imm; /**< number of immediates */
@@ -1352,15 +1351,13 @@ emit_function_call(struct codegen *gen,
static boolean
emit_TEX(struct codegen *gen, 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 target = inst->Texture.Texture;
+ const uint unit = inst->Src[1].Register.Index;
uint addr;
int ch;
int coord_regs[4], d_regs[4];
- assert(inst->Src[0].Register.File == TGSI_FILE_RESOURCE);
-
- switch (gen->resources[image_unit].Texture) {
+ switch (target) {
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_2D:
addr = lookup_function(gen->cell, "spu_tex_2d");
@@ -1376,13 +1373,13 @@ emit_TEX(struct codegen *gen, const struct tgsi_full_instruction *inst)
return FALSE;
}
- assert(inst->Src[2].Register.File == TGSI_FILE_SAMPLER);
+ assert(inst->Src[1].Register.File == TGSI_FILE_SAMPLER);
spe_comment(gen->f, -4, "CALL tex:");
/* get src/dst reg info */
for (ch = 0; ch < 4; ch++) {
- coord_regs[ch] = get_src_reg(gen, ch, &inst->Src[1]);
+ coord_regs[ch] = get_src_reg(gen, ch, &inst->Src[0]);
d_regs[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
}
@@ -1935,9 +1932,6 @@ emit_declaration(struct cell_context *cell,
}
}
break;
- case TGSI_FILE_RESOURCE:
- gen->resources[decl->Range.First] = decl->Resource;
- break;
default:
; /* ignore */
}
diff --git a/src/gallium/drivers/cell/spu/spu_exec.c b/src/gallium/drivers/cell/spu/spu_exec.c
index e4724aa506..d86d8e09a5 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.c
+++ b/src/gallium/drivers/cell/spu/spu_exec.c
@@ -677,32 +677,31 @@ exec_tex(struct spu_exec_machine *mach,
const struct tgsi_full_instruction *inst,
boolean biasLod, boolean projected)
{
- 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 spu_exec_channel r[8];
uint chan_index;
float lodBias;
/* printf("Sampler %u unit %u\n", sampler, unit); */
- switch (mach->Resources[image_unit].Texture) {
+ switch (inst->InstructionExtTexture.Texture) {
case TGSI_TEXTURE_1D:
- FETCH(&r[0], 1, CHAN_X);
+ FETCH(&r[0], 0, CHAN_X);
if (projected) {
- FETCH(&r[1], 1, CHAN_W);
+ FETCH(&r[1], 0, CHAN_W);
r[0].q = micro_div(r[0].q, r[1].q);
}
if (biasLod) {
- FETCH(&r[1], 1, CHAN_W);
+ FETCH(&r[1], 0, CHAN_W);
lodBias = r[2].f[0];
}
else
lodBias = 0.0;
- fetch_texel(&mach->Samplers[sampler_unit],
+ fetch_texel(&mach->Samplers[unit],
&r[0], NULL, NULL, lodBias, /* S, T, P, BIAS */
&r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
break;
@@ -710,9 +709,9 @@ exec_tex(struct spu_exec_machine *mach,
case TGSI_TEXTURE_2D:
case TGSI_TEXTURE_RECT:
- FETCH(&r[0], 1, CHAN_X);
- FETCH(&r[1], 1, CHAN_Y);
- FETCH(&r[2], 1, CHAN_Z);
+ FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[1], 0, CHAN_Y);
+ FETCH(&r[2], 0, CHAN_Z);
if (projected) {
FETCH(&r[3], 0, CHAN_W);
@@ -722,13 +721,13 @@ exec_tex(struct spu_exec_machine *mach,
}
if (biasLod) {
- FETCH(&r[3], 1, CHAN_W);
+ FETCH(&r[3], 0, CHAN_W);
lodBias = r[3].f[0];
}
else
lodBias = 0.0;
- fetch_texel(&mach->Samplers[sampler_unit],
+ fetch_texel(&mach->Samplers[unit],
&r[0], &r[1], &r[2], lodBias, /* inputs */
&r[0], &r[1], &r[2], &r[3]); /* outputs */
break;
@@ -736,9 +735,9 @@ exec_tex(struct spu_exec_machine *mach,
case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_CUBE:
- FETCH(&r[0], 1, CHAN_X);
- FETCH(&r[1], 1, CHAN_Y);
- FETCH(&r[2], 1, CHAN_Z);
+ FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[1], 0, CHAN_Y);
+ FETCH(&r[2], 0, CHAN_Z);
if (projected) {
FETCH(&r[3], 0, CHAN_W);
@@ -748,13 +747,13 @@ exec_tex(struct spu_exec_machine *mach,
}
if (biasLod) {
- FETCH(&r[3], 1, CHAN_W);
+ FETCH(&r[3], 0, CHAN_W);
lodBias = r[3].f[0];
}
else
lodBias = 0.0;
- fetch_texel(&mach->Samplers[sampler_unit],
+ fetch_texel(&mach->Samplers[unit],
&r[0], &r[1], &r[2], lodBias,
&r[0], &r[1], &r[2], &r[3]);
break;
@@ -829,11 +828,6 @@ static void
exec_declaration(struct spu_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 ) {
unsigned first, last, mask;
@@ -1403,43 +1397,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, FALSE, FALSE);
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 = load bias) */
+ /* src[1] = sampler unit */
exec_tex(mach, inst, TRUE, FALSE);
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 */
ASSERT (0);
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 = load bias) */
+ /* src[1] = sampler unit */
exec_tex(mach, inst, TRUE, FALSE);
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, TRUE, TRUE);
break;
diff --git a/src/gallium/drivers/cell/spu/spu_exec.h b/src/gallium/drivers/cell/spu/spu_exec.h
index ae978880be..8605679940 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.h
+++ b/src/gallium/drivers/cell/spu/spu_exec.h
@@ -152,8 +152,6 @@ struct spu_exec_machine
struct tgsi_full_declaration *Declarations;
uint NumDeclarations;
-
- struct tgsi_declaration_resource Resources[PIPE_MAX_SHADER_RESOURCES];
};
diff --git a/src/gallium/drivers/i915/i915_fpc.h b/src/gallium/drivers/i915/i915_fpc.h
index 46331e2222..2f0f99d046 100644
--- a/src/gallium/drivers/i915/i915_fpc.h
+++ b/src/gallium/drivers/i915/i915_fpc.h
@@ -57,8 +57,6 @@ struct i915_fp_compile {
uint declarations[I915_PROGRAM_SIZE];
uint program[I915_PROGRAM_SIZE];
- struct tgsi_declaration_resource resources[PIPE_MAX_SHADER_RESOURCES];
-
uint *csr; /**< Cursor, points into program. */
uint *decl; /**< Cursor, points into declarations. */
diff --git a/src/gallium/drivers/i915/i915_fpc_translate.c b/src/gallium/drivers/i915/i915_fpc_translate.c
index 82100d40ee..25c53210be 100644
--- a/src/gallium/drivers/i915/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915/i915_fpc_translate.c
@@ -338,11 +338,11 @@ emit_tex(struct i915_fp_compile *p,
const struct tgsi_full_instruction *inst,
uint opcode)
{
- uint image_unit = inst->Src[0].Register.Index;
- uint sampler_unit = inst->Src[2].Register.Index;
- uint tex = translate_tex_src_target(p, p->resources[image_unit].Texture);
- uint sampler = i915_emit_decl(p, REG_TYPE_S, sampler_unit, tex);
- uint coord = src_vector(p, &inst->Src[1]);
+ uint texture = inst->Texture.Texture;
+ uint unit = inst->Src[1].Register.Index;
+ uint tex = translate_tex_src_target( p, texture );
+ uint sampler = i915_emit_decl(p, REG_TYPE_S, unit, tex);
+ uint coord = src_vector( p, &inst->Src[0]);
i915_emit_texld( p,
get_result_vector( p, &inst->Dst[0] ),
@@ -946,8 +946,6 @@ i915_translate_instructions(struct i915_fp_compile *p,
/* XXX just use shader->info->file_mask[TGSI_FILE_TEMPORARY] */
p->temp_flag |= (1 << i); /* mark temp as used */
}
- } else if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_RESOURCE) {
- p->resources[parse.FullToken.FullDeclaration.Range.First] = parse.FullToken.FullDeclaration.Resource;
}
break;
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
index 998b0c93a8..fb1eda4423 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
@@ -95,8 +95,6 @@ struct lp_build_tgsi_soa_context
struct lp_build_sampler_soa *sampler;
- struct tgsi_declaration_resource resources[PIPE_MAX_SHADER_RESOURCES];
-
LLVMValueRef immediates[LP_MAX_IMMEDIATES][NUM_CHANNELS];
LLVMValueRef temps[LP_MAX_TEMPS][NUM_CHANNELS];
@@ -321,15 +319,14 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
boolean projected,
LLVMValueRef *texel)
{
- 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;
LLVMValueRef lodbias;
LLVMValueRef oow = NULL;
LLVMValueRef coords[3];
unsigned num_coords;
unsigned i;
- switch (bld->resources[image_unit].Texture) {
+ switch (inst->Texture.Texture) {
case TGSI_TEXTURE_1D:
num_coords = 1;
break;
@@ -350,17 +347,17 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
}
if(apply_lodbias)
- lodbias = emit_fetch( bld, inst, 1, 3 );
+ lodbias = emit_fetch( bld, inst, 0, 3 );
else
lodbias = bld->base.zero;
if (projected) {
- oow = emit_fetch( bld, inst, 1, 3 );
+ oow = emit_fetch( bld, inst, 0, 3 );
oow = lp_build_rcp(&bld->base, oow);
}
for (i = 0; i < num_coords; i++) {
- coords[i] = emit_fetch( bld, inst, 1, i );
+ coords[i] = emit_fetch( bld, inst, 0, i );
if (projected)
coords[i] = lp_build_mul(&bld->base, coords[i], oow);
}
@@ -371,7 +368,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
bld->sampler->emit_fetch_texel(bld->sampler,
bld->base.builder,
bld->base.type,
- sampler_unit, num_coords, coords, lodbias,
+ unit, num_coords, coords, lodbias,
texel);
}
@@ -1434,9 +1431,6 @@ lp_build_tgsi_soa(LLVMBuilderRef builder,
switch( parse.FullToken.Token.Type ) {
case TGSI_TOKEN_TYPE_DECLARATION:
/* Inputs already interpolated */
- if (parse.FullToken.FullDeclaration.Declaration.File == TGSI_FILE_RESOURCE) {
- bld.resources[parse.FullToken.FullDeclaration.Range.First] = parse.FullToken.FullDeclaration.Resource;
- }
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
index 84674a38d0..2d565cb631 100644
--- a/src/gallium/drivers/nv30/nv30_fragprog.c
+++ b/src/gallium/drivers/nv30/nv30_fragprog.c
@@ -412,7 +412,7 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
case TGSI_FILE_TEMPORARY:
/* handled above */
break;
- case TGSI_FILE_RESOURCE:
+ case TGSI_FILE_SAMPLER:
unit = fsrc->Register.Index;
break;
case TGSI_FILE_OUTPUT:
@@ -558,13 +558,13 @@ nv30_fragprog_parse_instruction(struct nv30_fpc *fpc,
arith(fpc, sat, ADD, dst, mask, src[0], neg(src[1]), none);
break;
case TGSI_OPCODE_TEX:
- tex(fpc, sat, TEX, unit, dst, mask, src[1], none, none);
+ tex(fpc, sat, TEX, unit, dst, mask, src[0], none, none);
break;
case TGSI_OPCODE_TXB:
- tex(fpc, sat, TXB, unit, dst, mask, src[1], none, none);
+ tex(fpc, sat, TXB, unit, dst, mask, src[0], none, none);
break;
case TGSI_OPCODE_TXP:
- tex(fpc, sat, TXP, unit, dst, mask, src[1], none, none);
+ tex(fpc, sat, TXP, unit, dst, mask, src[0], none, none);
break;
case TGSI_OPCODE_XPD:
tmp = temp(fpc);
diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
index 7b3c71764a..1237066c39 100644
--- a/src/gallium/drivers/nv40/nv40_fragprog.c
+++ b/src/gallium/drivers/nv40/nv40_fragprog.c
@@ -422,7 +422,7 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
case TGSI_FILE_TEMPORARY:
/* handled above */
break;
- case TGSI_FILE_RESOURCE:
+ case TGSI_FILE_SAMPLER:
unit = fsrc->Register.Index;
break;
case TGSI_FILE_OUTPUT:
@@ -629,13 +629,13 @@ nv40_fragprog_parse_instruction(struct nv40_fpc *fpc,
arith(fpc, sat, ADD, dst, mask, src[0], neg(src[1]), none);
break;
case TGSI_OPCODE_TEX:
- tex(fpc, sat, TEX, unit, dst, mask, src[1], none, none);
+ tex(fpc, sat, TEX, unit, dst, mask, src[0], none, none);
break;
case TGSI_OPCODE_TXB:
- tex(fpc, sat, TXB, unit, dst, mask, src[1], none, none);
+ tex(fpc, sat, TXB, unit, dst, mask, src[0], none, none);
break;
case TGSI_OPCODE_TXP:
- tex(fpc, sat, TXP, unit, dst, mask, src[1], none, none);
+ tex(fpc, sat, TXP, unit, dst, mask, src[0], none, none);
break;
case TGSI_OPCODE_XPD:
tmp = temp(fpc);
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index b8a2707d0b..53f9f0adf3 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -2009,12 +2009,17 @@ nv50_tgsi_src_mask(const struct tgsi_full_instruction *insn, int c)
case TGSI_OPCODE_TXL:
case TGSI_OPCODE_TXP:
{
+ const struct tgsi_instruction_texture *tex;
+
+ assert(insn->Instruction.Texture);
+ tex = &insn->Texture;
+
mask = 0x7;
if (insn->Instruction.Opcode != TGSI_OPCODE_TEX &&
insn->Instruction.Opcode != TGSI_OPCODE_TXD)
mask |= 0x8; /* bias, lod or proj */
- switch (pc->resources[insn->Src[0].Register.Index].Texture) {
+ switch (tex->Texture) {
case TGSI_TEXTURE_1D:
mask &= 0x9;
break;
@@ -2302,7 +2307,7 @@ nv50_program_tx_insn(struct nv50_pc *pc,
const struct tgsi_full_instruction *inst)
{
struct nv50_reg *rdst[4], *dst[4], *brdc, *src[3][4], *temp;
- unsigned mask, sat, image_unit, sampler_unit;
+ unsigned mask, sat, unit;
int i, c;
mask = inst->Dst[0].Register.WriteMask;
@@ -2326,10 +2331,8 @@ nv50_program_tx_insn(struct nv50_pc *pc,
src_mask = nv50_tgsi_src_mask(inst, i);
mod_supp = get_supported_mods(inst, i);
- if (fs->Register.File == TGSI_FILE_RESOURCE)
- image_unit = fs->Register.Index;
- else if (fs->Register.File == TGSI_FILE_SAMPLER)
- sampler_unit = fs->Register.Index;
+ if (fs->Register.File == TGSI_FILE_SAMPLER)
+ unit = fs->Register.Index;
for (c = 0; c < 4; c++)
if (src_mask & (1 << c))
@@ -2793,20 +2796,20 @@ nv50_program_tx_insn(struct nv50_pc *pc,
}
break;
case TGSI_OPCODE_TEX:
- emit_tex(pc, dst, mask, src[1], sampler_unit,
- pc->resources[image_unit].Texture, FALSE, 0);
+ emit_tex(pc, dst, mask, src[0], unit,
+ inst->Texture.Texture, FALSE, 0);
break;
case TGSI_OPCODE_TXB:
- emit_tex(pc, dst, mask, src[1], sampler_unit,
- pc->resources[image_unit].Texture, FALSE, -1);
+ emit_tex(pc, dst, mask, src[0], unit,
+ inst->Texture.Texture, FALSE, -1);
break;
case TGSI_OPCODE_TXL:
- emit_tex(pc, dst, mask, src[1], sampler_unit,
- pc->resources[image_unit].Texture, FALSE, 1);
+ emit_tex(pc, dst, mask, src[0], unit,
+ inst->Texture.Texture, FALSE, 1);
break;
case TGSI_OPCODE_TXP:
- emit_tex(pc, dst, mask, src[1], sampler_unit,
- pc->resources[image_unit].Texture, TRUE, 0);
+ emit_tex(pc, dst, mask, src[0], unit,
+ inst->Texture.Texture, TRUE, 0);
break;
case TGSI_OPCODE_TRUNC:
for (c = 0; c < 4; c++) {
@@ -3635,9 +3638,6 @@ nv50_program_tx(struct nv50_program *p)
tgsi_parse_token(&parse);
switch (tok->Token.Type) {
- case TGSI_TOKEN_TYPE_DECLARATION:
- pc->resources[parse.FullToken.FullDeclaration.Range.First] = parse.FullToken.FullDeclaration.Resource;
- break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
pc->insn_pos[pc->insn_cur] = pc->p->exec_size;
++pc->insn_cur;
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.c b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
index 9b6c76e0a8..a792c2cf98 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
@@ -212,12 +212,10 @@ static void transform_srcreg(
dst->Negate = src->Register.Negate ? RC_MASK_XYZW : 0;
}
-static void transform_texture(struct tgsi_to_rc * ttr,
- struct rc_instruction * dst,
- uint32_t imageUnit,
+static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src,
uint32_t *shadowSamplers)
{
- switch(ttr->resources[imageUnit].Texture) {
+ switch(src.Texture) {
case TGSI_TEXTURE_1D:
dst->U.I.TexSrcTarget = RC_TEXTURE_1D;
break;
@@ -267,15 +265,16 @@ static void transform_instruction(struct tgsi_to_rc * ttr, struct tgsi_full_inst
transform_dstreg(ttr, &dst->U.I.DstReg, &src->Dst[0]);
for(i = 0; i < src->Instruction.NumSrcRegs; ++i) {
- if (src->Src[i].Register.File == TGSI_FILE_RESOURCE) {
+ if (src->Src[i].Register.File == TGSI_FILE_SAMPLER)
dst->U.I.TexSrcUnit = src->Src[i].Register.Index;
- /* Texturing. */
- transform_texture(ttr, dst, src->Src[i].Register.Index,
- &ttr->compiler->Program.ShadowSamplers);
- } else {
+ else
transform_srcreg(ttr, &dst->U.I.SrcReg[i], &src->Src[i]);
- }
}
+
+ /* Texturing. */
+ if (src->Instruction.Texture)
+ transform_texture(dst, src->Texture,
+ &ttr->compiler->Program.ShadowSamplers);
}
static void handle_immediate(struct tgsi_to_rc * ttr, struct tgsi_full_immediate * imm)
@@ -290,13 +289,6 @@ static void handle_immediate(struct tgsi_to_rc * ttr, struct tgsi_full_immediate
rc_constants_add(&ttr->compiler->Program.Constants, &constant);
}
-static void handle_declaration(struct tgsi_to_rc * ttr, struct tgsi_full_declaration * decl)
-{
- if (decl->Declaration.File == TGSI_FILE_RESOURCE) {
- ttr->resources[decl->Range.First] = decl->Resource;
- }
-}
-
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
{
struct tgsi_parse_context parser;
@@ -323,7 +315,6 @@ void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens)
switch (parser.FullToken.Token.Type) {
case TGSI_TOKEN_TYPE_DECLARATION:
- handle_declaration(ttr, &parse.FullToken.FullDeclaration);
break;
case TGSI_TOKEN_TYPE_IMMEDIATE:
handle_immediate(ttr, &parser.FullToken.FullImmediate);
diff --git a/src/gallium/drivers/r300/r300_tgsi_to_rc.h b/src/gallium/drivers/r300/r300_tgsi_to_rc.h
index b58061709c..93e90ec6d2 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.h
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.h
@@ -34,8 +34,6 @@ struct tgsi_to_rc {
const struct tgsi_shader_info * info;
int immediate_offset;
-
- struct tgsi_declaration_resource resources[PIPE_MAX_SHADER_RESOURCES];
};
void r300_tgsi_to_rc(struct tgsi_to_rc * ttr, const struct tgsi_token * tokens);
diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c
index 6e4e0f91f9..dc5eb8fc60 100644
--- a/src/gallium/drivers/svga/svga_tgsi_insn.c
+++ b/src/gallium/drivers/svga/svga_tgsi_insn.c
@@ -1169,8 +1169,8 @@ static boolean emit_tex2(struct svga_shader_emitter *emit,
SVGA3dShaderDestToken dst )
{
SVGA3dShaderInstToken inst;
+ struct src_register src0;
struct src_register src1;
- struct src_register src2;
inst.value = 0;
inst.op = SVGA3DOP_TEX;
@@ -1189,21 +1189,21 @@ static boolean emit_tex2(struct svga_shader_emitter *emit,
return FALSE;
}
+ src0 = translate_src_register( emit, &insn->Src[0] );
src1 = translate_src_register( emit, &insn->Src[1] );
- src2 = translate_src_register( emit, &insn->Src[2] );
- if (emit->key.fkey.tex[src2.base.num].unnormalized) {
- struct src_register wh = get_tex_dimensions( emit, src2.base.num );
+ if (emit->key.fkey.tex[src1.base.num].unnormalized) {
+ struct src_register wh = get_tex_dimensions( emit, src1.base.num );
SVGA3dShaderDestToken tmp = get_temp( emit );
- /* MUL tmp, SRC1, WH */
+ /* MUL tmp, SRC0, WH */
if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ),
- tmp, src1, wh ))
+ tmp, src0, wh ))
return FALSE;
- src1 = src( tmp );
+ src0 = src( tmp );
}
- return submit_op2( emit, inst, dst, src1, src2 );
+ return submit_op2( emit, inst, dst, src0, src1 );
}
@@ -1216,9 +1216,9 @@ static boolean emit_tex3(struct svga_shader_emitter *emit,
SVGA3dShaderDestToken dst )
{
SVGA3dShaderInstToken inst;
+ struct src_register src0;
struct src_register src1;
struct src_register src2;
- struct src_register src3;
inst.value = 0;
@@ -1231,11 +1231,11 @@ static boolean emit_tex3(struct svga_shader_emitter *emit,
break;
}
+ src0 = translate_src_register( emit, &insn->Src[0] );
src1 = translate_src_register( emit, &insn->Src[1] );
src2 = translate_src_register( emit, &insn->Src[2] );
- src3 = translate_src_register( emit, &insn->Src[3] );
- return submit_op3( emit, inst, dst, src1, src2, src3 );
+ return submit_op3( emit, inst, dst, src0, src1, src2 );
}
@@ -1244,15 +1244,15 @@ static boolean emit_tex(struct svga_shader_emitter *emit,
{
SVGA3dShaderDestToken dst =
translate_dst_register( emit, insn, 0 );
+ struct src_register src0 =
+ translate_src_register( emit, &insn->Src[0] );
struct src_register src1 =
translate_src_register( emit, &insn->Src[1] );
- struct src_register src2 =
- translate_src_register( emit, &insn->Src[2] );
SVGA3dShaderDestToken tex_result;
/* check for shadow samplers */
- boolean compare = (emit->key.fkey.tex[src2.base.num].compare_mode ==
+ boolean compare = (emit->key.fkey.tex[src1.base.num].compare_mode ==
PIPE_TEX_COMPARE_R_TO_TEXTURE);
@@ -1293,12 +1293,12 @@ static boolean emit_tex(struct svga_shader_emitter *emit,
/* Divide texcoord R by Q */
if (!submit_op1( emit, inst_token( SVGA3DOP_RCP ),
src0_zdivw,
- scalar(src1, TGSI_SWIZZLE_W) ))
+ scalar(src0, TGSI_SWIZZLE_W) ))
return FALSE;
if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ),
src0_zdivw,
- scalar(src1, TGSI_SWIZZLE_Z),
+ scalar(src0, TGSI_SWIZZLE_Z),
src(src0_zdivw) ))
return FALSE;
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 85e5d00504..550e2abc32 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -1,7 +1,7 @@
/**************************************************************************
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
- * Copyright 2009-2010 VMware, Inc.
+ * Copyright 2009 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -76,7 +76,6 @@ enum tgsi_file_type {
TGSI_FILE_LOOP =8,
TGSI_FILE_PREDICATE =9,
TGSI_FILE_SYSTEM_VALUE =10,
- TGSI_FILE_RESOURCE =11,
TGSI_FILE_COUNT /**< how many TGSI_FILE_ types */
};
@@ -113,8 +112,7 @@ struct tgsi_declaration
unsigned Semantic : 1; /**< BOOL, any semantic info? */
unsigned Centroid : 1; /**< centroid sampling? */
unsigned Invariant : 1; /**< invariant optimization? */
- unsigned Resource:1; /**< BOOL, any resource info? */
- unsigned Padding:4;
+ unsigned Padding : 5;
};
struct tgsi_declaration_range
@@ -142,22 +140,6 @@ struct tgsi_declaration_semantic
unsigned Padding : 8;
};
-#define TGSI_TEXTURE_UNKNOWN 0
-#define TGSI_TEXTURE_1D 1
-#define TGSI_TEXTURE_2D 2
-#define TGSI_TEXTURE_3D 3
-#define TGSI_TEXTURE_CUBE 4
-#define TGSI_TEXTURE_RECT 5
-#define TGSI_TEXTURE_SHADOW1D 6
-#define TGSI_TEXTURE_SHADOW2D 7
-#define TGSI_TEXTURE_SHADOWRECT 8
-#define TGSI_TEXTURE_COUNT 9
-
-struct tgsi_declaration_resource {
- unsigned Texture:5; /* TGSI_TEXTURE_ */
- unsigned Padding:24;
-};
-
#define TGSI_IMM_FLOAT32 0
#define TGSI_IMM_UINT32 1
#define TGSI_IMM_INT32 2
@@ -367,12 +349,15 @@ struct tgsi_instruction
unsigned NumSrcRegs : 4; /* UINT */
unsigned Predicate : 1; /* BOOL */
unsigned Label : 1;
- unsigned Padding : 2;
+ unsigned Texture : 1;
+ unsigned Padding : 1;
};
/*
* If tgsi_instruction::Label is TRUE, tgsi_instruction_label follows.
*
+ * If tgsi_instruction::Texture is TRUE, tgsi_instruction_texture follows.
+ *
* Then, tgsi_instruction::NumDstRegs of tgsi_dst_register follow.
*
* Then, tgsi_instruction::NumSrcRegs of tgsi_src_register follow.
@@ -392,6 +377,23 @@ struct tgsi_instruction_label
unsigned Padding : 8;
};
+#define TGSI_TEXTURE_UNKNOWN 0
+#define TGSI_TEXTURE_1D 1
+#define TGSI_TEXTURE_2D 2
+#define TGSI_TEXTURE_3D 3
+#define TGSI_TEXTURE_CUBE 4
+#define TGSI_TEXTURE_RECT 5
+#define TGSI_TEXTURE_SHADOW1D 6
+#define TGSI_TEXTURE_SHADOW2D 7
+#define TGSI_TEXTURE_SHADOWRECT 8
+#define TGSI_TEXTURE_COUNT 9
+
+struct tgsi_instruction_texture
+{
+ unsigned Texture : 8; /* TGSI_TEXTURE_ */
+ unsigned Padding : 24;
+};
+
/*
* For SM3, the following constraint applies.
* - Swizzle is either set to identity or replicate.
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index a8cfefe051..60e96b98de 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -61,7 +61,6 @@ extern "C" {
#define PIPE_MAX_CONSTANT 32
#define PIPE_MAX_SAMPLERS 16
#define PIPE_MAX_VERTEX_SAMPLERS 16
-#define PIPE_MAX_SHADER_RESOURCES 16
#define PIPE_MAX_SHADER_INPUTS 16
#define PIPE_MAX_SHADER_OUTPUTS 16
#define PIPE_MAX_TEXTURE_LEVELS 16