summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary
diff options
context:
space:
mode:
authorChristoph Bumiller <[email protected]>2013-03-15 22:11:31 +0100
committerChristoph Bumiller <[email protected]>2013-03-20 12:25:21 +0100
commit8acaf862dfeac62550514b0e46f5aa6212b08992 (patch)
tree742186f981a608ef42f62aff6271aeec6451b7bc /src/gallium/auxiliary
parent3eaf823b9086ae400a000a1f639e74d2f2be9166 (diff)
gallium: add TGSI_SEMANTIC_TEXCOORD,PCOORD v3
This makes it possible to identify gl_TexCoord and gl_PointCoord for drivers where sprite coordinate replacement is restricted. The new PIPE_CAP_TGSI_TEXCOORD decides whether these varyings should be hidden behind the GENERIC semantic or not. With this patch only nvc0 and nv30 will request that they be used. v2: introduce a CAP so other drivers don't have to bother with the new semantic v3: adapt to introduction gl_varying_slot enum
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_wide_point.c46
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_dump.c1
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_strings.c4
3 files changed, 32 insertions, 19 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index 8e0a117843e..0d3fee4bb0d 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -52,6 +52,7 @@
*/
+#include "pipe/p_screen.h"
#include "pipe/p_context.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -74,6 +75,9 @@ struct widepoint_stage {
uint num_texcoord_gen;
uint texcoord_gen_slot[PIPE_MAX_SHADER_OUTPUTS];
+ /* TGSI_SEMANTIC to which sprite_coord_enable applies */
+ unsigned sprite_coord_semantic;
+
int psize_slot;
};
@@ -233,28 +237,29 @@ widepoint_first_point(struct draw_stage *stage,
wide->num_texcoord_gen = 0;
- /* Loop over fragment shader inputs looking for generic inputs
+ /* Loop over fragment shader inputs looking for the PCOORD input or inputs
* for which bit 'k' in sprite_coord_enable is set.
*/
for (i = 0; i < fs->info.num_inputs; i++) {
- if (fs->info.input_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
- const int generic_index = fs->info.input_semantic_index[i];
- /* Note that sprite_coord enable is a bitfield of
- * PIPE_MAX_SHADER_OUTPUTS bits.
- */
- if (generic_index < PIPE_MAX_SHADER_OUTPUTS &&
- (rast->sprite_coord_enable & (1 << generic_index))) {
- /* OK, this generic attribute needs to be replaced with a
- * texcoord (see above).
- */
- int slot = draw_alloc_extra_vertex_attrib(draw,
- TGSI_SEMANTIC_GENERIC,
- generic_index);
-
- /* add this slot to the texcoord-gen list */
- wide->texcoord_gen_slot[wide->num_texcoord_gen++] = slot;
- }
+ int slot;
+ const unsigned sn = fs->info.input_semantic_name[i];
+ const unsigned si = fs->info.input_semantic_index[i];
+
+ if (sn == wide->sprite_coord_semantic) {
+ /* Note that sprite_coord_enable is a bitfield of 32 bits. */
+ if (si >= 32 || !(rast->sprite_coord_enable & (1 << si)))
+ continue;
+ } else if (sn != TGSI_SEMANTIC_PCOORD) {
+ continue;
}
+
+ /* OK, this generic attribute needs to be replaced with a
+ * sprite coord (see above).
+ */
+ slot = draw_alloc_extra_vertex_attrib(draw, sn, si);
+
+ /* add this slot to the texcoord-gen list */
+ wide->texcoord_gen_slot[wide->num_texcoord_gen++] = slot;
}
}
@@ -326,6 +331,11 @@ struct draw_stage *draw_wide_point_stage( struct draw_context *draw )
if (!draw_alloc_temp_verts( &wide->stage, 4 ))
goto fail;
+ wide->sprite_coord_semantic =
+ draw->pipe->screen->get_param(draw->pipe->screen, PIPE_CAP_TGSI_TEXCOORD)
+ ?
+ TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC;
+
return &wide->stage;
fail:
diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c
index d98f6c49366..365665fa6f7 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c
@@ -305,6 +305,7 @@ iter_declaration(
TXT( ", " );
ENM( decl->Semantic.Name, tgsi_semantic_names );
if (decl->Semantic.Index != 0 ||
+ decl->Semantic.Name == TGSI_SEMANTIC_TEXCOORD ||
decl->Semantic.Name == TGSI_SEMANTIC_GENERIC) {
CHR( '[' );
UID( decl->Semantic.Index );
diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c b/src/gallium/auxiliary/tgsi/tgsi_strings.c
index 5c92e9a1001..95a5aded819 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
@@ -76,7 +76,9 @@ const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =
"GRID_SIZE",
"BLOCK_ID",
"BLOCK_SIZE",
- "THREAD_ID"
+ "THREAD_ID",
+ "TEXCOORD",
+ "PCOORD"
};
const char *tgsi_texture_names[TGSI_TEXTURE_COUNT] =