2 * Copyright 2017 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
22 * Authors: Karol Herbst <kherbst@redhat.com>
25 #include "compiler/nir/nir.h"
27 #include "util/u_debug.h"
29 #include "codegen/nv50_ir.h"
30 #include "codegen/nv50_ir_from_common.h"
31 #include "codegen/nv50_ir_lowering_helper.h"
32 #include "codegen/nv50_ir_util.h"
34 #if __cplusplus >= 201103L
35 #include <unordered_map>
37 #include <tr1/unordered_map>
43 #if __cplusplus >= 201103L
45 using std::unordered_map
;
48 using std::tr1::unordered_map
;
51 using namespace nv50_ir
;
54 type_size(const struct glsl_type
*type
)
56 return glsl_count_attribute_slots(type
, false);
59 class Converter
: public ConverterCommon
62 Converter(Program
*, nir_shader
*, nv50_ir_prog_info
*);
66 typedef std::vector
<LValue
*> LValues
;
67 typedef unordered_map
<unsigned, LValues
> NirDefMap
;
68 typedef unordered_map
<unsigned, BasicBlock
*> NirBlockMap
;
70 LValues
& convert(nir_alu_dest
*);
71 BasicBlock
* convert(nir_block
*);
72 LValues
& convert(nir_dest
*);
73 LValues
& convert(nir_register
*);
74 LValues
& convert(nir_ssa_def
*);
76 Value
* getSrc(nir_alu_src
*, uint8_t component
= 0);
77 Value
* getSrc(nir_register
*, uint8_t);
78 Value
* getSrc(nir_src
*, uint8_t, bool indirect
= false);
79 Value
* getSrc(nir_ssa_def
*, uint8_t);
81 // returned value is the constant part of the given source (either the
82 // nir_src or the selected source component of an intrinsic). Even though
83 // this is mostly an optimization to be able to skip indirects in a few
84 // cases, sometimes we require immediate values or set some fileds on
85 // instructions (e.g. tex) in order for codegen to consume those.
86 // If the found value has not a constant part, the Value gets returned
87 // through the Value parameter.
88 uint32_t getIndirect(nir_src
*, uint8_t, Value
*&);
89 uint32_t getIndirect(nir_intrinsic_instr
*, uint8_t s
, uint8_t c
, Value
*&);
91 uint32_t getSlotAddress(nir_intrinsic_instr
*, uint8_t idx
, uint8_t slot
);
93 void setInterpolate(nv50_ir_varying
*,
98 Instruction
*loadFrom(DataFile
, uint8_t, DataType
, Value
*def
, uint32_t base
,
99 uint8_t c
, Value
*indirect0
= NULL
,
100 Value
*indirect1
= NULL
, bool patch
= false);
101 void storeTo(nir_intrinsic_instr
*, DataFile
, operation
, DataType
,
102 Value
*src
, uint8_t idx
, uint8_t c
, Value
*indirect0
= NULL
,
103 Value
*indirect1
= NULL
);
105 bool isFloatType(nir_alu_type
);
106 bool isSignedType(nir_alu_type
);
107 bool isResultFloat(nir_op
);
108 bool isResultSigned(nir_op
);
110 DataType
getDType(nir_alu_instr
*);
111 DataType
getDType(nir_intrinsic_instr
*);
112 DataType
getDType(nir_op
, uint8_t);
114 std::vector
<DataType
> getSTypes(nir_alu_instr
*);
115 DataType
getSType(nir_src
&, bool isFloat
, bool isSigned
);
120 bool visit(nir_block
*);
121 bool visit(nir_cf_node
*);
122 bool visit(nir_function
*);
123 bool visit(nir_if
*);
124 bool visit(nir_instr
*);
125 bool visit(nir_intrinsic_instr
*);
126 bool visit(nir_jump_instr
*);
127 bool visit(nir_load_const_instr
*);
128 bool visit(nir_loop
*);
135 unsigned int curLoopDepth
;
146 Converter::Converter(Program
*prog
, nir_shader
*nir
, nv50_ir_prog_info
*info
)
147 : ConverterCommon(prog
, info
),
152 Converter::convert(nir_block
*block
)
154 NirBlockMap::iterator it
= blocks
.find(block
->index
);
155 if (it
!= blocks
.end())
158 BasicBlock
*bb
= new BasicBlock(func
);
159 blocks
[block
->index
] = bb
;
164 Converter::isFloatType(nir_alu_type type
)
166 return nir_alu_type_get_base_type(type
) == nir_type_float
;
170 Converter::isSignedType(nir_alu_type type
)
172 return nir_alu_type_get_base_type(type
) == nir_type_int
;
176 Converter::isResultFloat(nir_op op
)
178 const nir_op_info
&info
= nir_op_infos
[op
];
179 if (info
.output_type
!= nir_type_invalid
)
180 return isFloatType(info
.output_type
);
182 ERROR("isResultFloat not implemented for %s\n", nir_op_infos
[op
].name
);
188 Converter::isResultSigned(nir_op op
)
191 // there is no umul and we get wrong results if we treat all muls as signed
196 const nir_op_info
&info
= nir_op_infos
[op
];
197 if (info
.output_type
!= nir_type_invalid
)
198 return isSignedType(info
.output_type
);
199 ERROR("isResultSigned not implemented for %s\n", nir_op_infos
[op
].name
);
206 Converter::getDType(nir_alu_instr
*insn
)
208 if (insn
->dest
.dest
.is_ssa
)
209 return getDType(insn
->op
, insn
->dest
.dest
.ssa
.bit_size
);
211 return getDType(insn
->op
, insn
->dest
.dest
.reg
.reg
->bit_size
);
215 Converter::getDType(nir_intrinsic_instr
*insn
)
217 if (insn
->dest
.is_ssa
)
218 return typeOfSize(insn
->dest
.ssa
.bit_size
/ 8, false, false);
220 return typeOfSize(insn
->dest
.reg
.reg
->bit_size
/ 8, false, false);
224 Converter::getDType(nir_op op
, uint8_t bitSize
)
226 DataType ty
= typeOfSize(bitSize
/ 8, isResultFloat(op
), isResultSigned(op
));
227 if (ty
== TYPE_NONE
) {
228 ERROR("couldn't get Type for op %s with bitSize %u\n", nir_op_infos
[op
].name
, bitSize
);
234 std::vector
<DataType
>
235 Converter::getSTypes(nir_alu_instr
*insn
)
237 const nir_op_info
&info
= nir_op_infos
[insn
->op
];
238 std::vector
<DataType
> res(info
.num_inputs
);
240 for (uint8_t i
= 0; i
< info
.num_inputs
; ++i
) {
241 if (info
.input_types
[i
] != nir_type_invalid
) {
242 res
[i
] = getSType(insn
->src
[i
].src
, isFloatType(info
.input_types
[i
]), isSignedType(info
.input_types
[i
]));
244 ERROR("getSType not implemented for %s idx %u\n", info
.name
, i
);
255 Converter::getSType(nir_src
&src
, bool isFloat
, bool isSigned
)
259 bitSize
= src
.ssa
->bit_size
;
261 bitSize
= src
.reg
.reg
->bit_size
;
263 DataType ty
= typeOfSize(bitSize
/ 8, isFloat
, isSigned
);
264 if (ty
== TYPE_NONE
) {
272 ERROR("couldn't get Type for %s with bitSize %u\n", str
, bitSize
);
279 Converter::convert(nir_dest
*dest
)
282 return convert(&dest
->ssa
);
283 if (dest
->reg
.indirect
) {
284 ERROR("no support for indirects.");
287 return convert(dest
->reg
.reg
);
291 Converter::convert(nir_register
*reg
)
293 NirDefMap::iterator it
= regDefs
.find(reg
->index
);
294 if (it
!= regDefs
.end())
297 LValues
newDef(reg
->num_components
);
298 for (uint8_t i
= 0; i
< reg
->num_components
; i
++)
299 newDef
[i
] = getScratch(std::max(4, reg
->bit_size
/ 8));
300 return regDefs
[reg
->index
] = newDef
;
304 Converter::convert(nir_ssa_def
*def
)
306 NirDefMap::iterator it
= ssaDefs
.find(def
->index
);
307 if (it
!= ssaDefs
.end())
310 LValues
newDef(def
->num_components
);
311 for (uint8_t i
= 0; i
< def
->num_components
; i
++)
312 newDef
[i
] = getSSA(std::max(4, def
->bit_size
/ 8));
313 return ssaDefs
[def
->index
] = newDef
;
317 Converter::getSrc(nir_alu_src
*src
, uint8_t component
)
319 if (src
->abs
|| src
->negate
) {
320 ERROR("modifiers currently not supported on nir_alu_src\n");
323 return getSrc(&src
->src
, src
->swizzle
[component
]);
327 Converter::getSrc(nir_register
*reg
, uint8_t idx
)
329 NirDefMap::iterator it
= regDefs
.find(reg
->index
);
330 if (it
== regDefs
.end())
331 return convert(reg
)[idx
];
332 return it
->second
[idx
];
336 Converter::getSrc(nir_src
*src
, uint8_t idx
, bool indirect
)
339 return getSrc(src
->ssa
, idx
);
341 if (src
->reg
.indirect
) {
343 return getSrc(src
->reg
.indirect
, idx
);
344 ERROR("no support for indirects.");
349 return getSrc(src
->reg
.reg
, idx
);
353 Converter::getSrc(nir_ssa_def
*src
, uint8_t idx
)
355 NirDefMap::iterator it
= ssaDefs
.find(src
->index
);
356 if (it
== ssaDefs
.end()) {
357 ERROR("SSA value %u not found\n", src
->index
);
361 return it
->second
[idx
];
365 Converter::getIndirect(nir_src
*src
, uint8_t idx
, Value
*&indirect
)
367 nir_const_value
*offset
= nir_src_as_const_value(*src
);
371 return offset
->u32
[0];
374 indirect
= getSrc(src
, idx
, true);
379 Converter::getIndirect(nir_intrinsic_instr
*insn
, uint8_t s
, uint8_t c
, Value
*&indirect
)
381 int32_t idx
= nir_intrinsic_base(insn
) + getIndirect(&insn
->src
[s
], c
, indirect
);
383 indirect
= mkOp2v(OP_SHL
, TYPE_U32
, getSSA(4, FILE_ADDRESS
), indirect
, loadImm(NULL
, 4));
388 vert_attrib_to_tgsi_semantic(gl_vert_attrib slot
, unsigned *name
, unsigned *index
)
390 assert(name
&& index
);
392 if (slot
>= VERT_ATTRIB_MAX
) {
393 ERROR("invalid varying slot %u\n", slot
);
398 if (slot
>= VERT_ATTRIB_GENERIC0
&&
399 slot
< VERT_ATTRIB_GENERIC0
+ VERT_ATTRIB_GENERIC_MAX
) {
400 *name
= TGSI_SEMANTIC_GENERIC
;
401 *index
= slot
- VERT_ATTRIB_GENERIC0
;
405 if (slot
>= VERT_ATTRIB_TEX0
&&
406 slot
< VERT_ATTRIB_TEX0
+ VERT_ATTRIB_TEX_MAX
) {
407 *name
= TGSI_SEMANTIC_TEXCOORD
;
408 *index
= slot
- VERT_ATTRIB_TEX0
;
413 case VERT_ATTRIB_COLOR0
:
414 *name
= TGSI_SEMANTIC_COLOR
;
417 case VERT_ATTRIB_COLOR1
:
418 *name
= TGSI_SEMANTIC_COLOR
;
421 case VERT_ATTRIB_EDGEFLAG
:
422 *name
= TGSI_SEMANTIC_EDGEFLAG
;
425 case VERT_ATTRIB_FOG
:
426 *name
= TGSI_SEMANTIC_FOG
;
429 case VERT_ATTRIB_NORMAL
:
430 *name
= TGSI_SEMANTIC_NORMAL
;
433 case VERT_ATTRIB_POS
:
434 *name
= TGSI_SEMANTIC_POSITION
;
437 case VERT_ATTRIB_POINT_SIZE
:
438 *name
= TGSI_SEMANTIC_PSIZE
;
442 ERROR("unknown vert attrib slot %u\n", slot
);
449 varying_slot_to_tgsi_semantic(gl_varying_slot slot
, unsigned *name
, unsigned *index
)
451 assert(name
&& index
);
453 if (slot
>= VARYING_SLOT_TESS_MAX
) {
454 ERROR("invalid varying slot %u\n", slot
);
459 if (slot
>= VARYING_SLOT_PATCH0
) {
460 *name
= TGSI_SEMANTIC_PATCH
;
461 *index
= slot
- VARYING_SLOT_PATCH0
;
465 if (slot
>= VARYING_SLOT_VAR0
) {
466 *name
= TGSI_SEMANTIC_GENERIC
;
467 *index
= slot
- VARYING_SLOT_VAR0
;
471 if (slot
>= VARYING_SLOT_TEX0
&& slot
<= VARYING_SLOT_TEX7
) {
472 *name
= TGSI_SEMANTIC_TEXCOORD
;
473 *index
= slot
- VARYING_SLOT_TEX0
;
478 case VARYING_SLOT_BFC0
:
479 *name
= TGSI_SEMANTIC_BCOLOR
;
482 case VARYING_SLOT_BFC1
:
483 *name
= TGSI_SEMANTIC_BCOLOR
;
486 case VARYING_SLOT_CLIP_DIST0
:
487 *name
= TGSI_SEMANTIC_CLIPDIST
;
490 case VARYING_SLOT_CLIP_DIST1
:
491 *name
= TGSI_SEMANTIC_CLIPDIST
;
494 case VARYING_SLOT_CLIP_VERTEX
:
495 *name
= TGSI_SEMANTIC_CLIPVERTEX
;
498 case VARYING_SLOT_COL0
:
499 *name
= TGSI_SEMANTIC_COLOR
;
502 case VARYING_SLOT_COL1
:
503 *name
= TGSI_SEMANTIC_COLOR
;
506 case VARYING_SLOT_EDGE
:
507 *name
= TGSI_SEMANTIC_EDGEFLAG
;
510 case VARYING_SLOT_FACE
:
511 *name
= TGSI_SEMANTIC_FACE
;
514 case VARYING_SLOT_FOGC
:
515 *name
= TGSI_SEMANTIC_FOG
;
518 case VARYING_SLOT_LAYER
:
519 *name
= TGSI_SEMANTIC_LAYER
;
522 case VARYING_SLOT_PNTC
:
523 *name
= TGSI_SEMANTIC_PCOORD
;
526 case VARYING_SLOT_POS
:
527 *name
= TGSI_SEMANTIC_POSITION
;
530 case VARYING_SLOT_PRIMITIVE_ID
:
531 *name
= TGSI_SEMANTIC_PRIMID
;
534 case VARYING_SLOT_PSIZ
:
535 *name
= TGSI_SEMANTIC_PSIZE
;
538 case VARYING_SLOT_TESS_LEVEL_INNER
:
539 *name
= TGSI_SEMANTIC_TESSINNER
;
542 case VARYING_SLOT_TESS_LEVEL_OUTER
:
543 *name
= TGSI_SEMANTIC_TESSOUTER
;
546 case VARYING_SLOT_VIEWPORT
:
547 *name
= TGSI_SEMANTIC_VIEWPORT_INDEX
;
551 ERROR("unknown varying slot %u\n", slot
);
558 frag_result_to_tgsi_semantic(unsigned slot
, unsigned *name
, unsigned *index
)
560 if (slot
>= FRAG_RESULT_DATA0
) {
561 *name
= TGSI_SEMANTIC_COLOR
;
562 *index
= slot
- FRAG_RESULT_COLOR
- 2; // intentional
567 case FRAG_RESULT_COLOR
:
568 *name
= TGSI_SEMANTIC_COLOR
;
571 case FRAG_RESULT_DEPTH
:
572 *name
= TGSI_SEMANTIC_POSITION
;
575 case FRAG_RESULT_SAMPLE_MASK
:
576 *name
= TGSI_SEMANTIC_SAMPLEMASK
;
580 ERROR("unknown frag result slot %u\n", slot
);
586 // copy of _mesa_sysval_to_semantic
588 system_val_to_tgsi_semantic(unsigned val
, unsigned *name
, unsigned *index
)
593 case SYSTEM_VALUE_VERTEX_ID
:
594 *name
= TGSI_SEMANTIC_VERTEXID
;
596 case SYSTEM_VALUE_INSTANCE_ID
:
597 *name
= TGSI_SEMANTIC_INSTANCEID
;
599 case SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
:
600 *name
= TGSI_SEMANTIC_VERTEXID_NOBASE
;
602 case SYSTEM_VALUE_BASE_VERTEX
:
603 *name
= TGSI_SEMANTIC_BASEVERTEX
;
605 case SYSTEM_VALUE_BASE_INSTANCE
:
606 *name
= TGSI_SEMANTIC_BASEINSTANCE
;
608 case SYSTEM_VALUE_DRAW_ID
:
609 *name
= TGSI_SEMANTIC_DRAWID
;
613 case SYSTEM_VALUE_INVOCATION_ID
:
614 *name
= TGSI_SEMANTIC_INVOCATIONID
;
618 case SYSTEM_VALUE_FRAG_COORD
:
619 *name
= TGSI_SEMANTIC_POSITION
;
621 case SYSTEM_VALUE_FRONT_FACE
:
622 *name
= TGSI_SEMANTIC_FACE
;
624 case SYSTEM_VALUE_SAMPLE_ID
:
625 *name
= TGSI_SEMANTIC_SAMPLEID
;
627 case SYSTEM_VALUE_SAMPLE_POS
:
628 *name
= TGSI_SEMANTIC_SAMPLEPOS
;
630 case SYSTEM_VALUE_SAMPLE_MASK_IN
:
631 *name
= TGSI_SEMANTIC_SAMPLEMASK
;
633 case SYSTEM_VALUE_HELPER_INVOCATION
:
634 *name
= TGSI_SEMANTIC_HELPER_INVOCATION
;
637 // Tessellation shader
638 case SYSTEM_VALUE_TESS_COORD
:
639 *name
= TGSI_SEMANTIC_TESSCOORD
;
641 case SYSTEM_VALUE_VERTICES_IN
:
642 *name
= TGSI_SEMANTIC_VERTICESIN
;
644 case SYSTEM_VALUE_PRIMITIVE_ID
:
645 *name
= TGSI_SEMANTIC_PRIMID
;
647 case SYSTEM_VALUE_TESS_LEVEL_OUTER
:
648 *name
= TGSI_SEMANTIC_TESSOUTER
;
650 case SYSTEM_VALUE_TESS_LEVEL_INNER
:
651 *name
= TGSI_SEMANTIC_TESSINNER
;
655 case SYSTEM_VALUE_LOCAL_INVOCATION_ID
:
656 *name
= TGSI_SEMANTIC_THREAD_ID
;
658 case SYSTEM_VALUE_WORK_GROUP_ID
:
659 *name
= TGSI_SEMANTIC_BLOCK_ID
;
661 case SYSTEM_VALUE_NUM_WORK_GROUPS
:
662 *name
= TGSI_SEMANTIC_GRID_SIZE
;
664 case SYSTEM_VALUE_LOCAL_GROUP_SIZE
:
665 *name
= TGSI_SEMANTIC_BLOCK_SIZE
;
669 case SYSTEM_VALUE_SUBGROUP_SIZE
:
670 *name
= TGSI_SEMANTIC_SUBGROUP_SIZE
;
672 case SYSTEM_VALUE_SUBGROUP_INVOCATION
:
673 *name
= TGSI_SEMANTIC_SUBGROUP_INVOCATION
;
675 case SYSTEM_VALUE_SUBGROUP_EQ_MASK
:
676 *name
= TGSI_SEMANTIC_SUBGROUP_EQ_MASK
;
678 case SYSTEM_VALUE_SUBGROUP_GE_MASK
:
679 *name
= TGSI_SEMANTIC_SUBGROUP_GE_MASK
;
681 case SYSTEM_VALUE_SUBGROUP_GT_MASK
:
682 *name
= TGSI_SEMANTIC_SUBGROUP_GT_MASK
;
684 case SYSTEM_VALUE_SUBGROUP_LE_MASK
:
685 *name
= TGSI_SEMANTIC_SUBGROUP_LE_MASK
;
687 case SYSTEM_VALUE_SUBGROUP_LT_MASK
:
688 *name
= TGSI_SEMANTIC_SUBGROUP_LT_MASK
;
692 ERROR("unknown system value %u\n", val
);
699 Converter::setInterpolate(nv50_ir_varying
*var
,
705 case INTERP_MODE_FLAT
:
708 case INTERP_MODE_NONE
:
709 if (semantic
== TGSI_SEMANTIC_COLOR
)
711 else if (semantic
== TGSI_SEMANTIC_POSITION
)
714 case INTERP_MODE_NOPERSPECTIVE
:
717 case INTERP_MODE_SMOOTH
:
720 var
->centroid
= centroid
;
724 calcSlots(const glsl_type
*type
, Program::Type stage
, const shader_info
&info
,
725 bool input
, const nir_variable
*var
)
727 if (!type
->is_array())
728 return type
->count_attribute_slots(false);
732 case Program::TYPE_GEOMETRY
:
733 slots
= type
->uniform_locations();
735 slots
/= info
.gs
.vertices_in
;
737 case Program::TYPE_TESSELLATION_CONTROL
:
738 case Program::TYPE_TESSELLATION_EVAL
:
739 // remove first dimension
740 if (var
->data
.patch
|| (!input
&& stage
== Program::TYPE_TESSELLATION_EVAL
))
741 slots
= type
->uniform_locations();
743 slots
= type
->fields
.array
->uniform_locations();
746 slots
= type
->count_attribute_slots(false);
753 bool Converter::assignSlots() {
757 info
->io
.viewportId
= -1;
760 // we have to fixup the uniform locations for arrays
761 unsigned numImages
= 0;
762 nir_foreach_variable(var
, &nir
->uniforms
) {
763 const glsl_type
*type
= var
->type
;
764 if (!type
->without_array()->is_image())
766 var
->data
.driver_location
= numImages
;
767 numImages
+= type
->is_array() ? type
->arrays_of_arrays_size() : 1;
770 nir_foreach_variable(var
, &nir
->inputs
) {
771 const glsl_type
*type
= var
->type
;
772 int slot
= var
->data
.location
;
773 uint16_t slots
= calcSlots(type
, prog
->getType(), nir
->info
, true, var
);
774 uint32_t comp
= type
->is_array() ? type
->without_array()->component_slots()
775 : type
->component_slots();
776 uint32_t frac
= var
->data
.location_frac
;
777 uint32_t vary
= var
->data
.driver_location
;
779 if (glsl_base_type_is_64bit(type
->without_array()->base_type
)) {
784 assert(vary
+ slots
<= PIPE_MAX_SHADER_INPUTS
);
786 switch(prog
->getType()) {
787 case Program::TYPE_FRAGMENT
:
788 varying_slot_to_tgsi_semantic((gl_varying_slot
)slot
, &name
, &index
);
789 for (uint16_t i
= 0; i
< slots
; ++i
) {
790 setInterpolate(&info
->in
[vary
+ i
], var
->data
.interpolation
,
791 var
->data
.centroid
| var
->data
.sample
, name
);
794 case Program::TYPE_GEOMETRY
:
795 varying_slot_to_tgsi_semantic((gl_varying_slot
)slot
, &name
, &index
);
797 case Program::TYPE_TESSELLATION_CONTROL
:
798 case Program::TYPE_TESSELLATION_EVAL
:
799 varying_slot_to_tgsi_semantic((gl_varying_slot
)slot
, &name
, &index
);
800 if (var
->data
.patch
&& name
== TGSI_SEMANTIC_PATCH
)
801 info
->numPatchConstants
= MAX2(info
->numPatchConstants
, index
+ slots
);
803 case Program::TYPE_VERTEX
:
804 vert_attrib_to_tgsi_semantic((gl_vert_attrib
)slot
, &name
, &index
);
806 case TGSI_SEMANTIC_EDGEFLAG
:
807 info
->io
.edgeFlagIn
= vary
;
814 ERROR("unknown shader type %u in assignSlots\n", prog
->getType());
818 for (uint16_t i
= 0u; i
< slots
; ++i
, ++vary
) {
819 info
->in
[vary
].id
= vary
;
820 info
->in
[vary
].patch
= var
->data
.patch
;
821 info
->in
[vary
].sn
= name
;
822 info
->in
[vary
].si
= index
+ i
;
823 if (glsl_base_type_is_64bit(type
->without_array()->base_type
))
825 info
->in
[vary
].mask
|= (((1 << (comp
* 2)) - 1) << (frac
* 2) >> 0x4);
827 info
->in
[vary
].mask
|= (((1 << (comp
* 2)) - 1) << (frac
* 2) & 0xf);
829 info
->in
[vary
].mask
|= ((1 << comp
) - 1) << frac
;
831 info
->numInputs
= std::max
<uint8_t>(info
->numInputs
, vary
);
834 info
->numOutputs
= 0;
835 nir_foreach_variable(var
, &nir
->outputs
) {
836 const glsl_type
*type
= var
->type
;
837 int slot
= var
->data
.location
;
838 uint16_t slots
= calcSlots(type
, prog
->getType(), nir
->info
, false, var
);
839 uint32_t comp
= type
->is_array() ? type
->without_array()->component_slots()
840 : type
->component_slots();
841 uint32_t frac
= var
->data
.location_frac
;
842 uint32_t vary
= var
->data
.driver_location
;
844 if (glsl_base_type_is_64bit(type
->without_array()->base_type
)) {
849 assert(vary
< PIPE_MAX_SHADER_OUTPUTS
);
851 switch(prog
->getType()) {
852 case Program::TYPE_FRAGMENT
:
853 frag_result_to_tgsi_semantic((gl_frag_result
)slot
, &name
, &index
);
855 case TGSI_SEMANTIC_COLOR
:
856 if (!var
->data
.fb_fetch_output
)
857 info
->prop
.fp
.numColourResults
++;
858 info
->prop
.fp
.separateFragData
= true;
859 // sometimes we get FRAG_RESULT_DATAX with data.index 0
860 // sometimes we get FRAG_RESULT_DATA0 with data.index X
861 index
= index
== 0 ? var
->data
.index
: index
;
863 case TGSI_SEMANTIC_POSITION
:
864 info
->io
.fragDepth
= vary
;
865 info
->prop
.fp
.writesDepth
= true;
867 case TGSI_SEMANTIC_SAMPLEMASK
:
868 info
->io
.sampleMask
= vary
;
874 case Program::TYPE_GEOMETRY
:
875 case Program::TYPE_TESSELLATION_CONTROL
:
876 case Program::TYPE_TESSELLATION_EVAL
:
877 case Program::TYPE_VERTEX
:
878 varying_slot_to_tgsi_semantic((gl_varying_slot
)slot
, &name
, &index
);
880 if (var
->data
.patch
&& name
!= TGSI_SEMANTIC_TESSINNER
&&
881 name
!= TGSI_SEMANTIC_TESSOUTER
)
882 info
->numPatchConstants
= MAX2(info
->numPatchConstants
, index
+ slots
);
885 case TGSI_SEMANTIC_CLIPDIST
:
886 info
->io
.genUserClip
= -1;
888 case TGSI_SEMANTIC_EDGEFLAG
:
889 info
->io
.edgeFlagOut
= vary
;
896 ERROR("unknown shader type %u in assignSlots\n", prog
->getType());
900 for (uint16_t i
= 0u; i
< slots
; ++i
, ++vary
) {
901 info
->out
[vary
].id
= vary
;
902 info
->out
[vary
].patch
= var
->data
.patch
;
903 info
->out
[vary
].sn
= name
;
904 info
->out
[vary
].si
= index
+ i
;
905 if (glsl_base_type_is_64bit(type
->without_array()->base_type
))
907 info
->out
[vary
].mask
|= (((1 << (comp
* 2)) - 1) << (frac
* 2) >> 0x4);
909 info
->out
[vary
].mask
|= (((1 << (comp
* 2)) - 1) << (frac
* 2) & 0xf);
911 info
->out
[vary
].mask
|= ((1 << comp
) - 1) << frac
;
913 if (nir
->info
.outputs_read
& 1ll << slot
)
914 info
->out
[vary
].oread
= 1;
916 info
->numOutputs
= std::max
<uint8_t>(info
->numOutputs
, vary
);
919 info
->numSysVals
= 0;
920 for (uint8_t i
= 0; i
< 64; ++i
) {
921 if (!(nir
->info
.system_values_read
& 1ll << i
))
924 system_val_to_tgsi_semantic(i
, &name
, &index
);
925 info
->sv
[info
->numSysVals
].sn
= name
;
926 info
->sv
[info
->numSysVals
].si
= index
;
927 info
->sv
[info
->numSysVals
].input
= 0; // TODO inferSysValDirection(sn);
930 case SYSTEM_VALUE_INSTANCE_ID
:
931 info
->io
.instanceId
= info
->numSysVals
;
933 case SYSTEM_VALUE_TESS_LEVEL_INNER
:
934 case SYSTEM_VALUE_TESS_LEVEL_OUTER
:
935 info
->sv
[info
->numSysVals
].patch
= 1;
937 case SYSTEM_VALUE_VERTEX_ID
:
938 info
->io
.vertexId
= info
->numSysVals
;
944 info
->numSysVals
+= 1;
947 if (info
->io
.genUserClip
> 0) {
948 info
->io
.clipDistances
= info
->io
.genUserClip
;
950 const unsigned int nOut
= (info
->io
.genUserClip
+ 3) / 4;
952 for (unsigned int n
= 0; n
< nOut
; ++n
) {
953 unsigned int i
= info
->numOutputs
++;
955 info
->out
[i
].sn
= TGSI_SEMANTIC_CLIPDIST
;
957 info
->out
[i
].mask
= ((1 << info
->io
.clipDistances
) - 1) >> (n
* 4);
961 return info
->assignSlots(info
) == 0;
965 Converter::getSlotAddress(nir_intrinsic_instr
*insn
, uint8_t idx
, uint8_t slot
)
968 int offset
= nir_intrinsic_component(insn
);
971 if (nir_intrinsic_infos
[insn
->intrinsic
].has_dest
)
974 ty
= getSType(insn
->src
[0], false, false);
976 switch (insn
->intrinsic
) {
977 case nir_intrinsic_load_input
:
978 case nir_intrinsic_load_interpolated_input
:
979 case nir_intrinsic_load_per_vertex_input
:
982 case nir_intrinsic_load_output
:
983 case nir_intrinsic_load_per_vertex_output
:
984 case nir_intrinsic_store_output
:
985 case nir_intrinsic_store_per_vertex_output
:
989 ERROR("unknown intrinsic in getSlotAddress %s",
990 nir_intrinsic_infos
[insn
->intrinsic
].name
);
996 if (typeSizeof(ty
) == 8) {
1008 assert(!input
|| idx
< PIPE_MAX_SHADER_INPUTS
);
1009 assert(input
|| idx
< PIPE_MAX_SHADER_OUTPUTS
);
1011 const nv50_ir_varying
*vary
= input
? info
->in
: info
->out
;
1012 return vary
[idx
].slot
[slot
] * 4;
1016 Converter::loadFrom(DataFile file
, uint8_t i
, DataType ty
, Value
*def
,
1017 uint32_t base
, uint8_t c
, Value
*indirect0
,
1018 Value
*indirect1
, bool patch
)
1020 unsigned int tySize
= typeSizeof(ty
);
1023 (file
== FILE_MEMORY_CONST
|| file
== FILE_MEMORY_BUFFER
|| indirect0
)) {
1024 Value
*lo
= getSSA();
1025 Value
*hi
= getSSA();
1028 mkLoad(TYPE_U32
, lo
,
1029 mkSymbol(file
, i
, TYPE_U32
, base
+ c
* tySize
),
1031 loi
->setIndirect(0, 1, indirect1
);
1032 loi
->perPatch
= patch
;
1035 mkLoad(TYPE_U32
, hi
,
1036 mkSymbol(file
, i
, TYPE_U32
, base
+ c
* tySize
+ 4),
1038 hii
->setIndirect(0, 1, indirect1
);
1039 hii
->perPatch
= patch
;
1041 return mkOp2(OP_MERGE
, ty
, def
, lo
, hi
);
1044 mkLoad(ty
, def
, mkSymbol(file
, i
, ty
, base
+ c
* tySize
), indirect0
);
1045 ld
->setIndirect(0, 1, indirect1
);
1046 ld
->perPatch
= patch
;
1052 Converter::storeTo(nir_intrinsic_instr
*insn
, DataFile file
, operation op
,
1053 DataType ty
, Value
*src
, uint8_t idx
, uint8_t c
,
1054 Value
*indirect0
, Value
*indirect1
)
1056 uint8_t size
= typeSizeof(ty
);
1057 uint32_t address
= getSlotAddress(insn
, idx
, c
);
1059 if (size
== 8 && indirect0
) {
1061 mkSplit(split
, 4, src
);
1063 if (op
== OP_EXPORT
) {
1064 split
[0] = mkMov(getSSA(), split
[0], ty
)->getDef(0);
1065 split
[1] = mkMov(getSSA(), split
[1], ty
)->getDef(0);
1068 mkStore(op
, TYPE_U32
, mkSymbol(file
, 0, TYPE_U32
, address
), indirect0
,
1069 split
[0])->perPatch
= info
->out
[idx
].patch
;
1070 mkStore(op
, TYPE_U32
, mkSymbol(file
, 0, TYPE_U32
, address
+ 4), indirect0
,
1071 split
[1])->perPatch
= info
->out
[idx
].patch
;
1073 if (op
== OP_EXPORT
)
1074 src
= mkMov(getSSA(size
), src
, ty
)->getDef(0);
1075 mkStore(op
, ty
, mkSymbol(file
, 0, ty
, address
), indirect0
,
1076 src
)->perPatch
= info
->out
[idx
].patch
;
1081 Converter::parseNIR()
1083 info
->io
.clipDistances
= nir
->info
.clip_distance_array_size
;
1084 info
->io
.cullDistances
= nir
->info
.cull_distance_array_size
;
1086 switch(prog
->getType()) {
1087 case Program::TYPE_COMPUTE
:
1088 info
->prop
.cp
.numThreads
[0] = nir
->info
.cs
.local_size
[0];
1089 info
->prop
.cp
.numThreads
[1] = nir
->info
.cs
.local_size
[1];
1090 info
->prop
.cp
.numThreads
[2] = nir
->info
.cs
.local_size
[2];
1091 info
->bin
.smemSize
= nir
->info
.cs
.shared_size
;
1093 case Program::TYPE_FRAGMENT
:
1094 info
->prop
.fp
.earlyFragTests
= nir
->info
.fs
.early_fragment_tests
;
1095 info
->prop
.fp
.persampleInvocation
=
1096 (nir
->info
.system_values_read
& SYSTEM_BIT_SAMPLE_ID
) ||
1097 (nir
->info
.system_values_read
& SYSTEM_BIT_SAMPLE_POS
);
1098 info
->prop
.fp
.postDepthCoverage
= nir
->info
.fs
.post_depth_coverage
;
1099 info
->prop
.fp
.readsSampleLocations
=
1100 (nir
->info
.system_values_read
& SYSTEM_BIT_SAMPLE_POS
);
1101 info
->prop
.fp
.usesDiscard
= nir
->info
.fs
.uses_discard
;
1102 info
->prop
.fp
.usesSampleMaskIn
=
1103 !!(nir
->info
.system_values_read
& SYSTEM_BIT_SAMPLE_MASK_IN
);
1105 case Program::TYPE_GEOMETRY
:
1106 info
->prop
.gp
.inputPrim
= nir
->info
.gs
.input_primitive
;
1107 info
->prop
.gp
.instanceCount
= nir
->info
.gs
.invocations
;
1108 info
->prop
.gp
.maxVertices
= nir
->info
.gs
.vertices_out
;
1109 info
->prop
.gp
.outputPrim
= nir
->info
.gs
.output_primitive
;
1111 case Program::TYPE_TESSELLATION_CONTROL
:
1112 case Program::TYPE_TESSELLATION_EVAL
:
1113 if (nir
->info
.tess
.primitive_mode
== GL_ISOLINES
)
1114 info
->prop
.tp
.domain
= GL_LINES
;
1116 info
->prop
.tp
.domain
= nir
->info
.tess
.primitive_mode
;
1117 info
->prop
.tp
.outputPatchSize
= nir
->info
.tess
.tcs_vertices_out
;
1118 info
->prop
.tp
.outputPrim
=
1119 nir
->info
.tess
.point_mode
? PIPE_PRIM_POINTS
: PIPE_PRIM_TRIANGLES
;
1120 info
->prop
.tp
.partitioning
= (nir
->info
.tess
.spacing
+ 1) % 3;
1121 info
->prop
.tp
.winding
= !nir
->info
.tess
.ccw
;
1123 case Program::TYPE_VERTEX
:
1124 info
->prop
.vp
.usesDrawParameters
=
1125 (nir
->info
.system_values_read
& BITFIELD64_BIT(SYSTEM_VALUE_BASE_VERTEX
)) ||
1126 (nir
->info
.system_values_read
& BITFIELD64_BIT(SYSTEM_VALUE_BASE_INSTANCE
)) ||
1127 (nir
->info
.system_values_read
& BITFIELD64_BIT(SYSTEM_VALUE_DRAW_ID
));
1137 Converter::visit(nir_function
*function
)
1139 // we only support emiting the main function for now
1140 assert(!strcmp(function
->name
, "main"));
1141 assert(function
->impl
);
1143 // usually the blocks will set everything up, but main is special
1144 BasicBlock
*entry
= new BasicBlock(prog
->main
);
1145 exit
= new BasicBlock(prog
->main
);
1146 blocks
[nir_start_block(function
->impl
)->index
] = entry
;
1147 prog
->main
->setEntry(entry
);
1148 prog
->main
->setExit(exit
);
1150 setPosition(entry
, true);
1152 switch (prog
->getType()) {
1153 case Program::TYPE_TESSELLATION_CONTROL
:
1155 OP_SUB
, TYPE_U32
, getSSA(),
1156 mkOp1v(OP_RDSV
, TYPE_U32
, getSSA(), mkSysVal(SV_LANEID
, 0)),
1157 mkOp1v(OP_RDSV
, TYPE_U32
, getSSA(), mkSysVal(SV_INVOCATION_ID
, 0)));
1159 case Program::TYPE_FRAGMENT
: {
1160 Symbol
*sv
= mkSysVal(SV_POSITION
, 3);
1161 fragCoord
[3] = mkOp1v(OP_RDSV
, TYPE_F32
, getSSA(), sv
);
1162 fp
.position
= mkOp1v(OP_RCP
, TYPE_F32
, fragCoord
[3], fragCoord
[3]);
1169 nir_index_ssa_defs(function
->impl
);
1170 foreach_list_typed(nir_cf_node
, node
, node
, &function
->impl
->body
) {
1175 bb
->cfg
.attach(&exit
->cfg
, Graph::Edge::TREE
);
1176 setPosition(exit
, true);
1178 // TODO: for non main function this needs to be a OP_RETURN
1179 mkOp(OP_EXIT
, TYPE_NONE
, NULL
)->terminator
= 1;
1184 Converter::visit(nir_cf_node
*node
)
1186 switch (node
->type
) {
1187 case nir_cf_node_block
:
1188 return visit(nir_cf_node_as_block(node
));
1189 case nir_cf_node_if
:
1190 return visit(nir_cf_node_as_if(node
));
1191 case nir_cf_node_loop
:
1192 return visit(nir_cf_node_as_loop(node
));
1194 ERROR("unknown nir_cf_node type %u\n", node
->type
);
1200 Converter::visit(nir_block
*block
)
1202 if (!block
->predecessors
->entries
&& block
->instr_list
.is_empty())
1205 BasicBlock
*bb
= convert(block
);
1207 setPosition(bb
, true);
1208 nir_foreach_instr(insn
, block
) {
1216 Converter::visit(nir_if
*nif
)
1218 DataType sType
= getSType(nif
->condition
, false, false);
1219 Value
*src
= getSrc(&nif
->condition
, 0);
1221 nir_block
*lastThen
= nir_if_last_then_block(nif
);
1222 nir_block
*lastElse
= nir_if_last_else_block(nif
);
1224 assert(!lastThen
->successors
[1]);
1225 assert(!lastElse
->successors
[1]);
1227 BasicBlock
*ifBB
= convert(nir_if_first_then_block(nif
));
1228 BasicBlock
*elseBB
= convert(nir_if_first_else_block(nif
));
1230 bb
->cfg
.attach(&ifBB
->cfg
, Graph::Edge::TREE
);
1231 bb
->cfg
.attach(&elseBB
->cfg
, Graph::Edge::TREE
);
1233 // we only insert joinats, if both nodes end up at the end of the if again.
1234 // the reason for this to not happens are breaks/continues/ret/... which
1235 // have their own handling
1236 if (lastThen
->successors
[0] == lastElse
->successors
[0])
1237 bb
->joinAt
= mkFlow(OP_JOINAT
, convert(lastThen
->successors
[0]),
1240 mkFlow(OP_BRA
, elseBB
, CC_EQ
, src
)->setType(sType
);
1242 foreach_list_typed(nir_cf_node
, node
, node
, &nif
->then_list
) {
1246 setPosition(convert(lastThen
), true);
1247 if (!bb
->getExit() ||
1248 !bb
->getExit()->asFlow() ||
1249 bb
->getExit()->asFlow()->op
== OP_JOIN
) {
1250 BasicBlock
*tailBB
= convert(lastThen
->successors
[0]);
1251 mkFlow(OP_BRA
, tailBB
, CC_ALWAYS
, NULL
);
1252 bb
->cfg
.attach(&tailBB
->cfg
, Graph::Edge::FORWARD
);
1255 foreach_list_typed(nir_cf_node
, node
, node
, &nif
->else_list
) {
1259 setPosition(convert(lastElse
), true);
1260 if (!bb
->getExit() ||
1261 !bb
->getExit()->asFlow() ||
1262 bb
->getExit()->asFlow()->op
== OP_JOIN
) {
1263 BasicBlock
*tailBB
= convert(lastElse
->successors
[0]);
1264 mkFlow(OP_BRA
, tailBB
, CC_ALWAYS
, NULL
);
1265 bb
->cfg
.attach(&tailBB
->cfg
, Graph::Edge::FORWARD
);
1268 if (lastThen
->successors
[0] == lastElse
->successors
[0]) {
1269 setPosition(convert(lastThen
->successors
[0]), true);
1270 mkFlow(OP_JOIN
, NULL
, CC_ALWAYS
, NULL
)->fixed
= 1;
1277 Converter::visit(nir_loop
*loop
)
1280 func
->loopNestingBound
= std::max(func
->loopNestingBound
, curLoopDepth
);
1282 BasicBlock
*loopBB
= convert(nir_loop_first_block(loop
));
1283 BasicBlock
*tailBB
=
1284 convert(nir_cf_node_as_block(nir_cf_node_next(&loop
->cf_node
)));
1285 bb
->cfg
.attach(&loopBB
->cfg
, Graph::Edge::TREE
);
1287 mkFlow(OP_PREBREAK
, tailBB
, CC_ALWAYS
, NULL
);
1288 setPosition(loopBB
, false);
1289 mkFlow(OP_PRECONT
, loopBB
, CC_ALWAYS
, NULL
);
1291 foreach_list_typed(nir_cf_node
, node
, node
, &loop
->body
) {
1295 Instruction
*insn
= bb
->getExit();
1296 if (bb
->cfg
.incidentCount() != 0) {
1297 if (!insn
|| !insn
->asFlow()) {
1298 mkFlow(OP_CONT
, loopBB
, CC_ALWAYS
, NULL
);
1299 bb
->cfg
.attach(&loopBB
->cfg
, Graph::Edge::BACK
);
1300 } else if (insn
&& insn
->op
== OP_BRA
&& !insn
->getPredicate() &&
1301 tailBB
->cfg
.incidentCount() == 0) {
1302 // RA doesn't like having blocks around with no incident edge,
1303 // so we create a fake one to make it happy
1304 bb
->cfg
.attach(&tailBB
->cfg
, Graph::Edge::TREE
);
1314 Converter::visit(nir_instr
*insn
)
1316 switch (insn
->type
) {
1317 case nir_instr_type_intrinsic
:
1318 return visit(nir_instr_as_intrinsic(insn
));
1319 case nir_instr_type_jump
:
1320 return visit(nir_instr_as_jump(insn
));
1321 case nir_instr_type_load_const
:
1322 return visit(nir_instr_as_load_const(insn
));
1324 ERROR("unknown nir_instr type %u\n", insn
->type
);
1331 Converter::visit(nir_intrinsic_instr
*insn
)
1333 nir_intrinsic_op op
= insn
->intrinsic
;
1337 ERROR("unknown nir_intrinsic_op %s\n", nir_intrinsic_infos
[op
].name
);
1345 Converter::visit(nir_jump_instr
*insn
)
1347 switch (insn
->type
) {
1348 case nir_jump_return
:
1349 // TODO: this only works in the main function
1350 mkFlow(OP_BRA
, exit
, CC_ALWAYS
, NULL
);
1351 bb
->cfg
.attach(&exit
->cfg
, Graph::Edge::CROSS
);
1353 case nir_jump_break
:
1354 case nir_jump_continue
: {
1355 bool isBreak
= insn
->type
== nir_jump_break
;
1356 nir_block
*block
= insn
->instr
.block
;
1357 assert(!block
->successors
[1]);
1358 BasicBlock
*target
= convert(block
->successors
[0]);
1359 mkFlow(isBreak
? OP_BREAK
: OP_CONT
, target
, CC_ALWAYS
, NULL
);
1360 bb
->cfg
.attach(&target
->cfg
, isBreak
? Graph::Edge::CROSS
: Graph::Edge::BACK
);
1364 ERROR("unknown nir_jump_type %u\n", insn
->type
);
1372 Converter::visit(nir_load_const_instr
*insn
)
1374 assert(insn
->def
.bit_size
<= 64);
1376 LValues
&newDefs
= convert(&insn
->def
);
1377 for (int i
= 0; i
< insn
->def
.num_components
; i
++) {
1378 switch (insn
->def
.bit_size
) {
1380 loadImm(newDefs
[i
], insn
->value
.u64
[i
]);
1383 loadImm(newDefs
[i
], insn
->value
.u32
[i
]);
1386 loadImm(newDefs
[i
], insn
->value
.u16
[i
]);
1389 loadImm(newDefs
[i
], insn
->value
.u8
[i
]);
1401 if (prog
->dbgFlags
& NV50_IR_DEBUG_VERBOSE
)
1402 nir_print_shader(nir
, stderr
);
1404 NIR_PASS_V(nir
, nir_lower_io
, nir_var_all
, type_size
, (nir_lower_io_options
)0);
1405 NIR_PASS_V(nir
, nir_lower_regs_to_ssa
);
1406 NIR_PASS_V(nir
, nir_lower_load_const_to_scalar
);
1407 NIR_PASS_V(nir
, nir_lower_vars_to_ssa
);
1408 NIR_PASS_V(nir
, nir_lower_alu_to_scalar
);
1409 NIR_PASS_V(nir
, nir_lower_phis_to_scalar
);
1413 NIR_PASS(progress
, nir
, nir_copy_prop
);
1414 NIR_PASS(progress
, nir
, nir_opt_remove_phis
);
1415 NIR_PASS(progress
, nir
, nir_opt_trivial_continues
);
1416 NIR_PASS(progress
, nir
, nir_opt_cse
);
1417 NIR_PASS(progress
, nir
, nir_opt_algebraic
);
1418 NIR_PASS(progress
, nir
, nir_opt_constant_folding
);
1419 NIR_PASS(progress
, nir
, nir_copy_prop
);
1420 NIR_PASS(progress
, nir
, nir_opt_dce
);
1421 NIR_PASS(progress
, nir
, nir_opt_dead_cf
);
1424 NIR_PASS_V(nir
, nir_lower_bool_to_int32
);
1425 NIR_PASS_V(nir
, nir_lower_locals_to_regs
);
1426 NIR_PASS_V(nir
, nir_remove_dead_variables
, nir_var_function_temp
);
1427 NIR_PASS_V(nir
, nir_convert_from_ssa
, true);
1429 // Garbage collect dead instructions
1433 ERROR("Couldn't prase NIR!\n");
1437 if (!assignSlots()) {
1438 ERROR("Couldn't assign slots!\n");
1442 if (prog
->dbgFlags
& NV50_IR_DEBUG_BASIC
)
1443 nir_print_shader(nir
, stderr
);
1445 nir_foreach_function(function
, nir
) {
1446 if (!visit(function
))
1453 } // unnamed namespace
1458 Program::makeFromNIR(struct nv50_ir_prog_info
*info
)
1460 nir_shader
*nir
= (nir_shader
*)info
->bin
.source
;
1461 Converter
converter(this, nir
, info
);
1462 bool result
= converter
.run();
1465 LoweringHelper lowering
;
1467 tlsSize
= info
->bin
.tlsSpace
;
1471 } // namespace nv50_ir