summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gallium/drivers/freedreno/freedreno_draw.c17
-rw-r--r--src/gallium/drivers/freedreno/freedreno_util.h3
2 files changed, 10 insertions, 10 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_draw.c b/src/gallium/drivers/freedreno/freedreno_draw.c
index dd4a720dd0e..e371d2bf7dc 100644
--- a/src/gallium/drivers/freedreno/freedreno_draw.c
+++ b/src/gallium/drivers/freedreno/freedreno_draw.c
@@ -134,14 +134,13 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
batch->gmem_reason |= FD_GMEM_BLEND_ENABLED;
}
- /* Skip over buffer 0, that is sent along with the command stream */
- for (i = 1; i < PIPE_MAX_CONSTANT_BUFFERS; i++) {
+ foreach_bit(i, ctx->constbuf[PIPE_SHADER_VERTEX].enabled_mask)
resource_read(batch, ctx->constbuf[PIPE_SHADER_VERTEX].cb[i].buffer);
+ foreach_bit(i, ctx->constbuf[PIPE_SHADER_FRAGMENT].enabled_mask)
resource_read(batch, ctx->constbuf[PIPE_SHADER_FRAGMENT].cb[i].buffer);
- }
/* Mark VBOs as being read */
- for (i = 0; i < ctx->vtx.vertexbuf.count; i++) {
+ foreach_bit(i, ctx->vtx.vertexbuf.enabled_mask) {
assert(!ctx->vtx.vertexbuf.vb[i].user_buffer);
resource_read(batch, ctx->vtx.vertexbuf.vb[i].buffer);
}
@@ -150,12 +149,10 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
resource_read(batch, ctx->indexbuf.buffer);
/* Mark textures as being read */
- for (i = 0; i < ctx->verttex.num_textures; i++)
- if (ctx->verttex.textures[i])
- resource_read(batch, ctx->verttex.textures[i]->texture);
- for (i = 0; i < ctx->fragtex.num_textures; i++)
- if (ctx->fragtex.textures[i])
- resource_read(batch, ctx->fragtex.textures[i]->texture);
+ foreach_bit(i, ctx->verttex.valid_textures)
+ resource_read(batch, ctx->verttex.textures[i]->texture);
+ foreach_bit(i, ctx->fragtex.valid_textures)
+ resource_read(batch, ctx->fragtex.textures[i]->texture);
/* Mark streamout buffers as being written.. */
for (i = 0; i < ctx->streamout.num_targets; i++)
diff --git a/src/gallium/drivers/freedreno/freedreno_util.h b/src/gallium/drivers/freedreno/freedreno_util.h
index 6321cd7b4cd..30097008e2a 100644
--- a/src/gallium/drivers/freedreno/freedreno_util.h
+++ b/src/gallium/drivers/freedreno/freedreno_util.h
@@ -338,4 +338,7 @@ pack_rgba(enum pipe_format format, const float *rgba)
#define swap(a, b) \
do { __typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
+#define foreach_bit(b, mask) \
+ for (uint32_t _m = (mask); _m && ({(b) = u_bit_scan(&_m); 1;});)
+
#endif /* FREEDRENO_UTIL_H_ */