Lines Matching refs:spv

45 namespace spv {  namespace
76 SpecConstantOpModeGuard(spv::Builder* builder) in SpecConstantOpModeGuard()
89 spv::Builder* builder_;
94 spv::Decoration precision;
95 spv::Decoration noContraction;
96 spv::Decoration nonUniform;
108 …TGlslangToSpvTraverser(unsigned int spvVersion, const glslang::TIntermediate*, spv::SpvBuildLogger…
129 spv::Decoration TranslateInterpolationDecoration(const glslang::TQualifier& qualifier);
130 spv::Decoration TranslateAuxiliaryStorageDecoration(const glslang::TQualifier& qualifier);
131 spv::Decoration TranslateNonUniformDecoration(const glslang::TQualifier& qualifier);
132 spv::Builder::AccessChain::CoherentFlags TranslateCoherent(const glslang::TType& type);
133spv::MemoryAccessMask TranslateMemoryAccess(const spv::Builder::AccessChain::CoherentFlags &cohere…
134spv::ImageOperandsMask TranslateImageOperands(const spv::Builder::AccessChain::CoherentFlags &cohe…
135 spv::Scope TranslateMemoryScope(const spv::Builder::AccessChain::CoherentFlags &coherentFlags);
136 spv::BuiltIn TranslateBuiltInDecoration(glslang::TBuiltInVariable, bool memberDeclaration);
137 spv::ImageFormat TranslateImageFormat(const glslang::TType& type);
138 spv::SelectionControlMask TranslateSelectionControl(const glslang::TIntermSelection&) const;
139 spv::SelectionControlMask TranslateSwitchControl(const glslang::TIntermSwitch&) const;
140spv::LoopControlMask TranslateLoopControl(const glslang::TIntermLoop&, unsigned int& dependencyLen…
141 spv::StorageClass TranslateStorageClass(const glslang::TType&);
143 spv::Id createSpvVariable(const glslang::TIntermSymbol*);
144 spv::Id getSampledType(const glslang::TSampler&);
145 spv::Id getInvertedSwizzleType(const glslang::TIntermTyped&);
146spv::Id createInvertedSwizzle(spv::Decoration precision, const glslang::TIntermTyped&, spv::Id par…
148 spv::Id convertGlslangToSpvType(const glslang::TType& type, bool forwardReferenceOnly = false);
149spv::Id convertGlslangToSpvType(const glslang::TType& type, glslang::TLayoutPacking, const glslang…
152spv::Id convertGlslangStructToSpvType(const glslang::TType&, const glslang::TTypeList* glslangStru…
155 const glslang::TQualifier&, spv::Id);
156 spv::Id makeArraySizeId(const glslang::TArraySizes&, int dim);
157 spv::Id accessChainLoad(const glslang::TType& type);
158 void accessChainStore(const glslang::TType& type, spv::Id rvalue);
159 void multiTypeStore(const glslang::TType&, spv::Id rValue);
174 void translateArguments(const glslang::TIntermAggregate& node, std::vector<spv::Id>& arguments);
175 void translateArguments(glslang::TIntermUnary& node, std::vector<spv::Id>& arguments);
176 spv::Id createImageTextureFunctionCall(glslang::TIntermOperator* node);
177 spv::Id handleUserFunctionCall(const glslang::TIntermAggregate*);
179spv::Id createBinaryOperation(glslang::TOperator op, OpDecorations&, spv::Id typeId, spv::Id left,…
181spv::Id createBinaryMatrixOperation(spv::Op, OpDecorations&, spv::Id typeId, spv::Id left, spv::Id…
182spv::Id createUnaryOperation(glslang::TOperator op, OpDecorations&, spv::Id typeId, spv::Id operan…
184 spv::Id createUnaryMatrixOperation(spv::Op op, OpDecorations&, spv::Id typeId, spv::Id operand,
186spv::Id createConversion(glslang::TOperator op, OpDecorations&, spv::Id destTypeId, spv::Id operan…
188 spv::Id createIntWidthConversion(glslang::TOperator op, spv::Id operand, int vectorSize);
189 spv::Id makeSmearedConstant(spv::Id constant, int vectorSize);
190spv::Id createAtomicOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, st…
191spv::Id createInvocationsOperation(glslang::TOperator op, spv::Id typeId, std::vector<spv::Id>& op…
192spv::Id CreateInvocationsVectorOperation(spv::Op op, spv::GroupOperation groupOperation, spv::Id t…
193spv::Id createSubgroupOperation(glslang::TOperator op, spv::Id typeId, std::vector<spv::Id>& opera…
194spv::Id createMiscOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId, std:…
195 spv::Id createNoArgOperation(glslang::TOperator op, spv::Decoration precision, spv::Id typeId);
196 spv::Id getSymbolId(const glslang::TIntermSymbol* node);
198 void addMeshNVDecoration(spv::Id id, int member, const glslang::TQualifier & qualifier);
200 spv::Id createSpvConstant(const glslang::TIntermTyped&);
201spv::Id createSpvConstantFromConstUnionArray(const glslang::TType& type, const glslang::TConstUnio…
204spv::Id createShortCircuit(glslang::TOperator, glslang::TIntermTyped& left, glslang::TIntermTyped&…
206 spv::Id getExtBuiltins(const char* name);
224 spv::Function* shaderEntry;
225 spv::Function* currentFunction;
226 spv::Instruction* entryPoint;
229 spv::SpvBuildLogger* logger;
232 spv::Builder builder;
236 …std::set<spv::Id> iOSet; // all input/output variables from either static use or declara…
238 spv::Id stdBuiltins;
239 std::unordered_map<const char*, spv::Id> extBuiltinMap;
241 std::unordered_map<int, spv::Id> symbolValues;
243 std::unordered_map<std::string, spv::Function*> functionMap;
244 …std::unordered_map<const glslang::TTypeList*, spv::Id> structMap[glslang::ElpCount][glslang::ElmCo…
250 std::map<const glslang::TType *, spv::Id> forwardPointers;
258 spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile profile) in TranslateSourceLanguage()
266 return spv::SourceLanguageGLSL; in TranslateSourceLanguage()
268 return spv::SourceLanguageESSL; in TranslateSourceLanguage()
270 return spv::SourceLanguageUnknown; in TranslateSourceLanguage()
273 return spv::SourceLanguageHLSL; in TranslateSourceLanguage()
275 return spv::SourceLanguageUnknown; in TranslateSourceLanguage()
280 spv::ExecutionModel TranslateExecutionModel(EShLanguage stage) in TranslateExecutionModel()
283 case EShLangVertex: return spv::ExecutionModelVertex; in TranslateExecutionModel()
284 case EShLangTessControl: return spv::ExecutionModelTessellationControl; in TranslateExecutionModel()
285 case EShLangTessEvaluation: return spv::ExecutionModelTessellationEvaluation; in TranslateExecutionModel()
286 case EShLangGeometry: return spv::ExecutionModelGeometry; in TranslateExecutionModel()
287 case EShLangFragment: return spv::ExecutionModelFragment; in TranslateExecutionModel()
288 case EShLangCompute: return spv::ExecutionModelGLCompute; in TranslateExecutionModel()
290 case EShLangRayGenNV: return spv::ExecutionModelRayGenerationNV; in TranslateExecutionModel()
291 case EShLangIntersectNV: return spv::ExecutionModelIntersectionNV; in TranslateExecutionModel()
292 case EShLangAnyHitNV: return spv::ExecutionModelAnyHitNV; in TranslateExecutionModel()
293 case EShLangClosestHitNV: return spv::ExecutionModelClosestHitNV; in TranslateExecutionModel()
294 case EShLangMissNV: return spv::ExecutionModelMissNV; in TranslateExecutionModel()
295 case EShLangCallableNV: return spv::ExecutionModelCallableNV; in TranslateExecutionModel()
296 case EShLangTaskNV: return spv::ExecutionModelTaskNV; in TranslateExecutionModel()
297 case EShLangMeshNV: return spv::ExecutionModelMeshNV; in TranslateExecutionModel()
301 return spv::ExecutionModelFragment; in TranslateExecutionModel()
306 spv::Dim TranslateDimensionality(const glslang::TSampler& sampler) in TranslateDimensionality()
309 case glslang::Esd1D: return spv::Dim1D; in TranslateDimensionality()
310 case glslang::Esd2D: return spv::Dim2D; in TranslateDimensionality()
311 case glslang::Esd3D: return spv::Dim3D; in TranslateDimensionality()
312 case glslang::EsdCube: return spv::DimCube; in TranslateDimensionality()
313 case glslang::EsdRect: return spv::DimRect; in TranslateDimensionality()
314 case glslang::EsdBuffer: return spv::DimBuffer; in TranslateDimensionality()
315 case glslang::EsdSubpass: return spv::DimSubpassData; in TranslateDimensionality()
318 return spv::Dim2D; in TranslateDimensionality()
323 spv::Decoration TranslatePrecisionDecoration(glslang::TPrecisionQualifier glslangPrecision) in TranslatePrecisionDecoration()
326 case glslang::EpqLow: return spv::DecorationRelaxedPrecision; in TranslatePrecisionDecoration()
327 case glslang::EpqMedium: return spv::DecorationRelaxedPrecision; in TranslatePrecisionDecoration()
329 return spv::NoPrecision; in TranslatePrecisionDecoration()
334 spv::Decoration TranslatePrecisionDecoration(const glslang::TType& type) in TranslatePrecisionDecoration()
340 spv::Decoration TranslateBlockDecoration(const glslang::TType& type, bool useStorageBuffer) in TranslateBlockDecoration()
344 case glslang::EvqUniform: return spv::DecorationBlock; in TranslateBlockDecoration()
345 …case glslang::EvqBuffer: return useStorageBuffer ? spv::DecorationBlock : spv::DecorationBuf… in TranslateBlockDecoration()
346 case glslang::EvqVaryingIn: return spv::DecorationBlock; in TranslateBlockDecoration()
347 case glslang::EvqVaryingOut: return spv::DecorationBlock; in TranslateBlockDecoration()
349 case glslang::EvqPayloadNV: return spv::DecorationBlock; in TranslateBlockDecoration()
350 case glslang::EvqPayloadInNV: return spv::DecorationBlock; in TranslateBlockDecoration()
351 case glslang::EvqHitAttrNV: return spv::DecorationBlock; in TranslateBlockDecoration()
352 case glslang::EvqCallableDataNV: return spv::DecorationBlock; in TranslateBlockDecoration()
353 case glslang::EvqCallableDataInNV: return spv::DecorationBlock; in TranslateBlockDecoration()
361 return spv::DecorationMax; in TranslateBlockDecoration()
365 void TranslateMemoryDecoration(const glslang::TQualifier& qualifier, std::vector<spv::Decoration>& … in TranslateMemoryDecoration()
369 memory.push_back(spv::DecorationCoherent); in TranslateMemoryDecoration()
371 memory.push_back(spv::DecorationVolatile); in TranslateMemoryDecoration()
372 memory.push_back(spv::DecorationCoherent); in TranslateMemoryDecoration()
376 memory.push_back(spv::DecorationRestrict); in TranslateMemoryDecoration()
378 memory.push_back(spv::DecorationNonWritable); in TranslateMemoryDecoration()
380 memory.push_back(spv::DecorationNonReadable); in TranslateMemoryDecoration()
384 spv::Decoration TranslateLayoutDecoration(const glslang::TType& type, glslang::TLayoutMatrix matrix… in TranslateLayoutDecoration()
389 return spv::DecorationRowMajor; in TranslateLayoutDecoration()
391 return spv::DecorationColMajor; in TranslateLayoutDecoration()
394 return spv::DecorationMax; in TranslateLayoutDecoration()
399 return spv::DecorationMax; in TranslateLayoutDecoration()
406 case glslang::ElpShared: return spv::DecorationGLSLShared; in TranslateLayoutDecoration()
407 case glslang::ElpPacked: return spv::DecorationGLSLPacked; in TranslateLayoutDecoration()
409 return spv::DecorationMax; in TranslateLayoutDecoration()
415 case glslang::ElpShared: return spv::DecorationGLSLShared; in TranslateLayoutDecoration()
416 case glslang::ElpPacked: return spv::DecorationGLSLPacked; in TranslateLayoutDecoration()
422 return spv::DecorationMax; in TranslateLayoutDecoration()
429 return spv::DecorationMax; in TranslateLayoutDecoration()
433 return spv::DecorationMax; in TranslateLayoutDecoration()
442 spv::Decoration TGlslangToSpvTraverser::TranslateInterpolationDecoration(const glslang::TQualifier&… in TranslateInterpolationDecoration()
446 return spv::DecorationMax; in TranslateInterpolationDecoration()
448 return spv::DecorationNoPerspective; in TranslateInterpolationDecoration()
450 return spv::DecorationFlat; in TranslateInterpolationDecoration()
453 builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter); in TranslateInterpolationDecoration()
454 return spv::DecorationExplicitInterpAMD; in TranslateInterpolationDecoration()
458 return spv::DecorationMax; in TranslateInterpolationDecoration()
464 spv::Decoration TGlslangToSpvTraverser::TranslateAuxiliaryStorageDecoration(const glslang::TQualifi… in TranslateAuxiliaryStorageDecoration()
467 return spv::DecorationPatch; in TranslateAuxiliaryStorageDecoration()
469 return spv::DecorationCentroid; in TranslateAuxiliaryStorageDecoration()
471 builder.addCapability(spv::CapabilitySampleRateShading); in TranslateAuxiliaryStorageDecoration()
472 return spv::DecorationSample; in TranslateAuxiliaryStorageDecoration()
474 return spv::DecorationMax; in TranslateAuxiliaryStorageDecoration()
478 spv::Decoration TranslateInvariantDecoration(const glslang::TQualifier& qualifier) in TranslateInvariantDecoration()
481 return spv::DecorationInvariant; in TranslateInvariantDecoration()
483 return spv::DecorationMax; in TranslateInvariantDecoration()
487 spv::Decoration TranslateNoContractionDecoration(const glslang::TQualifier& qualifier) in TranslateNoContractionDecoration()
490 return spv::DecorationNoContraction; in TranslateNoContractionDecoration()
492 return spv::DecorationMax; in TranslateNoContractionDecoration()
496 spv::Decoration TGlslangToSpvTraverser::TranslateNonUniformDecoration(const glslang::TQualifier& qu… in TranslateNonUniformDecoration()
500 builder.addCapability(spv::CapabilityShaderNonUniformEXT); in TranslateNonUniformDecoration()
501 return spv::DecorationNonUniformEXT; in TranslateNonUniformDecoration()
503 return spv::DecorationMax; in TranslateNonUniformDecoration()
506 spv::MemoryAccessMask TGlslangToSpvTraverser::TranslateMemoryAccess(const spv::Builder::AccessChain… in TranslateMemoryAccess()
509 return spv::MemoryAccessMaskNone; in TranslateMemoryAccess()
511 spv::MemoryAccessMask mask = spv::MemoryAccessMaskNone; in TranslateMemoryAccess()
518 mask = mask | spv::MemoryAccessMakePointerAvailableKHRMask | in TranslateMemoryAccess()
519 spv::MemoryAccessMakePointerVisibleKHRMask; in TranslateMemoryAccess()
522 mask = mask | spv::MemoryAccessNonPrivatePointerKHRMask; in TranslateMemoryAccess()
525 mask = mask | spv::MemoryAccessVolatileMask; in TranslateMemoryAccess()
527 if (mask != spv::MemoryAccessMaskNone) { in TranslateMemoryAccess()
528 builder.addCapability(spv::CapabilityVulkanMemoryModelKHR); in TranslateMemoryAccess()
533 spv::ImageOperandsMask TGlslangToSpvTraverser::TranslateImageOperands(const spv::Builder::AccessCha… in TranslateImageOperands()
536 return spv::ImageOperandsMaskNone; in TranslateImageOperands()
538 spv::ImageOperandsMask mask = spv::ImageOperandsMaskNone; in TranslateImageOperands()
545 mask = mask | spv::ImageOperandsMakeTexelAvailableKHRMask | in TranslateImageOperands()
546 spv::ImageOperandsMakeTexelVisibleKHRMask; in TranslateImageOperands()
549 mask = mask | spv::ImageOperandsNonPrivateTexelKHRMask; in TranslateImageOperands()
552 mask = mask | spv::ImageOperandsVolatileTexelKHRMask; in TranslateImageOperands()
554 if (mask != spv::ImageOperandsMaskNone) { in TranslateImageOperands()
555 builder.addCapability(spv::CapabilityVulkanMemoryModelKHR); in TranslateImageOperands()
560 spv::Builder::AccessChain::CoherentFlags TGlslangToSpvTraverser::TranslateCoherent(const glslang::T… in TranslateCoherent()
562 spv::Builder::AccessChain::CoherentFlags flags; in TranslateCoherent()
582 spv::Scope TGlslangToSpvTraverser::TranslateMemoryScope(const spv::Builder::AccessChain::CoherentFl… in TranslateMemoryScope()
584 spv::Scope scope; in TranslateMemoryScope()
587 …scope = glslangIntermediate->usingVulkanMemoryModel() ? spv::ScopeQueueFamilyKHR : spv::ScopeDevic… in TranslateMemoryScope()
589 scope = spv::ScopeDevice; in TranslateMemoryScope()
591 scope = spv::ScopeQueueFamilyKHR; in TranslateMemoryScope()
593 scope = spv::ScopeWorkgroup; in TranslateMemoryScope()
595 scope = spv::ScopeSubgroup; in TranslateMemoryScope()
597 scope = spv::ScopeMax; in TranslateMemoryScope()
599 if (glslangIntermediate->usingVulkanMemoryModel() && scope == spv::ScopeDevice) { in TranslateMemoryScope()
600 builder.addCapability(spv::CapabilityVulkanMemoryModelDeviceScopeKHR); in TranslateMemoryScope()
610 spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltInVariable builtIn, … in TranslateBuiltInDecoration()
618 builder.addCapability(spv::CapabilityGeometryPointSize); in TranslateBuiltInDecoration()
622 builder.addCapability(spv::CapabilityTessellationPointSize); in TranslateBuiltInDecoration()
628 return spv::BuiltInPointSize; in TranslateBuiltInDecoration()
638 builder.addCapability(spv::CapabilityClipDistance); in TranslateBuiltInDecoration()
639 return spv::BuiltInClipDistance; in TranslateBuiltInDecoration()
643 builder.addCapability(spv::CapabilityCullDistance); in TranslateBuiltInDecoration()
644 return spv::BuiltInCullDistance; in TranslateBuiltInDecoration()
647 builder.addCapability(spv::CapabilityMultiViewport); in TranslateBuiltInDecoration()
652 builder.addExtension(spv::E_SPV_EXT_shader_viewport_index_layer); in TranslateBuiltInDecoration()
653 builder.addCapability(spv::CapabilityShaderViewportIndexLayerEXT); in TranslateBuiltInDecoration()
655 return spv::BuiltInViewportIndex; in TranslateBuiltInDecoration()
658 builder.addCapability(spv::CapabilitySampleRateShading); in TranslateBuiltInDecoration()
659 return spv::BuiltInSampleId; in TranslateBuiltInDecoration()
662 builder.addCapability(spv::CapabilitySampleRateShading); in TranslateBuiltInDecoration()
663 return spv::BuiltInSamplePosition; in TranslateBuiltInDecoration()
666 return spv::BuiltInSampleMask; in TranslateBuiltInDecoration()
671 return spv::BuiltInLayer; in TranslateBuiltInDecoration()
674 builder.addCapability(spv::CapabilityGeometry); in TranslateBuiltInDecoration()
679 builder.addExtension(spv::E_SPV_EXT_shader_viewport_index_layer); in TranslateBuiltInDecoration()
680 builder.addCapability(spv::CapabilityShaderViewportIndexLayerEXT); in TranslateBuiltInDecoration()
682 return spv::BuiltInLayer; in TranslateBuiltInDecoration()
684 case glslang::EbvPosition: return spv::BuiltInPosition; in TranslateBuiltInDecoration()
685 case glslang::EbvVertexId: return spv::BuiltInVertexId; in TranslateBuiltInDecoration()
686 case glslang::EbvInstanceId: return spv::BuiltInInstanceId; in TranslateBuiltInDecoration()
687 case glslang::EbvVertexIndex: return spv::BuiltInVertexIndex; in TranslateBuiltInDecoration()
688 case glslang::EbvInstanceIndex: return spv::BuiltInInstanceIndex; in TranslateBuiltInDecoration()
691 addPre13Extension(spv::E_SPV_KHR_shader_draw_parameters); in TranslateBuiltInDecoration()
692 builder.addCapability(spv::CapabilityDrawParameters); in TranslateBuiltInDecoration()
693 return spv::BuiltInBaseVertex; in TranslateBuiltInDecoration()
696 addPre13Extension(spv::E_SPV_KHR_shader_draw_parameters); in TranslateBuiltInDecoration()
697 builder.addCapability(spv::CapabilityDrawParameters); in TranslateBuiltInDecoration()
698 return spv::BuiltInBaseInstance; in TranslateBuiltInDecoration()
701 addPre13Extension(spv::E_SPV_KHR_shader_draw_parameters); in TranslateBuiltInDecoration()
702 builder.addCapability(spv::CapabilityDrawParameters); in TranslateBuiltInDecoration()
703 return spv::BuiltInDrawIndex; in TranslateBuiltInDecoration()
707 builder.addCapability(spv::CapabilityGeometry); in TranslateBuiltInDecoration()
708 return spv::BuiltInPrimitiveId; in TranslateBuiltInDecoration()
711 builder.addExtension(spv::E_SPV_EXT_shader_stencil_export); in TranslateBuiltInDecoration()
712 builder.addCapability(spv::CapabilityStencilExportEXT); in TranslateBuiltInDecoration()
713 return spv::BuiltInFragStencilRefEXT; in TranslateBuiltInDecoration()
715 case glslang::EbvInvocationId: return spv::BuiltInInvocationId; in TranslateBuiltInDecoration()
716 case glslang::EbvTessLevelInner: return spv::BuiltInTessLevelInner; in TranslateBuiltInDecoration()
717 case glslang::EbvTessLevelOuter: return spv::BuiltInTessLevelOuter; in TranslateBuiltInDecoration()
718 case glslang::EbvTessCoord: return spv::BuiltInTessCoord; in TranslateBuiltInDecoration()
719 case glslang::EbvPatchVertices: return spv::BuiltInPatchVertices; in TranslateBuiltInDecoration()
720 case glslang::EbvFragCoord: return spv::BuiltInFragCoord; in TranslateBuiltInDecoration()
721 case glslang::EbvPointCoord: return spv::BuiltInPointCoord; in TranslateBuiltInDecoration()
722 case glslang::EbvFace: return spv::BuiltInFrontFacing; in TranslateBuiltInDecoration()
723 case glslang::EbvFragDepth: return spv::BuiltInFragDepth; in TranslateBuiltInDecoration()
724 case glslang::EbvHelperInvocation: return spv::BuiltInHelperInvocation; in TranslateBuiltInDecoration()
725 case glslang::EbvNumWorkGroups: return spv::BuiltInNumWorkgroups; in TranslateBuiltInDecoration()
726 case glslang::EbvWorkGroupSize: return spv::BuiltInWorkgroupSize; in TranslateBuiltInDecoration()
727 case glslang::EbvWorkGroupId: return spv::BuiltInWorkgroupId; in TranslateBuiltInDecoration()
728 case glslang::EbvLocalInvocationId: return spv::BuiltInLocalInvocationId; in TranslateBuiltInDecoration()
729 case glslang::EbvLocalInvocationIndex: return spv::BuiltInLocalInvocationIndex; in TranslateBuiltInDecoration()
730 case glslang::EbvGlobalInvocationId: return spv::BuiltInGlobalInvocationId; in TranslateBuiltInDecoration()
733 builder.addExtension(spv::E_SPV_KHR_shader_ballot); in TranslateBuiltInDecoration()
734 builder.addCapability(spv::CapabilitySubgroupBallotKHR); in TranslateBuiltInDecoration()
735 return spv::BuiltInSubgroupSize; in TranslateBuiltInDecoration()
738 builder.addExtension(spv::E_SPV_KHR_shader_ballot); in TranslateBuiltInDecoration()
739 builder.addCapability(spv::CapabilitySubgroupBallotKHR); in TranslateBuiltInDecoration()
740 return spv::BuiltInSubgroupLocalInvocationId; in TranslateBuiltInDecoration()
743 builder.addExtension(spv::E_SPV_KHR_shader_ballot); in TranslateBuiltInDecoration()
744 builder.addCapability(spv::CapabilitySubgroupBallotKHR); in TranslateBuiltInDecoration()
745 return spv::BuiltInSubgroupEqMaskKHR; in TranslateBuiltInDecoration()
748 builder.addExtension(spv::E_SPV_KHR_shader_ballot); in TranslateBuiltInDecoration()
749 builder.addCapability(spv::CapabilitySubgroupBallotKHR); in TranslateBuiltInDecoration()
750 return spv::BuiltInSubgroupGeMaskKHR; in TranslateBuiltInDecoration()
753 builder.addExtension(spv::E_SPV_KHR_shader_ballot); in TranslateBuiltInDecoration()
754 builder.addCapability(spv::CapabilitySubgroupBallotKHR); in TranslateBuiltInDecoration()
755 return spv::BuiltInSubgroupGtMaskKHR; in TranslateBuiltInDecoration()
758 builder.addExtension(spv::E_SPV_KHR_shader_ballot); in TranslateBuiltInDecoration()
759 builder.addCapability(spv::CapabilitySubgroupBallotKHR); in TranslateBuiltInDecoration()
760 return spv::BuiltInSubgroupLeMaskKHR; in TranslateBuiltInDecoration()
763 builder.addExtension(spv::E_SPV_KHR_shader_ballot); in TranslateBuiltInDecoration()
764 builder.addCapability(spv::CapabilitySubgroupBallotKHR); in TranslateBuiltInDecoration()
765 return spv::BuiltInSubgroupLtMaskKHR; in TranslateBuiltInDecoration()
768 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
769 return spv::BuiltInNumSubgroups; in TranslateBuiltInDecoration()
772 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
773 return spv::BuiltInSubgroupId; in TranslateBuiltInDecoration()
776 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
777 return spv::BuiltInSubgroupSize; in TranslateBuiltInDecoration()
780 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
781 return spv::BuiltInSubgroupLocalInvocationId; in TranslateBuiltInDecoration()
784 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
785 builder.addCapability(spv::CapabilityGroupNonUniformBallot); in TranslateBuiltInDecoration()
786 return spv::BuiltInSubgroupEqMask; in TranslateBuiltInDecoration()
789 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
790 builder.addCapability(spv::CapabilityGroupNonUniformBallot); in TranslateBuiltInDecoration()
791 return spv::BuiltInSubgroupGeMask; in TranslateBuiltInDecoration()
794 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
795 builder.addCapability(spv::CapabilityGroupNonUniformBallot); in TranslateBuiltInDecoration()
796 return spv::BuiltInSubgroupGtMask; in TranslateBuiltInDecoration()
799 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
800 builder.addCapability(spv::CapabilityGroupNonUniformBallot); in TranslateBuiltInDecoration()
801 return spv::BuiltInSubgroupLeMask; in TranslateBuiltInDecoration()
804 builder.addCapability(spv::CapabilityGroupNonUniform); in TranslateBuiltInDecoration()
805 builder.addCapability(spv::CapabilityGroupNonUniformBallot); in TranslateBuiltInDecoration()
806 return spv::BuiltInSubgroupLtMask; in TranslateBuiltInDecoration()
809 builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter); in TranslateBuiltInDecoration()
810 return spv::BuiltInBaryCoordNoPerspAMD; in TranslateBuiltInDecoration()
813 builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter); in TranslateBuiltInDecoration()
814 return spv::BuiltInBaryCoordNoPerspCentroidAMD; in TranslateBuiltInDecoration()
817 builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter); in TranslateBuiltInDecoration()
818 return spv::BuiltInBaryCoordNoPerspSampleAMD; in TranslateBuiltInDecoration()
821 builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter); in TranslateBuiltInDecoration()
822 return spv::BuiltInBaryCoordSmoothAMD; in TranslateBuiltInDecoration()
825 builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter); in TranslateBuiltInDecoration()
826 return spv::BuiltInBaryCoordSmoothCentroidAMD; in TranslateBuiltInDecoration()
829 builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter); in TranslateBuiltInDecoration()
830 return spv::BuiltInBaryCoordSmoothSampleAMD; in TranslateBuiltInDecoration()
833 builder.addExtension(spv::E_SPV_AMD_shader_explicit_vertex_parameter); in TranslateBuiltInDecoration()
834 return spv::BuiltInBaryCoordPullModelAMD; in TranslateBuiltInDecoration()
838 addPre13Extension(spv::E_SPV_KHR_device_group); in TranslateBuiltInDecoration()
839 builder.addCapability(spv::CapabilityDeviceGroup); in TranslateBuiltInDecoration()
840 return spv::BuiltInDeviceIndex; in TranslateBuiltInDecoration()
843 addPre13Extension(spv::E_SPV_KHR_multiview); in TranslateBuiltInDecoration()
844 builder.addCapability(spv::CapabilityMultiView); in TranslateBuiltInDecoration()
845 return spv::BuiltInViewIndex; in TranslateBuiltInDecoration()
848 builder.addExtension(spv::E_SPV_EXT_fragment_invocation_density); in TranslateBuiltInDecoration()
849 builder.addCapability(spv::CapabilityFragmentDensityEXT); in TranslateBuiltInDecoration()
850 return spv::BuiltInFragSizeEXT; in TranslateBuiltInDecoration()
853 builder.addExtension(spv::E_SPV_EXT_fragment_invocation_density); in TranslateBuiltInDecoration()
854 builder.addCapability(spv::CapabilityFragmentDensityEXT); in TranslateBuiltInDecoration()
855 return spv::BuiltInFragInvocationCountEXT; in TranslateBuiltInDecoration()
860 builder.addExtension(spv::E_SPV_NV_viewport_array2); in TranslateBuiltInDecoration()
861 builder.addCapability(spv::CapabilityShaderViewportMaskNV); in TranslateBuiltInDecoration()
863 return spv::BuiltInViewportMaskNV; in TranslateBuiltInDecoration()
866 builder.addExtension(spv::E_SPV_NV_stereo_view_rendering); in TranslateBuiltInDecoration()
867 builder.addCapability(spv::CapabilityShaderStereoViewNV); in TranslateBuiltInDecoration()
869 return spv::BuiltInSecondaryPositionNV; in TranslateBuiltInDecoration()
872 builder.addExtension(spv::E_SPV_NV_stereo_view_rendering); in TranslateBuiltInDecoration()
873 builder.addCapability(spv::CapabilityShaderStereoViewNV); in TranslateBuiltInDecoration()
875 return spv::BuiltInSecondaryViewportMaskNV; in TranslateBuiltInDecoration()
878 builder.addExtension(spv::E_SPV_NVX_multiview_per_view_attributes); in TranslateBuiltInDecoration()
879 builder.addCapability(spv::CapabilityPerViewAttributesNV); in TranslateBuiltInDecoration()
881 return spv::BuiltInPositionPerViewNV; in TranslateBuiltInDecoration()
884 builder.addExtension(spv::E_SPV_NVX_multiview_per_view_attributes); in TranslateBuiltInDecoration()
885 builder.addCapability(spv::CapabilityPerViewAttributesNV); in TranslateBuiltInDecoration()
887 return spv::BuiltInViewportMaskPerViewNV; in TranslateBuiltInDecoration()
889 builder.addExtension(spv::E_SPV_EXT_fragment_fully_covered); in TranslateBuiltInDecoration()
890 builder.addCapability(spv::CapabilityFragmentFullyCoveredEXT); in TranslateBuiltInDecoration()
891 return spv::BuiltInFullyCoveredEXT; in TranslateBuiltInDecoration()
893 builder.addExtension(spv::E_SPV_NV_shading_rate); in TranslateBuiltInDecoration()
894 builder.addCapability(spv::CapabilityShadingRateNV); in TranslateBuiltInDecoration()
895 return spv::BuiltInFragmentSizeNV; in TranslateBuiltInDecoration()
897 builder.addExtension(spv::E_SPV_NV_shading_rate); in TranslateBuiltInDecoration()
898 builder.addCapability(spv::CapabilityShadingRateNV); in TranslateBuiltInDecoration()
899 return spv::BuiltInInvocationsPerPixelNV; in TranslateBuiltInDecoration()
903 return spv::BuiltInLaunchIdNV; in TranslateBuiltInDecoration()
905 return spv::BuiltInLaunchSizeNV; in TranslateBuiltInDecoration()
907 return spv::BuiltInWorldRayOriginNV; in TranslateBuiltInDecoration()
909 return spv::BuiltInWorldRayDirectionNV; in TranslateBuiltInDecoration()
911 return spv::BuiltInObjectRayOriginNV; in TranslateBuiltInDecoration()
913 return spv::BuiltInObjectRayDirectionNV; in TranslateBuiltInDecoration()
915 return spv::BuiltInRayTminNV; in TranslateBuiltInDecoration()
917 return spv::BuiltInRayTmaxNV; in TranslateBuiltInDecoration()
919 return spv::BuiltInInstanceCustomIndexNV; in TranslateBuiltInDecoration()
921 return spv::BuiltInHitTNV; in TranslateBuiltInDecoration()
923 return spv::BuiltInHitKindNV; in TranslateBuiltInDecoration()
925 return spv::BuiltInObjectToWorldNV; in TranslateBuiltInDecoration()
927 return spv::BuiltInWorldToObjectNV; in TranslateBuiltInDecoration()
929 return spv::BuiltInIncomingRayFlagsNV; in TranslateBuiltInDecoration()
931 builder.addExtension(spv::E_SPV_NV_fragment_shader_barycentric); in TranslateBuiltInDecoration()
932 builder.addCapability(spv::CapabilityFragmentBarycentricNV); in TranslateBuiltInDecoration()
933 return spv::BuiltInBaryCoordNV; in TranslateBuiltInDecoration()
935 builder.addExtension(spv::E_SPV_NV_fragment_shader_barycentric); in TranslateBuiltInDecoration()
936 builder.addCapability(spv::CapabilityFragmentBarycentricNV); in TranslateBuiltInDecoration()
937 return spv::BuiltInBaryCoordNoPerspNV; in TranslateBuiltInDecoration()
939 return spv::BuiltInTaskCountNV; in TranslateBuiltInDecoration()
941 return spv::BuiltInPrimitiveCountNV; in TranslateBuiltInDecoration()
943 return spv::BuiltInPrimitiveIndicesNV; in TranslateBuiltInDecoration()
945 return spv::BuiltInClipDistancePerViewNV; in TranslateBuiltInDecoration()
947 return spv::BuiltInCullDistancePerViewNV; in TranslateBuiltInDecoration()
949 return spv::BuiltInLayerPerViewNV; in TranslateBuiltInDecoration()
951 return spv::BuiltInMeshViewCountNV; in TranslateBuiltInDecoration()
953 return spv::BuiltInMeshViewIndicesNV; in TranslateBuiltInDecoration()
956 return spv::BuiltInMax; in TranslateBuiltInDecoration()
961 spv::ImageFormat TGlslangToSpvTraverser::TranslateImageFormat(const glslang::TType& type) in TranslateImageFormat()
995 builder.addCapability(spv::CapabilityStorageImageExtendedFormats); in TranslateImageFormat()
1004 case glslang::ElfNone: return spv::ImageFormatUnknown; in TranslateImageFormat()
1005 case glslang::ElfRgba32f: return spv::ImageFormatRgba32f; in TranslateImageFormat()
1006 case glslang::ElfRgba16f: return spv::ImageFormatRgba16f; in TranslateImageFormat()
1007 case glslang::ElfR32f: return spv::ImageFormatR32f; in TranslateImageFormat()
1008 case glslang::ElfRgba8: return spv::ImageFormatRgba8; in TranslateImageFormat()
1009 case glslang::ElfRgba8Snorm: return spv::ImageFormatRgba8Snorm; in TranslateImageFormat()
1010 case glslang::ElfRg32f: return spv::ImageFormatRg32f; in TranslateImageFormat()
1011 case glslang::ElfRg16f: return spv::ImageFormatRg16f; in TranslateImageFormat()
1012 case glslang::ElfR11fG11fB10f: return spv::ImageFormatR11fG11fB10f; in TranslateImageFormat()
1013 case glslang::ElfR16f: return spv::ImageFormatR16f; in TranslateImageFormat()
1014 case glslang::ElfRgba16: return spv::ImageFormatRgba16; in TranslateImageFormat()
1015 case glslang::ElfRgb10A2: return spv::ImageFormatRgb10A2; in TranslateImageFormat()
1016 case glslang::ElfRg16: return spv::ImageFormatRg16; in TranslateImageFormat()
1017 case glslang::ElfRg8: return spv::ImageFormatRg8; in TranslateImageFormat()
1018 case glslang::ElfR16: return spv::ImageFormatR16; in TranslateImageFormat()
1019 case glslang::ElfR8: return spv::ImageFormatR8; in TranslateImageFormat()
1020 case glslang::ElfRgba16Snorm: return spv::ImageFormatRgba16Snorm; in TranslateImageFormat()
1021 case glslang::ElfRg16Snorm: return spv::ImageFormatRg16Snorm; in TranslateImageFormat()
1022 case glslang::ElfRg8Snorm: return spv::ImageFormatRg8Snorm; in TranslateImageFormat()
1023 case glslang::ElfR16Snorm: return spv::ImageFormatR16Snorm; in TranslateImageFormat()
1024 case glslang::ElfR8Snorm: return spv::ImageFormatR8Snorm; in TranslateImageFormat()
1025 case glslang::ElfRgba32i: return spv::ImageFormatRgba32i; in TranslateImageFormat()
1026 case glslang::ElfRgba16i: return spv::ImageFormatRgba16i; in TranslateImageFormat()
1027 case glslang::ElfRgba8i: return spv::ImageFormatRgba8i; in TranslateImageFormat()
1028 case glslang::ElfR32i: return spv::ImageFormatR32i; in TranslateImageFormat()
1029 case glslang::ElfRg32i: return spv::ImageFormatRg32i; in TranslateImageFormat()
1030 case glslang::ElfRg16i: return spv::ImageFormatRg16i; in TranslateImageFormat()
1031 case glslang::ElfRg8i: return spv::ImageFormatRg8i; in TranslateImageFormat()
1032 case glslang::ElfR16i: return spv::ImageFormatR16i; in TranslateImageFormat()
1033 case glslang::ElfR8i: return spv::ImageFormatR8i; in TranslateImageFormat()
1034 case glslang::ElfRgba32ui: return spv::ImageFormatRgba32ui; in TranslateImageFormat()
1035 case glslang::ElfRgba16ui: return spv::ImageFormatRgba16ui; in TranslateImageFormat()
1036 case glslang::ElfRgba8ui: return spv::ImageFormatRgba8ui; in TranslateImageFormat()
1037 case glslang::ElfR32ui: return spv::ImageFormatR32ui; in TranslateImageFormat()
1038 case glslang::ElfRg32ui: return spv::ImageFormatRg32ui; in TranslateImageFormat()
1039 case glslang::ElfRg16ui: return spv::ImageFormatRg16ui; in TranslateImageFormat()
1040 case glslang::ElfRgb10a2ui: return spv::ImageFormatRgb10a2ui; in TranslateImageFormat()
1041 case glslang::ElfRg8ui: return spv::ImageFormatRg8ui; in TranslateImageFormat()
1042 case glslang::ElfR16ui: return spv::ImageFormatR16ui; in TranslateImageFormat()
1043 case glslang::ElfR8ui: return spv::ImageFormatR8ui; in TranslateImageFormat()
1044 default: return spv::ImageFormatMax; in TranslateImageFormat()
1048 spv::SelectionControlMask TGlslangToSpvTraverser::TranslateSelectionControl(const glslang::TIntermS… in TranslateSelectionControl()
1051 return spv::SelectionControlFlattenMask; in TranslateSelectionControl()
1053 return spv::SelectionControlDontFlattenMask; in TranslateSelectionControl()
1054 return spv::SelectionControlMaskNone; in TranslateSelectionControl()
1057 spv::SelectionControlMask TGlslangToSpvTraverser::TranslateSwitchControl(const glslang::TIntermSwit… in TranslateSwitchControl()
1060 return spv::SelectionControlFlattenMask; in TranslateSwitchControl()
1062 return spv::SelectionControlDontFlattenMask; in TranslateSwitchControl()
1063 return spv::SelectionControlMaskNone; in TranslateSwitchControl()
1067 spv::LoopControlMask TGlslangToSpvTraverser::TranslateLoopControl(const glslang::TIntermLoop& loopN… in TranslateLoopControl()
1070 spv::LoopControlMask control = spv::LoopControlMaskNone; in TranslateLoopControl()
1073 control = control | spv::LoopControlDontUnrollMask; in TranslateLoopControl()
1075 control = control | spv::LoopControlUnrollMask; in TranslateLoopControl()
1077 control = control | spv::LoopControlDependencyInfiniteMask; in TranslateLoopControl()
1079 control = control | spv::LoopControlDependencyLengthMask; in TranslateLoopControl()
1087 spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::TType& type) in TranslateStorageClass()
1090 return spv::StorageClassInput; in TranslateStorageClass()
1092 return spv::StorageClassOutput; in TranslateStorageClass()
1097 return spv::StorageClassAtomicCounter; in TranslateStorageClass()
1099 return spv::StorageClassUniformConstant; in TranslateStorageClass()
1105 return spv::StorageClassShaderRecordBufferNV; in TranslateStorageClass()
1110 addPre13Extension(spv::E_SPV_KHR_storage_buffer_storage_class); in TranslateStorageClass()
1111 return spv::StorageClassStorageBuffer; in TranslateStorageClass()
1116 return spv::StorageClassPushConstant; in TranslateStorageClass()
1118 return spv::StorageClassUniform; in TranslateStorageClass()
1119 return spv::StorageClassUniformConstant; in TranslateStorageClass()
1123 case glslang::EvqShared: return spv::StorageClassWorkgroup; in TranslateStorageClass()
1124 case glslang::EvqGlobal: return spv::StorageClassPrivate; in TranslateStorageClass()
1125 case glslang::EvqConstReadOnly: return spv::StorageClassFunction; in TranslateStorageClass()
1126 case glslang::EvqTemporary: return spv::StorageClassFunction; in TranslateStorageClass()
1128 case glslang::EvqPayloadNV: return spv::StorageClassRayPayloadNV; in TranslateStorageClass()
1129 case glslang::EvqPayloadInNV: return spv::StorageClassIncomingRayPayloadNV; in TranslateStorageClass()
1130 case glslang::EvqHitAttrNV: return spv::StorageClassHitAttributeNV; in TranslateStorageClass()
1131 case glslang::EvqCallableDataNV: return spv::StorageClassCallableDataNV; in TranslateStorageClass()
1132 case glslang::EvqCallableDataInNV: return spv::StorageClassIncomingCallableDataNV; in TranslateStorageClass()
1139 return spv::StorageClassFunction; in TranslateStorageClass()
1151 builder.addCapability(spv::CapabilityInputAttachmentArrayNonUniformIndexingEXT); in addIndirectionIndexCapabilities()
1153 builder.addCapability(spv::CapabilityStorageTexelBufferArrayNonUniformIndexingEXT); in addIndirectionIndexCapabilities()
1155 builder.addCapability(spv::CapabilityUniformTexelBufferArrayNonUniformIndexingEXT); in addIndirectionIndexCapabilities()
1157 builder.addCapability(spv::CapabilityStorageImageArrayNonUniformIndexingEXT); in addIndirectionIndexCapabilities()
1159 builder.addCapability(spv::CapabilitySampledImageArrayNonUniformIndexingEXT); in addIndirectionIndexCapabilities()
1162 builder.addCapability(spv::CapabilityStorageBufferArrayNonUniformIndexingEXT); in addIndirectionIndexCapabilities()
1164 builder.addCapability(spv::CapabilityUniformBufferArrayNonUniformIndexingEXT); in addIndirectionIndexCapabilities()
1171 builder.addCapability(spv::CapabilityInputAttachmentArrayDynamicIndexingEXT); in addIndirectionIndexCapabilities()
1174 builder.addCapability(spv::CapabilityStorageTexelBufferArrayDynamicIndexingEXT); in addIndirectionIndexCapabilities()
1177 builder.addCapability(spv::CapabilityUniformTexelBufferArrayDynamicIndexingEXT); in addIndirectionIndexCapabilities()
1275spv::SpvBuildLogger* buildLogger, glslang::SpvOptions& options) in TGlslangToSpvTraverser()
1284 spv::ExecutionModel executionModel = TranslateExecutionModel(glslangIntermediate->getStage()); in TGlslangToSpvTraverser()
1300 if (glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_1) { in TGlslangToSpvTraverser()
1307 … if (glslangIntermediate->getSpv().spv < glslang::EShTargetSpv_1_1 && (int)processes.size() > 0) in TGlslangToSpvTraverser()
1318 spv::AddressingModel addressingModel = spv::AddressingModelLogical; in TGlslangToSpvTraverser()
1319 spv::MemoryModel memoryModel = spv::MemoryModelGLSL450; in TGlslangToSpvTraverser()
1322 addressingModel = spv::AddressingModelPhysicalStorageBuffer64EXT; in TGlslangToSpvTraverser()
1323 builder.addExtension(spv::E_SPV_EXT_physical_storage_buffer); in TGlslangToSpvTraverser()
1324 builder.addCapability(spv::CapabilityPhysicalStorageBufferAddressesEXT); in TGlslangToSpvTraverser()
1327 memoryModel = spv::MemoryModelVulkanKHR; in TGlslangToSpvTraverser()
1328 builder.addCapability(spv::CapabilityVulkanMemoryModelKHR); in TGlslangToSpvTraverser()
1329 builder.addExtension(spv::E_SPV_KHR_vulkan_memory_model); in TGlslangToSpvTraverser()
1344 builder.addCapability(spv::CapabilityTransformFeedback); in TGlslangToSpvTraverser()
1345 builder.addExecutionMode(shaderEntry, spv::ExecutionModeXfb); in TGlslangToSpvTraverser()
1351 builder.addCapability(spv::CapabilityShader); in TGlslangToSpvTraverser()
1356 builder.addCapability(spv::CapabilityTessellation); in TGlslangToSpvTraverser()
1361 …builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVe… in TGlslangToSpvTraverser()
1368 case glslang::ElgTriangles: mode = spv::ExecutionModeTriangles; break; in TGlslangToSpvTraverser()
1369 case glslang::ElgQuads: mode = spv::ExecutionModeQuads; break; in TGlslangToSpvTraverser()
1370 case glslang::ElgIsolines: mode = spv::ExecutionModeIsolines; break; in TGlslangToSpvTraverser()
1371 default: mode = spv::ExecutionModeMax; break; in TGlslangToSpvTraverser()
1373 if (mode != spv::ExecutionModeMax) in TGlslangToSpvTraverser()
1374 builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode); in TGlslangToSpvTraverser()
1377 case glslang::EvsEqual: mode = spv::ExecutionModeSpacingEqual; break; in TGlslangToSpvTraverser()
1378 case glslang::EvsFractionalEven: mode = spv::ExecutionModeSpacingFractionalEven; break; in TGlslangToSpvTraverser()
1379 case glslang::EvsFractionalOdd: mode = spv::ExecutionModeSpacingFractionalOdd; break; in TGlslangToSpvTraverser()
1380 default: mode = spv::ExecutionModeMax; break; in TGlslangToSpvTraverser()
1382 if (mode != spv::ExecutionModeMax) in TGlslangToSpvTraverser()
1383 builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode); in TGlslangToSpvTraverser()
1386 case glslang::EvoCw: mode = spv::ExecutionModeVertexOrderCw; break; in TGlslangToSpvTraverser()
1387 case glslang::EvoCcw: mode = spv::ExecutionModeVertexOrderCcw; break; in TGlslangToSpvTraverser()
1388 default: mode = spv::ExecutionModeMax; break; in TGlslangToSpvTraverser()
1390 if (mode != spv::ExecutionModeMax) in TGlslangToSpvTraverser()
1391 builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode); in TGlslangToSpvTraverser()
1394 builder.addExecutionMode(shaderEntry, spv::ExecutionModePointMode); in TGlslangToSpvTraverser()
1398 builder.addCapability(spv::CapabilityGeometry); in TGlslangToSpvTraverser()
1400 … case glslang::ElgPoints: mode = spv::ExecutionModeInputPoints; break; in TGlslangToSpvTraverser()
1401 … case glslang::ElgLines: mode = spv::ExecutionModeInputLines; break; in TGlslangToSpvTraverser()
1402 … case glslang::ElgLinesAdjacency: mode = spv::ExecutionModeInputLinesAdjacency; break; in TGlslangToSpvTraverser()
1403 … case glslang::ElgTriangles: mode = spv::ExecutionModeTriangles; break; in TGlslangToSpvTraverser()
1404 … case glslang::ElgTrianglesAdjacency: mode = spv::ExecutionModeInputTrianglesAdjacency; break; in TGlslangToSpvTraverser()
1405 … default: mode = spv::ExecutionModeMax; break; in TGlslangToSpvTraverser()
1407 if (mode != spv::ExecutionModeMax) in TGlslangToSpvTraverser()
1408 builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode); in TGlslangToSpvTraverser()
1410 …builder.addExecutionMode(shaderEntry, spv::ExecutionModeInvocations, glslangIntermediate->getInvoc… in TGlslangToSpvTraverser()
1413 … case glslang::ElgPoints: mode = spv::ExecutionModeOutputPoints; break; in TGlslangToSpvTraverser()
1414 … case glslang::ElgLineStrip: mode = spv::ExecutionModeOutputLineStrip; break; in TGlslangToSpvTraverser()
1415 … case glslang::ElgTriangleStrip: mode = spv::ExecutionModeOutputTriangleStrip; break; in TGlslangToSpvTraverser()
1416 … default: mode = spv::ExecutionModeMax; break; in TGlslangToSpvTraverser()
1418 if (mode != spv::ExecutionModeMax) in TGlslangToSpvTraverser()
1419 builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode); in TGlslangToSpvTraverser()
1420 …builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVe… in TGlslangToSpvTraverser()
1424 builder.addCapability(spv::CapabilityShader); in TGlslangToSpvTraverser()
1426 builder.addExecutionMode(shaderEntry, spv::ExecutionModePixelCenterInteger); in TGlslangToSpvTraverser()
1429 builder.addExecutionMode(shaderEntry, spv::ExecutionModeOriginUpperLeft); in TGlslangToSpvTraverser()
1431 builder.addExecutionMode(shaderEntry, spv::ExecutionModeOriginLowerLeft); in TGlslangToSpvTraverser()
1434 builder.addExecutionMode(shaderEntry, spv::ExecutionModeEarlyFragmentTests); in TGlslangToSpvTraverser()
1437 builder.addCapability(spv::CapabilitySampleMaskPostDepthCoverage); in TGlslangToSpvTraverser()
1438 builder.addExecutionMode(shaderEntry, spv::ExecutionModePostDepthCoverage); in TGlslangToSpvTraverser()
1439 builder.addExtension(spv::E_SPV_KHR_post_depth_coverage); in TGlslangToSpvTraverser()
1443 case glslang::EldGreater: mode = spv::ExecutionModeDepthGreater; break; in TGlslangToSpvTraverser()
1444 case glslang::EldLess: mode = spv::ExecutionModeDepthLess; break; in TGlslangToSpvTraverser()
1445 default: mode = spv::ExecutionModeMax; break; in TGlslangToSpvTraverser()
1447 if (mode != spv::ExecutionModeMax) in TGlslangToSpvTraverser()
1448 builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode); in TGlslangToSpvTraverser()
1451 builder.addExecutionMode(shaderEntry, spv::ExecutionModeDepthReplacing); in TGlslangToSpvTraverser()
1455 builder.addCapability(spv::CapabilityShader); in TGlslangToSpvTraverser()
1456 …builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSi… in TGlslangToSpvTraverser()
1461 builder.addCapability(spv::CapabilityComputeDerivativeGroupQuadsNV); in TGlslangToSpvTraverser()
1462 builder.addExecutionMode(shaderEntry, spv::ExecutionModeDerivativeGroupQuadsNV); in TGlslangToSpvTraverser()
1463 builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives); in TGlslangToSpvTraverser()
1465 builder.addCapability(spv::CapabilityComputeDerivativeGroupLinearNV); in TGlslangToSpvTraverser()
1466 builder.addExecutionMode(shaderEntry, spv::ExecutionModeDerivativeGroupLinearNV); in TGlslangToSpvTraverser()
1467 builder.addExtension(spv::E_SPV_NV_compute_shader_derivatives); in TGlslangToSpvTraverser()
1479 builder.addCapability(spv::CapabilityRayTracingNV); in TGlslangToSpvTraverser()
1484 builder.addCapability(spv::CapabilityMeshShadingNV); in TGlslangToSpvTraverser()
1485 builder.addExtension(spv::E_SPV_NV_mesh_shader); in TGlslangToSpvTraverser()
1486 …builder.addExecutionMode(shaderEntry, spv::ExecutionModeLocalSize, glslangIntermediate->getLocalSi… in TGlslangToSpvTraverser()
1490 …builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputVertices, glslangIntermediate->getVe… in TGlslangToSpvTraverser()
1491 …builder.addExecutionMode(shaderEntry, spv::ExecutionModeOutputPrimitivesNV, glslangIntermediate->g… in TGlslangToSpvTraverser()
1494 case glslang::ElgPoints: mode = spv::ExecutionModeOutputPoints; break; in TGlslangToSpvTraverser()
1495 case glslang::ElgLines: mode = spv::ExecutionModeOutputLinesNV; break; in TGlslangToSpvTraverser()
1496 case glslang::ElgTriangles: mode = spv::ExecutionModeOutputTrianglesNV; break; in TGlslangToSpvTraverser()
1497 default: mode = spv::ExecutionModeMax; break; in TGlslangToSpvTraverser()
1499 if (mode != spv::ExecutionModeMax) in TGlslangToSpvTraverser()
1500 builder.addExecutionMode(shaderEntry, (spv::ExecutionMode)mode); in TGlslangToSpvTraverser()
1557 spv::Id id = getSymbolId(symbol); in visitSymbol()
1561 spv::StorageClass sc = builder.getStorageClass(id); in visitSymbol()
1562 if (sc == spv::StorageClassInput || sc == spv::StorageClassOutput) { in visitSymbol()
1609 if (id != spv::NoResult) { in visitSymbol()
1610 spv::Id counterId = getSymbolId(symbol); in visitSymbol()
1611 if (counterId != spv::NoResult) { in visitSymbol()
1613 … builder.addDecorationId(id, spv::DecorationHlslCounterBufferGOOGLE, counterId); in visitSymbol()
1656 spv::Builder::AccessChain lValue = builder.getAccessChain(); in visitBinary()
1661 spv::Id rValue = accessChainLoad(node->getRight()->getType()); in visitBinary()
1666 spv::Id leftRValue = accessChainLoad(node->getLeft()->getType()); in visitBinary()
1677 assert(rValue != spv::NoResult); in visitBinary()
1718 spv::Id left = accessChainLoad(node->getLeft()->getType()); in visitBinary()
1756 spv::Builder::AccessChain partial = builder.getAccessChain(); in visitBinary()
1761 spv::Id index = accessChainLoad(node->getRight()->getType()); in visitBinary()
1801spv::Id result = createShortCircuit(node->getOp(), *node->getLeft()->getAsTyped(), *node->getRight… in visitBinary()
1815 spv::Id left = accessChainLoad(node->getLeft()->getType()); in visitBinary()
1820 spv::Id right = accessChainLoad(node->getRight()->getType()); in visitBinary()
1826 spv::Id result = createBinaryOperation(node->getOp(), decorations, in visitBinary()
1848 spv::Id result = spv::NoResult; in visitUnary()
1852 if (result != spv::NoResult) { in visitUnary()
1876 spv::Id length = builder.createArrayLength(builder.accessChainGetLValue(), member); in visitUnary()
1882 length = builder.createUnaryOp(spv::OpBitcast, builder.makeIntType(32), length); in visitUnary()
1894 spv::Id invertedType = spv::NoType; in visitUnary()
1895 …auto resultType = [&invertedType, &node, this](){ return invertedType != spv::NoType ? invertedTyp… in visitUnary()
1900 if (invertedType != spv::NoType) in visitUnary()
1905 spv::Id operand = spv::NoResult; in visitUnary()
1947 spv::Id one = 0; in visitUnary()
1969 spv::Id result = createBinaryOperation(op, decorations, in visitUnary()
1972 assert(result != spv::NoResult); in visitUnary()
1988 builder.createNoResultOp(spv::OpEmitStreamVertex, operand); in visitUnary()
1991 builder.createNoResultOp(spv::OpEndStreamPrimitive, operand); in visitUnary()
2006 spv::Id result = spv::NoResult; in visitAggregate()
2007 spv::Id invertedType = spv::NoType; // to use to override the natural type of the node in visitAggregate()
2008 …auto resultType = [&invertedType, &node, this](){ return invertedType != spv::NoType ? invertedTyp… in visitAggregate()
2012 if (result != spv::NoResult) { in visitAggregate()
2034 spv::Decoration precision = TranslatePrecisionDecoration(node->getOperationPrecision()); in visitAggregate()
2227 std::vector<spv::Id> arguments; in visitAggregate()
2229 spv::Id constructed; in visitAggregate()
2231 constructed = builder.createOp(spv::OpSampledImage, resultType(), arguments); in visitAggregate()
2233 std::vector<spv::Id> constituents; in visitAggregate()
2337 builder.addCapability(spv::CapabilityAtomicStorageOps); in visitAggregate()
2365 spv::Id leftId = accessChainLoad(left->getType()); in visitAggregate()
2369 spv::Id rightId = accessChainLoad(right->getType()); in visitAggregate()
2380 assert(result != spv::NoResult); in visitAggregate()
2391 std::vector<spv::Id> operands; in visitAggregate()
2452 if (invertedType != spv::NoType && arg == 0) in visitAggregate()
2552 spv::Id result = spv::NoResult; // upcoming result selecting between trueValue and falseValue in visitSelection()
2555 spv::Id condition = accessChainLoad(node->getCondition()->getType()); in visitSelection()
2561 spv::Id trueValue = accessChainLoad(node->getTrueBlock()->getAsTyped()->getType()); in visitSelection()
2563 spv::Id falseValue = accessChainLoad(node->getTrueBlock()->getAsTyped()->getType()); in visitSelection()
2579 condition = builder.smearScalar(spv::NoPrecision, condition, in visitSelection()
2584 result = builder.createTriOp(spv::OpSelect, in visitSelection()
2593 …result = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()… in visitSelection()
2596 const spv::SelectionControlMask control = TranslateSelectionControl(*node); in visitSelection()
2599 spv::Builder::If ifBuilder(condition, control, builder); in visitSelection()
2619 …result = builder.createVariable(spv::StorageClassFunction, convertGlslangToSpvType(node->getType()… in visitSelection()
2622 const spv::SelectionControlMask control = TranslateSelectionControl(*node); in visitSelection()
2625 spv::Builder::If ifBuilder(condition, control, builder); in visitSelection()
2630 if (result != spv::NoResult) in visitSelection()
2638 if (result != spv::NoResult) in visitSelection()
2645 if (result != spv::NoResult) { in visitSelection()
2667 spv::Id selector = accessChainLoad(node->getCondition()->getAsTyped()->getType()); in visitSwitch()
2670 const spv::SelectionControlMask control = TranslateSwitchControl(*node); in visitSwitch()
2696 std::vector<spv::Block*> segmentBlocks; // returned, as the blocks allocated in the call in visitSwitch()
2718spv::Id constant = createSpvConstantFromConstUnionArray(node->getType(), node->getConstArray(), ne… in visitConstantUnion()
2731 const spv::LoopControlMask control = TranslateLoopControl(*node, dependencyLength); in visitLoop()
2743 spv::Block& test = builder.makeNewBlock(); in visitLoop()
2748 spv::Id condition = accessChainLoad(node->getTest()->getType()); in visitLoop()
2778 spv::Id condition = in visitLoop()
2816 spv::Id returnId = accessChainLoad(glslangReturnType); in visitBranch()
2819spv::Id copyId = builder.createVariable(spv::StorageClassFunction, currentFunction->getReturnType(… in visitBranch()
2839 spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol* node) in createSpvVariable()
2845 spv::Id result = createSpvConstant(*node); in createSpvVariable()
2846 if (result != spv::NoResult) in createSpvVariable()
2851 spv::StorageClass storageClass = TranslateStorageClass(node->getType()); in createSpvVariable()
2852 spv::Id spvType = convertGlslangToSpvType(node->getType()); in createSpvVariable()
2859 case spv::StorageClassInput: in createSpvVariable()
2860 case spv::StorageClassOutput: in createSpvVariable()
2861 addPre13Extension(spv::E_SPV_KHR_16bit_storage); in createSpvVariable()
2862 builder.addCapability(spv::CapabilityStorageInputOutput16); in createSpvVariable()
2864 case spv::StorageClassPushConstant: in createSpvVariable()
2865 addPre13Extension(spv::E_SPV_KHR_16bit_storage); in createSpvVariable()
2866 builder.addCapability(spv::CapabilityStoragePushConstant16); in createSpvVariable()
2868 case spv::StorageClassUniform: in createSpvVariable()
2869 addPre13Extension(spv::E_SPV_KHR_16bit_storage); in createSpvVariable()
2871 builder.addCapability(spv::CapabilityStorageUniformBufferBlock16); in createSpvVariable()
2873 builder.addCapability(spv::CapabilityStorageUniform16); in createSpvVariable()
2875 case spv::StorageClassStorageBuffer: in createSpvVariable()
2876 case spv::StorageClassPhysicalStorageBufferEXT: in createSpvVariable()
2877 addPre13Extension(spv::E_SPV_KHR_16bit_storage); in createSpvVariable()
2878 builder.addCapability(spv::CapabilityStorageUniformBufferBlock16); in createSpvVariable()
2888 if (storageClass == spv::StorageClassPushConstant) { in createSpvVariable()
2889 builder.addExtension(spv::E_SPV_KHR_8bit_storage); in createSpvVariable()
2890 builder.addCapability(spv::CapabilityStoragePushConstant8); in createSpvVariable()
2891 } else if (storageClass == spv::StorageClassUniform) { in createSpvVariable()
2892 builder.addExtension(spv::E_SPV_KHR_8bit_storage); in createSpvVariable()
2893 builder.addCapability(spv::CapabilityUniformAndStorageBuffer8BitAccess); in createSpvVariable()
2894 } else if (storageClass == spv::StorageClassStorageBuffer) { in createSpvVariable()
2895 builder.addExtension(spv::E_SPV_KHR_8bit_storage); in createSpvVariable()
2896 builder.addCapability(spv::CapabilityStorageBuffer8BitAccess); in createSpvVariable()
2908 spv::Id TGlslangToSpvTraverser::getSampledType(const glslang::TSampler& sampler) in getSampledType()
2914 builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float_fetch); in getSampledType()
2915 builder.addCapability(spv::CapabilityFloat16ImageAMD); in getSampledType()
2929 spv::Id TGlslangToSpvTraverser::getInvertedSwizzleType(const glslang::TIntermTyped& node) in getInvertedSwizzleType()
2935 return spv::NoType; in getInvertedSwizzleType()
2940 spv::Id TGlslangToSpvTraverser::createInvertedSwizzle(spv::Decoration precision, const glslang::TIn… in createInvertedSwizzle()
2958 spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& type, bool forwardRef… in convertGlslangToSpvType()
2966 spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& type, in convertGlslangToSpvType()
2970 spv::Id spvType = spv::NoResult; in convertGlslangToSpvType()
3019 builder.addCapability(spv::CapabilityAtomicStorage); in convertGlslangToSpvType()
3054 if (spvType != spv::NoResult) in convertGlslangToSpvType()
3068spv::Id forwardId = builder.makeForwardPointer(spv::StorageClassPhysicalStorageBufferEXT); in convertGlslangToSpvType()
3073 spv::Id referentType = convertGlslangToSpvType(*type.getReferentType()); in convertGlslangToSpvType()
3074 builder.makePointerFromForwardPointer(spv::StorageClassPhysicalStorageBufferEXT, in convertGlslangToSpvType()
3115 builder.addDecoration(spvType, spv::DecorationArrayStride, stride); in convertGlslangToSpvType()
3133 builder.addCapability(spv::CapabilityRuntimeDescriptorArrayEXT); in convertGlslangToSpvType()
3138 builder.addDecoration(spvType, spv::DecorationArrayStride, stride); in convertGlslangToSpvType()
3179 spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TType& type, in convertGlslangStructToSpvType()
3185 std::vector<spv::Id> spvMembers; in convertGlslangStructToSpvType()
3228 spv::Id spvType = builder.makeStructType(spvMembers, type.getTypeName().c_str()); in convertGlslangStructToSpvType()
3247 spv::Id spvType) in decorateStructType()
3291 std::vector<spv::Decoration> memory; in decorateStructType()
3302 …builder.addMemberDecoration(spvType, member, spv::DecorationLocation, memberQualifier.layoutLocati… in decorateStructType()
3310 builder.addMemberDecoration(spvType, member, spv::DecorationComponent, in decorateStructType()
3313 builder.addMemberDecoration(spvType, member, spv::DecorationOffset, in decorateStructType()
3320 builder.addMemberDecoration(spvType, member, spv::DecorationOffset, offset); in decorateStructType()
3325 builder.addMemberDecoration(spvType, member, spv::DecorationMatrixStride, in decorateStructType()
3329spv::BuiltIn builtIn = TranslateBuiltInDecoration(glslangMember.getQualifier().builtIn, true); in decorateStructType()
3330 if (builtIn != spv::BuiltInMax) in decorateStructType()
3331 builder.addMemberDecoration(spvType, member, spv::DecorationBuiltIn, (int)builtIn); in decorateStructType()
3338 … builder.addMemberDecoration(spvType, member, (spv::Decoration)spv::DecorationHlslSemanticGOOGLE, in decorateStructType()
3343 if (builtIn == spv::BuiltInLayer) { in decorateStructType()
3346 … builder.addMemberDecoration(spvType, member, (spv::Decoration)spv::DecorationViewportRelativeNV); in decorateStructType()
3347 builder.addCapability(spv::CapabilityShaderViewportMaskNV); in decorateStructType()
3348 builder.addExtension(spv::E_SPV_NV_viewport_array2); in decorateStructType()
3352 … (spv::Decoration)spv::DecorationSecondaryViewportRelativeNV, in decorateStructType()
3354 builder.addCapability(spv::CapabilityShaderStereoViewNV); in decorateStructType()
3355 builder.addExtension(spv::E_SPV_NV_stereo_view_rendering); in decorateStructType()
3359 … builder.addMemberDecoration(spvType, member, (spv::Decoration)spv::DecorationPassthroughNV); in decorateStructType()
3360 builder.addCapability(spv::CapabilityGeometryShaderPassthroughNV); in decorateStructType()
3361 builder.addExtension(spv::E_SPV_NV_geometry_shader_passthrough); in decorateStructType()
3375 spv::Id TGlslangToSpvTraverser::makeArraySizeId(const glslang::TArraySizes& arraySizes, int dim) in makeArraySizeId()
3396 spv::Id TGlslangToSpvTraverser::accessChainLoad(const glslang::TType& type) in accessChainLoad()
3398 spv::Id nominalTypeId = builder.accessChainGetInferredType(); in accessChainLoad()
3400 spv::Builder::AccessChain::CoherentFlags coherentFlags = builder.getAccessChain().coherentFlags; in accessChainLoad()
3406 spv::Id loadedId = builder.accessChainLoad(TranslatePrecisionDecoration(type), in accessChainLoad()
3409spv::MemoryAccessMask(TranslateMemoryAccess(coherentFlags) & ~spv::MemoryAccessMakePointerAvailabl… in accessChainLoad()
3417 spv::Id boolType = builder.makeBoolType(); in accessChainLoad()
3419 … loadedId = builder.createBinOp(spv::OpINotEqual, boolType, loadedId, builder.makeUintConstant(0)); in accessChainLoad()
3423 spv::Id bvecType = builder.makeVectorType(builder.makeBoolType(), vecSize); in accessChainLoad()
3425 …loadedId = builder.createBinOp(spv::OpINotEqual, bvecType, loadedId, makeSmearedConstant(builder.m… in accessChainLoad()
3436 void TGlslangToSpvTraverser::accessChainStore(const glslang::TType& type, spv::Id rvalue) in accessChainStore()
3440 spv::Id nominalTypeId = builder.accessChainGetInferredType(); in accessChainStore()
3444 spv::Id boolType = builder.makeBoolType(); in accessChainStore()
3447 spv::Id one = builder.makeUintConstant(1); in accessChainStore()
3448 spv::Id zero = builder.makeUintConstant(0); in accessChainStore()
3449 rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue, one, zero); in accessChainStore()
3451 … rvalue = builder.createBinOp(spv::OpINotEqual, boolType, rvalue, builder.makeUintConstant(0)); in accessChainStore()
3455 spv::Id bvecType = builder.makeVectorType(builder.makeBoolType(), vecSize); in accessChainStore()
3458 spv::Id one = makeSmearedConstant(builder.makeUintConstant(1), vecSize); in accessChainStore()
3459 spv::Id zero = makeSmearedConstant(builder.makeUintConstant(0), vecSize); in accessChainStore()
3460 rvalue = builder.createTriOp(spv::OpSelect, nominalTypeId, rvalue, one, zero); in accessChainStore()
3462 rvalue = builder.createBinOp(spv::OpINotEqual, bvecType, rvalue, in accessChainStore()
3467 spv::Builder::AccessChain::CoherentFlags coherentFlags = builder.getAccessChain().coherentFlags; in accessChainStore()
3474spv::MemoryAccessMask(TranslateMemoryAccess(coherentFlags) & ~spv::MemoryAccessMakePointerVisibleK… in accessChainStore()
3489 void TGlslangToSpvTraverser::multiTypeStore(const glslang::TType& type, spv::Id rValue) in multiTypeStore()
3498 spv::Id rType = builder.getTypeId(rValue); in multiTypeStore()
3499 spv::Id lValue = builder.accessChainGetLValue(); in multiTypeStore()
3500 spv::Id lType = builder.getContainedTypeId(builder.getTypeId(lValue)); in multiTypeStore()
3513 spv::Id elementRType = builder.getContainedTypeId(rType); in multiTypeStore()
3516 spv::Id elementRValue = builder.createCompositeExtract(rValue, elementRType, index); in multiTypeStore()
3535 spv::Id memberRType = builder.getContainedTypeId(rType, m); in multiTypeStore()
3536 spv::Id memberRValue = builder.createCompositeExtract(rValue, memberRType, m); in multiTypeStore()
3728 …const auto getParamDecorations = [&](std::vector<spv::Decoration>& decorations, const glslang::TTy… in makeFunctions()
3729 spv::Decoration paramPrecision = TranslatePrecisionDecoration(type); in makeFunctions()
3730 if (paramPrecision != spv::NoPrecision) in makeFunctions()
3739 …decorations.push_back(type.getQualifier().restrict ? spv::DecorationRestrict : spv::DecorationAlia… in makeFunctions()
3741 …decorations.push_back(type.getQualifier().restrict ? spv::DecorationRestrictPointerEXT : spv::Deco… in makeFunctions()
3765 std::vector<spv::Id> paramTypes; in makeFunctions()
3766 … std::vector<std::vector<spv::Decoration>> paramDecorations; // list of decorations per parameter in makeFunctions()
3775 spv::Id typeId = convertGlslangToSpvType(paramType); in makeFunctions()
3779 typeId = builder.makePointer(spv::StorageClassFunction, typeId); in makeFunctions()
3786 spv::Block* functionBlock; in makeFunctions()
3787spv::Function *function = builder.makeFunctionEntry(TranslatePrecisionDecoration(glslFunction->get… in makeFunctions()
3836 spv::Block* functionBlock = currentFunction->getEntryBlock(); in handleFunctionEntry()
3840 …averser::translateArguments(const glslang::TIntermAggregate& node, std::vector<spv::Id>& arguments) in translateArguments()
4005 void TGlslangToSpvTraverser::translateArguments(glslang::TIntermUnary& node, std::vector<spv::Id>& … in translateArguments()
4012 spv::Id TGlslangToSpvTraverser::createImageTextureFunctionCall(glslang::TIntermOperator* node)
4015 return spv::NoResult;
4030 std::vector<spv::Id> arguments;
4035 spv::Decoration precision = TranslatePrecisionDecoration(node->getOperationPrecision());
4037 spv::Builder::TextureParameters params = { };
4049 …params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.…
4056 … return builder.createTextureQueryCall(spv::OpImageQuerySizeLod, params, isUnsignedResult);
4058 … return builder.createTextureQueryCall(spv::OpImageQuerySize, params, isUnsignedResult);
4061 … return builder.createTextureQueryCall(spv::OpImageQuerySamples, params, isUnsignedResult);
4064 return builder.createTextureQueryCall(spv::OpImageQueryLod, params, isUnsignedResult);
4066 … return builder.createTextureQueryCall(spv::OpImageQueryLevels, params, isUnsignedResult);
4068 …return builder.createUnaryOp(spv::OpImageSparseTexelsResident, builder.makeBoolType(), arguments[0…
4091 std::vector<spv::IdImmediate> operands;
4093 spv::IdImmediate image = { true, *(opIt++) };
4101 spv::Id zero = builder.makeIntConstant(0);
4102 std::vector<spv::Id> comps;
4105 spv::IdImmediate coord = { true,
4109 spv::IdImmediate imageOperands = { false, spv::ImageOperandsSampleMask };
4111 spv::IdImmediate imageOperand = { true, *(opIt++) };
4114 spv::Id result = builder.createOp(spv::OpImageRead, resultType(), operands);
4119 spv::IdImmediate coord = { true, *(opIt++) };
4126 spv::ImageOperandsMask mask = spv::ImageOperandsMaskNone;
4128 mask = mask | spv::ImageOperandsSampleMask;
4132 builder.addExtension(spv::E_SPV_AMD_shader_image_load_store_lod);
4133 builder.addCapability(spv::CapabilityImageReadWriteLodAMD);
4134 mask = mask | spv::ImageOperandsLodMask;
4138 mask = (spv::ImageOperandsMask)(mask & ~spv::ImageOperandsMakeTexelAvailableKHRMask);
4140 spv::IdImmediate imageOperands = { false, (unsigned int)mask };
4143 if (mask & spv::ImageOperandsSampleMask) {
4144 spv::IdImmediate imageOperand = { true, *opIt++ };
4148 if (mask & spv::ImageOperandsLodMask) {
4149 spv::IdImmediate imageOperand = { true, *opIt++ };
4153 if (mask & spv::ImageOperandsMakeTexelVisibleKHRMask) {
4154spv::IdImmediate imageOperand = { true, builder.makeUintConstant(TranslateMemoryScope(TranslateCoh…
4158 …if (builder.getImageTypeFormat(builder.getImageType(operands.front().word)) == spv::ImageFormatUnk…
4159 builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
4161 … std::vector<spv::Id> result(1, builder.createOp(spv::OpImageRead, resultType(), operands));
4181 spv::IdImmediate texel = { true, *(opIt + 1) };
4184 spv::IdImmediate texel = { true, *opIt };
4188 spv::ImageOperandsMask mask = spv::ImageOperandsMaskNone;
4190 mask = mask | spv::ImageOperandsSampleMask;
4194 builder.addExtension(spv::E_SPV_AMD_shader_image_load_store_lod);
4195 builder.addCapability(spv::CapabilityImageReadWriteLodAMD);
4196 mask = mask | spv::ImageOperandsLodMask;
4200 mask = (spv::ImageOperandsMask)(mask & ~spv::ImageOperandsMakeTexelVisibleKHRMask);
4202 spv::IdImmediate imageOperands = { false, (unsigned int)mask };
4205 if (mask & spv::ImageOperandsSampleMask) {
4206 spv::IdImmediate imageOperand = { true, *opIt++ };
4210 if (mask & spv::ImageOperandsLodMask) {
4211 spv::IdImmediate imageOperand = { true, *opIt++ };
4215 if (mask & spv::ImageOperandsMakeTexelAvailableKHRMask) {
4216spv::IdImmediate imageOperand = { true, builder.makeUintConstant(TranslateMemoryScope(TranslateCoh…
4220 builder.createNoResultOp(spv::OpImageWrite, operands);
4221 …if (builder.getImageTypeFormat(builder.getImageType(operands.front().word)) == spv::ImageFormatUnk…
4222 builder.addCapability(spv::CapabilityStorageImageWriteWithoutFormat);
4223 return spv::NoResult;
4229 builder.addCapability(spv::CapabilitySparseResidency);
4230 …if (builder.getImageTypeFormat(builder.getImageType(operands.front().word)) == spv::ImageFormatUnk…
4231 builder.addCapability(spv::CapabilityStorageImageReadWithoutFormat);
4233 spv::ImageOperandsMask mask = spv::ImageOperandsMaskNone;
4235 mask = mask | spv::ImageOperandsSampleMask;
4239 builder.addExtension(spv::E_SPV_AMD_shader_image_load_store_lod);
4240 builder.addCapability(spv::CapabilityImageReadWriteLodAMD);
4242 mask = mask | spv::ImageOperandsLodMask;
4246 mask = (spv::ImageOperandsMask)(mask & ~spv::ImageOperandsMakeTexelAvailableKHRMask);
4248 spv::IdImmediate imageOperands = { false, (unsigned int)mask };
4251 if (mask & spv::ImageOperandsSampleMask) {
4252 spv::IdImmediate imageOperand = { true, *opIt++ };
4256 if (mask & spv::ImageOperandsLodMask) {
4257 spv::IdImmediate imageOperand = { true, *opIt++ };
4261 if (mask & spv::ImageOperandsMakeTexelVisibleKHRMask) {
4262spv::IdImmediate imageOperand = { true, builder.makeUintConstant(TranslateMemoryScope(TranslateCoh…
4267 spv::Id texelOut = *opIt;
4268 spv::Id typeId0 = resultType();
4269 spv::Id typeId1 = builder.getDerefTypeId(texelOut);
4270 spv::Id resultTypeId = builder.makeStructResultType(typeId0, typeId1);
4272 spv::Id resultId = builder.createOp(spv::OpImageSparseRead, resultTypeId, operands);
4283spv::IdImmediate sample = { true, sampler.ms ? *(opIt++) : builder.makeUintConstant(0) };
4286 spv::Id resultTypeId;
4290 …resultTypeId = builder.makePointer(spv::StorageClassImage, builder.getTypeId(operands[2].word)); …
4292 resultTypeId = builder.makePointer(spv::StorageClassImage, resultType());
4294 spv::Id pointer = builder.createOp(spv::OpImageTexelPointer, resultTypeId, operands);
4296 std::vector<spv::Id> operands;
4311 std::vector<spv::Id> operands;
4315 …params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.…
4322 spv::Id zero = builder.makeIntConstant(0);
4323 std::vector<spv::Id> comps;
4332 spv::Op fragMaskOp = spv::OpNop;
4334 fragMaskOp = spv::OpFragmentMaskFetchAMD;
4336 fragMaskOp = spv::OpFragmentFetchAMD;
4338 builder.addExtension(spv::E_SPV_AMD_shader_fragment_mask);
4339 builder.addCapability(spv::CapabilityFragmentMaskAMD);
4393 …params.sampler = builder.createUnaryOp(spv::OpImage, builder.getImageType(params.sampler), params.…
4401 builder.addExtension(spv::E_SPV_AMD_texture_gather_bias_lod);
4402 builder.addCapability(spv::CapabilityImageGatherBiasLodAMD);
4425 std::vector<spv::Id> indexes;
4493 spv::Id resultStruct = spv::NoResult;
4511 builder.addExtension(spv::E_SPV_NV_shader_image_footprint);
4512 builder.addCapability(spv::CapabilityImageFootprintNV);
4531 spv::Id resultStructType = builder.getContainedTypeId(builder.getTypeId(resultStruct));
4541 std::vector<spv::Id> members;
4546 spv::Id resType = builder.makeStructType(members, "ResType");
4549spv::Id res = builder.createTextureCall(precision, resType, sparse, cracked.fetch, cracked.proj, c…
4557 spv::Builder::AccessChain::CoherentFlags flags;
4583 spv::Id projComp = builder.createCompositeExtract(params.coords,
4601 std::vector<spv::Id> result( 1,
4611 spv::Id TGlslangToSpvTraverser::handleUserFunctionCall(const glslang::TIntermAggregate* node)
4614 spv::Function* function = functionMap[node->getName().c_str()];
4630 std::vector<spv::Builder::AccessChain> lValues;
4631 std::vector<spv::Id> rValues;
4655 std::vector<spv::Id> spvArgs;
4657 spv::Id arg;
4664 …arg = builder.createVariable(spv::StorageClassFunction, builder.getContainedTypeId(function->getPa…
4668 spv::Id copy = accessChainLoad(*argTypes[a]);
4677spv::Id argCopy = builder.createVariable(spv::StorageClassFunction, function->getParamType(a), "ar…
4690 spv::Id result = builder.createFunctionCall(function, spvArgs);
4700 spv::Id copy = builder.createLoad(spvArgs[a]);
4712 spv::Id TGlslangToSpvTraverser::createBinaryOperation(glslang::TOperator op, OpDecorations& decorat…
4713 spv::Id typeId, spv::Id left, spv::Id right,
4720 spv::Op binOp = spv::OpNop;
4728 binOp = spv::OpFAdd;
4730 binOp = spv::OpIAdd;
4735 binOp = spv::OpFSub;
4737 binOp = spv::OpISub;
4742 binOp = spv::OpFMul;
4744 binOp = spv::OpIMul;
4753 binOp = spv::OpVectorTimesScalar;
4755 binOp = spv::OpFMul;
4757 binOp = spv::OpIMul;
4761 binOp = spv::OpVectorTimesMatrix;
4764 binOp = spv::OpMatrixTimesVector;
4768 binOp = spv::OpMatrixTimesScalar;
4772 binOp = spv::OpMatrixTimesMatrix;
4775 binOp = spv::OpOuterProduct;
4782 binOp = spv::OpFDiv;
4784 binOp = spv::OpUDiv;
4786 binOp = spv::OpSDiv;
4791 binOp = spv::OpFMod;
4793 binOp = spv::OpUMod;
4795 binOp = spv::OpSMod;
4800 binOp = spv::OpShiftRightLogical;
4802 binOp = spv::OpShiftRightArithmetic;
4806 binOp = spv::OpShiftLeftLogical;
4810 binOp = spv::OpBitwiseAnd;
4814 binOp = spv::OpLogicalAnd;
4818 binOp = spv::OpBitwiseOr;
4822 binOp = spv::OpLogicalOr;
4826 binOp = spv::OpBitwiseXor;
4830 binOp = spv::OpLogicalNotEqual;
4848 if (binOp != spv::OpNop) {
4857 spv::Id result = builder.createBinOp(binOp, typeId, left, right);
4870spv::Id result = builder.createCompositeCompare(decorations.precision, left, right, op == glslang:…
4878 binOp = spv::OpFOrdLessThan;
4880 binOp = spv::OpULessThan;
4882 binOp = spv::OpSLessThan;
4886 binOp = spv::OpFOrdGreaterThan;
4888 binOp = spv::OpUGreaterThan;
4890 binOp = spv::OpSGreaterThan;
4894 binOp = spv::OpFOrdLessThanEqual;
4896 binOp = spv::OpULessThanEqual;
4898 binOp = spv::OpSLessThanEqual;
4902 binOp = spv::OpFOrdGreaterThanEqual;
4904 binOp = spv::OpUGreaterThanEqual;
4906 binOp = spv::OpSGreaterThanEqual;
4911 binOp = spv::OpFOrdEqual;
4913 binOp = spv::OpLogicalEqual;
4915 binOp = spv::OpIEqual;
4920 binOp = spv::OpFOrdNotEqual;
4922 binOp = spv::OpLogicalNotEqual;
4924 binOp = spv::OpINotEqual;
4930 if (binOp != spv::OpNop) {
4931 spv::Id result = builder.createBinOp(binOp, typeId, left, right);
4954 spv::Id TGlslangToSpvTraverser::createBinaryMatrixOperation(spv::Op op, OpDecorations& decorations,…
4955 spv::Id left, spv::Id right)
4961 case spv::OpFDiv:
4964 spv::Id resultType = builder.getTypeId(right);
4965 …right = builder.createBinOp(spv::OpFDiv, resultType, builder.makeFpConstant(resultType, 1.0), righ…
4966 op = spv::OpMatrixTimesScalar;
4970 case spv::OpMatrixTimesScalar:
4975 case spv::OpVectorTimesMatrix:
4979 case spv::OpMatrixTimesVector:
4983 case spv::OpMatrixTimesMatrix:
4993 spv::Id result = builder.createBinOp(op, typeId, left, right);
5007 case spv::OpFAdd:
5008 case spv::OpFSub:
5009 case spv::OpFDiv:
5010 case spv::OpFMod:
5011 case spv::OpFMul:
5018 spv::Id scalarType = builder.getScalarTypeId(typeId);
5019 spv::Id vecType = builder.makeVectorType(scalarType, numRows);
5020 std::vector<spv::Id> results;
5021 spv::Id smearVec = spv::NoResult;
5031spv::Id leftVec = leftMat ? builder.createCompositeExtract( left, vecType, indexes) : smearVec;
5032spv::Id rightVec = rightMat ? builder.createCompositeExtract(right, vecType, indexes) : smearVec;
5033 spv::Id result = builder.createBinOp(op, vecType, leftVec, rightVec);
5040spv::Id result = builder.setPrecision(builder.createCompositeConstruct(typeId, results), decoratio…
5046 return spv::NoResult;
5050 spv::Id TGlslangToSpvTraverser::createUnaryOperation(glslang::TOperator op, OpDecorations& decorati…
5051 spv::Id operand, glslang::TBasicType typeProxy)
5053 spv::Op unaryOp = spv::OpNop;
5062 unaryOp = spv::OpFNegate;
5066 unaryOp = spv::OpSNegate;
5071 unaryOp = spv::OpLogicalNot;
5074 unaryOp = spv::OpNot;
5078 libCall = spv::GLSLstd450Determinant;
5081 libCall = spv::GLSLstd450MatrixInverse;
5084 unaryOp = spv::OpTranspose;
5088 libCall = spv::GLSLstd450Radians;
5091 libCall = spv::GLSLstd450Degrees;
5094 libCall = spv::GLSLstd450Sin;
5097 libCall = spv::GLSLstd450Cos;
5100 libCall = spv::GLSLstd450Tan;
5103 libCall = spv::GLSLstd450Acos;
5106 libCall = spv::GLSLstd450Asin;
5109 libCall = spv::GLSLstd450Atan;
5113 libCall = spv::GLSLstd450Acosh;
5116 libCall = spv::GLSLstd450Asinh;
5119 libCall = spv::GLSLstd450Atanh;
5122 libCall = spv::GLSLstd450Tanh;
5125 libCall = spv::GLSLstd450Cosh;
5128 libCall = spv::GLSLstd450Sinh;
5132 libCall = spv::GLSLstd450Length;
5135 libCall = spv::GLSLstd450Normalize;
5139 libCall = spv::GLSLstd450Exp;
5142 libCall = spv::GLSLstd450Log;
5145 libCall = spv::GLSLstd450Exp2;
5148 libCall = spv::GLSLstd450Log2;
5151 libCall = spv::GLSLstd450Sqrt;
5154 libCall = spv::GLSLstd450InverseSqrt;
5158 libCall = spv::GLSLstd450Floor;
5161 libCall = spv::GLSLstd450Trunc;
5164 libCall = spv::GLSLstd450Round;
5167 libCall = spv::GLSLstd450RoundEven;
5170 libCall = spv::GLSLstd450Ceil;
5173 libCall = spv::GLSLstd450Fract;
5177 unaryOp = spv::OpIsNan;
5180 unaryOp = spv::OpIsInf;
5183 unaryOp = spv::OpIsFinite;
5198 unaryOp = spv::OpBitcast;
5202 libCall = spv::GLSLstd450PackSnorm2x16;
5205 libCall = spv::GLSLstd450UnpackSnorm2x16;
5208 libCall = spv::GLSLstd450PackUnorm2x16;
5211 libCall = spv::GLSLstd450UnpackUnorm2x16;
5214 libCall = spv::GLSLstd450PackHalf2x16;
5217 libCall = spv::GLSLstd450UnpackHalf2x16;
5220 libCall = spv::GLSLstd450PackSnorm4x8;
5223 libCall = spv::GLSLstd450UnpackSnorm4x8;
5226 libCall = spv::GLSLstd450PackUnorm4x8;
5229 libCall = spv::GLSLstd450UnpackUnorm4x8;
5232 libCall = spv::GLSLstd450PackDouble2x32;
5235 libCall = spv::GLSLstd450UnpackDouble2x32;
5258 unaryOp = spv::OpBitcast;
5262 unaryOp = spv::OpDPdx;
5265 unaryOp = spv::OpDPdy;
5268 unaryOp = spv::OpFwidth;
5271 unaryOp = spv::OpDPdxFine;
5274 unaryOp = spv::OpDPdyFine;
5277 unaryOp = spv::OpFwidthFine;
5280 unaryOp = spv::OpDPdxCoarse;
5283 unaryOp = spv::OpDPdyCoarse;
5286 unaryOp = spv::OpFwidthCoarse;
5291 builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
5293 libCall = spv::GLSLstd450InterpolateAtCentroid;
5296 unaryOp = spv::OpAny;
5299 unaryOp = spv::OpAll;
5304 libCall = spv::GLSLstd450FAbs;
5306 libCall = spv::GLSLstd450SAbs;
5310 libCall = spv::GLSLstd450FSign;
5312 libCall = spv::GLSLstd450SSign;
5320 std::vector<spv::Id> operands;
5326 unaryOp = spv::OpBitReverse;
5329 unaryOp = spv::OpBitCount;
5332 libCall = spv::GLSLstd450FindILsb;
5336 libCall = spv::GLSLstd450FindUMsb;
5338 libCall = spv::GLSLstd450FindSMsb;
5367 std::vector<spv::Id> operands;
5406 std::vector<spv::Id> operands;
5412 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_shader_ballot);
5413 libCall = spv::MbcntAMD;
5417 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_gcn_shader);
5418 libCall = spv::CubeFaceIndexAMD;
5422 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_gcn_shader);
5423 libCall = spv::CubeFaceCoordAMD;
5428 unaryOp = spv::OpGroupNonUniformPartitionNV;
5432 unaryOp = spv::OpBitcast;
5438 spv::Id id;
5440 std::vector<spv::Id> args;
5453 spv::Id TGlslangToSpvTraverser::createUnaryMatrixOperation(spv::Op op, OpDecorations& decorations,
5454spv::Id operand, glslang::TBasicType /* typeProxy */)
5466spv::Id srcVecType = builder.makeVectorType(builder.getScalarTypeId(builder.getTypeId(operand)), …
5467 spv::Id destVecType = builder.makeVectorType(builder.getScalarTypeId(typeId), numRows);
5468 std::vector<spv::Id> results;
5474 spv::Id srcVec = builder.createCompositeExtract(operand, srcVecType, indexes);
5475 spv::Id destVec = builder.createUnaryOp(op, destVecType, srcVec);
5482spv::Id result = builder.setPrecision(builder.createCompositeConstruct(typeId, results), decoratio…
5490 spv::Id TGlslangToSpvTraverser::createIntWidthConversion(glslang::TOperator op, spv::Id operand, in…
5535 spv::Id type = spv::NoType;
5536 spv::Op convOp = spv::OpNop;
5550 convOp = spv::OpSConvert;
5554 convOp = spv::OpUConvert;
5565 spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, OpDecorations& decorations,…
5566 spv::Id operand, glslang::TBasicType typeProxy)
5568 spv::Op convOp = spv::OpNop;
5569 spv::Id zero = 0;
5570 spv::Id one = 0;
5579 return builder.createBinOp(spv::OpINotEqual, destType, operand, zero);
5584 return builder.createBinOp(spv::OpINotEqual, destType, operand, zero);
5589 return builder.createBinOp(spv::OpINotEqual, destType, operand, zero);
5594 return builder.createBinOp(spv::OpINotEqual, destType, operand, zero);
5599 return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero);
5604 return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero);
5609 return builder.createBinOp(spv::OpFOrdNotEqual, destType, operand, zero);
5612 convOp = spv::OpSelect;
5618 convOp = spv::OpSelect;
5624 convOp = spv::OpSelect;
5632 convOp = spv::OpSelect;
5638 convOp = spv::OpSelect;
5644 convOp = spv::OpSelect;
5650 convOp = spv::OpSelect;
5665 convOp = spv::OpSelect;
5680 convOp = spv::OpSelect;
5695 convOp = spv::OpConvertSToF;
5710 convOp = spv::OpConvertUToF;
5719 convOp = spv::OpFConvert;
5736 convOp = spv::OpConvertFToS;
5761 return builder.createBinOp(spv::OpIAdd, destType, operand, zero);
5764 convOp = spv::OpBitcast;
5779 convOp = spv::OpConvertFToU;
5794 convOp = spv::OpSConvert;
5809 convOp = spv::OpUConvert;
5881 return builder.createBinOp(spv::OpIAdd, destType, operand, zero);
5884 convOp = spv::OpBitcast;
5887 convOp = spv::OpConvertUToPtr;
5890 convOp = spv::OpConvertPtrToU;
5896 spv::Id result = 0;
5897 if (convOp == spv::OpNop)
5900 if (convOp == spv::OpSelect) {
5912 spv::Id TGlslangToSpvTraverser::makeSmearedConstant(spv::Id constant, int vectorSize)
5917 spv::Id vectorTypeId = builder.makeVectorType(builder.getTypeId(constant), vectorSize);
5918 std::vector<spv::Id> components;
5925 spv::Id TGlslangToSpvTraverser::createAtomicOperation(glslang::TOperator op, spv::Decoration /*prec…
5927 spv::Op opCode = spv::OpNop;
5933 opCode = spv::OpAtomicIAdd;
5936 opCode = spv::OpAtomicISub;
5941 …eProxy == glslang::EbtUint || typeProxy == glslang::EbtUint64) ? spv::OpAtomicUMin : spv::OpAtomic…
5946 …eProxy == glslang::EbtUint || typeProxy == glslang::EbtUint64) ? spv::OpAtomicUMax : spv::OpAtomic…
5951 opCode = spv::OpAtomicAnd;
5956 opCode = spv::OpAtomicOr;
5961 opCode = spv::OpAtomicXor;
5966 opCode = spv::OpAtomicExchange;
5971 opCode = spv::OpAtomicCompareExchange;
5974 opCode = spv::OpAtomicIIncrement;
5977 opCode = spv::OpAtomicIDecrement;
5982 opCode = spv::OpAtomicLoad;
5986 opCode = spv::OpAtomicStore;
5994 builder.addCapability(spv::CapabilityInt64Atomics);
6002 spv::Id pointerId = 0, compareId = 0, valueId = 0;
6004 spv::Id scopeId;
6006 scopeId = builder.makeUintConstant(spv::ScopeQueueFamilyKHR);
6008 scopeId = builder.makeUintConstant(spv::ScopeDevice);
6011 spv::Id semanticsId = builder.makeUintConstant(spv::MemorySemanticsMaskNone);
6012 spv::Id semanticsId2 = semanticsId;
6015 if (opCode == spv::OpAtomicIIncrement || opCode == spv::OpAtomicIDecrement) {
6017 } else if (opCode == spv::OpAtomicCompareExchange) {
6025 } else if (opCode == spv::OpAtomicLoad) {
6041 …if (semanticsImmediate & (spv::MemorySemanticsMakeAvailableKHRMask | spv::MemorySemanticsMakeVisib…
6042 builder.addCapability(spv::CapabilityVulkanMemoryModelKHR);
6045 …if (glslangIntermediate->usingVulkanMemoryModel() && builder.getConstantScalar(scopeId) == spv::Sc…
6046 builder.addCapability(spv::CapabilityVulkanMemoryModelDeviceScopeKHR);
6049 std::vector<spv::Id> spvAtomicOperands; // hold the spv operands
6053 if (opCode == spv::OpAtomicCompareExchange) {
6057 …} else if (opCode != spv::OpAtomicLoad && opCode != spv::OpAtomicIIncrement && opCode != spv::OpAt…
6061 if (opCode == spv::OpAtomicStore) {
6065 spv::Id resultId = builder.createOp(opCode, typeId, spvAtomicOperands);
6070 … resultId = builder.createBinOp(spv::OpISub, typeId, resultId, builder.makeIntConstant(1));
6077 spv::Id TGlslangToSpvTraverser::createInvocationsOperation(glslang::TOperator op, spv::Id typeId, s…
6084 spv::Op opCode = spv::OpNop;
6085 std::vector<spv::IdImmediate> spvGroupOperands;
6086 spv::GroupOperation groupOperation = spv::GroupOperationMax;
6090 builder.addExtension(spv::E_SPV_KHR_shader_ballot);
6091 builder.addCapability(spv::CapabilitySubgroupBallotKHR);
6095 builder.addExtension(spv::E_SPV_KHR_subgroup_vote);
6096 builder.addCapability(spv::CapabilitySubgroupVoteKHR);
6098 builder.addCapability(spv::CapabilityGroups);
6109 builder.addExtension(spv::E_SPV_AMD_shader_ballot);
6120 groupOperation = spv::GroupOperationReduce;
6128 groupOperation = spv::GroupOperationInclusiveScan;
6136 groupOperation = spv::GroupOperationExclusiveScan;
6141 spv::IdImmediate scope = { true, builder.makeUintConstant(spv::ScopeSubgroup) };
6143 if (groupOperation != spv::GroupOperationMax) {
6144 spv::IdImmediate groupOp = { false, (unsigned)groupOperation };
6151 spv::IdImmediate op = { true, *opIt };
6157 opCode = spv::OpSubgroupAnyKHR;
6160 opCode = spv::OpSubgroupAllKHR;
6163 opCode = spv::OpSubgroupAllEqualKHR;
6166 opCode = spv::OpSubgroupReadInvocationKHR;
6171 opCode = spv::OpSubgroupFirstInvocationKHR;
6181 spv::Id uintType = builder.makeUintType(32);
6182 spv::Id uvec4Type = builder.makeVectorType(uintType, 4);
6183 spv::Id result = builder.createOp(spv::OpSubgroupBallotKHR, uvec4Type, spvGroupOperands);
6185 std::vector<spv::Id> components;
6189 spv::Id uvec2Type = builder.makeVectorType(uintType, 2);
6190 return builder.createUnaryOp(spv::OpBitcast, typeId,
6208 opCode = spv::OpGroupFMin;
6211 opCode = spv::OpGroupUMin;
6213 opCode = spv::OpGroupSMin;
6219 opCode = spv::OpGroupFMax;
6222 opCode = spv::OpGroupUMax;
6224 opCode = spv::OpGroupSMax;
6228 opCode = spv::OpGroupFAdd;
6230 opCode = spv::OpGroupIAdd;
6250 opCode = spv::OpGroupFMinNonUniformAMD;
6253 opCode = spv::OpGroupUMinNonUniformAMD;
6255 opCode = spv::OpGroupSMinNonUniformAMD;
6262 opCode = spv::OpGroupFMaxNonUniformAMD;
6265 opCode = spv::OpGroupUMaxNonUniformAMD;
6267 opCode = spv::OpGroupSMaxNonUniformAMD;
6272 opCode = spv::OpGroupFAddNonUniformAMD;
6274 opCode = spv::OpGroupIAddNonUniformAMD;
6284 return spv::NoResult;
6287 assert(opCode != spv::OpNop);
6292 spv::Id TGlslangToSpvTraverser::CreateInvocationsVectorOperation(spv::Op op, spv::GroupOperation gr…
6293 spv::Id typeId, std::vector<spv::Id>& operands)
6296 assert(op == spv::OpGroupFMin || op == spv::OpGroupUMin || op == spv::OpGroupSMin ||
6297 op == spv::OpGroupFMax || op == spv::OpGroupUMax || op == spv::OpGroupSMax ||
6298 op == spv::OpGroupFAdd || op == spv::OpGroupIAdd || op == spv::OpGroupBroadcast ||
6299 op == spv::OpSubgroupReadInvocationKHR ||
6300 …op == spv::OpGroupFMinNonUniformAMD || op == spv::OpGroupUMinNonUniformAMD || op == spv::OpGroupSM…
6301 …op == spv::OpGroupFMaxNonUniformAMD || op == spv::OpGroupUMaxNonUniformAMD || op == spv::OpGroupSM…
6302 op == spv::OpGroupFAddNonUniformAMD || op == spv::OpGroupIAddNonUniformAMD);
6304 assert(op == spv::OpGroupFMin || op == spv::OpGroupUMin || op == spv::OpGroupSMin ||
6305 op == spv::OpGroupFMax || op == spv::OpGroupUMax || op == spv::OpGroupSMax ||
6306 op == spv::OpGroupFAdd || op == spv::OpGroupIAdd || op == spv::OpGroupBroadcast ||
6307 op == spv::OpSubgroupReadInvocationKHR);
6319 spv::Id scalarType = builder.getScalarTypeId(builder.getTypeId(operands[0]));
6320 std::vector<spv::Id> results;
6326spv::IdImmediate scalar = { true, builder.createCompositeExtract(operands[0], scalarType, indexes)…
6327 std::vector<spv::IdImmediate> spvGroupOperands;
6328 if (op == spv::OpSubgroupReadInvocationKHR) {
6330 spv::IdImmediate operand = { true, operands[1] };
6332 } else if (op == spv::OpGroupBroadcast) {
6333 spv::IdImmediate scope = { true, builder.makeUintConstant(spv::ScopeSubgroup) };
6336 spv::IdImmediate operand = { true, operands[1] };
6339 spv::IdImmediate scope = { true, builder.makeUintConstant(spv::ScopeSubgroup) };
6341 spv::IdImmediate groupOp = { false, (unsigned)groupOperation };
6354 spv::Id TGlslangToSpvTraverser::createSubgroupOperation(glslang::TOperator op, spv::Id typeId,
6355 std::vector<spv::Id>& operands, glslang::TBasicType typeProxy)
6360 builder.addCapability(spv::CapabilityGroupNonUniform);
6365 builder.addCapability(spv::CapabilityGroupNonUniform);
6366 builder.addCapability(spv::CapabilityGroupNonUniformVote);
6378 builder.addCapability(spv::CapabilityGroupNonUniform);
6379 builder.addCapability(spv::CapabilityGroupNonUniformBallot);
6383 builder.addCapability(spv::CapabilityGroupNonUniform);
6384 builder.addCapability(spv::CapabilityGroupNonUniformShuffle);
6388 builder.addCapability(spv::CapabilityGroupNonUniform);
6389 builder.addCapability(spv::CapabilityGroupNonUniformShuffleRelative);
6412 builder.addCapability(spv::CapabilityGroupNonUniform);
6413 builder.addCapability(spv::CapabilityGroupNonUniformArithmetic);
6422 builder.addCapability(spv::CapabilityGroupNonUniform);
6423 builder.addCapability(spv::CapabilityGroupNonUniformClustered);
6429 builder.addCapability(spv::CapabilityGroupNonUniform);
6430 builder.addCapability(spv::CapabilityGroupNonUniformQuad);
6454 builder.addExtension(spv::E_SPV_NV_shader_subgroup_partitioned);
6455 builder.addCapability(spv::CapabilityGroupNonUniformPartitionedNV);
6465 spv::Op opCode = spv::OpNop;
6469 case glslang::EOpSubgroupElect: opCode = spv::OpGroupNonUniformElect; break;
6470 case glslang::EOpSubgroupAll: opCode = spv::OpGroupNonUniformAll; break;
6471 case glslang::EOpSubgroupAny: opCode = spv::OpGroupNonUniformAny; break;
6472 … case glslang::EOpSubgroupAllEqual: opCode = spv::OpGroupNonUniformAllEqual; break;
6473 … case glslang::EOpSubgroupBroadcast: opCode = spv::OpGroupNonUniformBroadcast; break;
6474 …case glslang::EOpSubgroupBroadcastFirst: opCode = spv::OpGroupNonUniformBroadcastFirst; b…
6475 case glslang::EOpSubgroupBallot: opCode = spv::OpGroupNonUniformBallot; break;
6476 …case glslang::EOpSubgroupInverseBallot: opCode = spv::OpGroupNonUniformInverseBallot; br…
6477 …case glslang::EOpSubgroupBallotBitExtract: opCode = spv::OpGroupNonUniformBallotBitExtract;…
6480 …case glslang::EOpSubgroupBallotExclusiveBitCount: opCode = spv::OpGroupNonUniformBallotBitCount; b…
6481 …case glslang::EOpSubgroupBallotFindLSB: opCode = spv::OpGroupNonUniformBallotFindLSB; br…
6482 …case glslang::EOpSubgroupBallotFindMSB: opCode = spv::OpGroupNonUniformBallotFindMSB; br…
6483 case glslang::EOpSubgroupShuffle: opCode = spv::OpGroupNonUniformShuffle; break;
6484 …case glslang::EOpSubgroupShuffleXor: opCode = spv::OpGroupNonUniformShuffleXor; break;
6485 … case glslang::EOpSubgroupShuffleUp: opCode = spv::OpGroupNonUniformShuffleUp; break;
6486 …case glslang::EOpSubgroupShuffleDown: opCode = spv::OpGroupNonUniformShuffleDown; brea…
6497 opCode = spv::OpGroupNonUniformFAdd;
6499 opCode = spv::OpGroupNonUniformIAdd;
6512 opCode = spv::OpGroupNonUniformFMul;
6514 opCode = spv::OpGroupNonUniformIMul;
6527 opCode = spv::OpGroupNonUniformFMin;
6529 opCode = spv::OpGroupNonUniformUMin;
6531 opCode = spv::OpGroupNonUniformSMin;
6544 opCode = spv::OpGroupNonUniformFMax;
6546 opCode = spv::OpGroupNonUniformUMax;
6548 opCode = spv::OpGroupNonUniformSMax;
6561 opCode = spv::OpGroupNonUniformLogicalAnd;
6563 opCode = spv::OpGroupNonUniformBitwiseAnd;
6576 opCode = spv::OpGroupNonUniformLogicalOr;
6578 opCode = spv::OpGroupNonUniformBitwiseOr;
6591 opCode = spv::OpGroupNonUniformLogicalXor;
6593 opCode = spv::OpGroupNonUniformBitwiseXor;
6596 … case glslang::EOpSubgroupQuadBroadcast: opCode = spv::OpGroupNonUniformQuadBroadcast; break;
6599 case glslang::EOpSubgroupQuadSwapDiagonal: opCode = spv::OpGroupNonUniformQuadSwap; break;
6604 spv::GroupOperation groupOperation = spv::GroupOperationMax;
6616 groupOperation = spv::GroupOperationReduce;
6626 groupOperation = spv::GroupOperationInclusiveScan;
6636 groupOperation = spv::GroupOperationExclusiveScan;
6645 groupOperation = spv::GroupOperationClusteredReduce;
6655 groupOperation = spv::GroupOperationPartitionedReduceNV;
6664 groupOperation = spv::GroupOperationPartitionedInclusiveScanNV;
6673 groupOperation = spv::GroupOperationPartitionedExclusiveScanNV;
6679 std::vector<spv::IdImmediate> spvGroupOperands;
6682 spv::IdImmediate executionScope = { true, builder.makeUintConstant(spv::ScopeSubgroup) };
6686 if (groupOperation != spv::GroupOperationMax) {
6687 spv::IdImmediate groupOperand = { false, (unsigned)groupOperation };
6693 spv::IdImmediate operand = { true, *opIt };
6698 spv::Id directionId = spv::NoResult;
6705 if (directionId != spv::NoResult) {
6706 spv::IdImmediate direction = { true, directionId };
6713 spv::Id TGlslangToSpvTraverser::createMiscOperation(glslang::TOperator op, spv::Decoration precisio…
6718 spv::Op opCode = spv::OpNop;
6722 spv::Id typeId0 = 0;
6725 spv::Id typeId1 = 0;
6728 spv::Id frexpIntType = 0;
6733 libCall = spv::GLSLstd450FMin;
6735 libCall = spv::GLSLstd450UMin;
6737 libCall = spv::GLSLstd450SMin;
6741 libCall = spv::GLSLstd450Modf;
6745 libCall = spv::GLSLstd450FMax;
6747 libCall = spv::GLSLstd450UMax;
6749 libCall = spv::GLSLstd450SMax;
6753 libCall = spv::GLSLstd450Pow;
6756 opCode = spv::OpDot;
6759 libCall = spv::GLSLstd450Atan2;
6764 libCall = spv::GLSLstd450FClamp;
6766 libCall = spv::GLSLstd450UClamp;
6768 libCall = spv::GLSLstd450SClamp;
6775 libCall = spv::GLSLstd450FMix;
6777 opCode = spv::OpSelect;
6783 libCall = spv::GLSLstd450Step;
6787 libCall = spv::GLSLstd450SmoothStep;
6793 libCall = spv::GLSLstd450Distance;
6796 libCall = spv::GLSLstd450Cross;
6799 libCall = spv::GLSLstd450FaceForward;
6802 libCall = spv::GLSLstd450Reflect;
6805 libCall = spv::GLSLstd450Refract;
6810 builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
6812 libCall = spv::GLSLstd450InterpolateAtSample;
6817 builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
6819 libCall = spv::GLSLstd450InterpolateAtOffset;
6822 opCode = spv::OpIAddCarry;
6827 opCode = spv::OpISubBorrow;
6832 opCode = spv::OpUMulExtended;
6837 opCode = spv::OpSMulExtended;
6843 opCode = spv::OpBitFieldUExtract;
6845 opCode = spv::OpBitFieldSExtract;
6848 opCode = spv::OpBitFieldInsert;
6852 libCall = spv::GLSLstd450Fma;
6856 libCall = spv::GLSLstd450FrexpStruct;
6863 builder.addExtension(spv::E_SPV_AMD_gpu_shader_int16);
6874 libCall = spv::GLSLstd450Ldexp;
6921 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_shader_ballot);
6922 libCall = spv::SwizzleInvocationsAMD;
6925 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_shader_ballot);
6926 libCall = spv::SwizzleInvocationsMaskedAMD;
6929 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_shader_ballot);
6930 libCall = spv::WriteInvocationAMD;
6934 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_shader_trinary_minmax);
6936 libCall = spv::FMin3AMD;
6939 libCall = spv::UMin3AMD;
6941 libCall = spv::SMin3AMD;
6945 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_shader_trinary_minmax);
6947 libCall = spv::FMax3AMD;
6950 libCall = spv::UMax3AMD;
6952 libCall = spv::SMax3AMD;
6956 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_shader_trinary_minmax);
6958 libCall = spv::FMid3AMD;
6961 libCall = spv::UMid3AMD;
6963 libCall = spv::SMid3AMD;
6969 builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float);
6970 extBuiltins = getExtBuiltins(spv::E_SPV_AMD_shader_explicit_vertex_parameter);
6971 libCall = spv::InterpolateAtVertexAMD;
6982 …builder.createControlBarrier((spv::Scope)executionScope, (spv::Scope)memoryScope, (spv::MemorySema…
6983 …if (semantics & (spv::MemorySemanticsMakeAvailableKHRMask | spv::MemorySemanticsMakeVisibleKHRMask…
6984 builder.addCapability(spv::CapabilityVulkanMemoryModelKHR);
6986 …rmediate->usingVulkanMemoryModel() && (executionScope == spv::ScopeDevice || memoryScope == spv::S…
6987 builder.addCapability(spv::CapabilityVulkanMemoryModelDeviceScopeKHR);
6999 … builder.createMemoryBarrier((spv::Scope)memoryScope, (spv::MemorySemanticsMask)semantics);
7000 …if (semantics & (spv::MemorySemanticsMakeAvailableKHRMask | spv::MemorySemanticsMakeVisibleKHRMask…
7001 builder.addCapability(spv::CapabilityVulkanMemoryModelKHR);
7003 if (glslangIntermediate->usingVulkanMemoryModel() && memoryScope == spv::ScopeDevice) {
7004 builder.addCapability(spv::CapabilityVulkanMemoryModelDeviceScopeKHR);
7014 opCode = spv::OpReportIntersectionNV;
7019 builder.createNoResultOp(spv::OpTraceNV, operands);
7025 builder.createNoResultOp(spv::OpExecuteCallableNV, operands);
7030 builder.createNoResultOp(spv::OpWritePackedPrimitiveIndices4x8NV, operands);
7037 spv::Id id = 0;
7042 std::vector<spv::Id> callArguments(operands.begin(), operands.begin() + consumedOperands);
7044 } else if (opCode == spv::OpDot && !isFloat) {
7048spv::Id mulOp = builder.createBinOp(spv::OpIMul, builder.getTypeId(operands[0]), operands[0], oper…
7053 …id = builder.createBinOp(spv::OpIAdd, typeId, id, builder.createCompositeExtract(operands[0], type…
7093 spv::Id member1 = builder.createCompositeExtract(id, frexpIntType, 1);
7094 member1 = builder.createUnaryOp(spv::OpConvertSToF, typeId1, member1);
7110 spv::Id TGlslangToSpvTraverser::createNoArgOperation(glslang::TOperator op, spv::Decoration precisi…
7113spv::Scope memoryBarrierScope = glslangIntermediate->usingVulkanMemoryModel() ? spv::ScopeQueueFam…
7117 builder.createNoResultOp(spv::OpEmitVertex);
7120 builder.createNoResultOp(spv::OpEndPrimitive);
7125 builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup,
7126 spv::MemorySemanticsOutputMemoryKHRMask |
7127 spv::MemorySemanticsAcquireReleaseMask);
7128 builder.addCapability(spv::CapabilityVulkanMemoryModelKHR);
7130 …builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeInvocation, spv::MemorySemanticsMaskNo…
7133 builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup,
7134 spv::MemorySemanticsWorkgroupMemoryMask |
7135 spv::MemorySemanticsAcquireReleaseMask);
7139 builder.createMemoryBarrier(memoryBarrierScope, spv::MemorySemanticsAllMemory |
7140 spv::MemorySemanticsAcquireReleaseMask);
7143 … builder.createMemoryBarrier(memoryBarrierScope, spv::MemorySemanticsAtomicCounterMemoryMask |
7144 spv::MemorySemanticsAcquireReleaseMask);
7147 builder.createMemoryBarrier(memoryBarrierScope, spv::MemorySemanticsUniformMemoryMask |
7148 spv::MemorySemanticsAcquireReleaseMask);
7151 builder.createMemoryBarrier(memoryBarrierScope, spv::MemorySemanticsImageMemoryMask |
7152 spv::MemorySemanticsAcquireReleaseMask);
7155 builder.createMemoryBarrier(memoryBarrierScope, spv::MemorySemanticsWorkgroupMemoryMask |
7156 spv::MemorySemanticsAcquireReleaseMask);
7159 builder.createMemoryBarrier(spv::ScopeWorkgroup, spv::MemorySemanticsAllMemory |
7160 spv::MemorySemanticsAcquireReleaseMask);
7163 builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeDevice,
7164 spv::MemorySemanticsAllMemory |
7165 spv::MemorySemanticsAcquireReleaseMask);
7168 builder.createMemoryBarrier(spv::ScopeDevice, spv::MemorySemanticsUniformMemoryMask |
7169 spv::MemorySemanticsImageMemoryMask |
7170 spv::MemorySemanticsAcquireReleaseMask);
7173 …builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeDevice, spv::MemorySemanticsUniformMem…
7174spv::MemorySemanticsImageMemoryMask |
7175spv::MemorySemanticsAcquireReleaseMask);
7178 builder.createMemoryBarrier(spv::ScopeWorkgroup, spv::MemorySemanticsWorkgroupMemoryMask |
7179 spv::MemorySemanticsAcquireReleaseMask);
7182 builder.createControlBarrier(spv::ScopeWorkgroup, spv::ScopeWorkgroup,
7183 spv::MemorySemanticsWorkgroupMemoryMask |
7184 spv::MemorySemanticsAcquireReleaseMask);
7187 …builder.createControlBarrier(spv::ScopeSubgroup, spv::ScopeSubgroup, spv::MemorySemanticsAllMemory…
7188spv::MemorySemanticsAcquireReleaseMask);
7189 return spv::NoResult;
7191 builder.createMemoryBarrier(spv::ScopeSubgroup, spv::MemorySemanticsAllMemory |
7192 spv::MemorySemanticsAcquireReleaseMask);
7193 return spv::NoResult;
7195 builder.createMemoryBarrier(spv::ScopeSubgroup, spv::MemorySemanticsUniformMemoryMask |
7196 spv::MemorySemanticsAcquireReleaseMask);
7197 return spv::NoResult;
7199 builder.createMemoryBarrier(spv::ScopeSubgroup, spv::MemorySemanticsImageMemoryMask |
7200 spv::MemorySemanticsAcquireReleaseMask);
7201 return spv::NoResult;
7203 builder.createMemoryBarrier(spv::ScopeSubgroup, spv::MemorySemanticsWorkgroupMemoryMask |
7204 spv::MemorySemanticsAcquireReleaseMask);
7205 return spv::NoResult;
7207 std::vector<spv::Id> operands;
7213 std::vector<spv::Id> args; // Dummy arguments
7214spv::Id id = builder.createBuiltinCall(typeId, getExtBuiltins(spv::E_SPV_AMD_gcn_shader), spv::Tim…
7220 builder.createNoResultOp(spv::OpIgnoreIntersectionNV);
7223 builder.createNoResultOp(spv::OpTerminateRayNV);
7232 spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol)
7235 spv::Id id;
7253 …builder.addDecoration(id, spv::DecorationSpecId, symbol->getType().getQualifier().layoutSpecConsta…
7255 builder.addDecoration(id, spv::DecorationIndex, symbol->getQualifier().layoutIndex);
7257 … builder.addDecoration(id, spv::DecorationComponent, symbol->getQualifier().layoutComponent);
7260 builder.addDecoration(id, spv::DecorationOffset, symbol->getQualifier().layoutOffset);
7264 builder.addDecoration(id, spv::DecorationLocation, symbol->getQualifier().layoutLocation);
7267 builder.addCapability(spv::CapabilityGeometryStreams);
7268 builder.addDecoration(id, spv::DecorationStream, symbol->getQualifier().layoutStream);
7271 builder.addDecoration(id, spv::DecorationDescriptorSet, symbol->getQualifier().layoutSet);
7274 builder.addDecoration(id, spv::DecorationDescriptorSet, 0);
7277 builder.addDecoration(id, spv::DecorationBinding, symbol->getQualifier().layoutBinding);
7280 builder.addDecoration(id, spv::DecorationBinding, 0);
7283 …builder.addDecoration(id, spv::DecorationInputAttachmentIndex, symbol->getQualifier().layoutAttach…
7285 builder.addCapability(spv::CapabilityTransformFeedback);
7287 … builder.addDecoration(id, spv::DecorationXfbBuffer, symbol->getQualifier().layoutXfbBuffer);
7290 builder.addDecoration(id, spv::DecorationXfbStride, stride);
7293 … builder.addDecoration(id, spv::DecorationOffset, symbol->getQualifier().layoutXfbOffset);
7297 std::vector<spv::Decoration> memory;
7304 spv::BuiltIn builtIn = TranslateBuiltInDecoration(symbol->getQualifier().builtIn, false);
7305 if (builtIn != spv::BuiltInMax)
7306 builder.addDecoration(id, spv::DecorationBuiltIn, (int)builtIn);
7312 if (builtIn == spv::BuiltInSampleMask) {
7313 spv::Decoration decoration;
7316 decoration = (spv::Decoration)spv::DecorationOverrideCoverageNV;
7318 decoration = (spv::Decoration)spv::DecorationMax;
7320 if (decoration != spv::DecorationMax) {
7321 builder.addExtension(spv::E_SPV_NV_sample_mask_override_coverage);
7324 else if (builtIn == spv::BuiltInLayer) {
7327 builder.addDecoration(id, (spv::Decoration)spv::DecorationViewportRelativeNV);
7328 builder.addCapability(spv::CapabilityShaderViewportMaskNV);
7329 builder.addExtension(spv::E_SPV_NV_viewport_array2);
7332 builder.addDecoration(id, (spv::Decoration)spv::DecorationSecondaryViewportRelativeNV,
7334 builder.addCapability(spv::CapabilityShaderStereoViewNV);
7335 builder.addExtension(spv::E_SPV_NV_stereo_view_rendering);
7340 builder.addDecoration(id, spv::DecorationPassthroughNV);
7341 builder.addCapability(spv::CapabilityGeometryShaderPassthroughNV);
7342 builder.addExtension(spv::E_SPV_NV_geometry_shader_passthrough);
7345 builder.addDecoration(id, spv::DecorationPerVertexNV);
7346 builder.addCapability(spv::CapabilityFragmentBarycentricNV);
7347 builder.addExtension(spv::E_SPV_NV_fragment_shader_barycentric);
7353 builder.addDecoration(id, (spv::Decoration)spv::DecorationHlslSemanticGOOGLE,
7358 …coration(id, symbol->getType().getQualifier().restrict ? spv::DecorationRestrictPointerEXT : spv::…
7366 void TGlslangToSpvTraverser::addMeshNVDecoration(spv::Id id, int member, const glslang::TQualifier&…
7373 builder.addCapability(spv::CapabilityMeshShadingNV);
7374 builder.addExtension(spv::E_SPV_NV_mesh_shader);
7376 builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerPrimitiveNV);
7379 builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerViewNV);
7381 builder.addMemberDecoration(id, (unsigned)member, spv::DecorationPerTaskNV);
7387 builder.addCapability(spv::CapabilityMeshShadingNV);
7388 builder.addExtension(spv::E_SPV_NV_mesh_shader);
7390 builder.addDecoration(id, spv::DecorationPerPrimitiveNV);
7393 builder.addDecoration(id, spv::DecorationPerViewNV);
7395 builder.addDecoration(id, spv::DecorationPerTaskNV);
7410 spv::Id TGlslangToSpvTraverser::createSpvConstant(const glslang::TIntermTyped& node)
7428 std::vector<spv::Id> dimConstId;
7433 builder.addDecoration(dimConstId.back(), spv::DecorationSpecId,
7443 spv::Id result;
7455 return spv::NoResult;
7464 return spv::NoResult;
7473 spv::Id TGlslangToSpvTraverser::createSpvConstantFromConstUnionArray(const glslang::TType& glslangT…
7476 std::vector<spv::Id> spvConsts;
7479 spv::Id typeId = convertGlslangToSpvType(glslangType);
7542 spv::Id scalar = 0;
7680 spv::Id TGlslangToSpvTraverser::createShortCircuit(glslang::TOperator op, glslang::TIntermTyped& le…
7682 spv::Id boolTypeId = builder.makeBoolType();
7687 spv::Id leftId = accessChainLoad(left.getType());
7690 std::vector<spv::Id> phiOperands;
7702 leftId = builder.createUnaryOp(spv::OpLogicalNot, boolTypeId, leftId);
7705 spv::Builder::If ifBuilder(leftId, spv::SelectionControlMaskNone, builder);
7710 spv::Id rightId = accessChainLoad(right.getType());
7720 return builder.createOp(spv::OpPhi, boolTypeId, phiOperands);
7726 spv::Id TGlslangToSpvTraverser::getExtBuiltins(const char* name)
7732 spv::Id extBuiltins = builder.import(name);
7747 snprintf(buf, bufSize, "0x%08x, Revision %d", spv::Version, spv::Revision);
7817 spv::SpvBuildLogger logger;
7822 spv::SpvBuildLogger* logger, SpvOptions* options)
7835 TGlslangToSpvTraverser it(intermediate.getSpv().spv, &intermediate, logger, *options);