From d8f3d0a3a85244450d43da44cb8eed2389969b47 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 4 Feb 2020 11:12:15 +0100 Subject: [PATCH] etnaviv: implement emit_string_marker Writes string to cmdstream in payload of a nop command. Could be useful for internal driver debugging too. Here is how it looks decoded: 0x18000000, /* NOP (3) OP=NOP */ 0x65736572, /* rese */ 0x18000000, /* NOP (3) OP=NOP */ 0x00000074, /* t */ 0x00000000, /* GL.API_MODE := OPENGL */ or 0x00000705, /* GL.STALL_TOKEN := FROM=RA,TO=PE,FLIP0=0,FLIP1=0 */ 0x00000001, /* TS.FLUSH_CACHE := FLUSH=1 */ 0x18000000, /* NOP (3) OP=NOP */ 0x616e7465, /* etna */ 0x18000000, /* NOP (3) OP=NOP */ 0x6275735f, /* _sub */ 0x18000000, /* NOP (3) OP=NOP */ 0x5f74696d, /* mit_ */ 0x18000000, /* NOP (3) OP=NOP */ 0x735f7372, /* rs_s */ 0x18000000, /* NOP (3) OP=NOP */ 0x65746174, /* tate */ 0x00004606, /* RS.CONFIG := SOURCE_FORMAT=A8R8G8B8 Signed-off-by: Christian Gmeiner Tested-by: Marge Bot Part-of: --- src/gallium/drivers/etnaviv/etnaviv_context.c | 31 +++++++++++++++++++ src/gallium/drivers/etnaviv/etnaviv_screen.c | 1 + 2 files changed, 32 insertions(+) diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index 76d80589950..5bca37ca524 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -57,6 +57,36 @@ #include "hw/common.xml.h" +static inline void +etna_emit_nop_with_data(struct etna_cmd_stream *stream, uint32_t value) +{ + etna_cmd_stream_emit(stream, VIV_FE_NOP_HEADER_OP_NOP); + etna_cmd_stream_emit(stream, value); +} + +static void +etna_emit_string_marker(struct pipe_context *pctx, const char *string, int len) +{ + struct etna_context *ctx = etna_context(pctx); + struct etna_cmd_stream *stream = ctx->stream; + const uint32_t *buf = (const void *)string; + + etna_cmd_stream_reserve(stream, len * 2); + + while (len >= 4) { + etna_emit_nop_with_data(stream, *buf); + buf++; + len -= 4; + } + + /* copy remainder bytes without reading past end of input string */ + if (len > 0) { + uint32_t w = 0; + memcpy(&w, buf, len); + etna_emit_nop_with_data(stream, w); + } +} + static void etna_context_destroy(struct pipe_context *pctx) { @@ -561,6 +591,7 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) pctx->set_debug_callback = etna_set_debug_callback; pctx->create_fence_fd = etna_create_fence_fd; pctx->fence_server_sync = etna_fence_server_sync; + pctx->emit_string_marker = etna_emit_string_marker; /* creation of compile states */ pctx->create_blend_state = etna_blend_state_create; diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c index 6fb75193430..1aeef0dea53 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_screen.c +++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c @@ -151,6 +151,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: case PIPE_CAP_MIXED_COLOR_DEPTH_BITS: case PIPE_CAP_MIXED_FRAMEBUFFER_SIZES: + case PIPE_CAP_STRING_MARKER: return 1; case PIPE_CAP_NATIVE_FENCE_FD: return screen->drm_version >= ETNA_DRM_VERSION_FENCE_FD; -- 2.30.2