Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
CompilerLinker.hpp
1/*
2Copyright (C) 2017,2018,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGAMES_COMPILERLINKER_HPP
17#define AEONGAMES_COMPILERLINKER_HPP
18
19#include <array>
20#include <string>
21#include "glslang/Public/ShaderLang.h"
22
23namespace AeonGames
24{
27 {
28 public:
30 // Command-line options
32 {
33 EOptionNone = 0,
34 EOptionIntermediate = ( 1 << 0 ),
35 EOptionSuppressInfolog = ( 1 << 1 ),
36 EOptionMemoryLeakMode = ( 1 << 2 ),
37 EOptionRelaxedErrors = ( 1 << 3 ),
38 EOptionGiveWarnings = ( 1 << 4 ),
39 EOptionLinkProgram = ( 1 << 5 ),
40 EOptionMultiThreaded = ( 1 << 6 ),
41 EOptionDumpConfig = ( 1 << 7 ),
42 EOptionDumpReflection = ( 1 << 8 ),
43 EOptionSuppressWarnings = ( 1 << 9 ),
44 EOptionDumpVersions = ( 1 << 10 ),
45 EOptionSpv = ( 1 << 11 ),
46 EOptionHumanReadableSpv = ( 1 << 12 ),
47 EOptionVulkanRules = ( 1 << 13 ),
48 EOptionDefaultDesktop = ( 1 << 14 ),
49 EOptionOutputPreprocessed = ( 1 << 15 ),
50 EOptionOutputHexadecimal = ( 1 << 16 ),
51 EOptionReadHlsl = ( 1 << 17 ),
52 EOptionCascadingErrors = ( 1 << 18 ),
53 EOptionAutoMapBindings = ( 1 << 19 ),
54 EOptionFlattenUniformArrays = ( 1 << 20 ),
55 EOptionNoStorageFormat = ( 1 << 21 ),
56 EOptionKeepUncalled = ( 1 << 22 ),
57 };
58
59 //
60 // Return codes from main/exit().
61 //
63 {
64 ESuccess = 0,
65 EFailCompile,
66 EFailLink,
67 };
68
70 CompilerLinker ( TOptions aOptions = static_cast<TOptions> ( EOptionSpv | EOptionVulkanRules | EOptionLinkProgram ) );
73 void AddShaderSource ( EShLanguage aStage, const char* aSource );
75 void RemoveShaderSource ( EShLanguage aStage );
79 const std::vector<uint32_t>& GetSpirV ( EShLanguage aStage ) const;
81 const std::string& GetLog() const;
82 private:
83 void SetMessageOptions ( EShMessages& messages ) const;
84 TOptions mOptions;
85 std::string mLog;
86 std::array<const char*, EShLangCount> mShaderCompilationUnits {{nullptr}};
87 std::array<uint32_t, EShLangCount> mBaseSamplerBinding{{0}};
88 std::array<uint32_t, EShLangCount> mBaseTextureBinding{ { 0 } };
89 std::array<uint32_t, EShLangCount> mBaseImageBinding{ { 0 } };
90 std::array<uint32_t, EShLangCount> mBaseUboBinding{ { 0 } };
91 std::array<std::vector<uint32_t>, EShLangCount> mSpirV;
92 };
93}
94#endif
Compiles and links GLSL shaders into SPIR-V bytecode.
FailCode
Process exit/result codes.
FailCode CompileAndLink()
Compile all added shader sources and link into a program.
CompilerLinker(TOptions aOptions=static_cast< TOptions >(EOptionSpv|EOptionVulkanRules|EOptionLinkProgram))
Constructor.
const std::vector< uint32_t > & GetSpirV(EShLanguage aStage) const
Get the compiled SPIR-V bytecode for a shader stage.
void AddShaderSource(EShLanguage aStage, const char *aSource)
Add GLSL source code for a shader stage.
void RemoveShaderSource(EShLanguage aStage)
Remove the shader source for a given stage.
const std::string & GetLog() const
Get the compilation/link log output.
TOptions
Compiler/linker option flags.
<- This is here just for the literals
Definition AABB.hpp:31