debug: Add command and object logging

Add flags cmd and obj to allow logging of the commands send by the guest

Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Jakob Bornecrantz <jakob@collabora.com>
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Signed-off-by: Jakob Bornecrantz <jakob@collabora.com>
macos/master
Gert Wollny 6 years ago committed by Jakob Bornecrantz
parent 05a10455a2
commit 8900596f96
  1. 3
      src/virgl_protocol.h
  2. 76
      src/vrend_debug.c
  3. 9
      src/vrend_debug.h
  4. 17
      src/vrend_decode.c

@ -27,6 +27,8 @@
#define VIRGL_QUERY_STATE_DONE 1
#define VIRGL_QUERY_STATE_WAIT_HOST 2
#include <stdint.h>
struct virgl_host_query_state {
uint32_t query_state;
uint32_t result_size;
@ -92,6 +94,7 @@ enum virgl_context_cmd {
VIRGL_CCMD_SET_FRAMEBUFFER_STATE_NO_ATTACH,
VIRGL_CCMD_TEXTURE_BARRIER,
VIRGL_CCMD_SET_ATOMIC_BUFFERS,
VIRGL_MAX_COMMANDS,
};
/*

@ -27,11 +27,87 @@
#include "util/u_debug.h"
#include <stdlib.h>
#include <stdio.h>
static const char *command_names[VIRGL_MAX_COMMANDS] = {
"NOP",
"CREATE_OBJECT",
"BIND_OBJECT",
"DESTROY_OBJECT",
"SET_VIEWPORT_STATE",
"SET_FRAMEBUFFER_STATE",
"SET_VERTEX_BUFFERS",
"CLEAR",
"DRAW_VBO",
"RESOURCE_INLINE_WRITE",
"SET_SAMPLER_VIEWS",
"SET_INDEX_BUFFER",
"SET_CONSTANT_BUFFER",
"SET_STENCIL_REF",
"SET_BLEND_COLOR",
"SET_SCISSOR_STATE",
"BLIT",
"RESOURCE_COPY_REGION",
"BIND_SAMPLER_STATES",
"BEGIN_QUERY",
"END_QUERY",
"GET_QUERY_RESULT",
"SET_POLYGON_STIPPLE",
"SET_CLIP_STATE",
"SET_SAMPLE_MASK",
"SET_STREAMOUT_TARGETS",
"SET_RENDER_CONDITION",
"SET_UNIFORM_BUFFER",
"SET_SUB_CTX",
"CREATE_SUB_CTX",
"DESTROY_SUB_CTX",
"BIND_SHADER",
"SET_TESS_STATE",
"SET_MIN_SAMPLES",
"SET_SHADER_BUFFERS",
"SET_SHADER_IMAGES",
"MEMORY_BARRIER",
"LAUNCH_GRID",
"SET_FRAMEBUFFER_STATE_NO_ATTACH",
"TEXTURE_BARRIER",
"SET_ATOMIC_BUFFERS",
"SET_DEBUG_FLAGS"
};
static const char *object_type_names[VIRGL_MAX_OBJECTS] = {
"NULL",
"BLEND",
"RASTERIZER",
"DSA",
"SHADER",
"VERTEX_ELEMENTS",
"SAMPLER_VIEW",
"SAMPLER_STATE",
"SURFACE",
"QUERY",
"STREAMOUT_TARGET"
};
const char *vrend_get_comand_name(enum virgl_context_cmd cmd)
{
if (cmd < VIRGL_MAX_COMMANDS)
return command_names[cmd];
return "UNKNOWN";
}
extern const char *vrend_get_object_type_name(enum virgl_object_type obj)
{
if (obj < VIRGL_MAX_OBJECTS)
return object_type_names[obj];
return "UNKNOWN";
}
static const struct debug_named_value vrend_debug_options[] = {
{"tgsi", dbg_shader_tgsi, "Print TGSI"},
{"glsl", dbg_shader_glsl, "Print GLSL shaders created from TGSI"},
{"shader", dbg_shader, "Print TGSI and created GLSL shaders"},
{"stream", dbg_shader_streamout, "Print shader streamout"},
{"cmd", dbg_cmd, "Print incoming commands"},
{"obj", dbg_object, "Print object creation"},
DEBUG_NAMED_VALUE_END
};

@ -25,6 +25,8 @@
#ifndef vrend_debug_h
#define vrend_debug_h
#include "virgl_protocol.h"
struct vrend_context;
void vrend_print_context_name(struct vrend_context *ctx);
@ -33,8 +35,15 @@ enum virgl_debug_flags {
dbg_shader_glsl = 1 << 1,
dbg_shader_streamout = 1 << 2,
dbg_shader = dbg_shader_tgsi | dbg_shader_glsl | dbg_shader_streamout,
dbg_cmd = 1 << 3,
dbg_object = 1 << 4,
};
const char *vrend_get_comand_name(enum virgl_context_cmd cmd);
const char *vrend_get_object_type_name(enum virgl_object_type cmd);
void vrend_init_debug_flags(void);
unsigned vrend_debug(struct vrend_context *ctx, enum virgl_debug_flags flag);

@ -33,6 +33,7 @@
#include "vrend_renderer.h"
#include "vrend_object.h"
#include "tgsi/tgsi_text.h"
#include "vrend_debug.h"
/* decode side */
#define DECODE_MAX_TOKENS 8000
@ -712,6 +713,9 @@ static int vrend_decode_create_object(struct vrend_decode_ctx *ctx, int length)
if (handle == 0)
return EINVAL;
VREND_DEBUG(dbg_object, ctx->grctx," CREATE %-18s handle:0x%x len:%d\n",
vrend_get_object_type_name(obj_type), handle, length);
switch (obj_type){
case VIRGL_OBJECT_BLEND:
ret = vrend_decode_create_blend(ctx, handle, length);
@ -759,6 +763,10 @@ static int vrend_decode_bind_object(struct vrend_decode_ctx *ctx, uint16_t lengt
uint32_t handle = get_buf_entry(ctx, VIRGL_OBJ_BIND_HANDLE);
uint8_t obj_type = (header >> 8) & 0xff;
VREND_DEBUG(dbg_object, ctx->grctx,
" BIND %-20s handle:0x%x len:%d\n",
vrend_get_object_type_name(obj_type), handle, length);
switch (obj_type) {
case VIRGL_OBJECT_BLEND:
vrend_object_bind_blend(ctx->grctx, handle);
@ -786,6 +794,11 @@ static int vrend_decode_destroy_object(struct vrend_decode_ctx *ctx, int length)
uint32_t handle = get_buf_entry(ctx, VIRGL_OBJ_DESTROY_HANDLE);
VREND_DEBUG_EXT(dbg_object, ctx->grctx,
uint32_t obj = (get_buf_entry(ctx, 0) >> 8) & 0xFF;
fprintf(stderr, " DESTROY %-17s handle:0x%x\n",
vrend_get_object_type_name(obj), handle));
vrend_renderer_object_destroy(ctx->grctx, handle);
return 0;
}
@ -1355,7 +1368,9 @@ int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw)
vrend_report_buffer_error(gdctx->grctx, 0);
break;
}
// fprintf(stderr,"[%d] cmd is %d (obj %d) len %d\n", gdctx->ds->buf_offset, header & 0xff, (header >> 8 & 0xff), (len));
VREND_DEBUG(dbg_cmd, gdctx->grctx,"%-4d %-20s len:%d\n",
gdctx->ds->buf_offset, vrend_get_comand_name(header & 0xff), len);
switch (header & 0xff) {
case VIRGL_CCMD_CREATE_OBJECT:

Loading…
Cancel
Save