LIBNAME = trace
C_SOURCES = \
+ tr_buffer.c \
tr_context.c \
tr_dump.c \
tr_screen.c \
trace = env.ConvenienceLibrary(
target = 'trace',
source = [
+ 'tr_buffer.c',
'tr_context.c',
'tr_dump.c',
'tr_screen.c',
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+
+#include "util/u_memory.h"
+
+#include "tr_buffer.h"
+
+
+struct pipe_buffer *
+trace_buffer_create(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer)
+{
+ struct trace_buffer *tr_buf;
+
+ if(!buffer)
+ goto error;
+
+ assert(buffer->screen == tr_scr->screen);
+
+ tr_buf = CALLOC_STRUCT(trace_buffer);
+ if(!tr_buf)
+ goto error;
+
+ memcpy(&tr_buf->base, buffer, sizeof(struct pipe_buffer));
+ tr_buf->base.screen = &tr_scr->base;
+ tr_buf->buffer = buffer;
+
+ return &tr_buf->base;
+
+error:
+ pipe_buffer_reference(&buffer, NULL);
+ return NULL;
+}
+
+
+void
+trace_buffer_destroy(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer)
+{
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, buffer);
+ pipe_buffer_reference(&tr_buf->buffer, NULL);
+ FREE(tr_buf);
+}
--- /dev/null
+/**************************************************************************
+ *
+ * Copyright 2009 VMware, Inc.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef TR_BUFFER_H_
+#define TR_BUFFER_H_
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+#include "tr_screen.h"
+
+
+struct trace_buffer
+{
+ struct pipe_buffer base;
+
+ struct pipe_buffer *buffer;
+
+ void *map;
+};
+
+
+static INLINE struct trace_buffer *
+trace_buffer(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer)
+{
+ if(!buffer)
+ return NULL;
+ assert(tr_scr);
+ assert(buffer->screen == &tr_scr->base);
+ return (struct trace_buffer *)buffer;
+}
+
+
+struct pipe_buffer *
+trace_buffer_create(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer);
+
+void
+trace_buffer_destroy(struct trace_screen *tr_scr,
+ struct pipe_buffer *buffer);
+
+
+#endif
#include "tr_dump.h"
#include "tr_state.h"
+#include "tr_buffer.h"
#include "tr_screen.h"
#include "tr_texture.h"
#include "tr_context.h"
+static INLINE struct pipe_buffer *
+trace_buffer_unwrap(struct trace_context *tr_ctx,
+ struct pipe_buffer *buffer)
+{
+ struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+ struct trace_buffer *tr_buf;
+
+ if(!buffer)
+ return NULL;
+
+ tr_buf = trace_buffer(tr_scr, buffer);
+
+ assert(tr_buf->buffer);
+ assert(tr_buf->buffer->screen == tr_scr->screen);
+ return tr_buf->buffer;
+}
+
+
static INLINE struct pipe_texture *
trace_texture_unwrap(struct trace_context *tr_ctx,
struct pipe_texture *texture)
static INLINE boolean
trace_context_draw_elements(struct pipe_context *_pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_buffer *_indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
+ struct trace_screen *tr_scr = trace_screen(_pipe->screen);
struct trace_context *tr_ctx = trace_context(_pipe);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer);
struct pipe_context *pipe = tr_ctx->pipe;
+ struct pipe_buffer *indexBuffer = tr_buf->buffer;
boolean result;
trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
static INLINE boolean
trace_context_draw_range_elements(struct pipe_context *_pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_buffer *_indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
unsigned start,
unsigned count)
{
+ struct trace_screen *tr_scr = trace_screen(_pipe->screen);
struct trace_context *tr_ctx = trace_context(_pipe);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _indexBuffer);
struct pipe_context *pipe = tr_ctx->pipe;
+ struct pipe_buffer *indexBuffer = tr_buf->buffer;
boolean result;
trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
- trace_screen_user_buffer_update(_pipe->screen, (struct pipe_buffer *)buffer);
+ if (buffer)
+ trace_screen_user_buffer_update(_pipe->screen, buffer->buffer);
trace_dump_call_begin("pipe_context", "set_constant_buffer");
trace_dump_arg(uint, index);
trace_dump_arg(constant_buffer, buffer);
- pipe->set_constant_buffer(pipe, shader, index, buffer);;
+ if (buffer) {
+ struct pipe_constant_buffer _buffer;
+ _buffer.buffer = trace_buffer_unwrap(tr_ctx, buffer->buffer);
+ pipe->set_constant_buffer(pipe, shader, index, &_buffer);
+ } else {
+ pipe->set_constant_buffer(pipe, shader, index, buffer);
+ }
trace_dump_call_end();
}
trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
trace_dump_arg_end();
- pipe->set_vertex_buffers(pipe, num_buffers, buffers);;
+ if (num_buffers) {
+ struct pipe_vertex_buffer *_buffers = malloc(num_buffers * sizeof(*_buffers));
+ memcpy(_buffers, buffers, num_buffers * sizeof(*_buffers));
+ for (i = 0; i < num_buffers; i++)
+ _buffers[i].buffer = trace_buffer_unwrap(tr_ctx, buffers[i].buffer);
+ pipe->set_vertex_buffers(pipe, num_buffers, _buffers);
+ } else {
+ pipe->set_vertex_buffers(pipe, num_buffers, buffers);
+ }
trace_dump_call_end();
}
#include "util/u_memory.h"
+#include "tr_buffer.h"
#include "tr_dump.h"
#include "tr_state.h"
#include "tr_texture.h"
#include "pipe/p_inlines.h"
+
static const char *
trace_screen_get_name(struct pipe_screen *_screen)
{
trace_dump_call_end();
- return result;
+ return trace_buffer_create(tr_scr, result);
}
}
}
- return result;
+ return trace_buffer_create(tr_scr, result);
}
result->usage |= TRACE_BUFFER_USAGE_USER;
}
- return result;
+ return trace_buffer_create(tr_scr, result);
}
*/
void
trace_screen_user_buffer_update(struct pipe_screen *_screen,
- struct pipe_buffer *buffer)
+ struct pipe_buffer *_buffer)
{
#if 0
struct trace_screen *tr_scr = trace_screen(_screen);
static void *
trace_screen_buffer_map(struct pipe_screen *_screen,
- struct pipe_buffer *buffer,
+ struct pipe_buffer *_buffer,
unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
void *map;
trace_dump_call_begin("pipe_screen", "buffer_map");
static void *
trace_screen_buffer_map_range(struct pipe_screen *_screen,
- struct pipe_buffer *buffer,
+ struct pipe_buffer *_buffer,
unsigned offset,
unsigned length,
unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
void *map;
trace_dump_call_begin("pipe_screen", "buffer_map_range");
static void
trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen,
- struct pipe_buffer *buffer,
+ struct pipe_buffer *_buffer,
unsigned offset,
unsigned length)
{
struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
trace_dump_call_begin("pipe_screen", "buffer_flush_mapped_range");
static void
trace_screen_buffer_unmap(struct pipe_screen *_screen,
- struct pipe_buffer *buffer)
+ struct pipe_buffer *_buffer)
{
struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
#if 0
const void *map;
static void
-trace_screen_buffer_destroy(struct pipe_buffer *buffer)
+trace_screen_buffer_destroy(struct pipe_buffer *_buffer)
{
- struct trace_screen *tr_scr = trace_screen(buffer->screen);
+ struct trace_screen *tr_scr = trace_screen(_buffer->screen);
+ struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer);
struct pipe_screen *screen = tr_scr->screen;
+ struct pipe_buffer *buffer = tr_buf->buffer;
trace_dump_call_begin("pipe_screen", "buffer_destroy");
trace_dump_arg(ptr, screen);
trace_dump_arg(ptr, buffer);
- assert(screen->buffer_destroy);
- screen->buffer_destroy(buffer);
-
trace_dump_call_end();
+
+ trace_buffer_destroy(tr_scr, _buffer);
}
+/********************************************************************
+ * fence
+ */
+
+
static void
trace_screen_fence_reference(struct pipe_screen *_screen,
struct pipe_fence_handle **dst,
trace_dump_struct_begin("pipe_constant_buffer");
- trace_dump_member(ptr, state, buffer);
+ trace_dump_member(buffer_ptr, state, buffer);
trace_dump_struct_end();
}
trace_dump_member(uint, state, stride);
trace_dump_member(uint, state, max_index);
trace_dump_member(uint, state, buffer_offset);
- trace_dump_member(ptr, state, buffer);
+ trace_dump_member(buffer_ptr, state, buffer);
trace_dump_struct_end();
}