summaryrefslogtreecommitdiffstats
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
parent23b4ad46268e4b3eb8399cadc448d8747492bd41 (diff)
r600g: add support for shadow array samplers
I had to guess & verify how some of the SAMPLE instructions work.
-rw-r--r--src/gallium/drivers/r600/r600_shader.c36
-rw-r--r--src/gallium/drivers/r600/r600d.h40
2 files changed, 57 insertions, 19 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)
diff --git a/src/gallium/drivers/r600/r600d.h b/src/gallium/drivers/r600/r600d.h
index 459aef68a83..6eb44d9bd81 100644
--- a/src/gallium/drivers/r600/r600d.h
+++ b/src/gallium/drivers/r600/r600d.h
@@ -3519,18 +3519,34 @@
#define R_03E200_SQ_LOOP_CONST_0 0x3E200
-#define SQ_TEX_INST_LD 0x03
-#define SQ_TEX_INST_GET_TEXTURE_RESINFO 0x04
-#define SQ_TEX_INST_GET_GRADIENTS_H 0x7
-#define SQ_TEX_INST_GET_GRADIENTS_V 0x8
-#define SQ_TEX_INST_SET_GRADIENTS_H 0xB
-#define SQ_TEX_INST_SET_GRADIENTS_V 0xC
+#define SQ_TEX_INST_LD 0x03
+#define SQ_TEX_INST_GET_TEXTURE_RESINFO 0x04
+#define SQ_TEX_INST_GET_BORDER_COLOR_FRAC 0x05
+#define SQ_TEX_INST_GET_COMP_TEX_LOD 0x06
+#define SQ_TEX_INST_GET_GRADIENTS_H 0x07
+#define SQ_TEX_INST_GET_GRADIENTS_V 0x08
+#define SQ_TEX_INST_GET_LERP_FACTORS 0x09
+#define SQ_TEX_INST_GET_WEIGHTS 0x0A
+#define SQ_TEX_INST_SET_GRADIENTS_H 0x0B
+#define SQ_TEX_INST_SET_GRADIENTS_V 0x0C
+#define SQ_TEX_INST_PASS 0x0D
+#define SQ_TEX_INST_SET_CUBEMAP_INDEX 0x0E
-#define SQ_TEX_INST_SAMPLE 0x10
-#define SQ_TEX_INST_SAMPLE_L 0x11
-#define SQ_TEX_INST_SAMPLE_G 0x14
-#define SQ_TEX_INST_SAMPLE_C 0x18
-#define SQ_TEX_INST_SAMPLE_C_L 0x19
-#define SQ_TEX_INST_SAMPLE_C_G 0x1C
+#define SQ_TEX_INST_SAMPLE 0x10
+#define SQ_TEX_INST_SAMPLE_L 0x11
+#define SQ_TEX_INST_SAMPLE_LB 0x12
+#define SQ_TEX_INST_SAMPLE_LZ 0x13
+#define SQ_TEX_INST_SAMPLE_G 0x14
+#define SQ_TEX_INST_SAMPLE_G_L 0x15
+#define SQ_TEX_INST_SAMPLE_G_LB 0x16
+#define SQ_TEX_INST_SAMPLE_G_LZ 0x17
+#define SQ_TEX_INST_SAMPLE_C 0x18 /* src.xyz = texcoord, src.z = array index (if needed), src.w = depth */
+#define SQ_TEX_INST_SAMPLE_C_L 0x19 /* src.xy = texcoord, src.y = array index (if needed), src.z = depth, src.w = lod */
+#define SQ_TEX_INST_SAMPLE_C_LB 0x1A /* src.xy = texcoord, src.y = array index (if needed), src.z = depth, src.w = bias */
+#define SQ_TEX_INST_SAMPLE_C_LZ 0x1B
+#define SQ_TEX_INST_SAMPLE_C_G 0x1C
+#define SQ_TEX_INST_SAMPLE_C_G_L 0x1D
+#define SQ_TEX_INST_SAMPLE_C_G_LB 0x1E
+#define SQ_TEX_INST_SAMPLE_C_G_LZ 0x1F
#endif