summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2013-07-25 09:27:09 -0600
committerBrian Paul <[email protected]>2013-07-31 06:53:48 -0600
commit365f38f3dfef292c4917e10cdf3011f22f37dc51 (patch)
tree770ab210297c6784f6db015893da20c1ae5506e3 /src
parent99c42d11a245d6709b33353c2d88e2640f6d101e (diff)
softpipe: use new softpipe_resource_data() accessor
We should probably be using map()/unmap() when accessing resource data, but this is a little better. v2: assert that the resource is not a display target, per Jose. Reviewed-by: José Fonseca <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c6
-rw-r--r--src/gallium/drivers/softpipe/sp_state_shader.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.h16
3 files changed, 20 insertions, 4 deletions
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 45b1390de4d..6b06f70a16e 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -81,7 +81,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
if (!sp->vertex_buffer[i].buffer) {
continue;
}
- buf = softpipe_resource(sp->vertex_buffer[i].buffer)->data;
+ buf = softpipe_resource_data(sp->vertex_buffer[i].buffer);
size = sp->vertex_buffer[i].buffer->width0;
}
draw_set_mapped_vertex_buffer(draw, i, buf, size);
@@ -92,7 +92,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
unsigned available_space = ~0;
mapped_indices = sp->index_buffer.user_buffer;
if (!mapped_indices) {
- mapped_indices = softpipe_resource(sp->index_buffer.buffer)->data;
+ mapped_indices = softpipe_resource_data(sp->index_buffer.buffer);
if (sp->index_buffer.buffer->width0 > sp->index_buffer.offset)
available_space =
(sp->index_buffer.buffer->width0 - sp->index_buffer.offset);
@@ -107,7 +107,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
for (i = 0; i < sp->num_so_targets; i++) {
- void *buf = softpipe_resource(sp->so_targets[i]->target.buffer)->data;
+ void *buf = softpipe_resource_data(sp->so_targets[i]->target.buffer);
sp->so_targets[i]->mapping = buf;
}
diff --git a/src/gallium/drivers/softpipe/sp_state_shader.c b/src/gallium/drivers/softpipe/sp_state_shader.c
index d80955e696c..eb4b6b1458c 100644
--- a/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -357,7 +357,7 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
}
size = cb ? cb->buffer_size : 0;
- data = constants ? softpipe_resource(constants)->data : NULL;
+ data = constants ? softpipe_resource_data(constants) : NULL;
if (data)
data = (const char *) data + cb->buffer_offset;
diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h
index 533d6252e25..96609f43489 100644
--- a/src/gallium/drivers/softpipe/sp_texture.h
+++ b/src/gallium/drivers/softpipe/sp_texture.h
@@ -93,6 +93,22 @@ softpipe_transfer(struct pipe_transfer *pt)
}
+/**
+ * Return pointer to a resource's actual data.
+ * This is a short-cut instead of using map()/unmap(), which should
+ * probably be fixed.
+ */
+static INLINE void *
+softpipe_resource_data(struct pipe_resource *pt)
+{
+ if (!pt)
+ return NULL;
+
+ assert(softpipe_resource(pt)->dt == NULL);
+ return softpipe_resource(pt)->data;
+}
+
+
extern void
softpipe_init_screen_texture_funcs(struct pipe_screen *screen);