rbug: Fix sampler views and surfaces in context info
authorJakob Bornecrantz <jakob@vmware.com>
Wed, 12 May 2010 14:33:40 +0000 (15:33 +0100)
committerJakob Bornecrantz <jakob@vmware.com>
Wed, 12 May 2010 19:15:23 +0000 (20:15 +0100)
src/gallium/drivers/rbug/rbug_context.c
src/gallium/drivers/rbug/rbug_context.h
src/gallium/drivers/rbug/rbug_core.c
src/gallium/drivers/rbug/rbug_objects.c

index 158904d2344c44b101464a862731828c819da26d..323d6d6dd6c670fa34bf70efdcb0a0eb22b02716 100644 (file)
@@ -535,13 +535,19 @@ rbug_set_framebuffer_state(struct pipe_context *_pipe,
    struct pipe_framebuffer_state *state = NULL;
    unsigned i;
 
+   rb_pipe->curr.nr_cbufs = 0;
+   memset(rb_pipe->curr.cbufs, 0, sizeof(rb_pipe->curr.cbufs));
+
    /* unwrap the input state */
    if (_state) {
       memcpy(&unwrapped_state, _state, sizeof(unwrapped_state));
-      for(i = 0; i < _state->nr_cbufs; i++)
+
+      rb_pipe->curr.nr_cbufs = _state->nr_cbufs;
+      for(i = 0; i < _state->nr_cbufs; i++) {
          unwrapped_state.cbufs[i] = rbug_surface_unwrap(_state->cbufs[i]);
-      for (; i < PIPE_MAX_COLOR_BUFS; i++)
-         unwrapped_state.cbufs[i] = NULL;
+         if (_state->cbufs[i])
+            rb_pipe->curr.cbufs[i] = rbug_resource(_state->cbufs[i]->texture);
+      }
       unwrapped_state.zsbuf = rbug_surface_unwrap(_state->zsbuf);
       state = &unwrapped_state;
    }
@@ -594,12 +600,18 @@ rbug_set_fragment_sampler_views(struct pipe_context *_pipe,
    struct pipe_sampler_view **views = NULL;
    unsigned i;
 
+   rb_pipe->curr.num_fs_views = 0;
+   memset(rb_pipe->curr.fs_views, 0, sizeof(rb_pipe->curr.fs_views));
+   memset(rb_pipe->curr.fs_texs, 0, sizeof(rb_pipe->curr.fs_texs));
+   memset(unwrapped_views, 0, sizeof(unwrapped_views));
+
    if (_views) {
-      for (i = 0; i < num; i++)
+      rb_pipe->curr.num_fs_views = num;
+      for (i = 0; i < num; i++) {
+         rb_pipe->curr.fs_views[i] = rbug_sampler_view(_views[i]);
+         rb_pipe->curr.fs_texs[i] = rbug_resource(_views[i] ? _views[i]->texture : NULL);
          unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]);
-      for (; i < PIPE_MAX_SAMPLERS; i++)
-         unwrapped_views[i] = NULL;
-
+      }
       views = unwrapped_views;
    }
 
@@ -617,12 +629,18 @@ rbug_set_vertex_sampler_views(struct pipe_context *_pipe,
    struct pipe_sampler_view **views = NULL;
    unsigned i;
 
+   rb_pipe->curr.num_vs_views = 0;
+   memset(rb_pipe->curr.vs_views, 0, sizeof(rb_pipe->curr.vs_views));
+   memset(rb_pipe->curr.vs_texs, 0, sizeof(rb_pipe->curr.vs_texs));
+   memset(unwrapped_views, 0, sizeof(unwrapped_views));
+
    if (_views) {
-      for (i = 0; i < num; i++)
+      rb_pipe->curr.num_vs_views = num;
+      for (i = 0; i < num; i++) {
+         rb_pipe->curr.vs_views[i] = rbug_sampler_view(_views[i]);
+         rb_pipe->curr.vs_texs[i] = rbug_resource(_views[i]->texture);
          unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]);
-      for (; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
-         unwrapped_views[i] = NULL;
-
+      }
       views = unwrapped_views;
    }
 
index ccba3c192542070812f93ef352b3f0df0a475cfd..0c99d60f2db8e098054ac5b7df4b79a113cfda9f 100644 (file)
@@ -50,11 +50,13 @@ struct rbug_context {
       struct rbug_shader *vs;
       struct rbug_shader *gs;
 
-      struct rbug_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
-      unsigned num_sampler_views;
+      struct rbug_sampler_view *fs_views[PIPE_MAX_SAMPLERS];
+      struct rbug_resource *fs_texs[PIPE_MAX_SAMPLERS];
+      unsigned num_fs_views;
 
-      struct rbug_sampler_view *vert_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
-      unsigned num_vert_sampler_views;
+      struct rbug_sampler_view *vs_views[PIPE_MAX_VERTEX_SAMPLERS];
+      struct rbug_resource *vs_texs[PIPE_MAX_VERTEX_SAMPLERS];
+      unsigned num_vs_views;
 
       unsigned nr_cbufs;
       struct rbug_resource *cbufs[PIPE_MAX_COLOR_BUFS];
index 13aa95a59b7e210b529b6b8e6366123ef33637be..503183518c9324aebf6b30c97839bcf62b62dc20 100644 (file)
@@ -337,12 +337,12 @@ rbug_context_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
    for (i = 0; i < rb_context->curr.nr_cbufs; i++)
       cbufs[i] = VOID2U64(rb_context->curr.cbufs[i]);
 
-   for (i = 0; i < rb_context->curr.num_sampler_views; i++)
-      texs[i] = VOID2U64(rb_context->curr.sampler_views[i]);
+   for (i = 0; i < rb_context->curr.num_fs_views; i++)
+      texs[i] = VOID2U64(rb_context->curr.fs_texs[i]);
 
    rbug_send_context_info_reply(tr_rbug->con, serial,
                                 VOID2U64(rb_context->curr.vs), VOID2U64(rb_context->curr.fs),
-                                texs, rb_context->curr.num_sampler_views,
+                                texs, rb_context->curr.num_fs_views,
                                 cbufs, rb_context->curr.nr_cbufs,
                                 VOID2U64(rb_context->curr.zsbuf),
                                 rb_context->draw_blocker, rb_context->draw_blocked, NULL);
index d963baab4177a04d03cc143a547b96999ab3f46f..0979fcff957590db2f35f405d56687db4452f31b 100644 (file)
@@ -133,7 +133,7 @@ rbug_sampler_view_create(struct rbug_context *rb_context,
    rb_view->base = *view;
    rb_view->base.reference.count = 1;
    rb_view->base.texture = NULL;
-   pipe_resource_reference(&rb_view->base.texture, rb_resource->resource);
+   pipe_resource_reference(&rb_view->base.texture, &rb_resource->base);
    rb_view->base.context = rb_context->pipe;
    rb_view->sampler_view = view;