summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/freedreno/freedreno_resource.c
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2017-04-15 10:04:55 -0400
committerRob Clark <[email protected]>2017-04-18 16:32:00 -0400
commit4299849ec7a873edf46a3a366749282fdec020fe (patch)
treed1fdc58b6fc65ad2c9fdbe096a4c3acd4eea3a6b /src/gallium/drivers/freedreno/freedreno_resource.c
parentd7fa7f5e7eafed8bb88f7e0b9ba4261a76ad9c95 (diff)
freedreno: refactor dirty state handling
In particular, move per-shader-stage info out to a seperate array of enum's indexed by shader stage. This will make it easier to add more shader stages as well as new per-stage state (like SSBOs). Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_resource.c')
-rw-r--r--src/gallium/drivers/freedreno/freedreno_resource.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c
index 427ada8b667..3b067095523 100644
--- a/src/gallium/drivers/freedreno/freedreno_resource.c
+++ b/src/gallium/drivers/freedreno/freedreno_resource.c
@@ -51,23 +51,13 @@
static void
fd_invalidate_resource(struct fd_context *ctx, struct pipe_resource *prsc)
{
- int i;
-
/* Go through the entire state and see if the resource is bound
* anywhere. If it is, mark the relevant state as dirty. This is called on
* realloc_bo.
*/
- /* Constbufs */
- for (i = 1; i < PIPE_MAX_CONSTANT_BUFFERS && !(ctx->dirty & FD_DIRTY_CONSTBUF); i++) {
- if (ctx->constbuf[PIPE_SHADER_VERTEX].cb[i].buffer == prsc)
- ctx->dirty |= FD_DIRTY_CONSTBUF;
- if (ctx->constbuf[PIPE_SHADER_FRAGMENT].cb[i].buffer == prsc)
- ctx->dirty |= FD_DIRTY_CONSTBUF;
- }
-
/* VBOs */
- for (i = 0; i < ctx->vtx.vertexbuf.count && !(ctx->dirty & FD_DIRTY_VTXBUF); i++) {
+ for (unsigned i = 0; i < ctx->vtx.vertexbuf.count && !(ctx->dirty & FD_DIRTY_VTXBUF); i++) {
if (ctx->vtx.vertexbuf.vb[i].buffer == prsc)
ctx->dirty |= FD_DIRTY_VTXBUF;
}
@@ -76,14 +66,26 @@ fd_invalidate_resource(struct fd_context *ctx, struct pipe_resource *prsc)
if (ctx->indexbuf.buffer == prsc)
ctx->dirty |= FD_DIRTY_INDEXBUF;
- /* Textures */
- for (i = 0; i < ctx->tex[PIPE_SHADER_VERTEX].num_textures && !(ctx->dirty & FD_DIRTY_VERTTEX); i++) {
- if (ctx->tex[PIPE_SHADER_VERTEX].textures[i] && (ctx->tex[PIPE_SHADER_VERTEX].textures[i]->texture == prsc))
- ctx->dirty |= FD_DIRTY_VERTTEX;
- }
- for (i = 0; i < ctx->tex[PIPE_SHADER_FRAGMENT].num_textures && !(ctx->dirty & FD_DIRTY_FRAGTEX); i++) {
- if (ctx->tex[PIPE_SHADER_FRAGMENT].textures[i] && (ctx->tex[PIPE_SHADER_FRAGMENT].textures[i]->texture == prsc))
- ctx->dirty |= FD_DIRTY_FRAGTEX;
+ /* per-shader-stage resources: */
+ for (unsigned stage = 0; stage < PIPE_SHADER_TYPES; stage++) {
+ /* Constbufs.. note that constbuf[0] is normal uniforms emitted in
+ * cmdstream rather than by pointer..
+ */
+ const unsigned num_ubos = util_last_bit(ctx->constbuf[stage].enabled_mask);
+ for (unsigned i = 1; i < num_ubos; i++) {
+ if (ctx->dirty_shader[stage] & FD_DIRTY_SHADER_CONST)
+ break;
+ if (ctx->constbuf[stage].cb[i].buffer == prsc)
+ ctx->dirty_shader[stage] |= FD_DIRTY_SHADER_CONST;
+ }
+
+ /* Textures */
+ for (unsigned i = 0; i < ctx->tex[stage].num_textures; i++) {
+ if (ctx->dirty_shader[stage] & FD_DIRTY_SHADER_TEX)
+ break;
+ if (ctx->tex[stage].textures[i] && (ctx->tex[stage].textures[i]->texture == prsc))
+ ctx->dirty_shader[stage] |= FD_DIRTY_SHADER_TEX;
+ }
}
}