rbug: update data structures, functions for future changes

To support geom/compute/etc shaders, samplers, sampler views, etc.
To support pipe->bind_sampler_states() w/ start_slot.
This commit is contained in:
Brian Paul
2012-08-09 20:59:44 -06:00
parent 109e87dc6a
commit 10e552d056
3 changed files with 71 additions and 76 deletions

View File

@@ -62,17 +62,21 @@ rbug_draw_block_locked(struct rbug_context *rb_pipe, int flag)
(rb_pipe->draw_blocker & RBUG_BLOCK_RULE)) { (rb_pipe->draw_blocker & RBUG_BLOCK_RULE)) {
int k; int k;
boolean block = FALSE; boolean block = FALSE;
unsigned sh;
debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__, debug_printf("%s (%p %p) (%p %p) (%p %u) (%p %u)\n", __FUNCTION__,
(void *) rb_pipe->draw_rule.fs, (void *) rb_pipe->curr.fs, (void *) rb_pipe->draw_rule.shader[PIPE_SHADER_FRAGMENT],
(void *) rb_pipe->draw_rule.vs, (void *) rb_pipe->curr.vs, (void *) rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT],
(void *) rb_pipe->draw_rule.shader[PIPE_SHADER_VERTEX],
(void *) rb_pipe->curr.shader[PIPE_SHADER_VERTEX],
(void *) rb_pipe->draw_rule.surf, 0, (void *) rb_pipe->draw_rule.surf, 0,
(void *) rb_pipe->draw_rule.texture, 0); (void *) rb_pipe->draw_rule.texture, 0);
if (rb_pipe->draw_rule.fs && for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) {
rb_pipe->draw_rule.fs == rb_pipe->curr.fs) if (rb_pipe->draw_rule.shader[sh] &&
block = TRUE; rb_pipe->draw_rule.shader[sh] == rb_pipe->curr.shader[sh])
if (rb_pipe->draw_rule.vs && block = TRUE;
rb_pipe->draw_rule.vs == rb_pipe->curr.vs) }
block = TRUE;
if (rb_pipe->draw_rule.surf && if (rb_pipe->draw_rule.surf &&
rb_pipe->draw_rule.surf == rb_pipe->curr.zsbuf) rb_pipe->draw_rule.surf == rb_pipe->curr.zsbuf)
block = TRUE; block = TRUE;
@@ -81,12 +85,13 @@ rbug_draw_block_locked(struct rbug_context *rb_pipe, int flag)
if (rb_pipe->draw_rule.surf == rb_pipe->curr.cbufs[k]) if (rb_pipe->draw_rule.surf == rb_pipe->curr.cbufs[k])
block = TRUE; block = TRUE;
if (rb_pipe->draw_rule.texture) { if (rb_pipe->draw_rule.texture) {
for (k = 0; k < rb_pipe->curr.num_fs_views; k++) for (sh = 0; sh < Elements(rb_pipe->curr.num_views); sh++) {
if (rb_pipe->draw_rule.texture == rb_pipe->curr.fs_texs[k]) for (k = 0; k < rb_pipe->curr.num_views[sh]; k++) {
block = TRUE; if (rb_pipe->draw_rule.texture == rb_pipe->curr.texs[sh][k]) {
for (k = 0; k < rb_pipe->curr.num_vs_views; k++) { block = TRUE;
if (rb_pipe->draw_rule.texture == rb_pipe->curr.vs_texs[k]) { sh = PIPE_SHADER_TYPES; /* to break out of both loops */
block = TRUE; break;
}
} }
} }
} }
@@ -116,9 +121,10 @@ rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info)
rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE); rbug_draw_block_locked(rb_pipe, RBUG_BLOCK_BEFORE);
pipe_mutex_lock(rb_pipe->call_mutex); pipe_mutex_lock(rb_pipe->call_mutex);
if (!(rb_pipe->curr.fs && rb_pipe->curr.fs->disabled) && /* XXX loop over PIPE_SHADER_x here */
!(rb_pipe->curr.gs && rb_pipe->curr.gs->disabled) && if (!(rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] && rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT]->disabled) &&
!(rb_pipe->curr.vs && rb_pipe->curr.vs->disabled)) !(rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] && rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY]->disabled) &&
!(rb_pipe->curr.shader[PIPE_SHADER_VERTEX] && rb_pipe->curr.shader[PIPE_SHADER_VERTEX]->disabled))
pipe->draw_vbo(pipe, info); pipe->draw_vbo(pipe, info);
pipe_mutex_unlock(rb_pipe->call_mutex); pipe_mutex_unlock(rb_pipe->call_mutex);
@@ -412,7 +418,7 @@ rbug_bind_fs_state(struct pipe_context *_pipe,
pipe_mutex_lock(rb_pipe->call_mutex); pipe_mutex_lock(rb_pipe->call_mutex);
fs = rbug_shader_unwrap(_fs); fs = rbug_shader_unwrap(_fs);
rb_pipe->curr.fs = rbug_shader(_fs); rb_pipe->curr.shader[PIPE_SHADER_FRAGMENT] = rbug_shader(_fs);
pipe->bind_fs_state(pipe, pipe->bind_fs_state(pipe,
fs); fs);
@@ -460,7 +466,7 @@ rbug_bind_vs_state(struct pipe_context *_pipe,
pipe_mutex_lock(rb_pipe->call_mutex); pipe_mutex_lock(rb_pipe->call_mutex);
vs = rbug_shader_unwrap(_vs); vs = rbug_shader_unwrap(_vs);
rb_pipe->curr.vs = rbug_shader(_vs); rb_pipe->curr.shader[PIPE_SHADER_VERTEX] = rbug_shader(_vs);
pipe->bind_vs_state(pipe, pipe->bind_vs_state(pipe,
vs); vs);
@@ -508,7 +514,7 @@ rbug_bind_gs_state(struct pipe_context *_pipe,
pipe_mutex_lock(rb_pipe->call_mutex); pipe_mutex_lock(rb_pipe->call_mutex);
gs = rbug_shader_unwrap(_gs); gs = rbug_shader_unwrap(_gs);
rb_pipe->curr.gs = rbug_shader(_gs); rb_pipe->curr.shader[PIPE_SHADER_GEOMETRY] = rbug_shader(_gs);
pipe->bind_gs_state(pipe, pipe->bind_gs_state(pipe,
gs); gs);
@@ -713,9 +719,11 @@ rbug_set_viewport_state(struct pipe_context *_pipe,
} }
static void static void
rbug_set_fragment_sampler_views(struct pipe_context *_pipe, rbug_set_sampler_views(struct pipe_context *_pipe,
unsigned num, unsigned shader,
struct pipe_sampler_view **_views) unsigned start,
unsigned num,
struct pipe_sampler_view **_views)
{ {
struct rbug_context *rb_pipe = rbug_context(_pipe); struct rbug_context *rb_pipe = rbug_context(_pipe);
struct pipe_context *pipe = rb_pipe->pipe; struct pipe_context *pipe = rb_pipe->pipe;
@@ -723,25 +731,36 @@ rbug_set_fragment_sampler_views(struct pipe_context *_pipe,
struct pipe_sampler_view **views = NULL; struct pipe_sampler_view **views = NULL;
unsigned i; unsigned i;
assert(start == 0); /* XXX fix */
/* must protect curr status */ /* must protect curr status */
pipe_mutex_lock(rb_pipe->call_mutex); pipe_mutex_lock(rb_pipe->call_mutex);
rb_pipe->curr.num_fs_views = 0; rb_pipe->curr.num_views[shader] = 0;
memset(rb_pipe->curr.fs_views, 0, sizeof(rb_pipe->curr.fs_views)); memset(rb_pipe->curr.views[shader], 0, sizeof(rb_pipe->curr.views[shader]));
memset(rb_pipe->curr.fs_texs, 0, sizeof(rb_pipe->curr.fs_texs)); memset(rb_pipe->curr.texs[shader], 0, sizeof(rb_pipe->curr.texs[shader]));
memset(unwrapped_views, 0, sizeof(unwrapped_views)); memset(unwrapped_views, 0, sizeof(unwrapped_views));
if (_views) { if (_views) {
rb_pipe->curr.num_fs_views = num; rb_pipe->curr.num_views[shader] = num;
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
rb_pipe->curr.fs_views[i] = rbug_sampler_view(_views[i]); rb_pipe->curr.views[shader][i] = rbug_sampler_view(_views[i]);
rb_pipe->curr.fs_texs[i] = rbug_resource(_views[i] ? _views[i]->texture : NULL); rb_pipe->curr.texs[shader][i] = rbug_resource(_views[i] ? _views[i]->texture : NULL);
unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]); unwrapped_views[i] = rbug_sampler_view_unwrap(_views[i]);
} }
views = unwrapped_views; views = unwrapped_views;
} }
pipe->set_fragment_sampler_views(pipe, num, views); switch (shader) {
case PIPE_SHADER_VERTEX:
pipe->set_vertex_sampler_views(pipe, num, views);
break;
case PIPE_SHADER_FRAGMENT:
pipe->set_fragment_sampler_views(pipe, num, views);
break;
default:
assert(0);
}
pipe_mutex_unlock(rb_pipe->call_mutex); pipe_mutex_unlock(rb_pipe->call_mutex);
} }
@@ -751,33 +770,15 @@ rbug_set_vertex_sampler_views(struct pipe_context *_pipe,
unsigned num, unsigned num,
struct pipe_sampler_view **_views) struct pipe_sampler_view **_views)
{ {
struct rbug_context *rb_pipe = rbug_context(_pipe); rbug_set_sampler_views(_pipe, PIPE_SHADER_VERTEX, 0, num, _views);
struct pipe_context *pipe = rb_pipe->pipe; }
struct pipe_sampler_view *unwrapped_views[PIPE_MAX_SAMPLERS];
struct pipe_sampler_view **views = NULL;
unsigned i;
/* must protect curr status */ static void
pipe_mutex_lock(rb_pipe->call_mutex); rbug_set_fragment_sampler_views(struct pipe_context *_pipe,
unsigned num,
rb_pipe->curr.num_vs_views = 0; struct pipe_sampler_view **_views)
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)); rbug_set_sampler_views(_pipe, PIPE_SHADER_FRAGMENT, 0, num, _views);
memset(unwrapped_views, 0, sizeof(unwrapped_views));
if (_views) {
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]);
}
views = unwrapped_views;
}
pipe->set_vertex_sampler_views(pipe, num, views);
pipe_mutex_unlock(rb_pipe->call_mutex);
} }
static void static void

