vrend: implement support for KHR_debug

This implements accepting a marker message string from the
guest and passing it to the host implementation.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
macos/master
Gert Wollny 4 years ago
parent b5d701683e
commit fd0769aeb7
  1. 1
      src/virgl_hw.h
  2. 6
      src/virgl_protocol.h
  3. 1
      src/vrend_debug.c
  4. 21
      src/vrend_decode.c
  5. 22
      src/vrend_renderer.c
  6. 2
      src/vrend_renderer.h

@ -439,6 +439,7 @@ enum virgl_formats {
#define VIRGL_CAP_V2_UNTYPED_RESOURCE (1 << 1)
#define VIRGL_CAP_V2_VIDEO_MEMORY (1 << 2)
#define VIRGL_CAP_V2_MEMINFO (1 << 3)
#define VIRGL_CAP_V2_STRING_MARKER (1 << 4)
/* virgl bind flags - these are compatible with mesa 10.5 gallium.
* but are fixed, no other should be passed to virgl either.

@ -114,6 +114,7 @@ enum virgl_context_cmd {
VIRGL_CCMD_PIPE_RESOURCE_CREATE,
VIRGL_CCMD_PIPE_RESOURCE_SET_TYPE,
VIRGL_CCMD_GET_MEMORY_INFO,
VIRGL_CCMD_SEND_STRING_MARKER,
VIRGL_MAX_COMMANDS
};
@ -661,4 +662,9 @@ enum vrend_tweak_type {
#define VIRGL_PIPE_RES_SET_TYPE_PLANE_STRIDE(plane) (9 + (plane) * 2)
#define VIRGL_PIPE_RES_SET_TYPE_PLANE_OFFSET(plane) (10 + (plane) * 2)
/* send string marker */
#define VIRGL_SEND_STRING_MARKER_MIN_SIZE 2
#define VIRGL_SEND_STRING_MARKER_STRING_SIZE 1
#define VIRGL_SEND_STRING_MARKER_OFFSET 2
#endif

@ -80,6 +80,7 @@ static const char *command_names[VIRGL_MAX_COMMANDS] = {
"PIPE_RESOURCE_CREATE",
"PIPE_RESOURCE_SET_TYPE",
"GET_MEMORY_INFO",
"SEND_STRING_MARKER",
};
static const char *object_type_names[VIRGL_MAX_OBJECTS] = {

@ -1561,6 +1561,26 @@ static int vrend_decode_get_memory_info(struct vrend_context *ctx, const uint32_
return 0;
}
static int vrend_decode_send_string_marker(struct vrend_context *ctx, const uint32_t *buf, uint32_t length)
{
int buf_len = sizeof(uint32_t) * (length - 1);
if (length < VIRGL_SEND_STRING_MARKER_MIN_SIZE) {
fprintf(stderr, "minimal command length not okay\n");
return EINVAL;
}
int32_t len = get_buf_entry(buf, VIRGL_SEND_STRING_MARKER_STRING_SIZE);
if (len > buf_len) {
fprintf(stderr, "String len %d > buf_len %d\n", len, buf_len);
return EINVAL;
}
vrend_context_emit_string_marker(ctx, len, get_buf_ptr(buf, VIRGL_SEND_STRING_MARKER_OFFSET));
return 0;
}
typedef int (*vrend_decode_callback)(struct vrend_context *ctx, const uint32_t *buf, uint32_t length);
static int vrend_decode_dummy(struct vrend_context *ctx, const uint32_t *buf, uint32_t length)
@ -1623,6 +1643,7 @@ static const vrend_decode_callback decode_table[VIRGL_MAX_COMMANDS] = {
[VIRGL_CCMD_PIPE_RESOURCE_CREATE] = vrend_decode_pipe_resource_create,
[VIRGL_CCMD_PIPE_RESOURCE_SET_TYPE] = vrend_decode_pipe_resource_set_type,
[VIRGL_CCMD_GET_MEMORY_INFO] = vrend_decode_get_memory_info,
[VIRGL_CCMD_SEND_STRING_MARKER] = vrend_decode_send_string_marker,
};
static int vrend_decode_ctx_submit_cmd(struct virgl_context *ctx,

@ -158,6 +158,7 @@ enum features_id
feat_indep_blend_func,
feat_indirect_draw,
feat_indirect_params,
feat_khr_debug,
feat_memory_object,
feat_memory_object_fd,
feat_mesa_invert,
@ -257,6 +258,7 @@ static const struct {
FEAT(indep_blend_func, 40, 32, "GL_ARB_draw_buffers_blend", "GL_OES_draw_buffers_indexed"),
FEAT(indirect_draw, 40, 31, "GL_ARB_draw_indirect" ),
FEAT(indirect_params, 46, UNAVAIL, "GL_ARB_indirect_parameters" ),
FEAT(khr_debug, 43, 32, "GL_KHR_debug" ),
FEAT(memory_object, UNAVAIL, UNAVAIL, "GL_EXT_memory_object"),
FEAT(memory_object_fd, UNAVAIL, UNAVAIL, "GL_EXT_memory_object_fd"),
FEAT(mesa_invert, UNAVAIL, UNAVAIL, "GL_MESA_pack_invert" ),
@ -10420,6 +10422,8 @@ static void vrend_renderer_fill_caps_v2(int gl_ver, int gles_ver, union virgl_c
caps->v2.capability_bits_v2 |= VIRGL_CAP_V2_MEMINFO;
}
if (has_feature(feat_khr_debug))
caps->v2.capability_bits_v2 |= VIRGL_CAP_V2_STRING_MARKER;
}
void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
@ -11132,3 +11136,21 @@ static uint32_t vrend_renderer_get_video_memory(void)
return video_memory;
}
void vrend_context_emit_string_marker(struct vrend_context *ctx, GLsizei length, const char * message)
{
VREND_DEBUG(dbg_khr, ctx, "MARKER: '%.*s'\n", length, message);
if (has_feature(feat_khr_debug)) {
if (vrend_state.use_gles)
glDebugMessageInsertKHR(GL_DEBUG_SOURCE_APPLICATION_KHR,
GL_DEBUG_TYPE_MARKER_KHR,
0, GL_DEBUG_SEVERITY_NOTIFICATION,
length, message);
else
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION,
GL_DEBUG_TYPE_MARKER,
0, GL_DEBUG_SEVERITY_NOTIFICATION_KHR,
length, message);
}
}

@ -521,4 +521,6 @@ int vrend_renderer_resource_map(struct pipe_resource *pres, void **map, uint64_t
int vrend_renderer_resource_unmap(struct pipe_resource *pres);
void vrend_renderer_get_meminfo(struct vrend_context *ctx, uint32_t res_handle);
void vrend_context_emit_string_marker(struct vrend_context *ctx, GLsizei length, const char * message);
#endif

Loading…
Cancel
Save