1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2011 Intel Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci
24bf215546Sopenharmony_ci/**
25bf215546Sopenharmony_ci * @file brw_vue_map.c
26bf215546Sopenharmony_ci *
27bf215546Sopenharmony_ci * This file computes the "VUE map" for a (non-fragment) shader stage, which
28bf215546Sopenharmony_ci * describes the layout of its output varyings.  The VUE map is used to match
29bf215546Sopenharmony_ci * outputs from one stage with the inputs of the next.
30bf215546Sopenharmony_ci *
31bf215546Sopenharmony_ci * Largely, varyings can be placed however we like - producers/consumers simply
32bf215546Sopenharmony_ci * have to agree on the layout.  However, there is also a "VUE Header" that
33bf215546Sopenharmony_ci * prescribes a fixed-layout for items that interact with fixed function
34bf215546Sopenharmony_ci * hardware, such as the clipper and rasterizer.
35bf215546Sopenharmony_ci *
36bf215546Sopenharmony_ci * Authors:
37bf215546Sopenharmony_ci *   Paul Berry <stereotype441@gmail.com>
38bf215546Sopenharmony_ci *   Chris Forbes <chrisf@ijw.co.nz>
39bf215546Sopenharmony_ci *   Eric Anholt <eric@anholt.net>
40bf215546Sopenharmony_ci */
41bf215546Sopenharmony_ci
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci#include "brw_compiler.h"
44bf215546Sopenharmony_ci#include "dev/intel_debug.h"
45bf215546Sopenharmony_ci
46bf215546Sopenharmony_cistatic inline void
47bf215546Sopenharmony_ciassign_vue_slot(struct brw_vue_map *vue_map, int varying, int slot)
48bf215546Sopenharmony_ci{
49bf215546Sopenharmony_ci   /* Make sure this varying hasn't been assigned a slot already */
50bf215546Sopenharmony_ci   assert (vue_map->varying_to_slot[varying] == -1);
51bf215546Sopenharmony_ci
52bf215546Sopenharmony_ci   vue_map->varying_to_slot[varying] = slot;
53bf215546Sopenharmony_ci   vue_map->slot_to_varying[slot] = varying;
54bf215546Sopenharmony_ci}
55bf215546Sopenharmony_ci
56bf215546Sopenharmony_ci/**
57bf215546Sopenharmony_ci * Compute the VUE map for a shader stage.
58bf215546Sopenharmony_ci */
59bf215546Sopenharmony_civoid
60bf215546Sopenharmony_cibrw_compute_vue_map(const struct intel_device_info *devinfo,
61bf215546Sopenharmony_ci                    struct brw_vue_map *vue_map,
62bf215546Sopenharmony_ci                    uint64_t slots_valid,
63bf215546Sopenharmony_ci                    bool separate,
64bf215546Sopenharmony_ci                    uint32_t pos_slots)
65bf215546Sopenharmony_ci{
66bf215546Sopenharmony_ci   /* Keep using the packed/contiguous layout on old hardware - we only need
67bf215546Sopenharmony_ci    * the SSO layout when using geometry/tessellation shaders or 32 FS input
68bf215546Sopenharmony_ci    * varyings, which only exist on Gen >= 6.  It's also a bit more efficient.
69bf215546Sopenharmony_ci    */
70bf215546Sopenharmony_ci   if (devinfo->ver < 6)
71bf215546Sopenharmony_ci      separate = false;
72bf215546Sopenharmony_ci
73bf215546Sopenharmony_ci   if (separate) {
74bf215546Sopenharmony_ci      /* In SSO mode, we don't know whether the adjacent stage will
75bf215546Sopenharmony_ci       * read/write gl_ClipDistance, which has a fixed slot location.
76bf215546Sopenharmony_ci       * We have to assume the worst and reserve a slot for it, or else
77bf215546Sopenharmony_ci       * the rest of our varyings will be off by a slot.
78bf215546Sopenharmony_ci       *
79bf215546Sopenharmony_ci       * Note that we don't have to worry about COL/BFC, as those built-in
80bf215546Sopenharmony_ci       * variables only exist in legacy GL, which only supports VS and FS.
81bf215546Sopenharmony_ci       */
82bf215546Sopenharmony_ci      slots_valid |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0);
83bf215546Sopenharmony_ci      slots_valid |= BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1);
84bf215546Sopenharmony_ci   }
85bf215546Sopenharmony_ci
86bf215546Sopenharmony_ci   vue_map->slots_valid = slots_valid;
87bf215546Sopenharmony_ci   vue_map->separate = separate;
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci   /* gl_Layer, gl_ViewportIndex & gl_PrimitiveShadingRateEXT don't get their
90bf215546Sopenharmony_ci    * own varying slots -- they are stored in the first VUE slot
91bf215546Sopenharmony_ci    * (VARYING_SLOT_PSIZ).
92bf215546Sopenharmony_ci    */
93bf215546Sopenharmony_ci   slots_valid &= ~(VARYING_BIT_LAYER | VARYING_BIT_VIEWPORT | VARYING_BIT_PRIMITIVE_SHADING_RATE);
94bf215546Sopenharmony_ci
95bf215546Sopenharmony_ci   /* Make sure that the values we store in vue_map->varying_to_slot and
96bf215546Sopenharmony_ci    * vue_map->slot_to_varying won't overflow the signed chars that are used
97bf215546Sopenharmony_ci    * to store them.  Note that since vue_map->slot_to_varying sometimes holds
98bf215546Sopenharmony_ci    * values equal to BRW_VARYING_SLOT_COUNT, we need to ensure that
99bf215546Sopenharmony_ci    * BRW_VARYING_SLOT_COUNT is <= 127, not 128.
100bf215546Sopenharmony_ci    */
101bf215546Sopenharmony_ci   STATIC_ASSERT(BRW_VARYING_SLOT_COUNT <= 127);
102bf215546Sopenharmony_ci
103bf215546Sopenharmony_ci   for (int i = 0; i < BRW_VARYING_SLOT_COUNT; ++i) {
104bf215546Sopenharmony_ci      vue_map->varying_to_slot[i] = -1;
105bf215546Sopenharmony_ci      vue_map->slot_to_varying[i] = BRW_VARYING_SLOT_PAD;
106bf215546Sopenharmony_ci   }
107bf215546Sopenharmony_ci
108bf215546Sopenharmony_ci   int slot = 0;
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci   /* VUE header: format depends on chip generation and whether clipping is
111bf215546Sopenharmony_ci    * enabled.
112bf215546Sopenharmony_ci    *
113bf215546Sopenharmony_ci    * See the Sandybridge PRM, Volume 2 Part 1, section 1.5.1 (page 30),
114bf215546Sopenharmony_ci    * "Vertex URB Entry (VUE) Formats" which describes the VUE header layout.
115bf215546Sopenharmony_ci    */
116bf215546Sopenharmony_ci   if (devinfo->ver < 6) {
117bf215546Sopenharmony_ci      /* There are 8 dwords in VUE header pre-Ironlake:
118bf215546Sopenharmony_ci       * dword 0-3 is indices, point width, clip flags.
119bf215546Sopenharmony_ci       * dword 4-7 is ndc position
120bf215546Sopenharmony_ci       * dword 8-11 is the first vertex data.
121bf215546Sopenharmony_ci       *
122bf215546Sopenharmony_ci       * On Ironlake the VUE header is nominally 20 dwords, but the hardware
123bf215546Sopenharmony_ci       * will accept the same header layout as Gfx4 [and should be a bit faster]
124bf215546Sopenharmony_ci       */
125bf215546Sopenharmony_ci      assign_vue_slot(vue_map, VARYING_SLOT_PSIZ, slot++);
126bf215546Sopenharmony_ci      assign_vue_slot(vue_map, BRW_VARYING_SLOT_NDC, slot++);
127bf215546Sopenharmony_ci      assign_vue_slot(vue_map, VARYING_SLOT_POS, slot++);
128bf215546Sopenharmony_ci   } else {
129bf215546Sopenharmony_ci      /* There are 8 or 16 DWs (D0-D15) in VUE header on Sandybridge:
130bf215546Sopenharmony_ci       * dword 0-3 of the header is shading rate, indices, point width, clip flags.
131bf215546Sopenharmony_ci       * dword 4-7 is the 4D space position
132bf215546Sopenharmony_ci       * dword 8-15 of the vertex header is the user clip distance if
133bf215546Sopenharmony_ci       * enabled.
134bf215546Sopenharmony_ci       * dword 8-11 or 16-19 is the first vertex element data we fill.
135bf215546Sopenharmony_ci       */
136bf215546Sopenharmony_ci      assign_vue_slot(vue_map, VARYING_SLOT_PSIZ, slot++);
137bf215546Sopenharmony_ci      assign_vue_slot(vue_map, VARYING_SLOT_POS, slot++);
138bf215546Sopenharmony_ci
139bf215546Sopenharmony_ci      /* When using Primitive Replication, multiple slots are used for storing
140bf215546Sopenharmony_ci       * positions for each view.
141bf215546Sopenharmony_ci       */
142bf215546Sopenharmony_ci      assert(pos_slots >= 1);
143bf215546Sopenharmony_ci      if (pos_slots > 1) {
144bf215546Sopenharmony_ci         for (int i = 1; i < pos_slots; i++) {
145bf215546Sopenharmony_ci            vue_map->slot_to_varying[slot++] = VARYING_SLOT_POS;
146bf215546Sopenharmony_ci         }
147bf215546Sopenharmony_ci      }
148bf215546Sopenharmony_ci
149bf215546Sopenharmony_ci      if (slots_valid & BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0))
150bf215546Sopenharmony_ci         assign_vue_slot(vue_map, VARYING_SLOT_CLIP_DIST0, slot++);
151bf215546Sopenharmony_ci      if (slots_valid & BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1))
152bf215546Sopenharmony_ci         assign_vue_slot(vue_map, VARYING_SLOT_CLIP_DIST1, slot++);
153bf215546Sopenharmony_ci
154bf215546Sopenharmony_ci      /* Vertex URB Formats table says: "Vertex Header shall be padded at the
155bf215546Sopenharmony_ci       * end so that the header ends on a 32-byte boundary".
156bf215546Sopenharmony_ci       */
157bf215546Sopenharmony_ci      slot += slot % 2;
158bf215546Sopenharmony_ci
159bf215546Sopenharmony_ci      /* front and back colors need to be consecutive so that we can use
160bf215546Sopenharmony_ci       * ATTRIBUTE_SWIZZLE_INPUTATTR_FACING to swizzle them when doing
161bf215546Sopenharmony_ci       * two-sided color.
162bf215546Sopenharmony_ci       */
163bf215546Sopenharmony_ci      if (slots_valid & BITFIELD64_BIT(VARYING_SLOT_COL0))
164bf215546Sopenharmony_ci         assign_vue_slot(vue_map, VARYING_SLOT_COL0, slot++);
165bf215546Sopenharmony_ci      if (slots_valid & BITFIELD64_BIT(VARYING_SLOT_BFC0))
166bf215546Sopenharmony_ci         assign_vue_slot(vue_map, VARYING_SLOT_BFC0, slot++);
167bf215546Sopenharmony_ci      if (slots_valid & BITFIELD64_BIT(VARYING_SLOT_COL1))
168bf215546Sopenharmony_ci         assign_vue_slot(vue_map, VARYING_SLOT_COL1, slot++);
169bf215546Sopenharmony_ci      if (slots_valid & BITFIELD64_BIT(VARYING_SLOT_BFC1))
170bf215546Sopenharmony_ci         assign_vue_slot(vue_map, VARYING_SLOT_BFC1, slot++);
171bf215546Sopenharmony_ci   }
172bf215546Sopenharmony_ci
173bf215546Sopenharmony_ci   /* The hardware doesn't care about the rest of the vertex outputs, so we
174bf215546Sopenharmony_ci    * can assign them however we like.  For normal programs, we simply assign
175bf215546Sopenharmony_ci    * them contiguously.
176bf215546Sopenharmony_ci    *
177bf215546Sopenharmony_ci    * For separate shader pipelines, we first assign built-in varyings
178bf215546Sopenharmony_ci    * contiguous slots.  This works because ARB_separate_shader_objects
179bf215546Sopenharmony_ci    * requires that all shaders have matching built-in varying interface
180bf215546Sopenharmony_ci    * blocks.  Next, we assign generic varyings based on their location
181bf215546Sopenharmony_ci    * (either explicit or linker assigned).  This guarantees a fixed layout.
182bf215546Sopenharmony_ci    *
183bf215546Sopenharmony_ci    * We generally don't need to assign a slot for VARYING_SLOT_CLIP_VERTEX,
184bf215546Sopenharmony_ci    * since it's encoded as the clip distances by emit_clip_distances().
185bf215546Sopenharmony_ci    * However, it may be output by transform feedback, and we'd rather not
186bf215546Sopenharmony_ci    * recompute state when TF changes, so we just always include it.
187bf215546Sopenharmony_ci    */
188bf215546Sopenharmony_ci   uint64_t builtins = slots_valid & BITFIELD64_MASK(VARYING_SLOT_VAR0);
189bf215546Sopenharmony_ci   while (builtins != 0) {
190bf215546Sopenharmony_ci      const int varying = ffsll(builtins) - 1;
191bf215546Sopenharmony_ci      if (vue_map->varying_to_slot[varying] == -1) {
192bf215546Sopenharmony_ci         assign_vue_slot(vue_map, varying, slot++);
193bf215546Sopenharmony_ci      }
194bf215546Sopenharmony_ci      builtins &= ~BITFIELD64_BIT(varying);
195bf215546Sopenharmony_ci   }
196bf215546Sopenharmony_ci
197bf215546Sopenharmony_ci   const int first_generic_slot = slot;
198bf215546Sopenharmony_ci   uint64_t generics = slots_valid & ~BITFIELD64_MASK(VARYING_SLOT_VAR0);
199bf215546Sopenharmony_ci   while (generics != 0) {
200bf215546Sopenharmony_ci      const int varying = ffsll(generics) - 1;
201bf215546Sopenharmony_ci      if (separate) {
202bf215546Sopenharmony_ci         slot = first_generic_slot + varying - VARYING_SLOT_VAR0;
203bf215546Sopenharmony_ci      }
204bf215546Sopenharmony_ci      assign_vue_slot(vue_map, varying, slot++);
205bf215546Sopenharmony_ci      generics &= ~BITFIELD64_BIT(varying);
206bf215546Sopenharmony_ci   }
207bf215546Sopenharmony_ci
208bf215546Sopenharmony_ci   vue_map->num_slots = slot;
209bf215546Sopenharmony_ci   vue_map->num_per_vertex_slots = 0;
210bf215546Sopenharmony_ci   vue_map->num_per_patch_slots = 0;
211bf215546Sopenharmony_ci}
212bf215546Sopenharmony_ci
213bf215546Sopenharmony_ci/**
214bf215546Sopenharmony_ci * Compute the VUE map for tessellation control shader outputs and
215bf215546Sopenharmony_ci * tessellation evaluation shader inputs.
216bf215546Sopenharmony_ci */
217bf215546Sopenharmony_civoid
218bf215546Sopenharmony_cibrw_compute_tess_vue_map(struct brw_vue_map *vue_map,
219bf215546Sopenharmony_ci                         uint64_t vertex_slots,
220bf215546Sopenharmony_ci                         uint32_t patch_slots)
221bf215546Sopenharmony_ci{
222bf215546Sopenharmony_ci   /* I don't think anything actually uses this... */
223bf215546Sopenharmony_ci   vue_map->slots_valid = vertex_slots;
224bf215546Sopenharmony_ci
225bf215546Sopenharmony_ci   /* separate isn't really meaningful, but make sure it's initialized */
226bf215546Sopenharmony_ci   vue_map->separate = false;
227bf215546Sopenharmony_ci
228bf215546Sopenharmony_ci   vertex_slots &= ~(VARYING_BIT_TESS_LEVEL_OUTER |
229bf215546Sopenharmony_ci                     VARYING_BIT_TESS_LEVEL_INNER);
230bf215546Sopenharmony_ci
231bf215546Sopenharmony_ci   /* Make sure that the values we store in vue_map->varying_to_slot and
232bf215546Sopenharmony_ci    * vue_map->slot_to_varying won't overflow the signed chars that are used
233bf215546Sopenharmony_ci    * to store them.  Note that since vue_map->slot_to_varying sometimes holds
234bf215546Sopenharmony_ci    * values equal to VARYING_SLOT_TESS_MAX , we need to ensure that
235bf215546Sopenharmony_ci    * VARYING_SLOT_TESS_MAX is <= 127, not 128.
236bf215546Sopenharmony_ci    */
237bf215546Sopenharmony_ci   STATIC_ASSERT(VARYING_SLOT_TESS_MAX <= 127);
238bf215546Sopenharmony_ci
239bf215546Sopenharmony_ci   for (int i = 0; i < VARYING_SLOT_TESS_MAX ; ++i) {
240bf215546Sopenharmony_ci      vue_map->varying_to_slot[i] = -1;
241bf215546Sopenharmony_ci      vue_map->slot_to_varying[i] = BRW_VARYING_SLOT_PAD;
242bf215546Sopenharmony_ci   }
243bf215546Sopenharmony_ci
244bf215546Sopenharmony_ci   int slot = 0;
245bf215546Sopenharmony_ci
246bf215546Sopenharmony_ci   /* The first 8 DWords are reserved for the "Patch Header".
247bf215546Sopenharmony_ci    *
248bf215546Sopenharmony_ci    * VARYING_SLOT_TESS_LEVEL_OUTER / INNER live here, but the exact layout
249bf215546Sopenharmony_ci    * depends on the domain type.  They might not be in slots 0 and 1 as
250bf215546Sopenharmony_ci    * described here, but pretending they're separate allows us to uniquely
251bf215546Sopenharmony_ci    * identify them by distinct slot locations.
252bf215546Sopenharmony_ci    */
253bf215546Sopenharmony_ci   assign_vue_slot(vue_map, VARYING_SLOT_TESS_LEVEL_INNER, slot++);
254bf215546Sopenharmony_ci   assign_vue_slot(vue_map, VARYING_SLOT_TESS_LEVEL_OUTER, slot++);
255bf215546Sopenharmony_ci
256bf215546Sopenharmony_ci   /* first assign per-patch varyings */
257bf215546Sopenharmony_ci   while (patch_slots != 0) {
258bf215546Sopenharmony_ci      const int varying = ffsll(patch_slots) - 1;
259bf215546Sopenharmony_ci      if (vue_map->varying_to_slot[varying + VARYING_SLOT_PATCH0] == -1) {
260bf215546Sopenharmony_ci         assign_vue_slot(vue_map, varying + VARYING_SLOT_PATCH0, slot++);
261bf215546Sopenharmony_ci      }
262bf215546Sopenharmony_ci      patch_slots &= ~BITFIELD64_BIT(varying);
263bf215546Sopenharmony_ci   }
264bf215546Sopenharmony_ci
265bf215546Sopenharmony_ci   /* apparently, including the patch header... */
266bf215546Sopenharmony_ci   vue_map->num_per_patch_slots = slot;
267bf215546Sopenharmony_ci
268bf215546Sopenharmony_ci   /* then assign per-vertex varyings for each vertex in our patch */
269bf215546Sopenharmony_ci   while (vertex_slots != 0) {
270bf215546Sopenharmony_ci      const int varying = ffsll(vertex_slots) - 1;
271bf215546Sopenharmony_ci      if (vue_map->varying_to_slot[varying] == -1) {
272bf215546Sopenharmony_ci         assign_vue_slot(vue_map, varying, slot++);
273bf215546Sopenharmony_ci      }
274bf215546Sopenharmony_ci      vertex_slots &= ~BITFIELD64_BIT(varying);
275bf215546Sopenharmony_ci   }
276bf215546Sopenharmony_ci
277bf215546Sopenharmony_ci   vue_map->num_per_vertex_slots = slot - vue_map->num_per_patch_slots;
278bf215546Sopenharmony_ci   vue_map->num_slots = slot;
279bf215546Sopenharmony_ci}
280bf215546Sopenharmony_ci
281bf215546Sopenharmony_cistatic const char *
282bf215546Sopenharmony_civarying_name(brw_varying_slot slot, gl_shader_stage stage)
283bf215546Sopenharmony_ci{
284bf215546Sopenharmony_ci   assume(slot < BRW_VARYING_SLOT_COUNT);
285bf215546Sopenharmony_ci
286bf215546Sopenharmony_ci   if (slot < VARYING_SLOT_MAX)
287bf215546Sopenharmony_ci      return gl_varying_slot_name_for_stage((gl_varying_slot)slot, stage);
288bf215546Sopenharmony_ci
289bf215546Sopenharmony_ci   static const char *brw_names[] = {
290bf215546Sopenharmony_ci      [BRW_VARYING_SLOT_NDC - VARYING_SLOT_MAX] = "BRW_VARYING_SLOT_NDC",
291bf215546Sopenharmony_ci      [BRW_VARYING_SLOT_PAD - VARYING_SLOT_MAX] = "BRW_VARYING_SLOT_PAD",
292bf215546Sopenharmony_ci      [BRW_VARYING_SLOT_PNTC - VARYING_SLOT_MAX] = "BRW_VARYING_SLOT_PNTC",
293bf215546Sopenharmony_ci   };
294bf215546Sopenharmony_ci
295bf215546Sopenharmony_ci   return brw_names[slot - VARYING_SLOT_MAX];
296bf215546Sopenharmony_ci}
297bf215546Sopenharmony_ci
298bf215546Sopenharmony_civoid
299bf215546Sopenharmony_cibrw_print_vue_map(FILE *fp, const struct brw_vue_map *vue_map,
300bf215546Sopenharmony_ci                  gl_shader_stage stage)
301bf215546Sopenharmony_ci{
302bf215546Sopenharmony_ci   if (vue_map->num_per_vertex_slots > 0 || vue_map->num_per_patch_slots > 0) {
303bf215546Sopenharmony_ci      fprintf(fp, "PUE map (%d slots, %d/patch, %d/vertex, %s)\n",
304bf215546Sopenharmony_ci              vue_map->num_slots,
305bf215546Sopenharmony_ci              vue_map->num_per_patch_slots,
306bf215546Sopenharmony_ci              vue_map->num_per_vertex_slots,
307bf215546Sopenharmony_ci              vue_map->separate ? "SSO" : "non-SSO");
308bf215546Sopenharmony_ci      for (int i = 0; i < vue_map->num_slots; i++) {
309bf215546Sopenharmony_ci         if (vue_map->slot_to_varying[i] >= VARYING_SLOT_PATCH0) {
310bf215546Sopenharmony_ci            fprintf(fp, "  [%d] VARYING_SLOT_PATCH%d\n", i,
311bf215546Sopenharmony_ci                    vue_map->slot_to_varying[i] - VARYING_SLOT_PATCH0);
312bf215546Sopenharmony_ci         } else {
313bf215546Sopenharmony_ci            fprintf(fp, "  [%d] %s\n", i,
314bf215546Sopenharmony_ci                    varying_name(vue_map->slot_to_varying[i], stage));
315bf215546Sopenharmony_ci         }
316bf215546Sopenharmony_ci      }
317bf215546Sopenharmony_ci   } else {
318bf215546Sopenharmony_ci      fprintf(fp, "VUE map (%d slots, %s)\n",
319bf215546Sopenharmony_ci              vue_map->num_slots, vue_map->separate ? "SSO" : "non-SSO");
320bf215546Sopenharmony_ci      for (int i = 0; i < vue_map->num_slots; i++) {
321bf215546Sopenharmony_ci         fprintf(fp, "  [%d] %s\n", i,
322bf215546Sopenharmony_ci                 varying_name(vue_map->slot_to_varying[i], stage));
323bf215546Sopenharmony_ci      }
324bf215546Sopenharmony_ci   }
325bf215546Sopenharmony_ci   fprintf(fp, "\n");
326bf215546Sopenharmony_ci}
327