mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-17 13:30:20 +01:00
nir/opt_preamble: Treat *size as an input
Some backends may wish to reserve early uniforms for internal system values, and use the remaining space for preamble storage. In this case, it's convenient to teach nir_opt_preamble about a reserved offset. It's logical to treat the output *size instead of an in/out variable that nir_opt_preamble adds to. This requires a slight change to the consumers to zero the input. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Acked-by-(with-sparkles): Asahi Lina <lina@asahilina.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20562>
This commit is contained in:
parent
d745e3b0ab
commit
05d3238692
2 changed files with 4 additions and 6 deletions
|
|
@ -421,7 +421,6 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options,
|
|||
}
|
||||
|
||||
if (num_candidates == 0) {
|
||||
*size = 0;
|
||||
free(ctx.states);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -485,7 +484,6 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options,
|
|||
num_candidates = candidate_idx;
|
||||
|
||||
if (num_candidates == 0) {
|
||||
*size = 0;
|
||||
free(ctx.states);
|
||||
free(candidates);
|
||||
return false;
|
||||
|
|
@ -498,11 +496,11 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options,
|
|||
* divided by size.
|
||||
*/
|
||||
|
||||
if (total_size > options->preamble_storage_size) {
|
||||
qsort(candidates, num_candidates, sizeof(*candidates), candidate_sort);
|
||||
if (((*size) + total_size) > options->preamble_storage_size) {
|
||||
qsort(candidates, num_candidates, sizeof(*candidates), candidate_sort);
|
||||
}
|
||||
|
||||
unsigned offset = 0;
|
||||
unsigned offset = *size;
|
||||
for (unsigned i = 0; i < num_candidates; i++) {
|
||||
def_state *state = candidates[i];
|
||||
offset = ALIGN_POT(offset, state->align);
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ ir3_nir_opt_preamble(nir_shader *nir, struct ir3_shader_variant *v)
|
|||
.rewrite_cost_cb = rewrite_cost,
|
||||
};
|
||||
|
||||
unsigned size;
|
||||
unsigned size = 0;
|
||||
bool progress = nir_opt_preamble(nir, &options, &size);
|
||||
|
||||
if (!v->binning_pass)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue