mirror of
https://github.com/ocornut/imgui.git
synced 2025-02-21 12:52:19 +01:00
SDL_GPU Shader and Instructions
Added source sharder files for the SDL_GPU Backend and instructions on how to compile them
This commit is contained in:
parent
96a260e14d
commit
9c054b196a
36
backends/sdlgpu3/build_instructions.txt
Normal file
36
backends/sdlgpu3/build_instructions.txt
Normal file
@ -0,0 +1,36 @@
|
||||
1) Compile the raw shader files to SPIRV:
|
||||
|
||||
glslc -o vertex.spv -c shader.vert
|
||||
glslc -o fragment.spv -c shader.frag
|
||||
|
||||
|
||||
2) Build SDL_shadercross (https://github.com/libsdl-org/SDL_shadercross)
|
||||
|
||||
|
||||
3-A) Compiling for the Vulkan Driver:
|
||||
|
||||
Nothing to do, you just need the previous vertex.spv/fragment.spv, proceed to step 4
|
||||
|
||||
|
||||
3-B) Compiling for the DirectX 12 Driver:
|
||||
|
||||
./shadercross vertex.spv -s SPIRV -d DXBC -t vertex -e main -o vertex.dxbc
|
||||
./shadercross fragment.spv -s SPIRV -d DXBC -t fragment -e main -o fragment.dxbc
|
||||
|
||||
Proceed to step 4
|
||||
|
||||
|
||||
3-C) Compiling for Metal (On windows you'll need the Metal Developer Tools for Windows, on linux you might use wine, but I never tested it):
|
||||
|
||||
./shadercross vertex.spv -s SPIRV -d MSL -t vertex -e main -o vertex.metal
|
||||
./shadercross fragment.spv -s SPIRV -d MSL -t fragment -e main -o fragment.metal
|
||||
|
||||
xcrun -sdk macosx metal -o vertex.ir -c vertex.metal
|
||||
xcrun -sdk macosx metal -o fragment.ir -c fragment.metal
|
||||
xcrun -sdk macosx metallib -o vertex.metallib -c vertex.ir
|
||||
xcrun -sdk macosx metallib -o fragment.metallib -c fragment.ir
|
||||
|
||||
Proceed to step 4
|
||||
|
||||
|
||||
4) Either find a way to load the shader bytecode from file, or use a tool like https://notisrac.github.io/FileToCArray/ to convert the file to a uint8_t array
|
14
backends/sdlgpu3/shader.frag
Normal file
14
backends/sdlgpu3/shader.frag
Normal file
@ -0,0 +1,14 @@
|
||||
#version 450 core
|
||||
layout(location = 0) out vec4 fColor;
|
||||
|
||||
layout(set=2, binding=0) uniform sampler2D sTexture;
|
||||
|
||||
layout(location = 0) in struct {
|
||||
vec4 Color;
|
||||
vec2 UV;
|
||||
} In;
|
||||
|
||||
void main()
|
||||
{
|
||||
fColor = In.Color * texture(sTexture, In.UV.st);
|
||||
}
|
22
backends/sdlgpu3/shader.vert
Normal file
22
backends/sdlgpu3/shader.vert
Normal file
@ -0,0 +1,22 @@
|
||||
#version 450 core
|
||||
layout(location = 0) in vec2 aPos;
|
||||
layout(location = 1) in vec2 aUV;
|
||||
layout(location = 2) in vec4 aColor;
|
||||
|
||||
layout(set=1,binding=0) uniform UBO {
|
||||
vec2 uScale;
|
||||
vec2 uTranslate;
|
||||
} ubo;
|
||||
|
||||
layout(location = 0) out struct {
|
||||
vec4 Color;
|
||||
vec2 UV;
|
||||
} Out;
|
||||
|
||||
void main()
|
||||
{
|
||||
Out.Color = aColor;
|
||||
Out.UV = aUV;
|
||||
gl_Position = vec4(aPos * ubo.uScale + ubo.uTranslate, 0, 1);
|
||||
gl_Position.y *= -1.0f;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user