summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nv50/codegen
diff options
context:
space:
mode:
authorFrancisco Jerez <[email protected]>2012-05-01 02:38:51 +0200
committerFrancisco Jerez <[email protected]>2012-05-11 12:39:39 +0200
commita5f44cc8c2ce0916809ce5da5a2490ad000ef099 (patch)
tree33ffba4161f7f3201a505ab5a23d6f70ea6cfc7f /src/gallium/drivers/nv50/codegen
parentd9d82dcd006c124e6569789c90390c43c1360c06 (diff)
gallium/tgsi: Split sampler views from shader resources.
This commit splits the current concept of resource into "sampler views" and "shader resources": "Sampler views" are textures or buffers that are bound to a given shader stage and can be read from in conjunction with a sampler object. They are analogous to OpenGL texture objects or Direct3D SRVs. "Shader resources" are textures or buffers that can be read and written from a shader. There's no support for floating point coordinates, address wrap modes or filtering, and, unlike sampler views, shader resources are global for the whole graphics pipeline. They are analogous to OpenGL image objects (as in ARB_shader_image_load_store) or Direct3D UAVs. Most hardware is likely to implement shader resources and sampler views as separate objects, so, having the distinction at the API level simplifies things slightly for the driver. This patch introduces the SVIEW register file with a declaration token and syntax analogous to the already existing RES register file. After this change, the SAMPLE_* opcodes no longer accept a resource as input, but rather a SVIEW object. To preserve the functionality of reading from a sampler view with integer coordinates, the SAMPLE_I(_MS) opcodes are introduced which are similar to LOAD(_MS) but take a SVIEW register instead of a RES register as argument.
Diffstat (limited to 'src/gallium/drivers/nv50/codegen')
-rw-r--r--src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp
index 82e23602ca0..334c584373a 100644
--- a/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp
+++ b/src/gallium/drivers/nv50/codegen/nv50_ir_from_tgsi.cpp
@@ -548,7 +548,7 @@ static nv50_ir::operation translateOpcode(uint opcode)
NV50_IR_OPCODE_CASE(SAMPLE_D, TXD);
NV50_IR_OPCODE_CASE(SAMPLE_L, TXL);
NV50_IR_OPCODE_CASE(GATHER4, TXG);
- NV50_IR_OPCODE_CASE(RESINFO, TXQ);
+ NV50_IR_OPCODE_CASE(SVIEWINFO, TXQ);
NV50_IR_OPCODE_CASE(END, EXIT);
@@ -597,8 +597,8 @@ public:
int clipVertexOutput;
- uint8_t *resourceTargets; // TGSI_TEXTURE_*
- unsigned resourceCount;
+ uint8_t *samplerViewTargets; // TGSI_TEXTURE_*
+ unsigned samplerViewCount;
private:
int inferSysValDirection(unsigned sn) const;
@@ -617,7 +617,7 @@ Source::Source(struct nv50_ir_prog_info *prog) : info(prog)
if (prog->dbgFlags & NV50_IR_DEBUG_BASIC)
tgsi_dump(tokens, 0);
- resourceTargets = NULL;
+ samplerViewTargets = NULL;
mainTempsInLMem = FALSE;
}
@@ -632,8 +632,8 @@ Source::~Source()
if (info->immd.type)
FREE(info->immd.type);
- if (resourceTargets)
- delete[] resourceTargets;
+ if (samplerViewTargets)
+ delete[] samplerViewTargets;
}
bool Source::scanSource()
@@ -650,8 +650,8 @@ bool Source::scanSource()
clipVertexOutput = -1;
- resourceCount = scan.file_max[TGSI_FILE_RESOURCE] + 1;
- resourceTargets = new uint8_t[resourceCount];
+ samplerViewCount = scan.file_max[TGSI_FILE_SAMPLER_VIEW] + 1;
+ samplerViewTargets = new uint8_t[samplerViewCount];
info->immd.bufSize = 0;
tempArrayCount = 0;
@@ -874,9 +874,9 @@ bool Source::scanDeclaration(const struct tgsi_full_declaration *decl)
info->sv[i].input = inferSysValDirection(sn);
}
break;
- case TGSI_FILE_RESOURCE:
+ case TGSI_FILE_SAMPLER_VIEW:
for (i = first; i <= last; ++i)
- resourceTargets[i] = decl->Resource.Resource;
+ samplerViewTargets[i] = decl->SamplerView.Resource;
break;
case TGSI_FILE_IMMEDIATE_ARRAY:
{
@@ -1000,13 +1000,15 @@ bool Source::scanInstruction(const struct tgsi_full_instruction *inst)
nv50_ir::TexInstruction::Target
Instruction::getTexture(const tgsi::Source *code, int s) const
{
- if (insn->Instruction.Texture) {
- return translateTexture(insn->Texture.Texture);
- } else {
+ switch (getSrc(s).getFile()) {
+ case TGSI_FILE_SAMPLER_VIEW: {
// XXX: indirect access
unsigned int r = getSrc(s).getIndex(0);
- assert(r < code->resourceCount);
- return translateTexture(code->resourceTargets[r]);
+ assert(r < code->samplerViewCount);
+ return translateTexture(code->samplerViewTargets[r]);
+ }
+ default:
+ return translateTexture(insn->Texture.Texture);
}
}
@@ -2042,7 +2044,7 @@ Converter::handleInstruction(const struct tgsi_full_instruction *insn)
handleTXF(dst0, 1);
break;
case TGSI_OPCODE_TXQ:
- case TGSI_OPCODE_RESINFO:
+ case TGSI_OPCODE_SVIEWINFO:
handleTXQ(dst0, TXQ_DIMS);
break;
case TGSI_OPCODE_F2I: