gallium/trace: consolidate sampler, sampler_view code
authorBrian Paul <brianp@vmware.com>
Fri, 10 Aug 2012 02:59:44 +0000 (20:59 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 16 Aug 2012 15:01:31 +0000 (09:01 -0600)
src/gallium/drivers/trace/tr_context.c

index 17f7e95087f322150d4d1434f7c0f30aa81fa8f5..54ad0e9197a4660647bea90ebbec2fb3a0ecd79c 100644 (file)
@@ -288,45 +288,65 @@ trace_context_create_sampler_state(struct pipe_context *_pipe,
 
 
 static INLINE void
-trace_context_bind_fragment_sampler_states(struct pipe_context *_pipe,
-                                           unsigned num_states,
-                                           void **states)
+trace_context_bind_sampler_states(struct pipe_context *_pipe,
+                                  unsigned shader,
+                                  unsigned num_states,
+                                  void **states)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
    struct pipe_context *pipe = tr_ctx->pipe;
 
-   trace_dump_call_begin("pipe_context", "bind_fragment_sampler_states");
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      trace_dump_call_begin("pipe_context", "bind_vertex_sampler_states");
+      break;
+   case PIPE_SHADER_GEOMETRY:
+      trace_dump_call_begin("pipe_context", "bind_geometry_sampler_states");
+      break;
+   case PIPE_SHADER_FRAGMENT:
+      trace_dump_call_begin("pipe_context", "bind_fragment_sampler_states");
+      break;
+   default:
+      debug_error("Unexpected shader in trace_context_bind_sampler_states()");
+   }
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(uint, num_states);
    trace_dump_arg_array(ptr, states, num_states);
 
-   pipe->bind_fragment_sampler_states(pipe, num_states, states);
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      pipe->bind_vertex_sampler_states(pipe, num_states, states);
+      break;
+   case PIPE_SHADER_GEOMETRY:
+      pipe->bind_geometry_sampler_states(pipe, num_states, states);
+      break;
+   case PIPE_SHADER_FRAGMENT:
+      pipe->bind_fragment_sampler_states(pipe, num_states, states);
+      break;
+   default:
+      debug_error("Unexpected shader in trace_context_bind_sampler_states()");
+   }
 
    trace_dump_call_end();
 }
 
 
 static INLINE void
-trace_context_bind_vertex_sampler_states(struct pipe_context *_pipe,
-                                         unsigned num_states,
-                                         void **states)
+trace_context_bind_fragment_sampler_states(struct pipe_context *_pipe,
+                                           unsigned num,
+                                           void **states)
 {
-   struct trace_context *tr_ctx = trace_context(_pipe);
-   struct pipe_context *pipe = tr_ctx->pipe;
-
-   if (!pipe->bind_vertex_sampler_states)
-      return;
-
-   trace_dump_call_begin("pipe_context", "bind_vertex_sampler_states");
-
-   trace_dump_arg(ptr, pipe);
-   trace_dump_arg(uint, num_states);
-   trace_dump_arg_array(ptr, states, num_states);
+   trace_context_bind_sampler_states(_pipe, PIPE_SHADER_FRAGMENT, num, states);
+}
 
-   pipe->bind_vertex_sampler_states(pipe, num_states, states);
 
-   trace_dump_call_end();
+static INLINE void
+trace_context_bind_vertex_sampler_states(struct pipe_context *_pipe,
+                                         unsigned num,
+                                         void **states)
+{
+   trace_context_bind_sampler_states(_pipe, PIPE_SHADER_VERTEX, num, states);
 }
 
 
@@ -962,9 +982,10 @@ trace_context_surface_destroy(struct pipe_context *_pipe,
 
 
 static INLINE void
-trace_context_set_fragment_sampler_views(struct pipe_context *_pipe,
-                                         unsigned num,
-                                         struct pipe_sampler_view **views)
+trace_context_set_sampler_views(struct pipe_context *_pipe,
+                                unsigned shader,
+                                unsigned num,
+                                struct pipe_sampler_view **views)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
    struct trace_sampler_view *tr_view;
@@ -978,47 +999,58 @@ trace_context_set_fragment_sampler_views(struct pipe_context *_pipe,
    }
    views = unwrapped_views;
 
-   trace_dump_call_begin("pipe_context", "set_fragment_sampler_views");
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      trace_dump_call_begin("pipe_context", "set_vertex_sampler_views");
+      break;
+   case PIPE_SHADER_GEOMETRY:
+      trace_dump_call_begin("pipe_context", "set_geometry_sampler_views");
+      break;
+   case PIPE_SHADER_FRAGMENT:
+      trace_dump_call_begin("pipe_context", "set_fragment_sampler_views");
+      break;
+   default:
+      debug_error("Unexpected shader in trace_context_set_sampler_views()");
+   }
 
    trace_dump_arg(ptr, pipe);
+   /*trace_dump_arg(uint, shader);*/
    trace_dump_arg(uint, num);
    trace_dump_arg_array(ptr, views, num);
 
-   pipe->set_fragment_sampler_views(pipe, num, views);
+   switch (shader) {
+   case PIPE_SHADER_VERTEX:
+      pipe->set_vertex_sampler_views(pipe, num, views);
+      break;
+   case PIPE_SHADER_GEOMETRY:
+      pipe->set_geometry_sampler_views(pipe, num, views);
+      break;
+   case PIPE_SHADER_FRAGMENT:
+      pipe->set_fragment_sampler_views(pipe, num, views);
+      break;
+   default:
+      debug_error("Unexpected shader in trace_context_set_sampler_views()");
+   }
 
    trace_dump_call_end();
 }
 
 
+static INLINE void
+trace_context_set_fragment_sampler_views(struct pipe_context *_pipe,
+                                         unsigned num,
+                                         struct pipe_sampler_view **views)
+{
+   trace_context_set_sampler_views(_pipe, PIPE_SHADER_FRAGMENT, num, views);
+}
+
+
 static INLINE void
 trace_context_set_vertex_sampler_views(struct pipe_context *_pipe,
                                        unsigned num,
                                        struct pipe_sampler_view **views)
 {
-   struct trace_context *tr_ctx = trace_context(_pipe);
-   struct trace_sampler_view *tr_view;
-   struct pipe_context *pipe = tr_ctx->pipe;
-   struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
-   unsigned i;
-
-   if (!pipe->set_vertex_sampler_views)
-      return;
-
-   for(i = 0; i < num; ++i) {
-      tr_view = trace_sampler_view(views[i]);
-      unwrapped_views[i] = tr_view ? tr_view->sampler_view : NULL;
-   }
-   views = unwrapped_views;
-
-   trace_dump_call_begin("pipe_context", "set_vertex_sampler_views");
-
-   trace_dump_arg(ptr, pipe);
-   trace_dump_arg(uint, num);
-   trace_dump_arg_array(ptr, views, num);
-
-   pipe->set_vertex_sampler_views(pipe, num, views);
-
-   trace_dump_call_end();
+   trace_context_set_sampler_views(_pipe, PIPE_SHADER_VERTEX, num, views);
 }