summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-12-02 23:17:44 -0800
committerKenneth Graunke <[email protected]>2019-02-21 10:26:10 -0800
commit5fde1fa988b4b118ea19d94ae1b9162589a7ae70 (patch)
tree3271f6e757015868f738f5373996a2121b40d713 /src
parent7ad7d0beea97eaec0c670865d62e7d7268a3d5bd (diff)
iris: Replace num_textures etc with a bitmask we can scan
More accurate bounds, plus can skip dead ones
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/iris/iris_context.h9
-rw-r--r--src/gallium/drivers/iris/iris_resolve.c10
-rw-r--r--src/gallium/drivers/iris/iris_state.c16
3 files changed, 21 insertions, 14 deletions
diff --git a/src/gallium/drivers/iris/iris_context.h b/src/gallium/drivers/iris/iris_context.h
index 5c5fbaf7eab..1eedd5d7100 100644
--- a/src/gallium/drivers/iris/iris_context.h
+++ b/src/gallium/drivers/iris/iris_context.h
@@ -298,9 +298,12 @@ struct iris_shader_state {
struct iris_state_ref sampler_table;
struct iris_sampler_state *samplers[IRIS_MAX_TEXTURE_SAMPLERS];
struct iris_sampler_view *textures[IRIS_MAX_TEXTURE_SAMPLERS];
- unsigned num_images;
- unsigned num_samplers;
- unsigned num_textures;
+
+ /** Bitfield of which image views are bound (non-null). */
+ uint32_t bound_image_views;
+
+ /** Bitfield of which sampler views are bound (non-null). */
+ uint32_t bound_sampler_views;
};
/**
diff --git a/src/gallium/drivers/iris/iris_resolve.c b/src/gallium/drivers/iris/iris_resolve.c
index 11967016663..7a884f813f9 100644
--- a/src/gallium/drivers/iris/iris_resolve.c
+++ b/src/gallium/drivers/iris/iris_resolve.c
@@ -39,7 +39,10 @@ static void
resolve_sampler_views(struct iris_batch *batch,
struct iris_shader_state *shs)
{
- for (int i = 0; i < shs->num_textures; i++) {
+ uint32_t views = shs->bound_sampler_views;
+
+ while (views) {
+ const int i = u_bit_scan(&views);
struct iris_sampler_view *isv = shs->textures[i];
if (!isv)
continue;
@@ -55,7 +58,10 @@ static void
resolve_image_views(struct iris_batch *batch,
struct iris_shader_state *shs)
{
- for (int i = 0; i < shs->num_images; i++) {
+ uint32_t views = shs->bound_image_views;
+
+ while (views) {
+ const int i = u_bit_scan(&views);
struct pipe_resource *res = shs->image[i].res;
if (!res)
continue;
diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c
index 7cd3e11a2b9..7af6cf2d04d 100644
--- a/src/gallium/drivers/iris/iris_state.c
+++ b/src/gallium/drivers/iris/iris_state.c
@@ -1373,15 +1373,11 @@ iris_bind_sampler_states(struct pipe_context *ctx,
struct iris_shader_state *shs = &ice->state.shaders[stage];
assert(start + count <= IRIS_MAX_TEXTURE_SAMPLERS);
- if (states)
- shs->num_samplers = MAX2(shs->num_samplers, start + count);
for (int i = 0; i < count; i++) {
shs->samplers[start + i] = states[i];
}
- // XXX: count may include NULLs
-
/* Assemble the SAMPLER_STATEs into a contiguous table that lives
* in the dynamic state memory zone, so we can point to it via the
* 3DSTATE_SAMPLER_STATE_POINTERS_* commands.
@@ -1679,8 +1675,7 @@ iris_set_shader_images(struct pipe_context *ctx,
gl_shader_stage stage = stage_from_pipe(p_stage);
struct iris_shader_state *shs = &ice->state.shaders[stage];
- if (p_images)
- shs->num_images = MAX2(shs->num_images, start_slot + count);
+ shs->bound_image_views &= ~u_bit_consecutive(start_slot, count);
for (unsigned i = 0; i < count; i++) {
if (p_images && p_images[i].resource) {
@@ -1688,6 +1683,8 @@ iris_set_shader_images(struct pipe_context *ctx,
struct iris_resource *res = (void *) img->resource;
pipe_resource_reference(&shs->image[start_slot + i].res, &res->base);
+ shs->bound_image_views |= 1 << (start_slot + i);
+
res->bind_history |= PIPE_BIND_SHADER_IMAGE;
// XXX: these are not retained forever, use a separate uploader?
@@ -1760,15 +1757,16 @@ iris_set_sampler_views(struct pipe_context *ctx,
gl_shader_stage stage = stage_from_pipe(p_stage);
struct iris_shader_state *shs = &ice->state.shaders[stage];
- if (views)
- shs->num_textures = MAX2(shs->num_textures, start + count);
+ shs->bound_sampler_views &= ~u_bit_consecutive(start, count);
for (unsigned i = 0; i < count; i++) {
pipe_sampler_view_reference((struct pipe_sampler_view **)
&shs->textures[start + i], views[i]);
struct iris_sampler_view *view = (void *) views[i];
- if (view)
+ if (view) {
view->res->bind_history |= PIPE_BIND_SAMPLER_VIEW;
+ shs->bound_sampler_views |= 1 << (start + i);
+ }
}
ice->state.dirty |= (IRIS_DIRTY_BINDINGS_VS << stage);