diff options
author | Alejandro Piñeiro <[email protected]> | 2019-03-07 17:42:49 +0100 |
---|---|---|
committer | Alejandro Piñeiro <[email protected]> | 2019-03-08 15:00:50 +0100 |
commit | 8d693746e99b79a78cc70c42b45e3fea3eaf9180 (patch) | |
tree | b3ca203f97b31b95c512b7a4f9b140b29b60946c /src/compiler | |
parent | cf0b2ad486c954086b4aa6843fdfc20c4ed60e7d (diff) |
nir/xfb: sort varyings too
Right now we are only re-sorting outputs. But it is better to sort too
varyings, as linker expect them to be sorted out (as it was done on
GLSL). For varyings, and to make easier to compute buffer_index, we
sort also by buffer. We could do the same for outputs, but we lack a
reason for that, so we left it as it is (just offset).
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir_gather_xfb_info.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/compiler/nir/nir_gather_xfb_info.c b/src/compiler/nir/nir_gather_xfb_info.c index 12c5d4507e3..40cd6f93a9a 100644 --- a/src/compiler/nir/nir_gather_xfb_info.c +++ b/src/compiler/nir/nir_gather_xfb_info.c @@ -123,9 +123,21 @@ add_var_xfb_outputs(nir_xfb_info *xfb, } static int +compare_xfb_varying_offsets(const void *_a, const void *_b) +{ + const nir_xfb_varying_info *a = _a, *b = _b; + + if (a->buffer != b->buffer) + return a->buffer - b->buffer; + + return a->offset - b->offset; +} + +static int compare_xfb_output_offsets(const void *_a, const void *_b) { const nir_xfb_output_info *a = _a, *b = _b; + return a->offset - b->offset; } @@ -199,12 +211,15 @@ nir_gather_xfb_info(const nir_shader *shader, void *mem_ctx) } } - /* Everything is easier in the state setup code if the list is sorted in - * order of output offset. + /* Everything is easier in the state setup code if outputs and varyings are + * sorted in order of output offset (and buffer for varyings). */ qsort(xfb->outputs, xfb->output_count, sizeof(xfb->outputs[0]), compare_xfb_output_offsets); + qsort(xfb->varyings, xfb->varying_count, sizeof(xfb->varyings[0]), + compare_xfb_varying_offsets); + #ifndef NDEBUG /* Finally, do a sanity check */ unsigned max_offset[NIR_MAX_XFB_BUFFERS] = {0}; |