• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright(C) 2021 Advanced Micro Devices, Inc.
3 //
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 //    Redistributions of source code must retain the above copyright
11 //    notice, this list of conditions and the following disclaimer.
12 //
13 //    Redistributions in binary form must reproduce the above
14 //    copyright notice, this list of conditions and the following
15 //    disclaimer in the documentation and/or other materials provided
16 //    with the distribution.
17 //
18 //    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
19 //    contributors may be used to endorse or promote products derived
20 //    from this software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 // POSSIBILITY OF SUCH DAMAGE.
34 //
35 
36 #pragma once
37 
38 #ifndef GLSLANG_WEB
39 
40 //
41 // GL_EXT_spirv_intrinsics
42 //
43 #include "Common.h"
44 
45 namespace glslang {
46 
47 class TIntermTyped;
48 class TIntermConstantUnion;
49 class TType;
50 
51 // SPIR-V requirements
52 struct TSpirvRequirement {
53     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
54 
55     // capability = [..]
56     TSet<TString> extensions;
57     // extension = [..]
58     TSet<int> capabilities;
59 };
60 
61 // SPIR-V execution modes
62 struct TSpirvExecutionMode {
63     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
64 
65     // spirv_execution_mode
66     TMap<int, TVector<const TIntermConstantUnion*>> modes;
67     // spirv_execution_mode_id
68     TMap<int, TVector<const TIntermTyped*> > modeIds;
69 };
70 
71 // SPIR-V decorations
72 struct TSpirvDecorate {
73     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
74 
75     // spirv_decorate
76     TMap<int, TVector<const TIntermConstantUnion*> > decorates;
77     // spirv_decorate_id
78     TMap<int, TVector<const TIntermTyped*>> decorateIds;
79     // spirv_decorate_string
80     TMap<int, TVector<const TIntermConstantUnion*> > decorateStrings;
81 };
82 
83 // SPIR-V instruction
84 struct TSpirvInstruction {
85     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
86 
TSpirvInstructionTSpirvInstruction87     TSpirvInstruction() { set = ""; id = -1; }
88 
89     bool operator==(const TSpirvInstruction& rhs) const { return set == rhs.set && id == rhs.id; }
90     bool operator!=(const TSpirvInstruction& rhs) const { return !operator==(rhs); }
91 
92     // spirv_instruction
93     TString set;
94     int     id;
95 };
96 
97 // SPIR-V type parameter
98 struct TSpirvTypeParameter {
99     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
100 
TSpirvTypeParameterTSpirvTypeParameter101     TSpirvTypeParameter(const TIntermConstantUnion* arg)
102     {
103         constant = arg;
104         type = nullptr;
105     }
106 
TSpirvTypeParameterTSpirvTypeParameter107     TSpirvTypeParameter(const TType *arg)
108     {
109         constant = nullptr;
110         type = arg;
111     }
112 
113     bool operator==(const TSpirvTypeParameter& rhs) const;
114     bool operator!=(const TSpirvTypeParameter& rhs) const { return !operator==(rhs); }
115 
116     const TIntermConstantUnion* constant; // Constant expression
117     const TType* type;                    // Type specifier
118 };
119 
120 typedef TVector<TSpirvTypeParameter> TSpirvTypeParameters;
121 
122 // SPIR-V type
123 struct TSpirvType {
124     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
125 
126     bool operator==(const TSpirvType& rhs) const
127     {
128         return spirvInst == rhs.spirvInst && typeParams == rhs.typeParams;
129     }
130     bool operator!=(const TSpirvType& rhs) const { return !operator==(rhs); }
131 
132     // spirv_type
133     TSpirvInstruction spirvInst;
134     TSpirvTypeParameters typeParams;
135 };
136 
137 } // end namespace glslang
138 
139 #endif // GLSLANG_WEB
140