View File

@@ -46,17 +46,11 @@ struct rbug_context {
/* current state */ /* current state */
struct { struct {
struct rbug_shader *fs; struct rbug_shader *shader[PIPE_SHADER_TYPES];
struct rbug_shader *vs;
struct rbug_shader *gs;
struct rbug_sampler_view *fs_views[PIPE_MAX_SAMPLERS]; struct rbug_sampler_view *views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
struct rbug_resource *fs_texs[PIPE_MAX_SAMPLERS]; struct rbug_resource *texs[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
unsigned num_fs_views; unsigned num_views[PIPE_SHADER_TYPES];
struct rbug_sampler_view *vs_views[PIPE_MAX_SAMPLERS];
struct rbug_resource *vs_texs[PIPE_MAX_SAMPLERS];
unsigned num_vs_views;
unsigned nr_cbufs; unsigned nr_cbufs;
struct rbug_resource *cbufs[PIPE_MAX_COLOR_BUFS]; struct rbug_resource *cbufs[PIPE_MAX_COLOR_BUFS];
@@ -71,8 +65,7 @@ struct rbug_context {
int draw_blocked; int draw_blocked;
struct { struct {
struct rbug_shader *fs; struct rbug_shader *shader[PIPE_SHADER_TYPES];
struct rbug_shader *vs;
struct rbug_resource *texture; struct rbug_resource *texture;
struct rbug_resource *surf; struct rbug_resource *surf;

View File

@@ -341,12 +341,13 @@ rbug_context_info(struct rbug_rbug *tr_rbug, struct rbug_header *header, uint32_
for (i = 0; i < rb_context->curr.nr_cbufs; i++) for (i = 0; i < rb_context->curr.nr_cbufs; i++)
cbufs[i] = VOID2U64(rb_context->curr.cbufs[i]); cbufs[i] = VOID2U64(rb_context->curr.cbufs[i]);
for (i = 0; i < rb_context->curr.num_fs_views; i++) /* XXX what about vertex/geometry shader texture views? */
texs[i] = VOID2U64(rb_context->curr.fs_texs[i]); for (i = 0; i < rb_context->curr.num_views[PIPE_SHADER_FRAGMENT]; i++)
texs[i] = VOID2U64(rb_context->curr.texs[PIPE_SHADER_FRAGMENT][i]);
rbug_send_context_info_reply(tr_rbug->con, serial, rbug_send_context_info_reply(tr_rbug->con, serial,
VOID2U64(rb_context->curr.vs), VOID2U64(rb_context->curr.fs), VOID2U64(rb_context->curr.shader[PIPE_SHADER_VERTEX]), VOID2U64(rb_context->curr.shader[PIPE_SHADER_FRAGMENT]),
texs, rb_context->curr.num_fs_views, texs, rb_context->curr.num_views[PIPE_SHADER_FRAGMENT],
cbufs, rb_context->curr.nr_cbufs, cbufs, rb_context->curr.nr_cbufs,
VOID2U64(rb_context->curr.zsbuf), VOID2U64(rb_context->curr.zsbuf),
rb_context->draw_blocker, rb_context->draw_blocked, NULL); rb_context->draw_blocker, rb_context->draw_blocked, NULL);
@@ -465,8 +466,8 @@ rbug_context_draw_rule(struct rbug_rbug *tr_rbug, struct rbug_header *header, ui
} }
pipe_mutex_lock(rb_context->draw_mutex); pipe_mutex_lock(rb_context->draw_mutex);
rb_context->draw_rule.vs = U642VOID(rule->vertex); rb_context->draw_rule.shader[PIPE_SHADER_VERTEX] = U642VOID(rule->vertex);
rb_context->draw_rule.fs = U642VOID(rule->fragment); rb_context->draw_rule.shader[PIPE_SHADER_FRAGMENT] = U642VOID(rule->fragment);
rb_context->draw_rule.texture = U642VOID(rule->texture); rb_context->draw_rule.texture = U642VOID(rule->texture);
rb_context->draw_rule.surf = U642VOID(rule->surface); rb_context->draw_rule.surf = U642VOID(rule->surface);
rb_context->draw_rule.blocker = rule->block; rb_context->draw_rule.blocker = rule->block;
@@ -665,7 +666,7 @@ rbug_shader_replace(struct rbug_rbug *tr_rbug, struct rbug_header *header)
/* remove old replaced shader */ /* remove old replaced shader */
if (tr_shdr->replaced_shader) { if (tr_shdr->replaced_shader) {
/* if this shader is bound rebind the original shader */ /* if this shader is bound rebind the original shader */
if (rb_context->curr.fs == tr_shdr || rb_context->curr.vs == tr_shdr) if (rb_context->curr.shader[PIPE_SHADER_FRAGMENT] == tr_shdr || rb_context->curr.shader[PIPE_SHADER_VERTEX] == tr_shdr)
rbug_shader_bind_locked(pipe, tr_shdr, tr_shdr->shader); rbug_shader_bind_locked(pipe, tr_shdr, tr_shdr->shader);
FREE(tr_shdr->replaced_tokens); FREE(tr_shdr->replaced_tokens);
@@ -687,7 +688,7 @@ rbug_shader_replace(struct rbug_rbug *tr_rbug, struct rbug_header *header)
goto err; goto err;
/* bind new shader if the shader is currently a bound */ /* bind new shader if the shader is currently a bound */
if (rb_context->curr.fs == tr_shdr || rb_context->curr.vs == tr_shdr) if (rb_context->curr.shader[PIPE_SHADER_FRAGMENT] == tr_shdr || rb_context->curr.shader[PIPE_SHADER_VERTEX] == tr_shdr)
rbug_shader_bind_locked(pipe, tr_shdr, state); rbug_shader_bind_locked(pipe, tr_shdr, state);
/* save state */ /* save state */