On on., sep. 5, 2018 at 5:34 PM, Gert Wollny <gw.foss...@gmail.com> wrote:
From: Gert Wollny <gert.wol...@collabora.com>

On the host VREND_DEBUG=guestallow must be set to let the guest override
the debug flags.

Signed-off-by: Gert Wollny <gert.wol...@collabora.com>
---
The corresponding code for virglrenderer can be found in this MR:
https://gitlab.freedesktop.org/virgl/virglrenderer/merge_requests/39

 src/gallium/drivers/virgl/virgl_context.c  | 17 +++++++++++++++++
 src/gallium/drivers/virgl/virgl_encode.c   |  8 ++++++++
 src/gallium/drivers/virgl/virgl_encode.h   |  3 +++
 src/gallium/drivers/virgl/virgl_protocol.h |  1 +
 src/gallium/drivers/virgl/virgl_screen.h   | 15 +++++++++++++++
 5 files changed, 44 insertions(+)

diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index 4511bf3b2f..087055b602 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -1157,6 +1157,20 @@ static void virgl_get_sample_position(struct pipe_context *ctx,
                    index, sample_count, out_value[0], out_value[1]);
 }

+static const struct debug_named_value host_debug_options[] = {
+   { "tgsi", debug_shader_tgsi , "Print TGSI on host"},
+ { "glsl", debug_shader_glsl, "Print GLSL shaders created from TGSI"}, + { "glsl", debug_shader_streamout, "Print GLSL shaders created from TGSI"},

Typo? Shouldn't the string be "streamout", and the description be something else?

With that fixed:

Reviewed-by: Erik Faye-Lund <erik.faye-l...@collabora.com>

+   { "shader", debug_shader, "Print TGSI and created GLSL shaders"},
+   { "cmd", debug_cmd, "Print incoming commands"},
+   { "obj", debug_object, "Print object creation"},
+   { "blit", debug_blit, "Debug blit code path"},
+ { "copyres", debug_copy_resource, "Debug copy resource code path"},
+   { "all", debug_all, "Enable all debugging output"},
+   DEBUG_NAMED_VALUE_END
+};
+DEBUG_GET_ONCE_FLAGS_OPTION(virgl_host_debug, "VIRGL_HOST_DEBUG", host_debug_options, 0)
+
struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
                                           void *priv,
                                           unsigned flags)
@@ -1268,6 +1282,9 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
    virgl_encoder_create_sub_ctx(vctx, vctx->hw_sub_ctx_id);

    virgl_encoder_set_sub_ctx(vctx, vctx->hw_sub_ctx_id);
+
+ virgl_encode_host_debug_flags(vctx, (unsigned)debug_get_option_virgl_host_debug());
+
    return &vctx->base;
 fail:
    return NULL;
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index 29920b22be..ff21eb4bda 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -1044,3 +1044,11 @@ int virgl_encode_texture_barrier(struct virgl_context *ctx,
    virgl_encoder_write_dword(ctx->cbuf, flags);
    return 0;
 }
+
+int virgl_encode_host_debug_flags(struct virgl_context *ctx,
+                                  unsigned flags)
+{
+ virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_DEBUG_FLAGS, 0, 1));
+   virgl_encoder_write_dword(ctx->cbuf, flags);
+   return 0;
+}
diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h
index 40e62d453b..330c59f366 100644
--- a/src/gallium/drivers/virgl/virgl_encode.h
+++ b/src/gallium/drivers/virgl/virgl_encode.h
@@ -276,4 +276,7 @@ int virgl_encode_launch_grid(struct virgl_context *ctx,
                              const struct pipe_grid_info *grid_info);
 int virgl_encode_texture_barrier(struct virgl_context *ctx,
                                  unsigned flags);
+
+int virgl_encode_host_debug_flags(struct virgl_context *ctx,
+                                  unsigned flags);
 #endif
diff --git a/src/gallium/drivers/virgl/virgl_protocol.h b/src/gallium/drivers/virgl/virgl_protocol.h
index 8d99c5ed47..3373121bf7 100644
--- a/src/gallium/drivers/virgl/virgl_protocol.h
+++ b/src/gallium/drivers/virgl/virgl_protocol.h
@@ -92,6 +92,7 @@ enum virgl_context_cmd {
    VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH,
    VIRGL_CCMD_TEXTURE_BARRIER,
    VIRGL_CCMD_SET_ATOMIC_BUFFERS,
+   VIRGL_CCMD_SET_DEBUG_FLAGS,
 };

 /*
diff --git a/src/gallium/drivers/virgl/virgl_screen.h b/src/gallium/drivers/virgl/virgl_screen.h
index 719f5166d7..939c782c83 100644
--- a/src/gallium/drivers/virgl/virgl_screen.h
+++ b/src/gallium/drivers/virgl/virgl_screen.h
@@ -29,6 +29,21 @@

 #define VIRGL_DEBUG_VERBOSE 1
 #define VIRGL_DEBUG_TGSI    2
+
+enum virgl_debug_flags {
+   debug_shader_tgsi = 1 << 0,
+   debug_shader_glsl = 1 << 1,
+   debug_shader_streamout = 1 << 2,
+ debug_shader = debug_shader_tgsi | debug_shader_glsl | debug_shader_streamout,
+   debug_cmd = 1 << 3,
+   debug_object = 1 << 4,
+   debug_blit = 1 << 5,
+   debug_copy_resource = 1 << 6,
+ /* debug_features = 1 << 7, can't be triggered from the guest, because
+    * the code is run there before the guest can send commands */
+   debug_all = (1 << 8) - 1,
+};
+
 extern int virgl_debug;

 struct virgl_screen {
--
2.16.4

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

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

Reply via email to