2
2
// This file is part of the "Nabla Engine".
3
3
// For conditions of distribution and use, see copyright notice in nabla.h
4
4
5
- #ifndef __NBL_ASSET_I_GLSL_COMPILER_H_INCLUDED__
6
- #define __NBL_ASSET_I_GLSL_COMPILER_H_INCLUDED__
5
+ #ifndef _NBL_ASSET_C_GLSL_COMPILER_H_INCLUDED_
6
+ #define _NBL_ASSET_C_GLSL_COMPILER_H_INCLUDED_
7
7
8
8
#include " nbl/asset/utils/ISPIRVOptimizer.h"
9
9
#include " nbl/asset/utils/IShaderCompiler.h"
10
10
11
11
namespace nbl ::asset
12
12
{
13
13
14
- // ! Will be derivative of IShaderGenerator, but we have to establish interface first
15
- class NBL_API IGLSLCompiler final : public IShaderCompiler
14
+ class NBL_API CGLSLCompiler final : public IShaderCompiler
16
15
{
17
16
public:
18
- enum E_SPIRV_VERSION
19
- {
20
- ESV_1_0 = 0x010000u ,
21
- ESV_1_1 = 0x010100u ,
22
- ESV_1_2 = 0x010200u ,
23
- ESV_1_3 = 0x010300u ,
24
- ESV_1_4 = 0x010400u ,
25
- ESV_1_5 = 0x010500u ,
26
- ESV_1_6 = 0x010600u ,
27
- ESV_COUNT = 0x7FFFFFFFu
28
- };
17
+ IShader::E_CONTENT_TYPE getCodeContentType () const override { return IShader::E_CONTENT_TYPE::ECT_GLSL; };
29
18
30
- IShader::E_CONTENT_TYPE getCodeContentType () const override { return IShader::E_CONTENT_TYPE::ECT_GLSL; } ;
19
+ CGLSLCompiler (core::smart_refctd_ptr<system::ISystem>&& system) ;
31
20
32
- IGLSLCompiler (core::smart_refctd_ptr<system::ISystem>&& system);
33
-
34
- core::smart_refctd_ptr<ICPUBuffer> compileSPIRVFromGLSL (
35
- const char * _glslCode,
36
- IShader::E_SHADER_STAGE _stage,
37
- const char * _entryPoint,
38
- const char * _compilationId,
39
- bool _genDebugInfo = true ,
40
- std::string* _outAssembly = nullptr ,
41
- system::logger_opt_ptr logger = nullptr ,
42
- const E_SPIRV_VERSION targetSpirvVersion = ESV_1_6) const ;
21
+ struct SOptions : IShaderCompiler::SOptions
22
+ {
23
+ virtual IShader::E_CONTENT_TYPE getCodeContentType () const override { return IShader::E_CONTENT_TYPE::ECT_GLSL; };
24
+ };
43
25
44
26
/* *
45
- If _stage is ESS_UNKNOWN, then compiler will try to deduce shader stage from #pragma annotation, i.e.:
27
+ If options.stage is ESS_UNKNOWN, then compiler will try to deduce shader stage from #pragma annotation, i.e.:
46
28
#pragma shader_stage(vertex), or
47
29
#pragma shader_stage(tesscontrol), or
48
30
#pragma shader_stage(tesseval), or
@@ -54,14 +36,34 @@ class NBL_API IGLSLCompiler final : public IShaderCompiler
54
36
55
37
This function does NOT process #include directives! Use resolveIncludeDirectives() first.
56
38
57
- @param _entryPoint Must be "main" since shaderc does not allow other entry points for GLSL. Kept with hope that shaderc will drop that requirement.
58
- @param _compilationId String that will be printed along with possible errors as source identifier.
59
- @param _genDebugInfo Requests compiler to generate debug info (most importantly objects' names).
60
- The engine, while running on OpenGL, won't be able to set push constants for shaders loaded as SPIR-V without debug info.
61
- @param _outAssembly Optional parameter; if not nullptr, SPIR-V assembly is saved in there.
39
+ @params code high level code
40
+ @param options
41
+ entryPoint Must be "main" since shaderc does not allow other entry points for GLSL. Kept with hope that shaderc will drop that requirement.
42
+ compilationId String that will be printed along with possible errors as source identifier.
43
+ genDebugInfo Requests compiler to generate debug info (most importantly objects' names).
44
+ The engine, while running on OpenGL, won't be able to set push constants for shaders loaded as SPIR-V without debug info.
45
+ outAssembly Optional parameter; if not nullptr, SPIR-V assembly is saved in there.
62
46
63
47
@returns Shader containing SPIR-V bytecode.
64
48
*/
49
+ core::smart_refctd_ptr<ICPUBuffer> compileToSPIRV (const char * code, const CGLSLCompiler::SOptions& options) const ;
50
+
51
+ core::smart_refctd_ptr<ICPUShader> createSPIRVShader (const char * code, const CGLSLCompiler::SOptions& options) const ;
52
+
53
+ core::smart_refctd_ptr<ICPUShader> createSPIRVShader (system::IFile* sourceFile, const CGLSLCompiler::SOptions& options) const ;
54
+
55
+ // TODO: REMOVE
56
+ core::smart_refctd_ptr<ICPUBuffer> compileSPIRVFromGLSL (
57
+ const char * _glslCode,
58
+ IShader::E_SHADER_STAGE _stage,
59
+ const char * _entryPoint,
60
+ const char * _compilationId,
61
+ bool _genDebugInfo = true ,
62
+ std::string* _outAssembly = nullptr ,
63
+ system::logger_opt_ptr logger = nullptr ,
64
+ const E_SPIRV_VERSION targetSpirvVersion = E_SPIRV_VERSION::ESV_1_6) const ;
65
+
66
+ // TODO: REMOVE
65
67
core::smart_refctd_ptr<ICPUShader> createSPIRVFromGLSL (
66
68
const char * _glslCode,
67
69
IShader::E_SHADER_STAGE _stage,
@@ -71,8 +73,9 @@ class NBL_API IGLSLCompiler final : public IShaderCompiler
71
73
bool _genDebugInfo = true ,
72
74
std::string* _outAssembly = nullptr ,
73
75
system::logger_opt_ptr logger = nullptr ,
74
- const E_SPIRV_VERSION targetSpirvVersion = ESV_1_6) const ;
76
+ const E_SPIRV_VERSION targetSpirvVersion = E_SPIRV_VERSION:: ESV_1_6) const ;
75
77
78
+ // TODO: REMOVE
76
79
core::smart_refctd_ptr<ICPUShader> createSPIRVFromGLSL (
77
80
system::IFile* _sourcefile,
78
81
IShader::E_SHADER_STAGE _stage,
@@ -82,7 +85,7 @@ class NBL_API IGLSLCompiler final : public IShaderCompiler
82
85
bool _genDebugInfo = true ,
83
86
std::string* _outAssembly = nullptr ,
84
87
system::logger_opt_ptr logger = nullptr ,
85
- const E_SPIRV_VERSION targetSpirvVersion = ESV_1_6) const ;
88
+ const E_SPIRV_VERSION targetSpirvVersion = E_SPIRV_VERSION:: ESV_1_6) const ;
86
89
87
90
/*
88
91
If original code contains #version specifier,
0 commit comments