summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2010-01-09 21:09:51 +0100
committerMichal Krol <michal@vmware.com>2010-01-09 21:09:51 +0100
commit50d0620db207d7650ccee0ba87e4d8f909aa30c5 (patch)
treefa6ad1c538aae4fa087cc6a00a13b4e83b85d40f
parentdddd5a36aced7c300bac64336a0a88e7bad62c18 (diff)
gallium: Replace texture target with resource operand in TGSI texture opcodes.
Instead of specifying a texture target for texture instructions: TEX OUT[0], IN[0], SAMP[0], 2D one declares a resource register and then uses it to access textures: DCL RES[0], 2D ... TEX OUT[0], RES[0], IN[0], SAMP[0] The resource index (not sampler index) is used to select a texture to be accessed. Texture target is taken from resource's declaration. This change allows us to separate samplers from textures, something that is needed by OpenCL. Fixed most of the tree, didn't compile-test gallium drivers. The 965 driver hasn't been touched at all -- will need help fixing that one.
-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, 628 insertions, 584 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index 4585dcdb48..77cf2c709a 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -122,8 +122,10 @@ 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 pstipple */
+ 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 */
int maxInput, maxGeneric; /**< max input index found */
int colorTemp, texTemp; /**< temp registers */
boolean firstInstruction;
@@ -139,33 +141,38 @@ 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;
- 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++) {
+ 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++) {
aactx->samplersUsed |= 1 << i;
}
- }
- else if (decl->Declaration.File == TGSI_FILE_INPUT) {
+ break;
+ case TGSI_FILE_RESOURCE:
+ for (i = decl->Range.First; i <= decl->Range.Last; i++) {
+ aactx->resourcesUsed |= 1 << i;
+ }
+ break;
+ case 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;
}
- }
- else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
- uint i;
- for (i = decl->Range.First;
- i <= decl->Range.Last; i++) {
+ break;
+ case TGSI_FILE_TEMPORARY:
+ for (i = decl->Range.First; i <= decl->Range.Last; i++) {
aactx->tempsUsed |= (1 << i);
}
+ break;
}
ctx->emit_declaration(ctx, decl);
@@ -209,6 +216,11 @@ 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) {
@@ -243,6 +255,15 @@ 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;
@@ -269,13 +290,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 = 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;
+ 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;
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 0cc2b71864..869dc943fd 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -116,6 +116,8 @@ 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;
@@ -131,25 +133,29 @@ 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;
- if (decl->Declaration.File == TGSI_FILE_SAMPLER) {
- uint i;
- for (i = decl->Range.First;
- i <= decl->Range.Last; i++) {
+ switch (decl->Declaration.File) {
+ case TGSI_FILE_SAMPLER:
+ for (i = decl->Range.First; i <= decl->Range.Last; i++) {
pctx->samplersUsed |= 1 << i;
}
- }
- else if (decl->Declaration.File == TGSI_FILE_INPUT) {
+ break;
+ case TGSI_FILE_RESOURCE:
+ for (i = decl->Range.First; i <= decl->Range.Last; i++) {
+ pctx->resourcesUsed |= 1 << i;
+ }
+ break;
+ case 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;
- }
- else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
- uint i;
- for (i = decl->Range.First;
- i <= decl->Range.Last; i++) {
+ break;
+ case TGSI_FILE_TEMPORARY:
+ for (i = decl->Range.First; i <= decl->Range.Last; i++) {
pctx->tempsUsed |= (1 << i);
}
+ break;
}
ctx->emit_declaration(ctx, decl);
@@ -204,6 +210,11 @@ 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
@@ -241,6 +252,15 @@ 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;
@@ -296,13 +316,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 = 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;
+ 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;
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 de9cbc8630..426f708c3d 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.c
@@ -106,6 +106,7 @@ tgsi_default_declaration( void )
declaration.Semantic = 0;
declaration.Centroid = 0;
declaration.Invariant = 0;
+ declaration.Resource = 0;
declaration.Padding = 0;
return declaration;
@@ -133,6 +134,7 @@ tgsi_build_declaration(
declaration.Semantic = semantic;
declaration.Centroid = centroid;
declaration.Invariant = invariant;
+ declaration.Resource = file == TGSI_FILE_RESOURCE;
header_bodysize_grow( header );
@@ -159,6 +161,7 @@ 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;
}
@@ -214,6 +217,20 @@ 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;
}
@@ -282,6 +299,32 @@ 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
*/
@@ -406,7 +449,6 @@ tgsi_default_instruction( void )
instruction.NumDstRegs = 1;
instruction.NumSrcRegs = 1;
instruction.Label = 0;
- instruction.Texture = 0;
instruction.Padding = 0;
return instruction;
@@ -460,7 +502,6 @@ 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();
}
@@ -533,23 +574,6 @@ 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;
@@ -755,35 +779,6 @@ 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 9de2757fe4..1532e81d32 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_build.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_build.h
@@ -99,6 +99,14 @@ 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
*/
@@ -203,16 +211,6 @@ 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 e2e5394f86..69ab1b4401 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -102,7 +102,8 @@ static const char *file_names[TGSI_FILE_COUNT] =
"IMM",
"LOOP",
"PRED",
- "SV"
+ "SV",
+ "RES"
};
static const char *interpolate_names[] =
@@ -319,6 +320,11 @@ 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)
{
@@ -537,11 +543,6 @@ 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 47fd1dd590..1b3f4852f7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump_c.c
@@ -278,10 +278,6 @@ 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 );
@@ -299,18 +295,6 @@ 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 2bcb33392a..c3d79c9136 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -52,8 +52,6 @@
*/
#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"
@@ -1541,14 +1539,15 @@ exec_tex(struct tgsi_exec_machine *mach,
const struct tgsi_full_instruction *inst,
uint modifier)
{
- const uint unit = inst->Src[1].Register.Index;
+ const uint image_unit = inst->Src[0].Register.Index;
+ const uint sampler_unit = inst->Src[2].Register.Index;
union tgsi_exec_channel r[4];
const union tgsi_exec_channel *lod = &ZeroVec;
enum tgsi_sampler_control control;
- uint chan_index;
+ uint chan;
if (modifier != TEX_MODIFIER_NONE) {
- FETCH(&r[3], 0, CHAN_W);
+ fetch_source(mach, &r[3], &inst->Src[1], CHAN_W, TGSI_EXEC_DATA_FLOAT);
if (modifier != TEX_MODIFIER_PROJECTED) {
lod = &r[3];
}
@@ -1560,16 +1559,16 @@ exec_tex(struct tgsi_exec_machine *mach,
control = tgsi_sampler_lod_bias;
}
- switch (inst->Texture.Texture) {
+ switch (mach->Resources[image_unit].Texture) {
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_SHADOW1D:
- FETCH(&r[0], 0, CHAN_X);
+ fetch_source(mach, &r[0], &inst->Src[1], CHAN_X, TGSI_EXEC_DATA_FLOAT);
if (modifier == TEX_MODIFIER_PROJECTED) {
micro_div(&r[0], &r[0], &r[3]);
}
- fetch_texel(mach->Samplers[unit],
+ fetch_texel(mach->Samplers[sampler_unit],
&r[0], &ZeroVec, &ZeroVec, lod, /* S, T, P, LOD */
control,
&r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
@@ -1579,9 +1578,9 @@ exec_tex(struct tgsi_exec_machine *mach,
case TGSI_TEXTURE_RECT:
case TGSI_TEXTURE_SHADOW2D:
case TGSI_TEXTURE_SHADOWRECT:
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
+ 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);
if (modifier == TEX_MODIFIER_PROJECTED) {
micro_div(&r[0], &r[0], &r[3]);
@@ -1589,7 +1588,7 @@ exec_tex(struct tgsi_exec_machine *mach,
micro_div(&r[2], &r[2], &r[3]);
}
- fetch_texel(mach->Samplers[unit],
+ fetch_texel(mach->Samplers[sampler_unit],
&r[0], &r[1], &r[2], lod, /* S, T, P, LOD */
control,
&r[0], &r[1], &r[2], &r[3]); /* outputs */
@@ -1597,9 +1596,9 @@ exec_tex(struct tgsi_exec_machine *mach,
case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_CUBE:
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
+ 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);
if (modifier == TEX_MODIFIER_PROJECTED) {
micro_div(&r[0], &r[0], &r[3]);
@@ -1607,7 +1606,7 @@ exec_tex(struct tgsi_exec_machine *mach,
micro_div(&r[2], &r[2], &r[3]);
}
- fetch_texel(mach->Samplers[unit],
+ fetch_texel(mach->Samplers[sampler_unit],
&r[0], &r[1], &r[2], lod,
control,
&r[0], &r[1], &r[2], &r[3]);
@@ -1617,8 +1616,10 @@ exec_tex(struct tgsi_exec_machine *mach,
assert(0);
}
- FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
- STORE(&r[chan_index], 0, chan_index);
+ 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);
+ }
}
}
@@ -1626,21 +1627,21 @@ static void
exec_txd(struct tgsi_exec_machine *mach,
const struct tgsi_full_instruction *inst)
{
- const uint unit = inst->Src[3].Register.Index;
+ const uint image_unit = inst->Src[0].Register.Index;
+ const uint sampler_unit = inst->Src[2].Register.Index;
union tgsi_exec_channel r[4];
- uint chan_index;
+ uint chan;
/*
* XXX: This is fake TXD -- the derivatives are not taken into account, yet.
*/
- switch (inst->Texture.Texture) {
+ switch (mach->Resources[image_unit].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);
-
- fetch_texel(mach->Samplers[unit],
+ fetch_texel(mach->Samplers[sampler_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 */
@@ -1650,12 +1651,11 @@ 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(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
-
- fetch_texel(mach->Samplers[unit],
+ fetch_texel(mach->Samplers[sampler_unit],
&r[0], &r[1], &r[2], &ZeroVec, /* inputs */
tgsi_sampler_lod_bias,
&r[0], &r[1], &r[2], &r[3]); /* outputs */
@@ -1663,12 +1663,11 @@ 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(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
-
- fetch_texel(mach->Samplers[unit],
+ fetch_texel(mach->Samplers[sampler_unit],
&r[0], &r[1], &r[2], &ZeroVec,
tgsi_sampler_lod_bias,
&r[0], &r[1], &r[2], &r[3]);
@@ -1678,8 +1677,10 @@ exec_txd(struct tgsi_exec_machine *mach,
assert(0);
}
- FOR_EACH_ENABLED_CHANNEL(*inst, chan_index) {
- STORE(&r[chan_index], 0, chan_index);
+ 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);
+ }
}
}
@@ -1755,6 +1756,11 @@ 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) {
@@ -2840,38 +2846,43 @@ exec_instruction(
case TGSI_OPCODE_TEX:
/* simple texture lookup */
- /* src[0] = texcoord */
- /* src[1] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord */
+ /* src[2] = sampler */
exec_tex(mach, inst, TEX_MODIFIER_NONE);
break;
case TGSI_OPCODE_TXB:
/* Texture lookup with lod bias */
- /* src[0] = texcoord (src[0].w = LOD bias) */
- /* src[1] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord (src[1].w = LOD bias) */
+ /* src[2] = sampler */
exec_tex(mach, inst, TEX_MODIFIER_LOD_BIAS);
break;
case TGSI_OPCODE_TXD:
/* Texture lookup with explict partial derivatives */
- /* src[0] = texcoord */
- /* src[1] = d[strq]/dx */
- /* src[2] = d[strq]/dy */
- /* src[3] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord */
+ /* src[2] = sampler */
+ /* src[3] = d[strq]/dx */
+ /* src[4] = d[strq]/dy */
exec_txd(mach, inst);
break;
case TGSI_OPCODE_TXL:
/* Texture lookup with explit LOD */
- /* src[0] = texcoord (src[0].w = LOD) */
- /* src[1] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord (src[1].w = LOD) */
+ /* src[2] = sampler */
exec_tex(mach, inst, TEX_MODIFIER_EXPLICIT_LOD);
break;
case TGSI_OPCODE_TXP:
/* Texture lookup with projection */
- /* src[0] = texcoord (src[0].w = projection) */
- /* src[1] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord (src[0].w = projection) */
+ /* src[2] = sampler */
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 59e3b445cc..61189fe5cb 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -31,6 +31,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
+#include "pipe/p_shader_tokens.h"
#if defined __cplusplus
extern "C" {
@@ -329,6 +330,8 @@ 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 de0e09cdba..46d1809dcb 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_info.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_info.c
@@ -2,6 +2,7 @@
*
* 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
@@ -83,9 +84,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, 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, 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, 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 },
@@ -99,11 +100,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, 2, 1, 0, 0, 0, "TXB", TGSI_OPCODE_TXB },
+ { 1, 3, 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, 2, 1, 0, 0, 0, "TXL", TGSI_OPCODE_TXL },
+ { 1, 3, 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 e4af15c156..c8f7a3a77b 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_opcode_tmp.h
@@ -2,6 +2,7 @@
*
* 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
@@ -24,13 +25,6 @@
* 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)
@@ -88,9 +82,9 @@ OP11(SIN)
OP12(SLE)
OP12(SNE)
OP12(STR)
-OP12_TEX(TEX)
-OP14_TEX(TXD)
-OP12_TEX(TXP)
+OP13(TEX)
+OP15(TXD)
+OP13(TXP)
OP11(UP2H)
OP11(UP2US)
OP11(UP4B)
@@ -104,11 +98,11 @@ OP00(RET)
OP11(SSG)
OP13(CMP)
OP11(SCS)
-OP12_TEX(TXB)
+OP13(TXB)
OP11(NRM)
OP12(DIV)
OP12(DP2)
-OP12_TEX(TXL)
+OP13(TXL)
OP00(BRK)
OP01_LBL(IF)
OP11(BGNFOR)
@@ -129,8 +123,8 @@ OP12(OR)
OP12(MOD)
OP12(XOR)
OP13(SAD)
-OP12_TEX(TXF)
-OP12_TEX(TXQ)
+OP12(TXF)
+OP13(TXQ)
OP00(CONT)
OP00(EMIT)
OP00(ENDPRIM)
@@ -175,14 +169,7 @@ OP12(USNE)
#undef OP11
#undef OP12
#undef OP13
-
-#ifdef OP14
-#undef OP14
-#endif
+#undef OP15
#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 8c7062d850..e46df70068 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.c
@@ -113,6 +113,10 @@ tgsi_parse_token(
next_token( ctx, &decl->Semantic );
}
+ if (decl->Declaration.Resource) {
+ next_token(ctx, &decl->Resource);
+ }
+
break;
}
@@ -167,10 +171,6 @@ 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 439a57269b..7ab2d01882 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_parse.h
@@ -1,6 +1,7 @@
/**************************************************************************
*
* 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
@@ -59,6 +60,7 @@ 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
@@ -74,14 +76,13 @@ struct tgsi_full_property
};
#define TGSI_FULL_MAX_DST_REGISTERS 2
-#define TGSI_FULL_MAX_SRC_REGISTERS 4 /* TXD has 4 */
+#define TGSI_FULL_MAX_SRC_REGISTERS 5 /* TXD has 5 */
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 2e13a7aaf9..853d277116 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c
@@ -55,6 +55,11 @@
#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++)
@@ -1457,18 +1462,19 @@ fetch_texel( struct tgsi_sampler **sampler,
*/
static void
-emit_tex( struct x86_function *func,
- const struct tgsi_full_instruction *inst,
- boolean lodbias,
- boolean projected)
-{
- const uint unit = inst->Src[1].Register.Index;
+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;
struct x86_reg args[2];
unsigned count;
unsigned i;
- assert(inst->Instruction.Texture);
- switch (inst->Texture.Texture) {
+ switch (info->resources[image_unit].Texture) {
case TGSI_TEXTURE_1D:
count = 1;
break;
@@ -1489,7 +1495,7 @@ emit_tex( struct x86_function *func,
}
if (lodbias) {
- FETCH( func, *inst, 3, 0, 3 );
+ FETCH( func, *inst, 3, 1, 3 );
}
else {
emit_tempf(
@@ -1509,13 +1515,13 @@ emit_tex( struct x86_function *func,
if (projected) {
- FETCH( func, *inst, 3, 0, 3 );
+ FETCH( func, *inst, 3, 1, 3 );
emit_rcp( func, 3, 3 );
}
for (i = 0; i < count; i++) {
- FETCH( func, *inst, i, 0, i );
+ FETCH( func, *inst, i, 1, i );
if (projected) {
sse_mulps(
@@ -1533,7 +1539,7 @@ emit_tex( struct x86_function *func,
}
args[0] = get_temp( TEMP_R0, 0 );
- args[1] = get_sampler_ptr( unit );
+ args[1] = get_sampler_ptr( sampler_unit );
emit_func_call( func,
@@ -1739,9 +1745,9 @@ indirect_temp_reference(const struct tgsi_full_instruction *inst)
static int
-emit_instruction(
- struct x86_function *func,
- struct tgsi_full_instruction *inst )
+emit_instruction(struct tgsi_sse_info *info,
+ struct x86_function *func,
+ struct tgsi_full_instruction *inst)
{
unsigned chan_index;
@@ -2303,7 +2309,7 @@ emit_instruction(
break;
case TGSI_OPCODE_TEX:
- emit_tex( func, inst, FALSE, FALSE );
+ emit_tex(info, func, inst, FALSE, FALSE);
break;
case TGSI_OPCODE_TXD:
@@ -2400,7 +2406,7 @@ emit_instruction(
break;
case TGSI_OPCODE_TXB:
- emit_tex( func, inst, TRUE, FALSE );
+ emit_tex(info, func, inst, TRUE, FALSE);
break;
case TGSI_OPCODE_NRM:
@@ -2512,7 +2518,7 @@ emit_instruction(
break;
case TGSI_OPCODE_TXP:
- emit_tex( func, inst, FALSE, TRUE );
+ emit_tex(info, func, inst, FALSE, TRUE);
break;
case TGSI_OPCODE_BRK:
@@ -2632,10 +2638,15 @@ emit_instruction(
}
static void
-emit_declaration(
- struct x86_function *func,
- struct tgsi_full_declaration *decl )
+emit_declaration(struct tgsi_sse_info *info,
+ 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;
@@ -2839,6 +2850,7 @@ tgsi_emit_sse2(
boolean do_swizzles )
{
struct tgsi_parse_context parse;
+ struct tgsi_sse_info info;
unsigned ok = 1;
uint num_immediates = 0;
@@ -2891,6 +2903,7 @@ 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 );
@@ -2898,16 +2911,16 @@ tgsi_emit_sse2(
switch( parse.FullToken.Token.Type ) {
case TGSI_TOKEN_TYPE_DECLARATION:
if (parse.FullHeader.Processor.Processor == TGSI_PROCESSOR_FRAGMENT) {
- emit_declaration(
- func,
- &parse.FullToken.FullDeclaration );
+ emit_declaration(&info,
+ func,
+ &parse.FullToken.FullDeclaration);
}
break;
case TGSI_TOKEN_TYPE_INSTRUCTION:
- ok = emit_instruction(
- func,
- &parse.FullToken.FullInstruction );
+ ok = emit_instruction(&info,
+ 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 9fcffeda36..86cab4218a 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_text.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_text.c
@@ -280,7 +280,8 @@ static const char *file_names[TGSI_FILE_COUNT] =
"IMM",
"LOOP",
"PRED",
- "SV"
+ "SV",
+ "RES"
};
static boolean
@@ -826,7 +827,7 @@ parse_instruction(
else if (str_match_no_case( &cur, "_SAT" ))
saturate = TGSI_SAT_ZERO_ONE;
- if (info->num_dst + info->num_src + info->is_tex == 0) {
+ if (info->num_dst + info->num_src == 0) {
if (!is_digit_alpha_underscore( cur )) {
ctx->cur = cur;
break;
@@ -854,7 +855,7 @@ parse_instruction(
/* Parse instruction operands.
*/
- for (i = 0; i < info->num_dst + info->num_src + info->is_tex; i++) {
+ for (i = 0; i < info->num_dst + info->num_src; i++) {
if (i > 0) {
eat_opt_white( &ctx->cur );
if (*ctx->cur != ',') {
@@ -868,28 +869,10 @@ parse_instruction(
if (i < info->num_dst) {
if (!parse_dst_operand( ctx, &inst.Dst[i] ))
return FALSE;
- }
- else if (i < info->num_dst + info->num_src) {
+ } else {
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) {
@@ -978,40 +961,61 @@ static boolean parse_declaration( struct translate_ctx *ctx )
cur++;
eat_opt_white( &cur );
- 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 (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;
}
- eat_opt_white( &cur2 );
- if (*cur2 != ']') {
- report_error( ctx, "Expected `]'" );
- 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;
}
- cur2++;
- decl.Semantic.Index = index;
+ decl.Declaration.Semantic = 1;
+ decl.Semantic.Name = i;
- cur = cur2;
+ ctx->cur = cur;
+ break;
}
-
- 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 e64e2b731d..ac2455a201 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2009 VMware, Inc.
+ * Copyright 2009-2010 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,6 +114,12 @@ 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;
@@ -490,6 +496,33 @@ 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,
@@ -678,6 +711,7 @@ 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);
@@ -805,23 +839,6 @@ 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 )
{
@@ -878,55 +895,6 @@ 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,
@@ -1009,6 +977,29 @@ 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 )
@@ -1073,6 +1064,12 @@ 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 6f11273320..d49dc21e8c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2009 VMware, Inc.
+ * Copyright 2009-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -186,6 +186,11 @@ 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,
@@ -353,16 +358,6 @@ 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,
@@ -397,11 +392,6 @@ 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 );
@@ -564,33 +554,6 @@ 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, \
@@ -617,35 +580,34 @@ static INLINE void ureg_##op( struct ureg_program *ureg, \
ureg_fixup_insn_size( ureg, insn ); \
}
-#define OP14_TEX( op ) \
+#define OP15( 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 src3, \
+ struct ureg_src src4 ) \
{ \
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, \
- 4); \
- ureg_emit_texture( ureg, insn.extended_token, target ); \
+ 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; \
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_fixup_insn_size( ureg, insn.insn_token ); \
+ ureg_emit_src( ureg, src4 ); \
+ ureg_fixup_insn_size( ureg, insn ); \
}
diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c
index b751e29ab6..ae890c2551 100644
--- a/src/gallium/auxiliary/util/u_simple_shaders.c
+++ b/src/gallium/auxiliary/util/u_simple_shaders.c
@@ -94,6 +94,7 @@ 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;
@@ -103,6 +104,8 @@ 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 );
@@ -119,7 +122,7 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
ureg_TEX( ureg,
ureg_writemask(out, writemask),
- tex_target, tex, sampler );
+ resource, tex, sampler );
ureg_END( ureg );
return ureg_create_shader_and_destroy( ureg, pipe );
@@ -150,6 +153,7 @@ 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;
@@ -160,6 +164,8 @@ 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 );
@@ -178,7 +184,7 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
ureg_TEX( ureg,
ureg_writemask(depth, TGSI_WRITEMASK_Z),
- tex_target, tex, sampler );
+ resource, 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 fc2a1c59a6..2f594c48dd 100644
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ b/src/gallium/auxiliary/vl/vl_compositor.c
@@ -199,8 +199,12 @@ 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);
- /* 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);
+ /* 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);
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 caf581aca6..9e72c5f32e 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
@@ -215,24 +215,30 @@ 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);
}
/*
- * tex2d t1, i0, s0 ; Read texel from luma texture
+ * tex t1, r0, i0, s0 ; Read texel from luma texture
* mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
+ * tex t1, r1, i1, s1 ; Read texel from chroma Cb texture
* mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
+ * tex t1, r2, 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_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
+ inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_RESOURCE, i, 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);
@@ -392,25 +398,32 @@ 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);
}
/*
- * tex2d t1, i0, s0 ; Read texel from luma texture
+ * tex t1, r0, i0, s0 ; Read texel from luma texture
* mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
+ * tex t1, r1, i1, s1 ; Read texel from chroma Cb texture
* mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
+ * tex t1, r2, 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_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
+ inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_RESOURCE, i, 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);
@@ -425,8 +438,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);
- /* 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);
+ /* 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);
ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
/* add o0, t0, t1 ; Add ref and differential to form final output */
@@ -598,26 +611,34 @@ 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);
}
/*
- * tex2d t1, i0, s0 ; Read texel from luma texture
+ * tex t1, r0, i0, s0 ; Read texel from luma texture
* mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
+ * tex t1, r1, i1, s1 ; Read texel from chroma Cb texture
* mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
+ * tex t1, r2, 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_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
+ inst = vl_inst4(TGSI_OPCODE_TEX, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_RESOURCE, i, 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);
@@ -633,11 +654,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);
/*
- * tex2d t1, i3, s3 ; Read texel from first ref macroblock
- * tex2d t2, i4, s4 ; Read texel from second ref macroblock
+ * tex t1, r3, i3, s3 ; Read texel from first ref macroblock
+ * tex t2, r4, i4, s4 ; Read texel from second ref macroblock
*/
for (i = 0; i < 2; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, i + 1, TGSI_FILE_INPUT, i + 3, TGSI_FILE_SAMPLER, i + 3);
+ 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);
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 d011ef97bd..30cd823383 100644
--- a/src/gallium/auxiliary/vl/vl_shader_build.c
+++ b/src/gallium/auxiliary/vl/vl_shader_build.c
@@ -125,6 +125,19 @@ 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,
@@ -173,34 +186,6 @@ 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 5da71f8e13..c3fb7c6110 100644
--- a/src/gallium/auxiliary/vl/vl_shader_build.h
+++ b/src/gallium/auxiliary/vl/vl_shader_build.h
@@ -43,6 +43,7 @@ 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,
@@ -61,16 +62,6 @@ 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 1d8a11a4ac..c7f9818a51 100644
--- a/src/gallium/drivers/cell/ppu/cell_gen_fp.c
+++ b/src/gallium/drivers/cell/ppu/cell_gen_fp.c
@@ -71,6 +71,7 @@ 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 */
@@ -1351,13 +1352,15 @@ emit_function_call(struct codegen *gen,
static boolean
emit_TEX(struct codegen *gen, const struct tgsi_full_instruction *inst)
{
- const uint target = inst->Texture.Texture;
- const uint unit = inst->Src[1].Register.Index;
+ const uint image_unit = inst->Src[0].Register.Index;
+ const uint sampler_unit = inst->Src[2].Register.Index;
uint addr;
int ch;
int coord_regs[4], d_regs[4];
- switch (target) {
+ assert(inst->Src[0].Register.File == TGSI_FILE_RESOURCE);
+
+ switch (gen->resources[image_unit].Texture) {
case TGSI_TEXTURE_1D:
case TGSI_TEXTURE_2D:
addr = lookup_function(gen->cell, "spu_tex_2d");
@@ -1373,13 +1376,13 @@ emit_TEX(struct codegen *gen, const struct tgsi_full_instruction *inst)
return FALSE;
}
- assert(inst->Src[1].Register.File == TGSI_FILE_SAMPLER);
+ assert(inst->Src[2].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[0]);
+ coord_regs[ch] = get_src_reg(gen, ch, &inst->Src[1]);
d_regs[ch] = get_dst_reg(gen, ch, &inst->Dst[0]);
}
@@ -1932,6 +1935,9 @@ 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 d86d8e09a5..e4724aa506 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.c
+++ b/src/gallium/drivers/cell/spu/spu_exec.c
@@ -677,31 +677,32 @@ exec_tex(struct spu_exec_machine *mach,
const struct tgsi_full_instruction *inst,
boolean biasLod, boolean projected)
{
- const uint unit = inst->Src[1].Register.Index;
+ const uint image_unit = inst->Src[0].Register.Index;
+ const uint sampler_unit = inst->Src[2].Register.Index;
union spu_exec_channel r[8];
uint chan_index;
float lodBias;
/* printf("Sampler %u unit %u\n", sampler, unit); */
- switch (inst->InstructionExtTexture.Texture) {
+ switch (mach->Resources[image_unit].Texture) {
case TGSI_TEXTURE_1D:
- FETCH(&r[0], 0, CHAN_X);
+ FETCH(&r[0], 1, CHAN_X);
if (projected) {
- FETCH(&r[1], 0, CHAN_W);
+ FETCH(&r[1], 1, CHAN_W);
r[0].q = micro_div(r[0].q, r[1].q);
}
if (biasLod) {
- FETCH(&r[1], 0, CHAN_W);
+ FETCH(&r[1], 1, CHAN_W);
lodBias = r[2].f[0];
}
else
lodBias = 0.0;
- fetch_texel(&mach->Samplers[unit],
+ fetch_texel(&mach->Samplers[sampler_unit],
&r[0], NULL, NULL, lodBias, /* S, T, P, BIAS */
&r[0], &r[1], &r[2], &r[3]); /* R, G, B, A */
break;
@@ -709,9 +710,9 @@ exec_tex(struct spu_exec_machine *mach,
case TGSI_TEXTURE_2D:
case TGSI_TEXTURE_RECT:
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
+ FETCH(&r[0], 1, CHAN_X);
+ FETCH(&r[1], 1, CHAN_Y);
+ FETCH(&r[2], 1, CHAN_Z);
if (projected) {
FETCH(&r[3], 0, CHAN_W);
@@ -721,13 +722,13 @@ exec_tex(struct spu_exec_machine *mach,
}
if (biasLod) {
- FETCH(&r[3], 0, CHAN_W);
+ FETCH(&r[3], 1, CHAN_W);
lodBias = r[3].f[0];
}
else
lodBias = 0.0;
- fetch_texel(&mach->Samplers[unit],
+ fetch_texel(&mach->Samplers[sampler_unit],
&r[0], &r[1], &r[2], lodBias, /* inputs */
&r[0], &r[1], &r[2], &r[3]); /* outputs */
break;
@@ -735,9 +736,9 @@ exec_tex(struct spu_exec_machine *mach,
case TGSI_TEXTURE_3D:
case TGSI_TEXTURE_CUBE:
- FETCH(&r[0], 0, CHAN_X);
- FETCH(&r[1], 0, CHAN_Y);
- FETCH(&r[2], 0, CHAN_Z);
+ FETCH(&r[0], 1, CHAN_X);
+ FETCH(&r[1], 1, CHAN_Y);
+ FETCH(&r[2], 1, CHAN_Z);
if (projected) {
FETCH(&r[3], 0, CHAN_W);
@@ -747,13 +748,13 @@ exec_tex(struct spu_exec_machine *mach,
}
if (biasLod) {
- FETCH(&r[3], 0, CHAN_W);
+ FETCH(&r[3], 1, CHAN_W);
lodBias = r[3].f[0];
}
else
lodBias = 0.0;
- fetch_texel(&mach->Samplers[unit],
+ fetch_texel(&mach->Samplers[sampler_unit],
&r[0], &r[1], &r[2], lodBias,
&r[0], &r[1], &r[2], &r[3]);
break;
@@ -828,6 +829,11 @@ 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;
@@ -1397,38 +1403,43 @@ exec_instruction(
case TGSI_OPCODE_TEX:
/* simple texture lookup */
- /* src[0] = texcoord */
- /* src[1] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord */
+ /* src[2] = sampler */
exec_tex(mach, inst, FALSE, FALSE);
break;
case TGSI_OPCODE_TXB:
/* Texture lookup with lod bias */
- /* src[0] = texcoord (src[0].w = load bias) */
- /* src[1] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord (src[1].w = LOD bias) */
+ /* src[2] = sampler */
exec_tex(mach, inst, TRUE, FALSE);
break;
case TGSI_OPCODE_TXD:
/* Texture lookup with explict partial derivatives */
- /* src[0] = texcoord */
- /* src[1] = d[strq]/dx */
- /* src[2] = d[strq]/dy */
- /* src[3] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord */
+ /* src[2] = sampler */
+ /* src[3] = d[strq]/dx */
+ /* src[4] = d[strq]/dy */
ASSERT (0);
break;
case TGSI_OPCODE_TXL:
/* Texture lookup with explit LOD */
- /* src[0] = texcoord (src[0].w = load bias) */
- /* src[1] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord (src[1].w = LOD) */
+ /* src[2] = sampler */
exec_tex(mach, inst, TRUE, FALSE);
break;
case TGSI_OPCODE_TXP:
/* Texture lookup with projection */
- /* src[0] = texcoord (src[0].w = projection) */
- /* src[1] = sampler unit */
+ /* src[0] = resource */
+ /* src[1] = texcoord (src[0].w = projection) */
+ /* src[2] = sampler */
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 8605679940..ae978880be 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.h
+++ b/src/gallium/drivers/cell/spu/spu_exec.h
@@ -152,6 +152,8 @@ 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 2f0f99d046..46331e2222 100644
--- a/src/gallium/drivers/i915/i915_fpc.h
+++ b/src/gallium/drivers/i915/i915_fpc.h
@@ -57,6 +57,8 @@ 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 25c53210be..82100d40ee 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 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]);
+ 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]);
i915_emit_texld( p,
get_result_vector( p, &inst->Dst[0] ),
@@ -946,6 +946,8 @@ 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 fb1eda4423..998b0c93a8 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c
@@ -95,6 +95,8 @@ 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];
@@ -319,14 +321,15 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
boolean projected,
LLVMValueRef *texel)
{
- const uint unit = inst->Src[1].Register.Index;
+ const uint image_unit = inst->Src[0].Register.Index;
+ const uint sampler_unit = inst->Src[2].Register.Index;
LLVMValueRef lodbias;
LLVMValueRef oow = NULL;
LLVMValueRef coords[3];
unsigned num_coords;
unsigned i;
- switch (inst->Texture.Texture) {
+ switch (bld->resources[image_unit].Texture) {
case TGSI_TEXTURE_1D:
num_coords = 1;
break;
@@ -347,17 +350,17 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
}
if(apply_lodbias)
- lodbias = emit_fetch( bld, inst, 0, 3 );
+ lodbias = emit_fetch( bld, inst, 1, 3 );
else
lodbias = bld->base.zero;
if (projected) {
- oow = emit_fetch( bld, inst, 0, 3 );
+ oow = emit_fetch( bld, inst, 1, 3 );
oow = lp_build_rcp(&bld->base, oow);
}
for (i = 0; i < num_coords; i++) {
- coords[i] = emit_fetch( bld, inst, 0, i );
+ coords[i] = emit_fetch( bld, inst, 1, i );
if (projected)
coords[i] = lp_build_mul(&bld->base, coords[i], oow);
}
@@ -368,7 +371,7 @@ emit_tex( struct lp_build_tgsi_soa_context *bld,
bld->sampler->emit_fetch_texel(bld->sampler,
bld->base.builder,
bld->base.type,
- unit, num_coords, coords, lodbias,
+ sampler_unit, num_coords, coords, lodbias,
texel);
}
@@ -1431,6 +1434,9 @@ 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 2d565cb631..84674a38d0 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_SAMPLER:
+ case TGSI_FILE_RESOURCE:
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[0], none, none);
+ tex(fpc, sat, TEX, unit, dst, mask, src[1], none, none);
break;
case TGSI_OPCODE_TXB:
- tex(fpc, sat, TXB, unit, dst, mask, src[0], none, none);
+ tex(fpc, sat, TXB, unit, dst, mask, src[1], none, none);
break;
case TGSI_OPCODE_TXP:
- tex(fpc, sat, TXP, unit, dst, mask, src[0], none, none);
+ tex(fpc, sat, TXP, unit, dst, mask, src[1], 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 1237066c39..7b3c71764a 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_SAMPLER:
+ case TGSI_FILE_RESOURCE:
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[0], none, none);
+ tex(fpc, sat, TEX, unit, dst, mask, src[1], none, none);
break;
case TGSI_OPCODE_TXB:
- tex(fpc, sat, TXB, unit, dst, mask, src[0], none, none);
+ tex(fpc, sat, TXB, unit, dst, mask, src[1], none, none);
break;
case TGSI_OPCODE_TXP:
- tex(fpc, sat, TXP, unit, dst, mask, src[0], none, none);
+ tex(fpc, sat, TXP, unit, dst, mask, src[1], 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 53f9f0adf3..b8a2707d0b 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -2009,17 +2009,12 @@ 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 (tex->Texture) {
+ switch (pc->resources[insn->Src[0].Register.Index].Texture) {
case TGSI_TEXTURE_1D:
mask &= 0x9;
break;
@@ -2307,7 +2302,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, unit;
+ unsigned mask, sat, image_unit, sampler_unit;
int i, c;
mask = inst->Dst[0].Register.WriteMask;
@@ -2331,8 +2326,10 @@ 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_SAMPLER)
- unit = fs->Register.Index;
+ 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;
for (c = 0; c < 4; c++)
if (src_mask & (1 << c))
@@ -2796,20 +2793,20 @@ nv50_program_tx_insn(struct nv50_pc *pc,
}
break;
case TGSI_OPCODE_TEX:
- emit_tex(pc, dst, mask, src[0], unit,
- inst->Texture.Texture, FALSE, 0);
+ emit_tex(pc, dst, mask, src[1], sampler_unit,
+ pc->resources[image_unit].Texture, FALSE, 0);
break;
case TGSI_OPCODE_TXB:
- emit_tex(pc, dst, mask, src[0], unit,
- inst->Texture.Texture, FALSE, -1);
+ emit_tex(pc, dst, mask, src[1], sampler_unit,
+ pc->resources[image_unit].Texture, FALSE, -1);
break;
case TGSI_OPCODE_TXL:
- emit_tex(pc, dst, mask, src[0], unit,
- inst->Texture.Texture, FALSE, 1);
+ emit_tex(pc, dst, mask, src[1], sampler_unit,
+ pc->resources[image_unit].Texture, FALSE, 1);
break;
case TGSI_OPCODE_TXP:
- emit_tex(pc, dst, mask, src[0], unit,
- inst->Texture.Texture, TRUE, 0);
+ emit_tex(pc, dst, mask, src[1], sampler_unit,
+ pc->resources[image_unit].Texture, TRUE, 0);
break;
case TGSI_OPCODE_TRUNC:
for (c = 0; c < 4; c++) {
@@ -3638,6 +3635,9 @@ 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 a792c2cf98..9b6c76e0a8 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.c
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.c
@@ -212,10 +212,12 @@ static void transform_srcreg(
dst->Negate = src->Register.Negate ? RC_MASK_XYZW : 0;
}
-static void transform_texture(struct rc_instruction * dst, struct tgsi_instruction_texture src,
+static void transform_texture(struct tgsi_to_rc * ttr,
+ struct rc_instruction * dst,
+ uint32_t imageUnit,
uint32_t *shadowSamplers)
{
- switch(src.Texture) {
+ switch(ttr->resources[imageUnit].Texture) {
case TGSI_TEXTURE_1D:
dst->U.I.TexSrcTarget = RC_TEXTURE_1D;
break;
@@ -265,16 +267,15 @@ 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_SAMPLER)
+ if (src->Src[i].Register.File == TGSI_FILE_RESOURCE) {
dst->U.I.TexSrcUnit = src->Src[i].Register.Index;
- else
+ /* Texturing. */
+ transform_texture(ttr, dst, src->Src[i].Register.Index,
+ &ttr->compiler->Program.ShadowSamplers);
+ } 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)
@@ -289,6 +290,13 @@ 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;
@@ -315,6 +323,7 @@ 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 93e90ec6d2..b58061709c 100644
--- a/src/gallium/drivers/r300/r300_tgsi_to_rc.h
+++ b/src/gallium/drivers/r300/r300_tgsi_to_rc.h
@@ -34,6 +34,8 @@ 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 dc5eb8fc60..6e4e0f91f9 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[src1.base.num].unnormalized) {
- struct src_register wh = get_tex_dimensions( emit, src1.base.num );
+ if (emit->key.fkey.tex[src2.base.num].unnormalized) {
+ struct src_register wh = get_tex_dimensions( emit, src2.base.num );
SVGA3dShaderDestToken tmp = get_temp( emit );
- /* MUL tmp, SRC0, WH */
+ /* MUL tmp, SRC1, WH */
if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ),
- tmp, src0, wh ))
+ tmp, src1, wh ))
return FALSE;
- src0 = src( tmp );
+ src1 = src( tmp );
}
- return submit_op2( emit, inst, dst, src0, src1 );
+ return submit_op2( emit, inst, dst, src1, src2 );
}
@@ -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, src0, src1, src2 );
+ return submit_op3( emit, inst, dst, src1, src2, src3 );
}
@@ -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[src1.base.num].compare_mode ==
+ boolean compare = (emit->key.fkey.tex[src2.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(src0, TGSI_SWIZZLE_W) ))
+ scalar(src1, TGSI_SWIZZLE_W) ))
return FALSE;
if (!submit_op2( emit, inst_token( SVGA3DOP_MUL ),
src0_zdivw,
- scalar(src0, TGSI_SWIZZLE_Z),
+ scalar(src1, 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 550e2abc32..85e5d00504 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 VMware, Inc.
+ * Copyright 2009-2010 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -76,6 +76,7 @@ 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 */
};
@@ -112,7 +113,8 @@ struct tgsi_declaration
unsigned Semantic : 1; /**< BOOL, any semantic info? */
unsigned Centroid : 1; /**< centroid sampling? */
unsigned Invariant : 1; /**< invariant optimization? */
- unsigned Padding : 5;
+ unsigned Resource:1; /**< BOOL, any resource info? */
+ unsigned Padding:4;
};
struct tgsi_declaration_range
@@ -140,6 +142,22 @@ 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
@@ -349,15 +367,12 @@ struct tgsi_instruction
unsigned NumSrcRegs : 4; /* UINT */
unsigned Predicate : 1; /* BOOL */
unsigned Label : 1;
- unsigned Texture : 1;
- unsigned Padding : 1;
+ unsigned Padding : 2;
};
/*
* 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.
@@ -377,23 +392,6 @@ 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 60e96b98de..a8cfefe051 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -61,6 +61,7 @@ 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