RetroArch
Initialize.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
3 // Copyright (C) 2013-2016 LunarG, Inc.
4 //
5 // All rights reserved.
6 //
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
9 // are met:
10 //
11 // Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 //
14 // Redistributions in binary form must reproduce the above
15 // copyright notice, this list of conditions and the following
16 // disclaimer in the documentation and/or other materials provided
17 // with the distribution.
18 //
19 // Neither the name of 3Dlabs Inc. Ltd. nor the names of its
20 // contributors may be used to endorse or promote products derived
21 // from this software without specific prior written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 // COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 // ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 // POSSIBILITY OF SUCH DAMAGE.
35 //
36 
37 #ifndef _INITIALIZE_INCLUDED_
38 #define _INITIALIZE_INCLUDED_
39 
40 #include "../Include/ResourceLimits.h"
41 #include "../Include/Common.h"
42 #include "../Include/ShHandle.h"
43 #include "SymbolTable.h"
44 #include "Versions.h"
45 
46 namespace glslang {
47 
48 //
49 // This is made to hold parseable strings for almost all the built-in
50 // functions and variables for one specific combination of version
51 // and profile. (Some still need to be added programmatically.)
52 // This is a base class for language-specific derivations, which
53 // can be used for language independent builtins.
54 //
55 // The strings are organized by
56 // commonBuiltins: intersection of all stages' built-ins, processed just once
57 // stageBuiltins[]: anything a stage needs that's not in commonBuiltins
58 //
60 public:
63  virtual ~TBuiltInParseables();
64  virtual void initialize(int version, EProfile, const SpvVersion& spvVersion) = 0;
65  virtual void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage) = 0;
66  virtual const TString& getCommonString() const { return commonBuiltins; }
67  virtual const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; }
68 
69  virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable) = 0;
70  virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources) = 0;
71 
72 protected:
75 };
76 
77 //
78 // This is a GLSL specific derivation of TBuiltInParseables. To present a stable
79 // interface and match other similar code, it is called TBuiltIns, rather
80 // than TBuiltInParseablesGlsl.
81 //
82 class TBuiltIns : public TBuiltInParseables {
83 public:
85  TBuiltIns();
86  virtual ~TBuiltIns();
87  void initialize(int version, EProfile, const SpvVersion& spvVersion);
88  void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage);
89 
90  void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable);
91  void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources);
92 
93 protected:
94  void add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion& spvVersion);
95  void addSubpassSampling(TSampler, const TString& typeName, int version, EProfile profile);
96  void addQueryFunctions(TSampler, const TString& typeName, int version, EProfile profile);
97  void addImageFunctions(TSampler, const TString& typeName, int version, EProfile profile);
98  void addSamplingFunctions(TSampler, const TString& typeName, int version, EProfile profile);
99  void addGatherFunctions(TSampler, const TString& typeName, int version, EProfile profile);
100 
101  // Helpers for making textual representations of the permutations
102  // of texturing/imaging functions.
103  const char* postfixes[5];
104  const char* prefixes[EbtNumTypes];
106 };
107 
108 } // end namespace glslang
109 
110 #endif // _INITIALIZE_INCLUDED_
virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion &spvVersion, EShLanguage language, TSymbolTable &symbolTable)=0
TString commonBuiltins
Definition: Initialize.h:73
Definition: Versions.h:83
Definition: Initialize.h:82
EShLanguage
Definition: ShaderLang.h:90
TBuiltInParseables()
Definition: Initialize.cpp:73
void initialize(int version, EProfile, const SpvVersion &spvVersion)
Definition: Initialize.cpp:123
const char * prefixes[EbtNumTypes]
Definition: Initialize.h:104
Definition: ResourceLimits.h:52
Definition: SymbolTable.h:539
Definition: Initialize.h:59
Definition: Types.h:74
TPoolAllocator & GetThreadPoolAllocator()
Definition: PoolAlloc.cpp:47
virtual const TString & getCommonString() const
Definition: Initialize.h:66
EProfile
Definition: Versions.h:51
void addQueryFunctions(TSampler, const TString &typeName, int version, EProfile profile)
Definition: Initialize.cpp:5950
version
Definition: setup.py:6
void addSubpassSampling(TSampler, const TString &typeName, int version, EProfile profile)
Definition: Initialize.cpp:6179
void addImageFunctions(TSampler, const TString &typeName, int version, EProfile profile)
Definition: Initialize.cpp:6049
Definition: Types.h:71
#define POOL_ALLOCATOR_NEW_DELETE(A)
Definition: Common.h:112
void addSamplingFunctions(TSampler, const TString &typeName, int version, EProfile profile)
Definition: Initialize.cpp:6196
virtual const TString & getStageString(EShLanguage language) const
Definition: Initialize.h:67
void addGatherFunctions(TSampler, const TString &typeName, int version, EProfile profile)
Definition: Initialize.cpp:6514
Definition: arrays.h:46
virtual void initialize(int version, EProfile, const SpvVersion &spvVersion)=0
int dimMap[EsdNumDims]
Definition: Initialize.h:105
const char * postfixes[5]
Definition: Initialize.h:103
TString stageBuiltins[EShLangCount]
Definition: Initialize.h:74
void add2ndGenerationSamplingImaging(int version, EProfile profile, const SpvVersion &spvVersion)
Definition: Initialize.cpp:5818
virtual ~TBuiltInParseables()
Definition: Initialize.cpp:78
TBuiltIns()
Definition: Initialize.cpp:82
virtual ~TBuiltIns()
Definition: Initialize.cpp:110
void identifyBuiltIns(int version, EProfile profile, const SpvVersion &spvVersion, EShLanguage language, TSymbolTable &symbolTable)
Definition: Initialize.cpp:7284
Definition: lobject.h:303
Definition: BaseTypes.h:68
Definition: ShaderLang.h:97