mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
iris: Replace num_textures etc with a bitmask we can scan
More accurate bounds, plus can skip dead ones
This commit is contained in:
parent
7ad7d0beea
commit
5fde1fa988
3 changed files with 21 additions and 14 deletions
|
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue