[Mesa-dev] [PATCH 07/10] i965/fs: Handle arrays of special regs more cleanly.
Kenneth Graunke
kenneth at whitecape.org
Wed Mar 26 23:55:03 PDT 2014
On 03/26/2014 02:23 PM, Eric Anholt wrote:
> I need to extend the size of the outputs[] array, and this was going to
> get ridiculous.
> ---
> src/mesa/drivers/dri/i965/brw_fs.cpp | 36 ++++++++++++++++++++++--------------
> 1 file changed, 22 insertions(+), 14 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
> index b3f1dfd..9610cde 100644
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
> @@ -1723,22 +1723,27 @@ fs_visitor::compact_virtual_grfs()
> /* In addition to registers used in instructions, fs_visitor keeps
> * direct references to certain special values which must be patched:
> */
> - fs_reg *special[] = {
> - &frag_depth, &pixel_x, &pixel_y, &pixel_w, &wpos_w, &dual_src_output,
> - &outputs[0], &outputs[1], &outputs[2], &outputs[3],
> - &outputs[4], &outputs[5], &outputs[6], &outputs[7],
> - &delta_x[0], &delta_x[1], &delta_x[2],
> - &delta_x[3], &delta_x[4], &delta_x[5],
> - &delta_y[0], &delta_y[1], &delta_y[2],
> - &delta_y[3], &delta_y[4], &delta_y[5],
> + struct {
> + fs_reg *reg;
> + unsigned count;
> + } special[] = {
> + { &frag_depth, 1 },
> + { &pixel_x, 1 },
> + { &pixel_y, 1 },
> + { &pixel_w, 1 },
> + { &wpos_w, 1 },
> + { &dual_src_output, 1 },
> + { outputs, ARRAY_SIZE(outputs) },
> + { delta_x, ARRAY_SIZE(delta_x) },
> + { delta_y, ARRAY_SIZE(delta_y) },
> };
> - STATIC_ASSERT(BRW_WM_BARYCENTRIC_INTERP_MODE_COUNT == 6);
> - STATIC_ASSERT(BRW_MAX_DRAW_BUFFERS == 8);
>
> /* Treat all special values as used, to be conservative */
> for (unsigned i = 0; i < ARRAY_SIZE(special); i++) {
> - if (special[i]->file == GRF)
> - remap_table[special[i]->reg] = 0;
> + for (unsigned j = 0; j < special[i].count; j++) {
> + if (special[i].reg[j].file == GRF)
> + remap_table[special[i].reg[j].reg] = 0;
> + }
> }
>
> /* Compact the GRF arrays. */
> @@ -1769,8 +1774,11 @@ fs_visitor::compact_virtual_grfs()
>
> /* Patch all the references to special values */
> for (unsigned i = 0; i < ARRAY_SIZE(special); i++) {
> - if (special[i]->file == GRF && remap_table[special[i]->reg] != -1)
> - special[i]->reg = remap_table[special[i]->reg];
> + for (unsigned j = 0; j < special[i].count; j++) {
> + fs_reg *reg = &special[i].reg[j];
> + if (reg->file == GRF && remap_table[reg->reg] != -1)
> + reg->reg = remap_table[reg->reg];
> + }
> }
> }
>
>
Much better - thanks for fixing my mess.
I did notice that a few newer registers are missing:
{ &sample_mask, 1 },
{ &shader_start_time, 1 },
It would be great to add them as a follow-up patch.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140326/a0b2152a/attachment.sig>
More information about the mesa-dev
mailing list