forked from BabylonJS/BabylonNative
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShaderCompiler.h
40 lines (34 loc) · 1.02 KB
/
ShaderCompiler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once
#include <string_view>
#include <gsl/span>
#include <functional>
namespace glslang
{
class TShader;
}
namespace spirv_cross
{
class Compiler;
class Parser;
}
namespace Babylon
{
class ShaderCompiler
{
public:
ShaderCompiler();
~ShaderCompiler();
struct ShaderInfo
{
std::unique_ptr<spirv_cross::Parser> Parser;
std::unique_ptr<const spirv_cross::Compiler> Compiler;
gsl::span<uint8_t> Bytes;
};
void Compile(std::string_view vertexSource, std::string_view fragmentSource, std::function<void(ShaderInfo, ShaderInfo)> onCompiled);
protected:
// Invert dFdy operands similar to bgfx_shader.sh
// https://github.com/bkaradzic/bgfx/blob/7be225bf490bb1cd231cfb4abf7e617bf35b59cb/src/bgfx_shader.sh#L44-L45
// https://github.com/bkaradzic/bgfx/blob/7be225bf490bb1cd231cfb4abf7e617bf35b59cb/src/bgfx_shader.sh#L62-L65
static void InvertYDerivativeOperands(glslang::TShader& shader);
};
}