[Mesa-dev] [PATCH v2 4/4] freedreno: implement emit_string_marker
Rob Clark
robdclark at gmail.com
Wed Jan 20 11:55:09 PST 2016
On Wed, Jan 20, 2016 at 2:50 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Wed, Jan 20, 2016 at 2:32 PM, Rob Clark <robdclark at gmail.com> wrote:
>> From: Rob Clark <robclark at freedesktop.org>
>>
>> Writes string to cmdstream in payload of a no-op packet.
>>
>> Signed-off-by: Rob Clark <robclark at freedesktop.org>
>> ---
>> src/gallium/drivers/freedreno/freedreno_context.c | 27 +++++++++++++++++++++++
>> src/gallium/drivers/freedreno/freedreno_screen.c | 2 +-
>> 2 files changed, 28 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c
>> index 0b6b9fb..c5ea86f 100644
>> --- a/src/gallium/drivers/freedreno/freedreno_context.c
>> +++ b/src/gallium/drivers/freedreno/freedreno_context.c
>> @@ -141,6 +141,32 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
>> }
>> }
>>
>> +/**
>> + * emit marker string as payload of a no-op packet, which can be
>> + * decoded by cffdump.
>> + */
>> +static void
>> +fd_emit_string_marker(struct pipe_context *pctx, const char *string, int len)
>> +{
>> + struct fd_context *ctx = fd_context(pctx);
>> + struct fd_ringbuffer *ring = ctx->ring;
>> + const uint32_t *buf = (const void *)string;
>> +
>> + OUT_PKT3(ring, CP_NOP, align(len, 4) / 4);
>
> Perhaps truncate len to whatever the max packet size is, just in case?
> Don't want to let apps totally corrupt your cmdstream...
yeah, probably doesn't hurt.. although it does beg the question about
what the max packet size actually is.
>> + while (len >= 4) {
>> + OUT_RING(ring, *buf);
>
> Isn't there an OUT_RINGp?
there is an OUT_RINGP() (but that isn't what you are thinking of
here.. it's for cases where we need to patch cmdstream later, ie. once
we've decided about gmem vs sysmem, etc). Haven't really had a need
for OUT_RINGp() yet.
BR,
-R
>> + buf++;
>> + len -= 4;
>> + }
>> +
>> + /* copy remainder bytes without reading past end of input string: */
>> + if (len > 0) {
>> + uint32_t w = 0;
>> + memcpy(&w, buf, len);
>> + OUT_RING(ring, w);
>> + }
>> +}
>> +
>> void
>> fd_context_destroy(struct pipe_context *pctx)
>> {
>> @@ -207,6 +233,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
>> pctx->screen = pscreen;
>> pctx->priv = priv;
>> pctx->flush = fd_context_flush;
>> + pctx->emit_string_marker = fd_emit_string_marker;
>>
>> for (i = 0; i < ARRAY_SIZE(ctx->rings); i++) {
>> ctx->rings[i] = fd_ringbuffer_new(screen->pipe, 0x100000);
>> diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
>> index e7b21de..4b5d9c8 100644
>> --- a/src/gallium/drivers/freedreno/freedreno_screen.c
>> +++ b/src/gallium/drivers/freedreno/freedreno_screen.c
>> @@ -155,6 +155,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>> case PIPE_CAP_USER_CONSTANT_BUFFERS:
>> case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
>> case PIPE_CAP_VERTEXID_NOBASE:
>> + case PIPE_CAP_STRING_MARKER:
>> return 1;
>>
>> case PIPE_CAP_SHADER_STENCIL_EXPORT:
>> @@ -164,7 +165,6 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
>> case PIPE_CAP_TEXTURE_BARRIER:
>> case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
>> case PIPE_CAP_COMPUTE:
>> - case PIPE_CAP_STRING_MARKER:
>> return 0;
>>
>> case PIPE_CAP_SM3:
>> --
>> 2.5.0
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list