Ah yes that was it. We can't expose that yet though since it would also require baseinstance and not just basevertex shader var support (plus DrawID too actually). So I still don't know what caps should be added...

Roland



On 10/13/2014 11:52 AM, Ilia Mirkin wrote:
Roland, is this the extension you were looking for?
https://urldefense.proofpoint.com/v1/url?u=https://www.opengl.org/registry/specs/ARB/shader_draw_parameters.txt&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=28tmQr5S4qUIBGuheE0xxkwdZmogBCPRYNIgQnp1SHc%3D%0A&s=bc5bf989d990de1e6ac853b06376d27362b58a2ac347ca34352d9211423578fa

On Mon, Oct 13, 2014 at 2:44 PM, Roland Scheidegger <srol...@vmware.com> wrote:
Oh I actually thought that BASEVERTEX was available as an vs input in some
gl extension. Looks like that's not the case.
Still, I guess we'd need some cap bit so we can tell the glsl compiler if it
actually should lower vertexid to vertexid_zerobase + basevertex or not. And
even then that still wouldn't cover drivers that don't want it lowered if
they can do the vertexid_zerobase thing (though it should not be an issue
with mesa state tracker as it would never use it).

Roland



On 10/13/2014 02:14 AM, Marek Olšák wrote:

radeonsi supports VERTEXID_ZEROBASE and BASEVERTEX. VERTEXID can be
implemented trivially using the two. I don't think we need any cap
bits, because this is required by OpenGL. In the worst case, drivers
will have to store BASEVERTEX in a constant buffer.

Marek

On Mon, Oct 13, 2014 at 9:45 AM,  <srol...@vmware.com> wrote:

From: Roland Scheidegger <srol...@vmware.com>

Just like in core mesa, expose a separate vertexid which doesn't include
the base vertex (aka d3d10 style). And expose basevertex too (vertexid is
basevertex + vertexid_zerobase). This will be needed to fix the piglit
vertexid failures in draw due to it following d3d10 semantics with
vertexid
(this patch does not actually fix that yet).

XXX: what cap bits do we want?
---
   src/gallium/auxiliary/draw/draw_llvm.c          |  8 +++++-
   src/gallium/auxiliary/gallivm/lp_bld_tgsi.h     |  1 +
   src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |  5 ++++
   src/gallium/auxiliary/tgsi/tgsi_strings.c       |  2 ++
   src/gallium/docs/source/tgsi.rst                | 36
+++++++++++++++++++++++++
   src/gallium/include/pipe/p_shader_tokens.h      |  4 ++-
   src/mesa/state_tracker/st_glsl_to_tgsi.cpp      |  8 ++++--
   7 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/src/gallium/auxiliary/draw/draw_llvm.c
