panfrost,panvk: Make fixed_sysval_ubo < 0 mean compiler-assigned

In 3559efb9bf ("panfrost: Allow passing an explicit UBO index for the
sysval UBO"), an explicit UBO index was added and it was implicitly
assumed that it would be > num_ubos.  This was convenient because it
meant 0, the default for designated initializers, implicitly meant
compiler-assigned.  However, we're about to move the sysval UBO to 0
which breaks this assumption.   Also, we don't want the back-end
compiler to even look at num_ubos since it's meaningless in Vulkan.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16276>
This commit is contained in:
Jason Ekstrand 2022-05-04 11:25:33 -05:00 committed by Marge Bot
parent 42aca84704
commit 4e60f0655a
11 changed files with 29 additions and 12 deletions

View File

@ -69,6 +69,7 @@ panfrost_shader_compile(struct pipe_screen *pscreen,
struct panfrost_compile_inputs inputs = {
.gpu_id = dev->gpu_id,
.shaderdb = !!(dev->debug & PAN_DBG_PRECOMPILE),
.fixed_sysval_ubo = -1,
.fixed_varying_mask = state->key.fixed_varying_mask
};

View File

@ -503,8 +503,9 @@ static bi_instr *
bi_load_sysval_to(bi_builder *b, bi_index dest, int sysval,
unsigned nr_components, unsigned offset)
{
unsigned sysval_ubo =
MAX2(b->shader->inputs->sysval_ubo, b->shader->nir->info.num_ubos);
unsigned sysval_ubo = b->shader->inputs->fixed_sysval_ubo >= 0 ?
b->shader->inputs->fixed_sysval_ubo :
b->shader->nir->info.num_ubos;
unsigned uniform =
pan_lookup_sysval(b->shader->sysval_to_id,
b->shader->info.sysvals,

View File

@ -193,6 +193,7 @@ compile_shader(int stages, char **files)
struct panfrost_compile_inputs inputs = {
.gpu_id = gpu_id,
.fixed_sysval_ubo = -1,
};
struct pan_shader_info info = { 0 };

View File

@ -822,6 +822,7 @@ GENX(pan_blend_get_shader_locked)(const struct panfrost_device *dev,
.is_blend = true,
.blend.rt = shader->key.rt,
.blend.nr_samples = key.nr_samples,
.fixed_sysval_ubo = -1,
.rt_formats = { key.format },
};
@ -834,6 +835,9 @@ GENX(pan_blend_get_shader_locked)(const struct panfrost_device *dev,
GENX(pan_shader_compile)(nir, &inputs, &variant->binary, &info);
/* Blend shaders can't have sysvals */
assert(info.sysvals.sysval_count == 0);
variant->work_reg_count = info.work_reg_count;
#if PAN_ARCH <= 5

View File

@ -604,6 +604,7 @@ pan_blitter_get_blit_shader(struct panfrost_device *dev,
.gpu_id = dev->gpu_id,
.is_blit = true,
.no_idvs = true,
.fixed_sysval_ubo = -1,
};
struct util_dynarray binary;
@ -619,6 +620,9 @@ pan_blitter_get_blit_shader(struct panfrost_device *dev,
GENX(pan_shader_compile)(b.shader, &inputs, &binary, &shader->info);
/* Blit shaders shouldn't have sysvals */
assert(shader->info.sysvals.sysval_count == 0);
shader->key = *key;
shader->address =
pan_pool_upload_aligned(dev->blitter.shaders.pool,

View File

@ -216,7 +216,10 @@ GENX(pan_indirect_dispatch_init)(struct panfrost_device *dev)
nir_pop_if(&b, NULL);
struct panfrost_compile_inputs inputs = { .gpu_id = dev->gpu_id };
struct panfrost_compile_inputs inputs = {
.gpu_id = dev->gpu_id,
.fixed_sysval_ubo = -1,
};
struct pan_shader_info shader_info;
struct util_dynarray binary;

View File

@ -1133,7 +1133,10 @@ create_indirect_draw_shader(struct panfrost_device *dev,
else
patch(&builder);
struct panfrost_compile_inputs inputs = { .gpu_id = dev->gpu_id };
struct panfrost_compile_inputs inputs = {
.gpu_id = dev->gpu_id,
.fixed_sysval_ubo = -1,
};
struct pan_shader_info shader_info;
struct util_dynarray binary;

View File

@ -312,10 +312,9 @@ GENX(pan_shader_compile)(nir_shader *s,
info->outputs_written = s->info.outputs_written;
/* Sysvals have dedicated UBO */
if (info->sysvals.sysval_count)
info->ubo_count = MAX2(s->info.num_ubos + 1, inputs->sysval_ubo + 1);
else
info->ubo_count = s->info.num_ubos;
info->ubo_count = s->info.num_ubos;
if (info->sysvals.sysval_count && inputs->fixed_sysval_ubo < 0)
info->ubo_count++;
info->attribute_count += BITSET_LAST_BIT(s->info.images_used);
info->writes_global = s->info.writes_memory;

View File

@ -1575,8 +1575,9 @@ emit_sysval_read(compiler_context *ctx, nir_instr *instr,
nir_dest nir_dest;
/* Figure out which uniform this is */
unsigned sysval_ubo =
MAX2(ctx->inputs->sysval_ubo, ctx->nir->info.num_ubos);
unsigned sysval_ubo = ctx->inputs->fixed_sysval_ubo >= 0 ?
ctx->inputs->fixed_sysval_ubo :
ctx->nir->info.num_ubos;
int sysval = panfrost_sysval_for_instr(instr, &nir_dest);
unsigned dest = nir_dest_index(&nir_dest);
unsigned uniform =

View File

@ -181,7 +181,7 @@ struct panfrost_compile_inputs {
unsigned nr_samples;
uint64_t bifrost_blend_desc;
} blend;
unsigned sysval_ubo;
int fixed_sysval_ubo;
bool shaderdb;
bool no_idvs;
bool no_ubo_to_push;

View File

@ -345,7 +345,7 @@ panvk_per_arch(shader_create)(struct panvk_device *dev,
.gpu_id = pdev->gpu_id,
.no_ubo_to_push = true,
.no_idvs = true, /* TODO */
.sysval_ubo = sysval_ubo,
.fixed_sysval_ubo = sysval_ubo,
};
NIR_PASS_V(nir, nir_lower_indirect_derefs,