summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r600
diff options
context:
space:
mode:
authorJerome Glisse <[email protected]>2010-09-21 14:36:44 -0400
committerJerome Glisse <[email protected]>2010-09-21 14:37:38 -0400
commit6048be89697fe27e30ef0f45594daba4e896362c (patch)
treebbec15d43210d8a3fa5ba3ce51c4e406023b4a15 /src/gallium/drivers/r600
parentb5bb21562942dab7571ef748c3ca562a66f25b33 (diff)
r600g: directly allocate bo for user buffer
Signed-off-by: Jerome Glisse <[email protected]>
Diffstat (limited to 'src/gallium/drivers/r600')
-rw-r--r--src/gallium/drivers/r600/r600.h4
-rw-r--r--src/gallium/drivers/r600/r600_state2.c38
2 files changed, 39 insertions, 3 deletions
diff --git a/src/gallium/drivers/r600/r600.h b/src/gallium/drivers/r600/r600.h
index a123eb62e0f..8879efca794 100644
--- a/src/gallium/drivers/r600/r600.h
+++ b/src/gallium/drivers/r600/r600.h
@@ -192,6 +192,8 @@ struct r600_reloc {
};
#pragma pack()
+struct radeon_bo;
+
struct r600_context {
struct radeon *radeon;
unsigned ngroups;
@@ -203,7 +205,7 @@ struct r600_context {
unsigned nreloc;
unsigned creloc;
struct r600_reloc *reloc;
- struct radeon_ws_bo **bo;
+ struct radeon_bo **bo;
u32 *pm4;
};
diff --git a/src/gallium/drivers/r600/r600_state2.c b/src/gallium/drivers/r600/r600_state2.c
index 5269e6db912..36a33760339 100644
--- a/src/gallium/drivers/r600/r600_state2.c
+++ b/src/gallium/drivers/r600/r600_state2.c
@@ -677,7 +677,7 @@ static void r600_flush2(struct pipe_context *ctx, unsigned flags,
struct pipe_fence_handle **fence)
{
struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
-#if 0
+#if 1
static int dc = 0;
char dname[256];
#endif
@@ -2174,11 +2174,44 @@ static int r600_get_shader_param(struct pipe_screen* pscreen, unsigned shader, e
}
}
+struct pipe_resource *r600_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *templ);
+struct pipe_resource *r600_user_buffer_create2(struct pipe_screen *screen,
+ void *ptr, unsigned bytes,
+ unsigned bind)
+{
+ struct pipe_resource *resource;
+ struct r600_resource *rresource;
+ struct pipe_resource desc;
+ struct radeon *radeon = (struct radeon *)screen->winsys;
+ void *rptr;
+
+ desc.screen = screen;
+ desc.target = PIPE_BUFFER;
+ desc.format = PIPE_FORMAT_R8_UNORM;
+ desc.usage = PIPE_USAGE_IMMUTABLE;
+ desc.bind = bind;
+ desc.width0 = bytes;
+ desc.height0 = 1;
+ desc.depth0 = 1;
+ desc.flags = 0;
+ resource = r600_buffer_create(screen, &desc);
+ if (resource == NULL) {
+ return NULL;
+ }
+
+ rresource = (struct r600_resource *)resource;
+ rptr = radeon_ws_bo_map(radeon, rresource->bo, 0, NULL);
+ memcpy(rptr, ptr, bytes);
+ radeon_ws_bo_unmap(radeon, rresource->bo);
+
+ return resource;
+}
+
void r600_init_screen_texture_functions(struct pipe_screen *screen);
struct pipe_screen *r600_screen_create2(struct radeon *radeon)
{
struct r600_screen *rscreen;
- enum radeon_family family = r600_get_family(radeon);
rscreen = CALLOC_STRUCT(r600_screen);
if (rscreen == NULL) {
@@ -2197,6 +2230,7 @@ struct pipe_screen *r600_screen_create2(struct radeon *radeon)
rscreen->screen.context_create = r600_create_context2;
r600_init_screen_texture_functions(&rscreen->screen);
r600_init_screen_resource_functions(&rscreen->screen);
+ rscreen->screen.user_buffer_create = r600_user_buffer_create2;
return &rscreen->screen;
}