[Mesa-dev] [PATCH 2/2] i965: Use new vtable entries for surface state updating functions.
Kenneth Graunke
kenneth at whitecape.org
Tue Nov 8 10:39:45 PST 2011
Now that we have vtable entries in place, we should use them. This
allows us to drop the cut and pasted Gen7 brw_tracked_state atoms as
they now do exactly the same thing as their brw_wm_surface_state
counterparts.
Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_state_upload.c | 4 +-
src/mesa/drivers/dri/i965/brw_vs_surface_state.c | 10 +--
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 16 ++--
src/mesa/drivers/dri/i965/gen7_wm_surface_state.c | 109 ---------------------
4 files changed, 13 insertions(+), 126 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 79d9188..2f16891 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -204,8 +204,8 @@ const struct brw_tracked_state *gen7_atoms[] =
&gen6_wm_constants, /* Before wm_surfaces and constant_buffer */
&brw_vs_surfaces, /* must do before unit */
- &gen7_wm_constant_surface, /* must do before wm surfaces/bind bo */
- &gen7_wm_surfaces, /* must do before samplers and unit */
+ &brw_wm_constant_surface, /* must do before wm surfaces/bind bo */
+ &brw_wm_surfaces, /* must do before samplers and unit */
&brw_wm_binding_table,
&gen7_samplers,
diff --git a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
index f838daa..8c63db8 100644
--- a/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_vs_surface_state.c
@@ -129,13 +129,9 @@ brw_update_vs_constant_surface( struct gl_context *ctx,
return;
}
- if (intel->gen >= 7) {
- gen7_create_constant_surface(brw, brw->vs.const_bo, params->NumParameters,
- &brw->vs.surf_offset[surf]);
- } else {
- brw_create_constant_surface(brw, brw->vs.const_bo, params->NumParameters,
- &brw->vs.surf_offset[surf]);
- }
+ intel->vtbl.create_constant_surface(brw, brw->vs.const_bo,
+ params->NumParameters,
+ &brw->vs.surf_offset[surf]);
}
/**
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
index b429802..534c127 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c
@@ -395,8 +395,9 @@ static void upload_wm_constant_surface(struct brw_context *brw )
return;
}
- brw_create_constant_surface(brw, brw->wm.const_bo, params->NumParameters,
- &brw->wm.surf_offset[surf]);
+ brw->intel.vtbl.create_constant_surface(brw, brw->wm.const_bo,
+ params->NumParameters,
+ &brw->wm.surf_offset[surf]);
brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
}
@@ -548,6 +549,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
static void
brw_upload_wm_surfaces(struct brw_context *brw)
{
+ struct intel_context *intel = &brw->intel;
struct gl_context *ctx = &brw->intel.ctx;
GLuint i;
int nr_surfaces = 0;
@@ -557,16 +559,14 @@ brw_upload_wm_surfaces(struct brw_context *brw)
if (ctx->DrawBuffer->_NumColorDrawBuffers >= 1) {
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
if (intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i])) {
- brw_update_renderbuffer_surface(brw,
- ctx->DrawBuffer->_ColorDrawBuffers[i],
- i);
+ intel->vtbl.update_renderbuffer_surface(brw, ctx->DrawBuffer->_ColorDrawBuffers[i], i);
} else {
- brw_update_null_renderbuffer_surface(brw, i);
+ intel->vtbl.update_null_renderbuffer_surface(brw, i);
}
}
nr_surfaces = SURF_INDEX_DRAW(ctx->DrawBuffer->_NumColorDrawBuffers);
} else {
- brw_update_null_renderbuffer_surface(brw, 0);
+ intel->vtbl.update_null_renderbuffer_surface(brw, 0);
nr_surfaces = SURF_INDEX_DRAW(0) + 1;
}
@@ -582,7 +582,7 @@ brw_upload_wm_surfaces(struct brw_context *brw)
/* _NEW_TEXTURE */
if (texUnit->_ReallyEnabled) {
- brw_update_texture_surface(ctx, i);
+ intel->vtbl.update_texture_surface(ctx, i);
nr_surfaces = SURF_INDEX_TEXTURE(i) + 1;
} else {
brw->wm.surf_offset[surf] = 0;
diff --git a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
index 3ae9236..b4730c4 100644
--- a/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
+++ b/src/mesa/drivers/dri/i965/gen7_wm_surface_state.c
@@ -166,48 +166,6 @@ gen7_create_constant_surface(struct brw_context *brw,
I915_GEM_DOMAIN_SAMPLER, 0);
}
-/**
- * Updates surface / buffer for fragment shader constant buffer, if
- * one is required.
- *
- * This consumes the state updates for the constant buffer, and produces
- * BRW_NEW_WM_SURFACES to get picked up by brw_prepare_wm_surfaces for
- * inclusion in the binding table.
- */
-static void upload_wm_constant_surface(struct brw_context *brw)
-{
- GLuint surf = SURF_INDEX_FRAG_CONST_BUFFER;
- struct brw_fragment_program *fp =
- (struct brw_fragment_program *) brw->fragment_program;
- const struct gl_program_parameter_list *params =
- fp->program.Base.Parameters;
-
- /* If there's no constant buffer, then no surface BO is needed to point at
- * it.
- */
- if (brw->wm.const_bo == 0) {
- if (brw->wm.surf_offset[surf]) {
- brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
- brw->wm.surf_offset[surf] = 0;
- }
- return;
- }
-
- gen7_create_constant_surface(brw, brw->wm.const_bo, params->NumParameters,
- &brw->wm.surf_offset[surf]);
- brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
-}
-
-const struct brw_tracked_state gen7_wm_constant_surface = {
- .dirty = {
- .mesa = 0,
- .brw = (BRW_NEW_WM_CONSTBUF |
- BRW_NEW_BATCH),
- .cache = 0
- },
- .emit = upload_wm_constant_surface,
-};
-
static void
gen7_update_null_renderbuffer_surface(struct brw_context *brw, unsigned unit)
{
@@ -302,73 +260,6 @@ gen7_update_renderbuffer_surface(struct brw_context *brw,
I915_GEM_DOMAIN_RENDER);
}
-/**
- * Constructs the set of surface state objects pointed to by the
- * binding table.
- */
-static void
-gen7_upload_wm_surfaces(struct brw_context *brw)
-{
- struct gl_context *ctx = &brw->intel.ctx;
- GLuint i;
- int nr_surfaces = 0;
-
- /* _NEW_BUFFERS | _NEW_COLOR */
- /* Update surfaces for drawing buffers */
- if (ctx->DrawBuffer->_NumColorDrawBuffers >= 1) {
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- if (intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i])) {
- gen7_update_renderbuffer_surface(brw,
- ctx->DrawBuffer->_ColorDrawBuffers[i], i);
- } else {
- gen7_update_null_renderbuffer_surface(brw, i);
- }
- }
- nr_surfaces = SURF_INDEX_DRAW(ctx->DrawBuffer->_NumColorDrawBuffers);
- } else {
- gen7_update_null_renderbuffer_surface(brw, 0);
- nr_surfaces = SURF_INDEX_DRAW(0) + 1;
- }
-
- /* BRW_NEW_WM_CONSTBUF */
- if (brw->wm.const_bo) {
- nr_surfaces = SURF_INDEX_FRAG_CONST_BUFFER + 1;
- }
-
- /* Update surfaces for textures */
- for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
- const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
- const GLuint surf = SURF_INDEX_TEXTURE(i);
-
- /* _NEW_TEXTURE */
- if (texUnit->_ReallyEnabled) {
- gen7_update_texture_surface(ctx, i);
- nr_surfaces = SURF_INDEX_TEXTURE(i) + 1;
- } else {
- brw->wm.surf_offset[surf] = 0;
- }
- }
-
- if (brw->wm.nr_surfaces != nr_surfaces) {
- brw->wm.nr_surfaces = nr_surfaces;
- brw->state.dirty.brw |= BRW_NEW_NR_WM_SURFACES;
- }
-
- brw->state.dirty.brw |= BRW_NEW_WM_SURFACES;
-}
-
-const struct brw_tracked_state gen7_wm_surfaces = {
- .dirty = {
- .mesa = (_NEW_COLOR |
- _NEW_TEXTURE |
- _NEW_BUFFERS),
- .brw = (BRW_NEW_BATCH |
- BRW_NEW_WM_CONSTBUF),
- .cache = 0
- },
- .emit = gen7_upload_wm_surfaces,
-};
-
void
gen7_init_vtable_surface_functions(struct brw_context *brw)
{
--
1.7.7.1
More information about the mesa-dev
mailing list