Add SDL3 GPU backend (Vulkan/Metal) with OpenGL fallback

This commit is contained in:
2026-05-04 11:45:43 +02:00
parent 0a03509323
commit f18d6143d1
42 changed files with 1273 additions and 738 deletions

View File

@@ -0,0 +1,19 @@
#include <metal_stdlib>
using namespace metal;
// Shared fullscreen-triangle vertex shader for the SDL3 GPU backend.
// Emits uv in Shadertoy convention: (0,0) bottom-left, (1,1) top-right.
struct PassthroughVOut {
float4 pos [[position]];
float2 uv;
};
vertex PassthroughVOut passthrough_vs(uint vid [[vertex_id]]) {
const float2 positions[3] = { {-1.0, -1.0}, {3.0, -1.0}, {-1.0, 3.0} };
PassthroughVOut out;
float2 pos = positions[vid];
out.uv = pos * 0.5 + 0.5;
out.pos = float4(pos.x, -pos.y, 0.0, 1.0);
return out;
}

Binary file not shown.

View File

@@ -0,0 +1,18 @@
#version 450
// Shared fullscreen-triangle vertex shader for the SDL3 GPU backend.
// Emits vUV in Shadertoy convention: (0,0) bottom-left, (1,1) top-right.
// Y flipped in NDC because Vulkan/Metal point Y down by default.
layout(location = 0) out vec2 vUV;
void main() {
const vec2 positions[3] = vec2[3](
vec2(-1.0, -1.0),
vec2( 3.0, -1.0),
vec2(-1.0, 3.0)
);
vec2 pos = positions[gl_VertexIndex];
vUV = pos * 0.5 + 0.5;
gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);
}

View File

@@ -0,0 +1,2 @@
Name: Cineshader Lava
Author: edankwan

View File

@@ -0,0 +1,2 @@
Name: Creation by Silexars
Author: Danguafer

View File

@@ -0,0 +1,2 @@
Name: Cube lines
Author: Danil

2
shaders/dbz/meta.txt Normal file
View File

@@ -0,0 +1,2 @@
Name: New Leaked 3I/Atlas NASA Footage
Author: msm01

View File

@@ -0,0 +1,2 @@
Name: Fractal Pyramid
Author: bradjamesgrant

View File

@@ -0,0 +1,2 @@
Name: Just Another Cube
Author: mrange

View File

@@ -0,0 +1,2 @@
Name: Octograms
Author: whisky_shusuky

View File

@@ -0,0 +1,2 @@
Name: Remember
Author: diatribes

View File

@@ -0,0 +1,2 @@
Name: Seascape
Author: Alexander Alekseev

View File

@@ -0,0 +1,2 @@
Name: Shader Art Coding Introduction
Author: kishimisu

2
shaders/test/meta.txt Normal file
View File

@@ -0,0 +1,2 @@
Name: Test
Author: JailDesigner

View File

@@ -0,0 +1,36 @@
#include <metal_stdlib>
using namespace metal;
// Test shader (Metal Shading Language port of test.vk.glsl).
// Author: JailDesigner
struct ShadertoyUBO {
float iTime;
float2 iResolution;
};
struct PassthroughVOut {
float4 pos [[position]];
float2 uv;
};
static float3 palette(float t) {
float3 a = float3(1.0, 0.5, 0.5);
float3 b = float3(1.0, 0.5, 0.5);
float3 c = float3(1.0, 1.0, 1.0);
float3 d = float3(0.263, 0.416, 0.557);
return a + b * cos(6.28318 * (c * t * d));
}
fragment float4 test_fs(PassthroughVOut in [[stage_in]],
constant ShadertoyUBO& u [[buffer(0)]]) {
float2 fragCoord = in.uv * u.iResolution;
float2 uv = (fragCoord * 2.0 - u.iResolution) / u.iResolution.y;
float d = length(uv);
float3 col = palette(d);
d = sin(d * 8.0 + u.iTime) / 8.0;
d = abs(d);
d = 0.02 / d;
col *= d;
return float4(col, 1.0);
}

BIN
shaders/test/test.frag.spv Normal file

Binary file not shown.

41
shaders/test/test.vk.glsl Normal file
View File

@@ -0,0 +1,41 @@
#version 450
// Name: Test
// Author: JailDesigner
//
// Vulkan port of test.gl.glsl. Bindings follow the SDL3 GPU convention:
// set=3, binding=0 — fragment uniform buffer (ShadertoyUniforms in C++).
layout(location = 0) in vec2 vUV;
layout(location = 0) out vec4 FragColor;
layout(set = 3, binding = 0) uniform ShadertoyUBO {
float iTime;
vec2 iResolution;
} u;
vec3 palette(float t) {
vec3 a = vec3(1.0, 0.5, 0.5);
vec3 b = vec3(1.0, 0.5, 0.5);
vec3 c = vec3(1.0, 1.0, 1.0);
vec3 d = vec3(0.263, 0.416, 0.557);
return a + b * cos(6.28318 * (c * t * d));
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord * 2.0 - u.iResolution) / u.iResolution.y;
float d = length(uv);
vec3 col = palette(d);
d = sin(d * 8.0 + u.iTime) / 8.0;
d = abs(d);
d = 0.02 / d;
col *= d;
fragColor = vec4(col, 1.0);
}
void main() {
vec2 fragCoordPixels = vUV * u.iResolution;
vec4 outColor;
mainImage(outColor, fragCoordPixels);
FragColor = outColor;
}

2
shaders/water/meta.txt Normal file
View File

@@ -0,0 +1,2 @@
Name: Water
Author: diatribes