gallium: add TGSI_SEMANTIC_VERTEXID_NOBASE and TGSI_SEMANTIC_BASEVERTEX

Plus a new PIPE_CAP_VERTEXID_NOBASE query. The idea is that drivers not
supporting vertex ids with base vertex offset applied (so, only support
d3d10-style vertex ids) will get such a d3d10-style vertex id instead -
with the caveat they'll also need to handle the basevertex system value
too (this follows what core mesa already does).
Additionally, this is also useful for other state trackers (for instance
llvmpipe / draw right now implement the d3d10 behavior on purpose, but
with different semantics it can just do both).
Doesn't do anything yet.
And fix up the docs wrt similar values.

v2: incorporate feedback from Brian and others, better names, better docs.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Roland Scheidegger
2014-12-12 04:13:43 +01:00
parent 3c8ef3a74b
commit ade8b26bf5
19 changed files with 84 additions and 6 deletions

View File

@@ -213,6 +213,12 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
else if (semName == TGSI_SEMANTIC_VERTEXID) {
info->uses_vertexid = TRUE;
}
else if (semName == TGSI_SEMANTIC_VERTEXID_NOBASE) {
info->uses_vertexid_nobase = TRUE;
}
else if (semName == TGSI_SEMANTIC_BASEVERTEX) {
info->uses_basevertex = TRUE;
}
else if (semName == TGSI_SEMANTIC_PRIMID) {
info->uses_primid = TRUE;
}

View File

@@ -74,6 +74,8 @@ struct tgsi_shader_info
boolean uses_kill; /**< KILL or KILL_IF instruction used? */
boolean uses_instanceid;
boolean uses_vertexid;
boolean uses_vertexid_nobase;
boolean uses_basevertex;
boolean uses_primid;
boolean uses_frontface;
boolean writes_psize;

View File

@@ -86,6 +86,8 @@ const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =
"SAMPLEPOS",
"SAMPLEMASK",
"INVOCATIONID",
"VERTEXID_NOBASE",
"BASEVERTEX",
};
const char *tgsi_texture_names[TGSI_TEXTURE_COUNT] =

View File

@@ -233,6 +233,14 @@ The integer capabilities:
* ``PIPE_CAP_CLIP_HALFZ``: Whether the driver supports the
pipe_rasterizer_state::clip_halfz being set to true. This is required
for enabling ARB_clip_control.
* ``PIPE_CAP_VERTEXID_NOBASE``: If true, the driver only supports
TGSI_SEMANTIC_VERTEXID_NOBASE (and not TGSI_SEMANTIC_VERTEXID). This means
state trackers for APIs whose vertexIDs are offset by basevertex (such as GL)
will need to lower TGSI_SEMANTIC_VERTEXID to TGSI_SEMANTIC_VERTEXID_NOBASE
and TGSI_SEMANTIC_BASEVERTEX, so drivers setting this must handle both these
semantics. Only relevant if geometry shaders are supported.
(Currently not possible to query availability of these two semantics outside
this, at least BASEVERTEX should be exposed separately too).
.. _pipe_capf:

View File

