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;
};
/**
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;
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;
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.
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) {
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?
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);