r300g: add get_cs_info winsys entrypoint, abandon check_cs
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 85e45d8..88ce186 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -236,6 +236,14 @@
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 efc6df3..97b69e7 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -490,6 +490,7 @@
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 996a4f4..6739f67 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 4271655..3f66f75 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -173,7 +173,7 @@
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 3d0413f..f7cbbde 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -47,6 +47,13 @@
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 @@
* 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 e188f7e..ecee1ee 100644
--- a/src/gallium/winsys/radeon/drm/radeon_r300.c
+++ b/src/gallium/winsys/radeon/drm/radeon_r300.c
@@ -183,12 +183,15 @@
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 @@
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;