@@ -2651,7 +2651,7 @@ TGSI_SEMANTIC_VIEWPORT_INDEX
For geometry shaders, this semantic label indicates that an output
contains the index of the viewport (and scissor) to use.
Only the X value is used.
This is an integer value, and only the X component is used.
TGSI_SEMANTIC_LAYER
@@ -2659,7 +2659,8 @@ TGSI_SEMANTIC_LAYER
For geometry shaders, this semantic label indicates that an output
contains the layer value to use for the color and depth/stencil surfaces.
Only the X value is used. (Also known as rendertarget array index.)
This is an integer value, and only the X component is used.
(Also known as rendertarget array index.)
TGSI_SEMANTIC_CULLDIST
@@ -2700,7 +2701,8 @@ TGSI_SEMANTIC_SAMPLEID
""""""""""""""""""""""
For fragment shaders, this semantic label indicates that a system value
contains the current sample id (i.e. gl_SampleID). Only the X value is used.
contains the current sample id (i.e. gl_SampleID).
This is an integer value, and only the X component is used.
TGSI_SEMANTIC_SAMPLEPOS
"""""""""""""""""""""""
@@ -2720,8 +2722,48 @@ TGSI_SEMANTIC_INVOCATIONID
""""""""""""""""""""""""""
For geometry shaders, this semantic label indicates that a system value
contains the current invocation id (i.e. gl_InvocationID). Only the X value is
used.
contains the current invocation id (i.e. gl_InvocationID).
This is an integer value, and only the X component is used.
TGSI_SEMANTIC_INSTANCEID
""""""""""""""""""""""""
For vertex shaders, this semantic label indicates that a system value contains
the current instance id (i.e. gl_InstanceID). It does not include the base
instance. This is an integer value, and only the X component is used.
TGSI_SEMANTIC_VERTEXID
""""""""""""""""""""""
For vertex shaders, this semantic label indicates that a system value contains
the current vertex id (i.e. gl_VertexID). It does (unlike in d3d10) include the
base vertex. This is an integer value, and only the X component is used.
TGSI_SEMANTIC_VERTEXID_NOBASE
"""""""""""""""""""""""""""""""
For vertex shaders, this semantic label indicates that a system value contains
the current vertex id without including the base vertex (this corresponds to
d3d10 vertex id, so TGSI_SEMANTIC_VERTEXID_NOBASE + TGSI_SEMANTIC_BASEVERTEX
== TGSI_SEMANTIC_VERTEXID). This is an integer value, and only the X component
is used.
TGSI_SEMANTIC_BASEVERTEX
""""""""""""""""""""""""
For vertex shaders, this semantic label indicates that a system value contains
the base vertex (i.e. gl_BaseVertex). Note that for non-indexed draw calls,
this contains the first (or start) value instead.
This is an integer value, and only the X component is used.
TGSI_SEMANTIC_PRIMID
""""""""""""""""""""
For geometry and fragment shaders, this semantic label indicates the value
contains the primitive id (i.e. gl_PrimitiveID). This is an integer value,
and only the X component is used.
FIXME: This right now can be either a ordinary input or a system value...
Declaration Interpolate
^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -228,6 +228,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_CLIP_HALFZ:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
case PIPE_CAP_MAX_VIEWPORTS:

View File

@@ -226,6 +226,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_CLIP_HALFZ:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:

View File

@@ -495,6 +495,8 @@ ilo_get_param(struct pipe_screen *screen, enum pipe_cap param)
return true;
case PIPE_CAP_CLIP_HALFZ:
return true;
case PIPE_CAP_VERTEXID_NOBASE:
return false;
default:
return 0;

View File

@@ -282,6 +282,8 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
return 0;
case PIPE_CAP_CLIP_HALFZ:
return 1;
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
}
/* should only get here on unhandled cases */
debug_printf("Unexpected PIPE_CAP %d query\n", param);

View File

@@ -157,6 +157,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_CLIP_HALFZ:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
case PIPE_CAP_VENDOR_ID:

View File

@@ -205,6 +205,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
case PIPE_CAP_COMPUTE:
case PIPE_CAP_DRAW_INDIRECT:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
case PIPE_CAP_VENDOR_ID:

View File

@@ -181,6 +181,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
/* SWTCL-only features. */

View File

@@ -325,6 +325,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_DRAW_INDIRECT:
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
/* Stream output. */

View File

@@ -253,6 +253,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:

View File

@@ -231,6 +231,8 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
return 1;
case PIPE_CAP_CLIP_HALFZ:
return 1;
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
}
/* should only get here on unhandled cases */
debug_printf("Unexpected PIPE_CAP %d query\n", param);

View File

@@ -282,6 +282,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_CLIP_HALFZ:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
return 64;

View File

@@ -168,6 +168,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_CONDITIONAL_RENDER_INVERTED:
case PIPE_CAP_SAMPLER_VIEW_TARGET:
case PIPE_CAP_CLIP_HALFZ:
case PIPE_CAP_VERTEXID_NOBASE:
return 0;
/* Stream output. */

View File

@@ -572,6 +572,7 @@ enum pipe_cap {
PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE = 109,
PIPE_CAP_SAMPLER_VIEW_TARGET = 110,
PIPE_CAP_CLIP_HALFZ = 111,
PIPE_CAP_VERTEXID_NOBASE,
};
#define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)

View File

@@ -176,7 +176,9 @@ struct tgsi_declaration_interp
#define TGSI_SEMANTIC_SAMPLEPOS 25
#define TGSI_SEMANTIC_SAMPLEMASK 26
#define TGSI_SEMANTIC_INVOCATIONID 27
#define TGSI_SEMANTIC_COUNT 28 /**< number of semantic values */
#define TGSI_SEMANTIC_VERTEXID_NOBASE 28
#define TGSI_SEMANTIC_BASEVERTEX 29
#define TGSI_SEMANTIC_COUNT 30 /**< number of semantic values */
struct tgsi_declaration_semantic
{