b/src/gallium/auxiliary/draw/draw_llvm.c
index 14c802b..073b8ef 100644
--- a/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/src/gallium/auxiliary/draw/draw_llvm.c
@@ -1653,7 +1653,11 @@ draw_llvm_generate(struct draw_llvm *llvm, struct
draw_llvm_variant *variant,
         lp_build_printf(gallivm, " --- io %d = %p, loop counter %d\n",
                         io_itr, io, lp_loop.counter);
   #endif
-      system_values.vertex_id = lp_build_zero(gallivm,
lp_type_uint_vec(32, 32*vector_length));
+      system_values.vertex_id = lp_build_zero(gallivm,
+                                              lp_type_uint_vec(32,
32*vector_length));
+      system_values.basevertex = lp_build_broadcast(gallivm,
lp_build_vec_type(gallivm,
+
lp_type_uint_vec(32, 32*vector_length)),
+                                                    vertex_id_offset);
         for (i = 0; i < vector_length; ++i) {
            LLVMValueRef vert_index =
               LLVMBuildAdd(builder,
@@ -1714,6 +1718,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct
draw_llvm_variant *variant,
             * the primitive was split (we split rendering into chunks of
at
             * most 4095-vertices) we need to back out the original start
             * index out of our vertex id here.
+          * XXX this is only true for d3d10 style vertex id otherwise
should
+          * skip the sub.
             */
            vertex_id = LLVMBuildSub(builder, true_index,
vertex_id_offset, "");

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
index 029ca3c..43a0feb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h
@@ -163,6 +163,7 @@ struct lp_bld_tgsi_system_values {
      LLVMValueRef instance_id;
      LLVMValueRef vertex_id;
      LLVMValueRef prim_id;
+   LLVMValueRef basevertex;
   };


diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index 05618bc..32c5a6f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -1538,6 +1538,11 @@ emit_fetch_system_value(
         atype = TGSI_TYPE_UNSIGNED;
         break;

+   case TGSI_SEMANTIC_BASEVERTEX:
+      res = bld->system_values.basevertex;
+      atype = TGSI_TYPE_UNSIGNED;
+      break;
+
      case TGSI_SEMANTIC_PRIMID:
         res = bld->system_values.prim_id;
         atype = TGSI_TYPE_UNSIGNED;
diff --git a/src/gallium/auxiliary/tgsi/tgsi_strings.c
b/src/gallium/auxiliary/tgsi/tgsi_strings.c
index f84cd79..77ef04c 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_strings.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_strings.c
@@ -86,6 +86,8 @@ const char *tgsi_semantic_names[TGSI_SEMANTIC_COUNT] =
      "SAMPLEPOS",
      "SAMPLEMASK",
      "INVOCATIONID",
+   "VERTEXID_ZEROBASE",
+   "BASEVERTEX",
   };

   const char *tgsi_texture_names[TGSI_TEXTURE_COUNT] =
diff --git a/src/gallium/docs/source/tgsi.rst
b/src/gallium/docs/source/tgsi.rst
index 7d5918f..d53e563 100644
--- a/src/gallium/docs/source/tgsi.rst
+++ b/src/gallium/docs/source/tgsi.rst
@@ -2839,6 +2839,42 @@ 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.

+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. Only the X value 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. Only the X value is used.
+
+TGSI_SEMANTIC_VERTEXID_ZEROBASE
+"""""""""""""""""""""""""""""""
+
+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_ZEROBASE +
TGSI_SEMANTIC_BASEVERTEX
+== TGSI_SEMANTIC_VERTEXID). Only the X value is used.
+
+TGSI_SEMANTIC_BASEVERTEX
+""""""""""""""""""""""""
+
+For vertex shaders, this semantic label indicates that a system value
contains
+the base vertex (i.e. gl_BaseVertex). Only the X value is used.
+
+TGSI_SEMANTIC_PRIMID
+""""""""""""""""""""
+
+For geometry and fragment shaders, this semantic label indicates the
value
+contains the primitive id (i.e. gl_PrimitiveID). Only the X value is
used.
+FIXME: This right now can be either a ordinary input or a system
value...
+
+
   Declaration Interpolate
   ^^^^^^^^^^^^^^^^^^^^^^^

diff --git a/src/gallium/include/pipe/p_shader_tokens.h
b/src/gallium/include/pipe/p_shader_tokens.h
index df154a2..7a68387 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -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_ZEROBASE 28
+#define TGSI_SEMANTIC_BASEVERTEX 29
+#define TGSI_SEMANTIC_COUNT      30 /**< number of semantic values */

   struct tgsi_declaration_semantic
   {
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index a0da9f6..872724c 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -4165,8 +4165,8 @@ const unsigned
_mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = {
       */
      TGSI_SEMANTIC_VERTEXID,
      TGSI_SEMANTIC_INSTANCEID,
-   0,
-   0,
+   TGSI_SEMANTIC_VERTEXID_ZEROBASE,
+   TGSI_SEMANTIC_BASEVERTEX,

      /* Geometry shader
       */
@@ -4866,6 +4866,10 @@ st_translate_program(
             TGSI_SEMANTIC_SAMPLEMASK);
      assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_INVOCATION_ID] ==
             TGSI_SEMANTIC_INVOCATIONID);
+   assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE] ==
+          TGSI_SEMANTIC_VERTEXID_ZEROBASE);
+   assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_BASE_VERTEX] ==
+          TGSI_SEMANTIC_BASEVERTEX);

      t = CALLOC_STRUCT(st_translate);
      if (!t) {
--
1.9.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org

https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=sf0cZEYYhbpkq15rNsD%2FeZyWnphZOJFkyfPz18wBmGg%3D%0A&s=95d3538cbfa66939e4cc9cfc1aaae8180aa1ac404e9ede7aeb8e46088d620014


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/mesa-dev&k=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0A&r=F4msKE2WxRzA%2BwN%2B25muztFm5TSPwE8HKJfWfR2NgfY%3D%0A&m=28tmQr5S4qUIBGuheE0xxkwdZmogBCPRYNIgQnp1SHc%3D%0A&s=e0af6fdf4a952b42c8a9e315fdbb142c8cec35787cb13b37597da231c931fc9e

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to