aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Bornecrantz <[email protected]>2009-05-15 05:30:43 +0200
committerJakob Bornecrantz <[email protected]>2009-05-16 01:50:53 +0100
commit3b4da4e9dac00f181380a9896ef3329964432c43 (patch)
treecc2b4da8a5c9a195cc286e6b42c2b00984ae7b9e
parentc30f66118974f41f57e86d49f372b7c78f891223 (diff)
trace: Put shaders on a list in the context
-rw-r--r--src/gallium/drivers/trace/Makefile1
-rw-r--r--src/gallium/drivers/trace/SConscript1
-rw-r--r--src/gallium/drivers/trace/tr_context.c41
-rw-r--r--src/gallium/drivers/trace/tr_context.h7
-rw-r--r--src/gallium/drivers/trace/tr_state.c50
-rw-r--r--src/gallium/drivers/trace/tr_state.h59
6 files changed, 151 insertions, 8 deletions
diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile
index 188998d5793..94be0bfd5a5 100644
--- a/src/gallium/drivers/trace/Makefile
+++ b/src/gallium/drivers/trace/Makefile
@@ -8,6 +8,7 @@ C_SOURCES = \
tr_context.c \
tr_dump.c \
tr_dump_state.c \
+ tr_state.c \
tr_screen.c \
tr_texture.c
diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript
index 4ab829a3a8e..9b5af0d86fb 100644
--- a/src/gallium/drivers/trace/SConscript
+++ b/src/gallium/drivers/trace/SConscript
@@ -10,6 +10,7 @@ trace = env.ConvenienceLibrary(
'tr_dump.c',
'tr_dump_state.c',
'tr_screen.c',
+ 'tr_state.c',
'tr_texture.c',
])
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index 6a19233a9ae..dee9ac57b49 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -32,10 +32,10 @@
#include "tr_dump.h"
#include "tr_dump_state.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 *
@@ -573,23 +573,30 @@ trace_context_create_fs_state(struct pipe_context *_pipe,
trace_dump_call_end();
+ result = trace_shader_create(tr_ctx, state, result);
+
return result;
}
static INLINE void
trace_context_bind_fs_state(struct pipe_context *_pipe,
- void *state)
+ void *_state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
+ struct trace_shader *tr_shdr = trace_shader(_state);
struct pipe_context *pipe = tr_ctx->pipe;
+ void *state = tr_shdr ? tr_shdr->state : NULL;
trace_dump_call_begin("pipe_context", "bind_fs_state");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, state);
- pipe->bind_fs_state(pipe, state);;
+ if (tr_shdr && tr_shdr->replaced)
+ state = tr_shdr->replaced;
+
+ pipe->bind_fs_state(pipe, state);
trace_dump_call_end();
}
@@ -597,19 +604,23 @@ trace_context_bind_fs_state(struct pipe_context *_pipe,
static INLINE void
trace_context_delete_fs_state(struct pipe_context *_pipe,
- void *state)
+ void *_state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
+ struct trace_shader *tr_shdr = trace_shader(_state);
struct pipe_context *pipe = tr_ctx->pipe;
+ void *state = tr_shdr->state;
trace_dump_call_begin("pipe_context", "delete_fs_state");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, state);
- pipe->delete_fs_state(pipe, state);;
+ pipe->delete_fs_state(pipe, state);
trace_dump_call_end();
+
+ trace_shader_destroy(tr_ctx, tr_shdr);
}
@@ -626,28 +637,35 @@ trace_context_create_vs_state(struct pipe_context *_pipe,
trace_dump_arg(ptr, pipe);
trace_dump_arg(shader_state, state);
- result = pipe->create_vs_state(pipe, state);;
+ result = pipe->create_vs_state(pipe, state);
trace_dump_ret(ptr, result);
trace_dump_call_end();
+ result = trace_shader_create(tr_ctx, state, result);
+
return result;
}
static INLINE void
trace_context_bind_vs_state(struct pipe_context *_pipe,
- void *state)
+ void *_state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
+ struct trace_shader *tr_shdr = trace_shader(_state);
struct pipe_context *pipe = tr_ctx->pipe;
+ void *state = tr_shdr ? tr_shdr->state : NULL;
trace_dump_call_begin("pipe_context", "bind_vs_state");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, state);
+ if (tr_shdr && tr_shdr->replaced)
+ state = tr_shdr->replaced;
+
pipe->bind_vs_state(pipe, state);;
trace_dump_call_end();
@@ -656,10 +674,12 @@ trace_context_bind_vs_state(struct pipe_context *_pipe,
static INLINE void
trace_context_delete_vs_state(struct pipe_context *_pipe,
- void *state)
+ void *_state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
+ struct trace_shader *tr_shdr = trace_shader(_state);
struct pipe_context *pipe = tr_ctx->pipe;
+ void *state = tr_shdr->state;
trace_dump_call_begin("pipe_context", "delete_vs_state");
@@ -669,6 +689,8 @@ trace_context_delete_vs_state(struct pipe_context *_pipe,
pipe->delete_vs_state(pipe, state);;
trace_dump_call_end();
+
+ trace_shader_destroy(tr_ctx, tr_shdr);
}
@@ -1099,6 +1121,9 @@ trace_context_create(struct pipe_screen *_screen,
if(!tr_ctx)
goto error1;
+ pipe_mutex_init(tr_ctx->list_mutex);
+ make_empty_list(&tr_ctx->shaders);
+
tr_ctx->base.winsys = _screen->winsys;
tr_ctx->base.screen = _screen;
tr_ctx->base.destroy = trace_context_destroy;
diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h
index 2512a0a2328..a7da7b95269 100644
--- a/src/gallium/drivers/trace/tr_context.h
+++ b/src/gallium/drivers/trace/tr_context.h
@@ -33,6 +33,7 @@
#include "util/u_debug.h"
#include "pipe/p_context.h"
+#include "tr_screen.h"
#ifdef __cplusplus
extern "C" {
@@ -45,7 +46,13 @@ struct trace_context
struct pipe_context *pipe;
+ /* for list on screen */
struct tr_list list;
+
+ /* list of state objects */
+ pipe_mutex list_mutex;
+ unsigned num_shaders;
+ struct tr_list shaders;
};
diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c
new file mode 100644
index 00000000000..c9ce63a0edc
--- /dev/null
+++ b/src/gallium/drivers/trace/tr_state.c
@@ -0,0 +1,50 @@
+/*
+ * 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
+ * on 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
+ * VMWARE AND/OR THEIR 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 "tr_state.h"
+
+#include "util/u_memory.h"
+#include "util/u_simple_list.h"
+
+struct trace_shader * trace_shader_create(struct trace_context *tr_ctx,
+ const struct pipe_shader_state *state,
+ void *result)
+{
+ struct trace_shader *tr_shdr = CALLOC_STRUCT(trace_shader);
+
+ tr_shdr->state = result;
+
+ /* works on context as well */
+ trace_screen_add_to_list(tr_ctx, shaders, tr_shdr);
+
+ return tr_shdr;
+}
+
+void trace_shader_destroy(struct trace_context *tr_ctx,
+ struct trace_shader *tr_shdr)
+{
+ trace_screen_remove_from_list(tr_ctx, shaders, tr_shdr);
+
+ FREE(tr_shdr);
+}
diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h
new file mode 100644
index 00000000000..bca615c50e0
--- /dev/null
+++ b/src/gallium/drivers/trace/tr_state.h
@@ -0,0 +1,59 @@
+/*
+ * 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
+ * on 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
+ * VMWARE AND/OR THEIR 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_STATE_H_
+#define TR_STATE_H_
+
+#include "tr_context.h"
+
+struct tgsi_token;
+
+struct trace_shader
+{
+ struct tr_list list;
+
+ void *state;
+ void *replaced;
+
+ struct tgsi_token *tokens;
+ struct tgsi_token *replaced_tokens;
+
+ boolean disabled;
+};
+
+
+static INLINE struct trace_shader *
+trace_shader(void *state)
+{
+ return (struct trace_shader *)state;
+}
+
+struct trace_shader * trace_shader_create(struct trace_context *tr_ctx,
+ const struct pipe_shader_state *state,
+ void *result);
+
+void trace_shader_destroy(struct trace_context *tr_ctx,
+ struct trace_shader *tr_shdr);
+
+#endif