summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600/r600_shader.c
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2011-09-05 03:32:12 +0200
committerMarek Olšák <[email protected]>2011-09-10 08:53:29 +0200
commit929ad43b11cfc24f3e27bc1da2523b7fc142917f (patch)
tree24c516bc03c645b73dc1c3ffa5793edd7a0e4ceb /src/gallium/drivers/r600/r600_shader.c
parent23b4ad46268e4b3eb8399cadc448d8747492bd41 (diff)
r600g: add support for shadow array samplers
I had to guess & verify how some of the SAMPLE instructions work.
Diffstat (limited to 'src/gallium/drivers/r600/r600_shader.c')
-rw-r--r--src/gallium/drivers/r600/r600_shader.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
index 9073cbfe30d..1723080c9eb 100644
--- a/src/gallium/drivers/r600/r600_shader.c
+++ b/src/gallium/drivers/r600/r600_shader.c
@@ -2177,7 +2177,10 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
}
opcode = ctx->inst_info->r600_opcode;
- if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D || inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D) {
+ if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D ||
+ inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D ||
+ inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY ||
+ inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D_ARRAY) {
switch (opcode) {
case SQ_TEX_INST_SAMPLE:
opcode = SQ_TEX_INST_SAMPLE_C;
@@ -2232,14 +2235,33 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
tex.offset_x = offset_x;
tex.offset_y = offset_y;
tex.offset_z = offset_z;
- if (inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY) {
- tex.coord_type_z = 0;
- tex.src_sel_z = tex.src_sel_y;
- } else if (inst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY)
- tex.coord_type_z = 0;
- if (inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D || inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D)
+ /* Put the depth for comparison in W.
+ * TGSI_TEXTURE_SHADOW2D_ARRAY already has the depth in W.
+ * Some instructions expect the depth in Z. */
+ if ((inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D ||
+ inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D ||
+ inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY) &&
+ opcode != SQ_TEX_INST_SAMPLE_C_L &&
+ opcode != SQ_TEX_INST_SAMPLE_C_LB) {
tex.src_sel_w = tex.src_sel_z;
+ }
+
+ if (inst->Texture.Texture == TGSI_TEXTURE_1D_ARRAY ||
+ inst->Texture.Texture == TGSI_TEXTURE_SHADOW1D_ARRAY) {
+ if (opcode == SQ_TEX_INST_SAMPLE_C_L ||
+ opcode == SQ_TEX_INST_SAMPLE_C_LB) {
+ /* the array index is read from Y */
+ tex.coord_type_y = 0;
+ } else {
+ /* the array index is read from Z */
+ tex.coord_type_z = 0;
+ tex.src_sel_z = tex.src_sel_y;
+ }
+ } else if (inst->Texture.Texture == TGSI_TEXTURE_2D_ARRAY ||
+ inst->Texture.Texture == TGSI_TEXTURE_SHADOW2D_ARRAY)
+ /* the array index is read from Z */
+ tex.coord_type_z = 0;
r = r600_bytecode_add_tex(ctx->bc, &tex);
if (r)