I guess it's needed to override the gl version to use this feature as 4.3 is not yet supported?

Anyway, this might be useful if apps use glDebugMessageInsert().

Reviewed-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>

On 04/03/2016 10:04 PM, Ilia Mirkin wrote:
This should hopefully make it a little easier to debug with GL
applications like glretrace and looking at command streams.

Signed-off-by: Ilia Mirkin <imir...@alum.mit.edu>
---
  src/gallium/drivers/nouveau/nv50/nv50_context.c | 25 +++++++++++++++++++++++++
  src/gallium/drivers/nouveau/nv50/nv50_screen.c  |  2 +-
  src/gallium/drivers/nouveau/nvc0/nvc0_context.c | 25 +++++++++++++++++++++++++
  src/gallium/drivers/nouveau/nvc0/nvc0_screen.c  |  2 +-
  4 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nv50/nv50_context.c 
b/src/gallium/drivers/nouveau/nv50/nv50_context.c
index 61a52c4..5af0e9b 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_context.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_context.c
@@ -93,6 +93,30 @@ nv50_memory_barrier(struct pipe_context *pipe, unsigned 
flags)
     }
  }

+static void
+nv50_emit_string_marker(struct pipe_context *pipe, const char *str, int len)
+{
+   struct nouveau_pushbuf *push = nv50_context(pipe)->base.pushbuf;
+   int string_words = len / 4;
+   int data_words;
+
+   if (len <= 0)
+      return;
+   string_words = MIN2(string_words, NV04_PFIFO_MAX_PACKET_LEN);
+   if (string_words == NV04_PFIFO_MAX_PACKET_LEN)
+      data_words = string_words;
+   else
+      data_words = string_words + !!(len & 3);
+   BEGIN_NI04(push, SUBC_3D(NV04_GRAPH_NOP), data_words);
+   if (string_words)
+      PUSH_DATAp(push, str, string_words);
+   if (string_words != data_words) {
+      int data = 0;
+      memcpy(&data, &str[string_words * 4], len & 3);
+      PUSH_DATA (push, data);
+   }
+}
+
  void
  nv50_default_kick_notify(struct nouveau_pushbuf *push)
  {
@@ -309,6 +333,7 @@ nv50_create(struct pipe_screen *pscreen, void *priv, 
unsigned ctxflags)
     pipe->texture_barrier = nv50_texture_barrier;
     pipe->memory_barrier = nv50_memory_barrier;
     pipe->get_sample_position = nv50_context_get_sample_position;
+   pipe->emit_string_marker = nv50_emit_string_marker;

     if (!screen->cur_ctx) {
        /* Restore the last context's state here, normally handled during
diff --git a/src/gallium/drivers/nouveau/nv50/nv50_screen.c 
b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
index 44167e1..6065394 100644
--- a/src/gallium/drivers/nouveau/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nouveau/nv50/nv50_screen.c
@@ -194,6 +194,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
     case PIPE_CAP_COMPUTE:
     case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
     case PIPE_CAP_INVALIDATE_BUFFER:
+   case PIPE_CAP_STRING_MARKER:
        return 1;
     case PIPE_CAP_SEAMLESS_CUBE_MAP:
        return 1; /* class_3d >= NVA0_3D_CLASS; */
@@ -236,7 +237,6 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
     case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
     case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
     case PIPE_CAP_GENERATE_MIPMAP:
-   case PIPE_CAP_STRING_MARKER:
     case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
     case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
     case PIPE_CAP_QUERY_BUFFER_OBJECT:
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
index 007cccf..fcb8289 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_context.c
@@ -97,6 +97,30 @@ nvc0_memory_barrier(struct pipe_context *pipe, unsigned 
flags)
  }

  static void
+nvc0_emit_string_marker(struct pipe_context *pipe, const char *str, int len)
+{
+   struct nouveau_pushbuf *push = nvc0_context(pipe)->base.pushbuf;
+   int string_words = len / 4;
+   int data_words;
+
+   if (len <= 0)
+      return;
+   string_words = MIN2(string_words, NV04_PFIFO_MAX_PACKET_LEN);
+   if (string_words == NV04_PFIFO_MAX_PACKET_LEN)
+      data_words = string_words;
+   else
+      data_words = string_words + !!(len & 3);
+   BEGIN_NIC0(push, SUBC_3D(NV04_GRAPH_NOP), data_words);
+   if (string_words)
+      PUSH_DATAp(push, str, string_words);
+   if (string_words != data_words) {
+      int data = 0;
+      memcpy(&data, &str[string_words * 4], len & 3);
+      PUSH_DATA (push, data);
+   }
+}
+
+static void
  nvc0_context_unreference_resources(struct nvc0_context *nvc0)
  {
     unsigned s, i;
@@ -333,6 +357,7 @@ nvc0_create(struct pipe_screen *pscreen, void *priv, 
unsigned ctxflags)
     pipe->texture_barrier = nvc0_texture_barrier;
     pipe->memory_barrier = nvc0_memory_barrier;
     pipe->get_sample_position = nvc0_context_get_sample_position;
+   pipe->emit_string_marker = nvc0_emit_string_marker;

     nouveau_context_init(&nvc0->base);
     nvc0_init_query_functions(nvc0);
diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
index b4bb27b..35f465b 100644
--- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c
@@ -215,6 +215,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
     case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
     case PIPE_CAP_QUERY_BUFFER_OBJECT:
     case PIPE_CAP_INVALIDATE_BUFFER:
+   case PIPE_CAP_STRING_MARKER:
        return 1;
     case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
        return (class_3d >= NVE4_3D_CLASS) ? 1 : 0;
@@ -241,7 +242,6 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
     case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
     case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
     case PIPE_CAP_GENERATE_MIPMAP:
-   case PIPE_CAP_STRING_MARKER:
     case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
     case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
     case PIPE_CAP_QUERY_MEMORY_INFO:

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

Reply via email to