summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/r300/r300_context.c8
-rw-r--r--src/gallium/drivers/r300/r300_context.h1
-rw-r--r--src/gallium/drivers/r300/r300_cs.h2
-rw-r--r--src/gallium/drivers/r300/r300_render.c2
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h12
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_r300.c9
6 files changed, 27 insertions, 7 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 85e45d8647d..88ce1867982 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -236,6 +236,14 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
return NULL;
}
+boolean r300_check_cs(struct r300_context *r300, unsigned size)
+{
+ struct r300_cs_info cs_info;
+
+ r300->rws->get_cs_info(r300->rws, &cs_info);
+ return size <= cs_info.free;
+}
+
void r300_finish(struct r300_context *r300)
{
struct pipe_framebuffer_state *fb;
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index efc6df3fabf..97b69e76527 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -490,6 +490,7 @@ void r300_init_render_functions(struct r300_context *r300);
void r300_init_state_functions(struct r300_context* r300);
void r300_init_resource_functions(struct r300_context* r300);
+boolean r300_check_cs(struct r300_context *r300, unsigned size);
void r300_finish(struct r300_context *r300);
void r500_dump_rs_block(struct r300_rs_block *rs);
diff --git a/src/gallium/drivers/r300/r300_cs.h b/src/gallium/drivers/r300/r300_cs.h
index 996a4f491e7..6739f6703ac 100644
--- a/src/gallium/drivers/r300/r300_cs.h
+++ b/src/gallium/drivers/r300/r300_cs.h
@@ -54,7 +54,7 @@
int cs_count = 0; (void) cs_count;
#define CHECK_CS(size) \
- assert(cs_winsys->check_cs(cs_winsys, (size)))
+ assert(r300_check_cs(cs_context_copy, (size)))
#define BEGIN_CS(size) do { \
CHECK_CS(size); \
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 42716552c7f..3f66f75943e 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -173,7 +173,7 @@ static void r300_prepare_for_rendering(struct r300_context *r300,
cs_dwords += 26; /* emit_query_end */
/* Reserve requested CS space. */
- if (!r300->rws->check_cs(r300->rws, cs_dwords)) {
+ if (!r300_check_cs(r300, cs_dwords)) {
r300->context.flush(&r300->context, 0, NULL);
flushed = TRUE;
}
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index 3d0413f90af..f7cbbde410a 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -47,6 +47,13 @@ enum r300_reference_domain { /* bitfield */
R300_REF_HW = 2
};
+struct r300_cs_info {
+ /* In DWORDs. */
+ unsigned used;
+ unsigned free;
+ unsigned capacity;
+};
+
struct r300_winsys_screen {
void (*destroy)(struct r300_winsys_screen *ws);
@@ -101,8 +108,9 @@ struct r300_winsys_screen {
* Returns TRUE if a flush is required. */
boolean (*validate)(struct r300_winsys_screen* winsys);
- /* Check to see if there's room for commands. */
- boolean (*check_cs)(struct r300_winsys_screen* winsys, int size);
+ /* Return current CS info. */
+ void (*get_cs_info)(struct r300_winsys_screen *winsys,
+ struct r300_cs_info *info);
/* Start a command emit. */
void (*begin_cs)(struct r300_winsys_screen* winsys,
diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c
index e188f7e7ccd..ecee1ee73db 100644
--- a/src/gallium/winsys/radeon/drm/radeon_r300.c
+++ b/src/gallium/winsys/radeon/drm/radeon_r300.c
@@ -183,12 +183,15 @@ static boolean radeon_validate(struct r300_winsys_screen *rws)
return TRUE;
}
-static boolean radeon_check_cs(struct r300_winsys_screen *rws, int size)
+static void radeon_get_cs_info(struct r300_winsys_screen *rws,
+ struct r300_cs_info *info)
{
struct radeon_libdrm_winsys *ws = radeon_winsys_screen(rws);
struct radeon_cs *cs = ws->cs;
- return cs->cdw + size <= cs->ndw;
+ info->capacity = cs->ndw;
+ info->used = cs->cdw;
+ info->free = cs->ndw - cs->cdw;
}
static void radeon_begin_cs(struct r300_winsys_screen *rws,
@@ -333,7 +336,7 @@ radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws)
ws->base.add_buffer = radeon_add_buffer;
ws->base.validate = radeon_validate;
ws->base.destroy = radeon_winsys_destroy;
- ws->base.check_cs = radeon_check_cs;
+ ws->base.get_cs_info = radeon_get_cs_info;
ws->base.begin_cs = radeon_begin_cs;
ws->base.write_cs_dword = radeon_write_cs_dword;
ws->base.write_cs_table = radeon_write_cs_table;