mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 09:08:10 +02:00
nir/xfb_info: nir_gather_xfb_info_from_intrinsics update nir xfb_info
Use this function to update nir_shader->xfb_info. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19489>
This commit is contained in:
parent
b6c172f26c
commit
49cfbe1fed
2 changed files with 12 additions and 19 deletions
|
|
@ -317,20 +317,14 @@ compare_xfb_out(const void *pa, const void *pb)
|
||||||
* Optionally return slot_to_register, an optional table to translate
|
* Optionally return slot_to_register, an optional table to translate
|
||||||
* gl_varying_slot to "base" indices.
|
* gl_varying_slot to "base" indices.
|
||||||
*/
|
*/
|
||||||
nir_xfb_info *
|
void
|
||||||
nir_gather_xfb_info_from_intrinsics(nir_shader *nir,
|
nir_gather_xfb_info_from_intrinsics(nir_shader *nir)
|
||||||
int slot_to_register[NUM_TOTAL_VARYING_SLOTS])
|
|
||||||
{
|
{
|
||||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||||
uint8_t buffer_to_stream[MAX_XFB_BUFFERS] = {0};
|
uint8_t buffer_to_stream[MAX_XFB_BUFFERS] = {0};
|
||||||
uint8_t buffer_mask = 0;
|
uint8_t buffer_mask = 0;
|
||||||
uint8_t stream_mask = 0;
|
uint8_t stream_mask = 0;
|
||||||
|
|
||||||
if (slot_to_register) {
|
|
||||||
memset(slot_to_register, -1,
|
|
||||||
sizeof(slot_to_register[0] * NUM_TOTAL_VARYING_SLOTS));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Gather xfb outputs. */
|
/* Gather xfb outputs. */
|
||||||
struct util_dynarray array = {0};
|
struct util_dynarray array = {0};
|
||||||
|
|
||||||
|
|
@ -368,9 +362,6 @@ nir_gather_xfb_info_from_intrinsics(nir_shader *nir,
|
||||||
buffer_mask |= BITFIELD_BIT(out.buffer);
|
buffer_mask |= BITFIELD_BIT(out.buffer);
|
||||||
stream_mask |= BITFIELD_BIT(stream);
|
stream_mask |= BITFIELD_BIT(stream);
|
||||||
|
|
||||||
if (slot_to_register)
|
|
||||||
slot_to_register[sem.location] = nir_intrinsic_base(intr);
|
|
||||||
|
|
||||||
/* No elements before component_offset are allowed to be set. */
|
/* No elements before component_offset are allowed to be set. */
|
||||||
assert(!(out.component_mask & BITFIELD_MASK(out.component_offset)));
|
assert(!(out.component_mask & BITFIELD_MASK(out.component_offset)));
|
||||||
}
|
}
|
||||||
|
|
@ -382,7 +373,7 @@ nir_gather_xfb_info_from_intrinsics(nir_shader *nir,
|
||||||
int count = util_dynarray_num_elements(&array, nir_xfb_output_info);
|
int count = util_dynarray_num_elements(&array, nir_xfb_output_info);
|
||||||
|
|
||||||
if (!count)
|
if (!count)
|
||||||
return NULL;
|
return;
|
||||||
|
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
/* Sort outputs by buffer, location, and component. */
|
/* Sort outputs by buffer, location, and component. */
|
||||||
|
|
@ -436,10 +427,10 @@ nir_gather_xfb_info_from_intrinsics(nir_shader *nir,
|
||||||
assert(outputs[i].component_mask);
|
assert(outputs[i].component_mask);
|
||||||
|
|
||||||
/* Create nir_xfb_info. */
|
/* Create nir_xfb_info. */
|
||||||
nir_xfb_info *info = calloc(1, nir_xfb_info_size(count));
|
nir_xfb_info *info = nir_xfb_info_create(nir, count);
|
||||||
if (!info) {
|
if (!info) {
|
||||||
util_dynarray_fini(&array);
|
util_dynarray_fini(&array);
|
||||||
return NULL;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill nir_xfb_info. */
|
/* Fill nir_xfb_info. */
|
||||||
|
|
@ -452,15 +443,18 @@ nir_gather_xfb_info_from_intrinsics(nir_shader *nir,
|
||||||
/* Set strides. */
|
/* Set strides. */
|
||||||
for (unsigned i = 0; i < MAX_XFB_BUFFERS; i++) {
|
for (unsigned i = 0; i < MAX_XFB_BUFFERS; i++) {
|
||||||
if (buffer_mask & BITFIELD_BIT(i))
|
if (buffer_mask & BITFIELD_BIT(i))
|
||||||
info->buffers[i].stride = nir->info.xfb_stride[i];
|
info->buffers[i].stride = nir->info.xfb_stride[i] * 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set varying_count. */
|
/* Set varying_count. */
|
||||||
for (unsigned i = 0; i < count; i++)
|
for (unsigned i = 0; i < count; i++)
|
||||||
info->buffers[outputs[i].buffer].varying_count++;
|
info->buffers[outputs[i].buffer].varying_count++;
|
||||||
|
|
||||||
|
/* Replace original xfb info. */
|
||||||
|
ralloc_free(nir->xfb_info);
|
||||||
|
nir->xfb_info = info;
|
||||||
|
|
||||||
util_dynarray_fini(&array);
|
util_dynarray_fini(&array);
|
||||||
return info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,8 @@ nir_gather_xfb_info_with_varyings(nir_shader *shader,
|
||||||
void *mem_ctx,
|
void *mem_ctx,
|
||||||
nir_xfb_varyings_info **varyings_info);
|
nir_xfb_varyings_info **varyings_info);
|
||||||
|
|
||||||
nir_xfb_info *
|
void
|
||||||
nir_gather_xfb_info_from_intrinsics(nir_shader *nir,
|
nir_gather_xfb_info_from_intrinsics(nir_shader *nir);
|
||||||
int slot_to_register[NUM_TOTAL_VARYING_SLOTS]);
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nir_print_xfb_info(nir_xfb_info *info, FILE *fp);
|
nir_print_xfb_info(nir_xfb_info *info, FILE *fp);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue