Compare commits
16 Commits
a8dd27f3a4
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
b9e39139bc | ||
|
ac6cb02184 | ||
|
2524dbf206 | ||
|
fc91b57f33 | ||
|
1c49ffa07f | ||
|
af559317fb | ||
|
27528c754c | ||
|
7c97adabbe | ||
|
64c94fd1b8 | ||
|
5ecc42ab89 | ||
|
d8f5c9bb61 | ||
|
c4c104538b | ||
|
114cc1b057 | ||
|
d268a6e8f6 | ||
|
e2a9053866 | ||
|
b4fc2b48d5 |
23
build.zig
23
build.zig
@@ -6,6 +6,8 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
const dep_sokol = b.dependency("sokol", .{ .target = target, .optimize = optimize });
|
const dep_sokol = b.dependency("sokol", .{ .target = target, .optimize = optimize });
|
||||||
|
|
||||||
|
// Exe
|
||||||
|
|
||||||
const exe = b.addExecutable(.{
|
const exe = b.addExecutable(.{
|
||||||
.name = "sok",
|
.name = "sok",
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
@@ -15,8 +17,27 @@ pub fn build(b: *std.Build) void {
|
|||||||
|
|
||||||
exe.root_module.addImport("sokol", dep_sokol.module("sokol"));
|
exe.root_module.addImport("sokol", dep_sokol.module("sokol"));
|
||||||
|
|
||||||
|
// Set this to hide console on windows
|
||||||
|
//exe.subsystem = .Windows;
|
||||||
|
|
||||||
b.installArtifact(exe);
|
b.installArtifact(exe);
|
||||||
|
|
||||||
|
// Check step (for ZLS)
|
||||||
|
|
||||||
|
const exe_check = b.addExecutable(.{
|
||||||
|
.name = "check_step",
|
||||||
|
.root_source_file = b.path("src/main.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
|
||||||
|
exe_check.root_module.addImport("sokol", dep_sokol.module("sokol"));
|
||||||
|
|
||||||
|
const check = b.step("check", "Check if project compiles");
|
||||||
|
check.dependOn(&exe_check.step);
|
||||||
|
|
||||||
|
// Run
|
||||||
|
|
||||||
const run_cmd = b.addRunArtifact(exe);
|
const run_cmd = b.addRunArtifact(exe);
|
||||||
|
|
||||||
run_cmd.step.dependOn(b.getInstallStep());
|
run_cmd.step.dependOn(b.getInstallStep());
|
||||||
@@ -28,6 +49,8 @@ pub fn build(b: *std.Build) void {
|
|||||||
const run_step = b.step("run", "Run the app");
|
const run_step = b.step("run", "Run the app");
|
||||||
run_step.dependOn(&run_cmd.step);
|
run_step.dependOn(&run_cmd.step);
|
||||||
|
|
||||||
|
// Tests
|
||||||
|
|
||||||
const exe_unit_tests = b.addTest(.{
|
const exe_unit_tests = b.addTest(.{
|
||||||
.root_source_file = b.path("src/main.zig"),
|
.root_source_file = b.path("src/main.zig"),
|
||||||
.target = target,
|
.target = target,
|
||||||
|
@@ -1,18 +1,17 @@
|
|||||||
.{
|
.{
|
||||||
.name = "sok",
|
.name = "sok",
|
||||||
.version = "0.0.0",
|
.version = "0.0.0",
|
||||||
.minimum_zig_version = "0.13.0",
|
.minimum_zig_version = "0.14.0-dev.144+a31fe8aa3",
|
||||||
|
|
||||||
.dependencies = .{
|
|
||||||
.sokol = .{
|
|
||||||
.url = "git+https://github.com/floooh/sokol-zig.git#d3e21f76498213d6d58179065756f5f2ed9b90cf",
|
|
||||||
.hash = "122052a192829b377c637ce242ee8c9121e03d8cd10c889758dc6fb176368de7d67b",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
.paths = .{
|
.paths = .{
|
||||||
"build.zig",
|
"build.zig",
|
||||||
"build.zig.zon",
|
"build.zig.zon",
|
||||||
"src",
|
"src",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.dependencies = .{
|
||||||
|
.sokol = .{
|
||||||
|
.url = "git+https://github.com/floooh/sokol-zig.git#ed91d03b62ef9e5850f33a98a3f703c01d86798d",
|
||||||
|
.hash = "12208af0258178372af254d34e32e7f6cdf2e0f6a51bfb8d6706aff159e2ec6d2c65",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
1
compile_shaders.bat
Normal file
1
compile_shaders.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
sokol-shdc -i src/shaders/triangle.glsl -o src/shaders/triangle2.glsl.zig -l glsl410:metal_macos:hlsl5:glsl300es:wgsl -f sokol_zig
|
39
readme.md
Normal file
39
readme.md
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
A little learning playground of [sokol](https://github.com/floooh/sokol) in [zig](https://ziglang.org/). Started on the gamejam at Decentrala, 9th June 2024.
|
||||||
|
|
||||||
|
The goal of this project is not fixed, and is just to try out some sokol features. But here's a few things I'd like to try out:
|
||||||
|
- [x] Draw a circle
|
||||||
|
- [ ] Load and render textures
|
||||||
|
- [ ] Render a 3D object
|
||||||
|
- [ ] Compile it for WebAssembly and run it in the browser
|
||||||
|
|
||||||
|
## Build
|
||||||
|
|
||||||
|
To build, you need to have zig master (you can use [zvm](https://www.zvm.app/) to help you with this). Then just `zig build run` and that should be it!
|
||||||
|
|
||||||
|
Note that if you change shaders, you have to recompile them manually - run compile_shaders.bat.
|
||||||
|
|
||||||
|
### Live error checking
|
||||||
|
|
||||||
|
This project has been configured so that zls can show live compile errors on save. To make it work, you need to set these zls config params (in VSCode just copy these to your preferences):
|
||||||
|
```
|
||||||
|
"zig.zls.enableBuildOnSave": true,
|
||||||
|
"zig.zls.buildOnSaveStep": "check"
|
||||||
|
```
|
||||||
|
|
||||||
|
Also, if you're in VSCode, install ErrorLens extension so you can see the errors inline.
|
||||||
|
|
||||||
|
## Why zig?
|
||||||
|
|
||||||
|
Zig is a low level language and toolchain that is designed as a "better C". Its main goal is to be simple, robust and fast. A few strong points:
|
||||||
|
- It can cross-compile from any platform to any platform.
|
||||||
|
- It can include C headers and you can use it in zig directly.
|
||||||
|
- It has a built-in build system that is also written in zig, so no other build systems like cmake are needed.
|
||||||
|
- Unlike C++, it's not OOP, there are no hidden constructor and destructor calls and overcomplicated copy/move rules.
|
||||||
|
- Unlike C, it solves A LOT of problems of C, and is MUCH harder to shoot yourself in the foot.
|
||||||
|
- There are no hidden allocations, everything that is heap-allocating has to be done explicitely.
|
||||||
|
- It has a powerful metaprogramming facility "comptime", which provides full static reflection.
|
||||||
|
- I can go on listing more cool features, but that is enough for now.. :)
|
||||||
|
|
||||||
|
## Why sokol?
|
||||||
|
|
||||||
|
Sokol is a cross platform graphics library with minimal footprint that can compile to any backend like DirectX, OpenGL, Vulcan, Metal or even WebAssembly.
|
116
src/main.zig
116
src/main.zig
@@ -1,15 +1,18 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const sokol = @import("sokol");
|
const sokol = @import("sokol");
|
||||||
|
|
||||||
const sg = sokol.gfx;
|
const sg = sokol.gfx;
|
||||||
|
const Event = sokol.app.Event;
|
||||||
|
|
||||||
const shader = @import("shaders/triangle.glsl.zig");
|
const shader = @import("shaders/triangle2.glsl.zig");
|
||||||
|
|
||||||
var pass_action: sg.PassAction = .{};
|
var pass_action: sg.PassAction = .{};
|
||||||
|
|
||||||
const state = struct {
|
const state = struct {
|
||||||
var bind: sg.Bindings = .{};
|
var bind: sg.Bindings = .{};
|
||||||
var pip: sg.Pipeline = .{};
|
var pip: sg.Pipeline = .{};
|
||||||
|
var vsParams: shader.VsParams = .{ .aspectRatio = 0.5 };
|
||||||
|
var fsParams: shader.FsParams = .{ .offset = .{ 0, 0, 0 } };
|
||||||
|
var indexCount: u16 = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
export fn init() void {
|
export fn init() void {
|
||||||
@@ -22,16 +25,75 @@ export fn init() void {
|
|||||||
|
|
||||||
std.log.info("Vertex buffers len: {}", .{state.bind.vertex_buffers.len});
|
std.log.info("Vertex buffers len: {}", .{state.bind.vertex_buffers.len});
|
||||||
|
|
||||||
|
const vertexCount = 100;
|
||||||
|
const radius: f32 = 0.7;
|
||||||
|
|
||||||
|
const cX: f32 = 0;
|
||||||
|
const cY: f32 = 0;
|
||||||
|
|
||||||
|
const attributesCount = 7;
|
||||||
|
|
||||||
|
var triangleVerts = std.mem.zeroes([vertexCount * attributesCount]f32);
|
||||||
|
|
||||||
|
const angleDiff: f32 = 1 / @as(f32, @floatFromInt(vertexCount));
|
||||||
|
|
||||||
|
var pcg = std.Random.Pcg.init(123);
|
||||||
|
const rand = pcg.random();
|
||||||
|
|
||||||
|
for (0..vertexCount) |i| {
|
||||||
|
const pi: f32 = @floatCast(std.math.pi);
|
||||||
|
const angle: f32 = @as(f32, @floatFromInt(i)) * angleDiff * pi * 2;
|
||||||
|
|
||||||
|
const x = radius * @cos(angle) + cX;
|
||||||
|
const y = radius * @sin(angle) + cY;
|
||||||
|
|
||||||
|
const si = i * attributesCount;
|
||||||
|
triangleVerts[si + 0] = x;
|
||||||
|
triangleVerts[si + 1] = y;
|
||||||
|
triangleVerts[si + 2] = 0.5;
|
||||||
|
|
||||||
|
triangleVerts[si + 3] = rand.float(f32);
|
||||||
|
triangleVerts[si + 4] = rand.float(f32);
|
||||||
|
triangleVerts[si + 5] = rand.float(f32);
|
||||||
|
triangleVerts[si + 6] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// var triangleVerts = [_]f32{
|
||||||
|
// // positions colors
|
||||||
|
// 0.0, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0,
|
||||||
|
// 0.5, -0.5, 0.5, 0.0, 1.0, 0.0, 1.0,
|
||||||
|
// -0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0,
|
||||||
|
// 0.7, 0.5, 0.5, 0.0, 1.0, 0.0, 1.0,
|
||||||
|
// };
|
||||||
|
|
||||||
state.bind.vertex_buffers[0] = sg.makeBuffer(.{
|
state.bind.vertex_buffers[0] = sg.makeBuffer(.{
|
||||||
.data = sg.asRange(&[_]f32{
|
.data = sg.asRange(&triangleVerts),
|
||||||
// positions colors
|
});
|
||||||
0.0, 0.5, 0.5, 1.0, 0.0, 0.0, 1.0,
|
|
||||||
0.5, -0.5, 0.5, 0.0, 1.0, 0.0, 1.0,
|
const trisCount = vertexCount - 2;
|
||||||
-0.5, -0.5, 0.5, 0.0, 0.0, 1.0, 1.0,
|
|
||||||
}),
|
var indexBuffer: [trisCount * 3]u16 = undefined;
|
||||||
|
state.indexCount = indexBuffer.len;
|
||||||
|
|
||||||
|
// const indexBuffer = [_]u16{
|
||||||
|
// 0, 1, 2,
|
||||||
|
// 0, 2, 3,
|
||||||
|
// };
|
||||||
|
|
||||||
|
for (0..trisCount) |tri| {
|
||||||
|
const triu: u16 = @intCast(tri);
|
||||||
|
indexBuffer[tri * 3 + 0] = 0;
|
||||||
|
indexBuffer[tri * 3 + 1] = triu + 1;
|
||||||
|
indexBuffer[tri * 3 + 2] = triu + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
state.bind.index_buffer = sg.makeBuffer(.{
|
||||||
|
.type = .INDEXBUFFER,
|
||||||
|
.data = sg.asRange(&indexBuffer),
|
||||||
});
|
});
|
||||||
|
|
||||||
var pip_desc: sg.PipelineDesc = .{
|
var pip_desc: sg.PipelineDesc = .{
|
||||||
|
.index_type = .UINT16,
|
||||||
.shader = sg.makeShader(shader.triangleShaderDesc(sg.queryBackend())),
|
.shader = sg.makeShader(shader.triangleShaderDesc(sg.queryBackend())),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,38 +104,66 @@ export fn init() void {
|
|||||||
|
|
||||||
pass_action.colors[0] = .{
|
pass_action.colors[0] = .{
|
||||||
.load_action = .CLEAR,
|
.load_action = .CLEAR,
|
||||||
.clear_value = .{ .r = 0, .g = 1, .b = 0, .a = 1 },
|
.clear_value = .{},
|
||||||
};
|
};
|
||||||
|
|
||||||
std.log.info("Backend: {}\n", .{sg.queryBackend()});
|
std.log.info("Backend: {}\n", .{sg.queryBackend()});
|
||||||
|
|
||||||
|
sokol.app.showMouse(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn timef() f32 {
|
fn timef() f32 {
|
||||||
return @floatCast(sokol.time.sec(sokol.time.now()));
|
return @floatCast(sokol.time.sec(sokol.time.now()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var time: f32 = 0;
|
||||||
|
|
||||||
export fn frame() void {
|
export fn frame() void {
|
||||||
|
const dt: f32 = @floatCast(sokol.app.frameDuration());
|
||||||
|
time += dt;
|
||||||
|
|
||||||
const col = &pass_action.colors[0].clear_value;
|
const col = &pass_action.colors[0].clear_value;
|
||||||
col.g = @abs(@sin(timef()));
|
col.g = @abs(@sin(time));
|
||||||
col.r = @abs(@cos(timef()));
|
col.r = @abs(@cos(time));
|
||||||
|
|
||||||
|
state.vsParams.aspectRatio = sokol.app.heightf() / sokol.app.widthf();
|
||||||
|
|
||||||
sg.beginPass(.{ .action = pass_action, .swapchain = sokol.glue.swapchain() });
|
sg.beginPass(.{ .action = pass_action, .swapchain = sokol.glue.swapchain() });
|
||||||
sg.applyPipeline(state.pip);
|
sg.applyPipeline(state.pip);
|
||||||
|
state.fsParams.offset[0] = col.r;
|
||||||
|
sg.applyUniforms(.FS, shader.SLOT_fs_params, sg.asRange(&state.fsParams));
|
||||||
|
sg.applyUniforms(.VS, shader.SLOT_vs_params, sg.asRange(&state.vsParams));
|
||||||
sg.applyBindings(state.bind);
|
sg.applyBindings(state.bind);
|
||||||
sg.draw(0, 3, 1);
|
sg.draw(0, state.indexCount, 1);
|
||||||
sg.endPass();
|
sg.endPass();
|
||||||
|
|
||||||
sg.commit();
|
sg.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
export fn cleanup() void {}
|
export fn cleanup() void {
|
||||||
|
std.log.info("Ended", .{});
|
||||||
|
}
|
||||||
|
|
||||||
|
export fn event(eptr: [*c]const Event) void {
|
||||||
|
const e: *const Event = @ptrCast(eptr);
|
||||||
|
|
||||||
|
const buttonPressed = e.type == .MOUSE_DOWN or e.type == .KEY_DOWN;
|
||||||
|
const mouseMoved = e.type == .MOUSE_MOVE and (@abs(e.mouse_dx) > 2 or @abs(e.mouse_dy) > 2);
|
||||||
|
|
||||||
|
if (buttonPressed or mouseMoved) {
|
||||||
|
sokol.app.quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
sokol.app.run(.{
|
sokol.app.run(.{
|
||||||
.init_cb = init,
|
.init_cb = init,
|
||||||
.frame_cb = frame,
|
.frame_cb = frame,
|
||||||
.cleanup_cb = cleanup,
|
.cleanup_cb = cleanup,
|
||||||
|
.event_cb = event,
|
||||||
.width = 800,
|
.width = 800,
|
||||||
.height = 600,
|
.height = 600,
|
||||||
|
.fullscreen = true,
|
||||||
.icon = .{ .sokol_default = true },
|
.icon = .{ .sokol_default = true },
|
||||||
.window_title = "sokol hello",
|
.window_title = "sokol hello",
|
||||||
.logger = .{ .func = sokol.log.func },
|
.logger = .{ .func = sokol.log.func },
|
||||||
|
@@ -1,4 +1,8 @@
|
|||||||
@vs vs
|
@vs vs
|
||||||
|
uniform vs_params {
|
||||||
|
float aspectRatio;
|
||||||
|
};
|
||||||
|
|
||||||
in vec4 position;
|
in vec4 position;
|
||||||
in vec4 color0;
|
in vec4 color0;
|
||||||
|
|
||||||
@@ -6,16 +10,21 @@ out vec4 color;
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = position;
|
gl_Position = position;
|
||||||
|
gl_Position.x *= aspectRatio;
|
||||||
color = color0;
|
color = color0;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@fs fs
|
@fs fs
|
||||||
|
uniform fs_params {
|
||||||
|
vec3 offset;
|
||||||
|
};
|
||||||
|
|
||||||
in vec4 color;
|
in vec4 color;
|
||||||
out vec4 frag_color;
|
out vec4 frag_color;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
frag_color = color;
|
frag_color = color * offset.r;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
704
src/shaders/triangle2.glsl.zig
Normal file
704
src/shaders/triangle2.glsl.zig
Normal file
@@ -0,0 +1,704 @@
|
|||||||
|
const sg = @import("sokol").gfx;
|
||||||
|
//
|
||||||
|
// #version:1# (machine generated, don't edit!)
|
||||||
|
//
|
||||||
|
// Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
|
||||||
|
//
|
||||||
|
// Cmdline:
|
||||||
|
// sokol-shdc -i src/shaders/triangle.glsl -o src/shaders/triangle2.glsl.zig -l glsl410:metal_macos:hlsl5:glsl300es:wgsl -f sokol_zig
|
||||||
|
//
|
||||||
|
// Overview:
|
||||||
|
// =========
|
||||||
|
// Shader program: 'triangle':
|
||||||
|
// Get shader desc: shd.triangleShaderDesc(sg.queryBackend());
|
||||||
|
// Vertex shader: vs
|
||||||
|
// Attributes:
|
||||||
|
// ATTR_vs_position => 0
|
||||||
|
// ATTR_vs_color0 => 1
|
||||||
|
// Uniform block 'vs_params':
|
||||||
|
// Zig struct: VsParams
|
||||||
|
// Bind slot: SLOT_vs_params => 0
|
||||||
|
// Fragment shader: fs
|
||||||
|
// Uniform block 'fs_params':
|
||||||
|
// Zig struct: FsParams
|
||||||
|
// Bind slot: SLOT_fs_params => 0
|
||||||
|
//
|
||||||
|
pub const ATTR_vs_position = 0;
|
||||||
|
pub const ATTR_vs_color0 = 1;
|
||||||
|
pub const SLOT_vs_params = 0;
|
||||||
|
pub const SLOT_fs_params = 0;
|
||||||
|
pub const VsParams = extern struct {
|
||||||
|
aspectRatio: f32 align(16),
|
||||||
|
_pad_4: [12]u8 align(1) = undefined,
|
||||||
|
};
|
||||||
|
pub const FsParams = extern struct {
|
||||||
|
offset: [3]f32 align(16),
|
||||||
|
_pad_12: [4]u8 align(1) = undefined,
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// #version 410
|
||||||
|
//
|
||||||
|
// uniform vec4 vs_params[1];
|
||||||
|
// layout(location = 0) in vec4 position;
|
||||||
|
// layout(location = 0) out vec4 color;
|
||||||
|
// layout(location = 1) in vec4 color0;
|
||||||
|
//
|
||||||
|
// void main()
|
||||||
|
// {
|
||||||
|
// gl_Position = position;
|
||||||
|
// gl_Position.x *= vs_params[0].x;
|
||||||
|
// color = color0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
const vs_source_glsl410 = [258]u8 {
|
||||||
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x75,0x6e,
|
||||||
|
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61,
|
||||||
|
0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||||
|
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,
|
||||||
|
0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
|
||||||
|
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
|
||||||
|
0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,
|
||||||
|
0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,
|
||||||
|
0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,
|
||||||
|
0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,
|
||||||
|
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,
|
||||||
|
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||||
|
0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
|
||||||
|
0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x3d,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,
|
||||||
|
0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,
|
||||||
|
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,
|
||||||
|
0x0a,0x00,
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// #version 410
|
||||||
|
//
|
||||||
|
// uniform vec4 fs_params[1];
|
||||||
|
// layout(location = 0) out vec4 frag_color;
|
||||||
|
// layout(location = 0) in vec4 color;
|
||||||
|
//
|
||||||
|
// void main()
|
||||||
|
// {
|
||||||
|
// frag_color = color * fs_params[0].x;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
const fs_source_glsl410 = [179]u8 {
|
||||||
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,0x0a,0x75,0x6e,
|
||||||
|
0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x73,0x5f,0x70,0x61,
|
||||||
|
0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,
|
||||||
|
0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,
|
||||||
|
0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||||
|
0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||||
|
0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,
|
||||||
|
0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||||
|
0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x66,
|
||||||
|
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x3b,0x0a,0x7d,
|
||||||
|
0x0a,0x0a,0x00,
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// #version 300 es
|
||||||
|
//
|
||||||
|
// uniform vec4 vs_params[1];
|
||||||
|
// layout(location = 0) in vec4 position;
|
||||||
|
// out vec4 color;
|
||||||
|
// layout(location = 1) in vec4 color0;
|
||||||
|
//
|
||||||
|
// void main()
|
||||||
|
// {
|
||||||
|
// gl_Position = position;
|
||||||
|
// gl_Position.x *= vs_params[0].x;
|
||||||
|
// color = color0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
const vs_source_glsl300es = [240]u8 {
|
||||||
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||||
|
0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,
|
||||||
|
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f,
|
||||||
|
0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,
|
||||||
|
0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||||
|
0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,
|
||||||
|
0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,
|
||||||
|
0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,
|
||||||
|
0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||||
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||||
|
0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
|
||||||
|
0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x3d,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||||
|
0x73,0x5b,0x30,0x5d,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// #version 300 es
|
||||||
|
// precision mediump float;
|
||||||
|
// precision highp int;
|
||||||
|
//
|
||||||
|
// uniform highp vec4 fs_params[1];
|
||||||
|
// layout(location = 0) out highp vec4 frag_color;
|
||||||
|
// in highp vec4 color;
|
||||||
|
//
|
||||||
|
// void main()
|
||||||
|
// {
|
||||||
|
// frag_color = color * fs_params[0].x;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
const fs_source_glsl300es = [225]u8 {
|
||||||
|
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||||
|
0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,
|
||||||
|
0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,
|
||||||
|
0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,
|
||||||
|
0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,
|
||||||
|
0x34,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,
|
||||||
|
0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,
|
||||||
|
0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,
|
||||||
|
0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,
|
||||||
|
0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,
|
||||||
|
0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,
|
||||||
|
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
||||||
|
0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x66,0x73,0x5f,
|
||||||
|
0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||||
|
0x00,
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// cbuffer vs_params : register(b0)
|
||||||
|
// {
|
||||||
|
// float _23_aspectRatio : packoffset(c0);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// static float4 gl_Position;
|
||||||
|
// static float4 position;
|
||||||
|
// static float4 color;
|
||||||
|
// static float4 color0;
|
||||||
|
//
|
||||||
|
// struct SPIRV_Cross_Input
|
||||||
|
// {
|
||||||
|
// float4 position : TEXCOORD0;
|
||||||
|
// float4 color0 : TEXCOORD1;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct SPIRV_Cross_Output
|
||||||
|
// {
|
||||||
|
// float4 color : TEXCOORD0;
|
||||||
|
// float4 gl_Position : SV_Position;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void vert_main()
|
||||||
|
// {
|
||||||
|
// gl_Position = position;
|
||||||
|
// gl_Position.x *= _23_aspectRatio;
|
||||||
|
// color = color0;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||||
|
// {
|
||||||
|
// position = stage_input.position;
|
||||||
|
// color0 = stage_input.color0;
|
||||||
|
// vert_main();
|
||||||
|
// SPIRV_Cross_Output stage_output;
|
||||||
|
// stage_output.gl_Position = gl_Position;
|
||||||
|
// stage_output.color = color;
|
||||||
|
// return stage_output;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
const vs_source_hlsl5 = [767]u8 {
|
||||||
|
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||||
|
0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,
|
||||||
|
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x32,0x33,
|
||||||
|
0x5f,0x61,0x73,0x70,0x65,0x63,0x74,0x52,0x61,0x74,0x69,0x6f,0x20,0x3a,0x20,0x70,
|
||||||
|
0x61,0x63,0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,
|
||||||
|
0x3b,0x0a,0x0a,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,
|
||||||
|
0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,
|
||||||
|
0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,
|
||||||
|
0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,
|
||||||
|
0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,
|
||||||
|
0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,
|
||||||
|
0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,
|
||||||
|
0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||||
|
0x6e,0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,
|
||||||
|
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,
|
||||||
|
0x20,0x3a,0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x31,0x3b,0x0a,0x7d,0x3b,
|
||||||
|
0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,
|
||||||
|
0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,
|
||||||
|
0x20,0x54,0x45,0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
|
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
|
||||||
|
0x6f,0x6e,0x20,0x3a,0x20,0x53,0x56,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,
|
||||||
|
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x76,0x65,0x72,0x74,0x5f,
|
||||||
|
0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,
|
||||||
|
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x70,0x6f,0x73,0x69,0x74,
|
||||||
|
0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,
|
||||||
|
0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,0x3d,0x20,0x5f,0x32,0x33,0x5f,0x61,0x73,
|
||||||
|
0x70,0x65,0x63,0x74,0x52,0x61,0x74,0x69,0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,
|
||||||
|
0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,
|
||||||
|
0x0a,0x0a,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,
|
||||||
|
0x74,0x70,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,
|
||||||
|
0x43,0x72,0x6f,0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,
|
||||||
|
0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x70,
|
||||||
|
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,
|
||||||
|
0x69,0x6e,0x70,0x75,0x74,0x2e,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,
|
||||||
|
0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x3d,0x20,0x73,0x74,0x61,
|
||||||
|
0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,
|
||||||
|
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x72,0x74,0x5f,0x6d,0x61,0x69,0x6e,0x28,0x29,
|
||||||
|
0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
|
||||||
|
0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,
|
||||||
|
0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,
|
||||||
|
0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,
|
||||||
|
0x69,0x6f,0x6e,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||||
|
0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,
|
||||||
|
0x70,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x73,0x74,
|
||||||
|
0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x00,
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// cbuffer fs_params : register(b0)
|
||||||
|
// {
|
||||||
|
// float3 _16_offset : packoffset(c0);
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// static float4 frag_color;
|
||||||
|
// static float4 color;
|
||||||
|
//
|
||||||
|
// struct SPIRV_Cross_Input
|
||||||
|
// {
|
||||||
|
// float4 color : TEXCOORD0;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct SPIRV_Cross_Output
|
||||||
|
// {
|
||||||
|
// float4 frag_color : SV_Target0;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// void frag_main()
|
||||||
|
// {
|
||||||
|
// frag_color = color * _16_offset.x;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||||
|
// {
|
||||||
|
// color = stage_input.color;
|
||||||
|
// frag_main();
|
||||||
|
// SPIRV_Cross_Output stage_output;
|
||||||
|
// stage_output.frag_color = frag_color;
|
||||||
|
// return stage_output;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
const fs_source_hlsl5 = [530]u8 {
|
||||||
|
0x63,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,
|
||||||
|
0x73,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,0x72,0x28,0x62,0x30,0x29,
|
||||||
|
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x33,0x20,0x5f,0x31,
|
||||||
|
0x36,0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x20,0x3a,0x20,0x70,0x61,0x63,0x6b,0x6f,
|
||||||
|
0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x0a,
|
||||||
|
0x73,0x74,0x61,0x74,0x69,0x63,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x66,0x72,
|
||||||
|
0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x73,0x74,0x61,0x74,0x69,0x63,
|
||||||
|
0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,
|
||||||
|
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,
|
||||||
|
0x73,0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||||
|
0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x54,0x45,
|
||||||
|
0x58,0x43,0x4f,0x4f,0x52,0x44,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,
|
||||||
|
0x75,0x63,0x74,0x20,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,
|
||||||
|
0x4f,0x75,0x74,0x70,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||||
|
0x61,0x74,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,
|
||||||
|
0x20,0x53,0x56,0x5f,0x54,0x61,0x72,0x67,0x65,0x74,0x30,0x3b,0x0a,0x7d,0x3b,0x0a,
|
||||||
|
0x0a,0x76,0x6f,0x69,0x64,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,0x61,0x69,0x6e,0x28,
|
||||||
|
0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,
|
||||||
|
0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x5f,0x31,0x36,
|
||||||
|
0x5f,0x6f,0x66,0x66,0x73,0x65,0x74,0x2e,0x78,0x3b,0x0a,0x7d,0x0a,0x0a,0x53,0x50,
|
||||||
|
0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,
|
||||||
|
0x20,0x6d,0x61,0x69,0x6e,0x28,0x53,0x50,0x49,0x52,0x56,0x5f,0x43,0x72,0x6f,0x73,
|
||||||
|
0x73,0x5f,0x49,0x6e,0x70,0x75,0x74,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,
|
||||||
|
0x70,0x75,0x74,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,
|
||||||
|
0x20,0x3d,0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x63,
|
||||||
|
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x6d,
|
||||||
|
0x61,0x69,0x6e,0x28,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x53,0x50,0x49,0x52,0x56,
|
||||||
|
0x5f,0x43,0x72,0x6f,0x73,0x73,0x5f,0x4f,0x75,0x74,0x70,0x75,0x74,0x20,0x73,0x74,
|
||||||
|
0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
|
0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x2e,0x66,0x72,0x61,
|
||||||
|
0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,
|
||||||
|
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,
|
||||||
|
0x20,0x73,0x74,0x61,0x67,0x65,0x5f,0x6f,0x75,0x74,0x70,0x75,0x74,0x3b,0x0a,0x7d,
|
||||||
|
0x0a,0x00,
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// #include <metal_stdlib>
|
||||||
|
// #include <simd/simd.h>
|
||||||
|
//
|
||||||
|
// using namespace metal;
|
||||||
|
//
|
||||||
|
// struct vs_params
|
||||||
|
// {
|
||||||
|
// float aspectRatio;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct main0_out
|
||||||
|
// {
|
||||||
|
// float4 color [[user(locn0)]];
|
||||||
|
// float4 gl_Position [[position]];
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct main0_in
|
||||||
|
// {
|
||||||
|
// float4 position [[attribute(0)]];
|
||||||
|
// float4 color0 [[attribute(1)]];
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// vertex main0_out main0(main0_in in [[stage_in]], constant vs_params& _23 [[buffer(0)]])
|
||||||
|
// {
|
||||||
|
// main0_out out = {};
|
||||||
|
// out.gl_Position = in.position;
|
||||||
|
// out.gl_Position.x *= _23.aspectRatio;
|
||||||
|
// out.color = in.color0;
|
||||||
|
// return out;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
const vs_source_metal_macos = [546]u8 {
|
||||||
|
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||||
|
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||||
|
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||||
|
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||||
|
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x76,
|
||||||
|
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||||
|
0x6c,0x6f,0x61,0x74,0x20,0x61,0x73,0x70,0x65,0x63,0x74,0x52,0x61,0x74,0x69,0x6f,
|
||||||
|
0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,
|
||||||
|
0x6e,0x30,0x5f,0x6f,0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,
|
||||||
|
0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x75,0x73,0x65,0x72,
|
||||||
|
0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||||
|
0x6c,0x6f,0x61,0x74,0x34,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
|
||||||
|
0x6e,0x20,0x5b,0x5b,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5d,0x5d,0x3b,0x0a,
|
||||||
|
0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,
|
||||||
|
0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
|
||||||
|
0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x5b,0x5b,0x61,0x74,0x74,0x72,
|
||||||
|
0x69,0x62,0x75,0x74,0x65,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x20,0x20,0x20,0x20,
|
||||||
|
0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x5b,0x5b,
|
||||||
|
0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x28,0x31,0x29,0x5d,0x5d,0x3b,0x0a,
|
||||||
|
0x7d,0x3b,0x0a,0x0a,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,
|
||||||
|
0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,0x69,0x6e,0x30,
|
||||||
|
0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,0x65,0x5f,0x69,
|
||||||
|
0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,0x76,0x73,
|
||||||
|
0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x32,0x33,0x20,0x5b,0x5b,0x62,
|
||||||
|
0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,0x75,0x74,0x20,
|
||||||
|
0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x67,0x6c,
|
||||||
|
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x69,0x6e,0x2e,0x70,
|
||||||
|
0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
|
||||||
|
0x2e,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x2a,
|
||||||
|
0x3d,0x20,0x5f,0x32,0x33,0x2e,0x61,0x73,0x70,0x65,0x63,0x74,0x52,0x61,0x74,0x69,
|
||||||
|
0x6f,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,0x72,
|
||||||
|
0x20,0x3d,0x20,0x69,0x6e,0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,
|
||||||
|
0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,
|
||||||
|
0x0a,0x00,
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// #include <metal_stdlib>
|
||||||
|
// #include <simd/simd.h>
|
||||||
|
//
|
||||||
|
// using namespace metal;
|
||||||
|
//
|
||||||
|
// struct fs_params
|
||||||
|
// {
|
||||||
|
// float3 offset;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct main0_out
|
||||||
|
// {
|
||||||
|
// float4 frag_color [[color(0)]];
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct main0_in
|
||||||
|
// {
|
||||||
|
// float4 color [[user(locn0)]];
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// fragment main0_out main0(main0_in in [[stage_in]], constant fs_params& _16 [[buffer(0)]])
|
||||||
|
// {
|
||||||
|
// main0_out out = {};
|
||||||
|
// out.frag_color = in.color * _16.offset.x;
|
||||||
|
// return out;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
const fs_source_metal_macos = [411]u8 {
|
||||||
|
0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,0x20,0x3c,0x6d,0x65,0x74,0x61,0x6c,0x5f,
|
||||||
|
0x73,0x74,0x64,0x6c,0x69,0x62,0x3e,0x0a,0x23,0x69,0x6e,0x63,0x6c,0x75,0x64,0x65,
|
||||||
|
0x20,0x3c,0x73,0x69,0x6d,0x64,0x2f,0x73,0x69,0x6d,0x64,0x2e,0x68,0x3e,0x0a,0x0a,
|
||||||
|
0x75,0x73,0x69,0x6e,0x67,0x20,0x6e,0x61,0x6d,0x65,0x73,0x70,0x61,0x63,0x65,0x20,
|
||||||
|
0x6d,0x65,0x74,0x61,0x6c,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x66,
|
||||||
|
0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,
|
||||||
|
0x6c,0x6f,0x61,0x74,0x33,0x20,0x6f,0x66,0x66,0x73,0x65,0x74,0x3b,0x0a,0x7d,0x3b,
|
||||||
|
0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,
|
||||||
|
0x75,0x74,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,
|
||||||
|
0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x5b,0x5b,0x63,0x6f,0x6c,
|
||||||
|
0x6f,0x72,0x28,0x30,0x29,0x5d,0x5d,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,
|
||||||
|
0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x69,0x6e,0x0a,0x7b,0x0a,0x20,
|
||||||
|
0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,
|
||||||
|
0x5b,0x5b,0x75,0x73,0x65,0x72,0x28,0x6c,0x6f,0x63,0x6e,0x30,0x29,0x5d,0x5d,0x3b,
|
||||||
|
0x0a,0x7d,0x3b,0x0a,0x0a,0x66,0x72,0x61,0x67,0x6d,0x65,0x6e,0x74,0x20,0x6d,0x61,
|
||||||
|
0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x6d,0x61,
|
||||||
|
0x69,0x6e,0x30,0x5f,0x69,0x6e,0x20,0x69,0x6e,0x20,0x5b,0x5b,0x73,0x74,0x61,0x67,
|
||||||
|
0x65,0x5f,0x69,0x6e,0x5d,0x5d,0x2c,0x20,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,
|
||||||
|
0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x36,0x20,
|
||||||
|
0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x29,0x0a,0x7b,
|
||||||
|
0x0a,0x20,0x20,0x20,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,0x20,0x6f,
|
||||||
|
0x75,0x74,0x20,0x3d,0x20,0x7b,0x7d,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,
|
||||||
|
0x2e,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x69,0x6e,
|
||||||
|
0x2e,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x2a,0x20,0x5f,0x31,0x36,0x2e,0x6f,0x66,0x66,
|
||||||
|
0x73,0x65,0x74,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x20,0x20,0x72,0x65,0x74,0x75,0x72,
|
||||||
|
0x6e,0x20,0x6f,0x75,0x74,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// diagnostic(off, derivative_uniformity);
|
||||||
|
//
|
||||||
|
// struct vs_params {
|
||||||
|
// /_ @offset(0) _/
|
||||||
|
// aspectRatio : f32,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var<private> position_1 : vec4f;
|
||||||
|
//
|
||||||
|
// @group(0) @binding(0) var<uniform> x_23 : vs_params;
|
||||||
|
//
|
||||||
|
// var<private> color : vec4f;
|
||||||
|
//
|
||||||
|
// var<private> color0 : vec4f;
|
||||||
|
//
|
||||||
|
// var<private> gl_Position : vec4f;
|
||||||
|
//
|
||||||
|
// fn main_1() {
|
||||||
|
// let x_18 : vec4f = position_1;
|
||||||
|
// gl_Position = x_18;
|
||||||
|
// let x_26 : f32 = x_23.aspectRatio;
|
||||||
|
// let x_30 : f32 = gl_Position.x;
|
||||||
|
// gl_Position.x = (x_30 * x_26);
|
||||||
|
// let x_35 : vec4f = color0;
|
||||||
|
// color = x_35;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// struct main_out {
|
||||||
|
// @builtin(position)
|
||||||
|
// gl_Position : vec4f,
|
||||||
|
// @location(0)
|
||||||
|
// color_1 : vec4f,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @vertex
|
||||||
|
// fn main(@location(0) position_1_param : vec4f, @location(1) color0_param : vec4f) -> main_out {
|
||||||
|
// position_1 = position_1_param;
|
||||||
|
// color0 = color0_param;
|
||||||
|
// main_1();
|
||||||
|
// return main_out(gl_Position, color);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
const vs_source_wgsl = [832]u8 {
|
||||||
|
0x64,0x69,0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x28,0x6f,0x66,0x66,0x2c,0x20,
|
||||||
|
0x64,0x65,0x72,0x69,0x76,0x61,0x74,0x69,0x76,0x65,0x5f,0x75,0x6e,0x69,0x66,0x6f,
|
||||||
|
0x72,0x6d,0x69,0x74,0x79,0x29,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||||
|
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x7b,0x0a,0x20,0x20,0x2f,0x2a,
|
||||||
|
0x20,0x40,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x30,0x29,0x20,0x2a,0x2f,0x0a,0x20,
|
||||||
|
0x20,0x61,0x73,0x70,0x65,0x63,0x74,0x52,0x61,0x74,0x69,0x6f,0x20,0x3a,0x20,0x66,
|
||||||
|
0x33,0x32,0x2c,0x0a,0x7d,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,
|
||||||
|
0x74,0x65,0x3e,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x31,0x20,0x3a,
|
||||||
|
0x20,0x76,0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x40,0x67,0x72,0x6f,0x75,0x70,0x28,
|
||||||
|
0x30,0x29,0x20,0x40,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x28,0x30,0x29,0x20,0x76,
|
||||||
|
0x61,0x72,0x3c,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x3e,0x20,0x78,0x5f,0x32,0x33,
|
||||||
|
0x20,0x3a,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,0x0a,0x0a,0x76,
|
||||||
|
0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x3e,0x20,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,
|
||||||
|
0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x3e,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,
|
||||||
|
0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,
|
||||||
|
0x69,0x76,0x61,0x74,0x65,0x3e,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
|
||||||
|
0x6f,0x6e,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x3b,0x0a,0x0a,0x66,0x6e,0x20,
|
||||||
|
0x6d,0x61,0x69,0x6e,0x5f,0x31,0x28,0x29,0x20,0x7b,0x0a,0x20,0x20,0x6c,0x65,0x74,
|
||||||
|
0x20,0x78,0x5f,0x31,0x38,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x20,0x3d,0x20,
|
||||||
|
0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x31,0x3b,0x0a,0x20,0x20,0x67,0x6c,
|
||||||
|
0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x78,0x5f,0x31,0x38,
|
||||||
|
0x3b,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,0x78,0x5f,0x32,0x36,0x20,0x3a,0x20,0x66,
|
||||||
|
0x33,0x32,0x20,0x3d,0x20,0x78,0x5f,0x32,0x33,0x2e,0x61,0x73,0x70,0x65,0x63,0x74,
|
||||||
|
0x52,0x61,0x74,0x69,0x6f,0x3b,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,0x78,0x5f,0x33,
|
||||||
|
0x30,0x20,0x3a,0x20,0x66,0x33,0x32,0x20,0x3d,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,
|
||||||
|
0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,
|
||||||
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x2e,0x78,0x20,0x3d,0x20,0x28,0x78,0x5f,0x33,0x30,
|
||||||
|
0x20,0x2a,0x20,0x78,0x5f,0x32,0x36,0x29,0x3b,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,
|
||||||
|
0x78,0x5f,0x33,0x35,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x20,0x3d,0x20,0x63,
|
||||||
|
0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
|
||||||
|
0x20,0x78,0x5f,0x33,0x35,0x3b,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x3b,
|
||||||
|
0x0a,0x7d,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x5f,
|
||||||
|
0x6f,0x75,0x74,0x20,0x7b,0x0a,0x20,0x20,0x40,0x62,0x75,0x69,0x6c,0x74,0x69,0x6e,
|
||||||
|
0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x29,0x0a,0x20,0x20,0x67,0x6c,0x5f,
|
||||||
|
0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,
|
||||||
|
0x2c,0x0a,0x20,0x20,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,0x30,0x29,
|
||||||
|
0x0a,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x31,0x20,0x3a,0x20,0x76,0x65,0x63,
|
||||||
|
0x34,0x66,0x2c,0x0a,0x7d,0x0a,0x0a,0x40,0x76,0x65,0x72,0x74,0x65,0x78,0x0a,0x66,
|
||||||
|
0x6e,0x20,0x6d,0x61,0x69,0x6e,0x28,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,
|
||||||
|
0x28,0x30,0x29,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x31,0x5f,0x70,
|
||||||
|
0x61,0x72,0x61,0x6d,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x2c,0x20,0x40,0x6c,
|
||||||
|
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,0x31,0x29,0x20,0x63,0x6f,0x6c,0x6f,0x72,
|
||||||
|
0x30,0x5f,0x70,0x61,0x72,0x61,0x6d,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x29,
|
||||||
|
0x20,0x2d,0x3e,0x20,0x6d,0x61,0x69,0x6e,0x5f,0x6f,0x75,0x74,0x20,0x7b,0x0a,0x20,
|
||||||
|
0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x31,0x20,0x3d,0x20,0x70,0x6f,
|
||||||
|
0x73,0x69,0x74,0x69,0x6f,0x6e,0x5f,0x31,0x5f,0x70,0x61,0x72,0x61,0x6d,0x3b,0x0a,
|
||||||
|
0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,
|
||||||
|
0x30,0x5f,0x70,0x61,0x72,0x61,0x6d,0x3b,0x0a,0x20,0x20,0x6d,0x61,0x69,0x6e,0x5f,
|
||||||
|
0x31,0x28,0x29,0x3b,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6d,0x61,
|
||||||
|
0x69,0x6e,0x5f,0x6f,0x75,0x74,0x28,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,
|
||||||
|
0x6f,0x6e,0x2c,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||||
|
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// diagnostic(off, derivative_uniformity);
|
||||||
|
//
|
||||||
|
// struct fs_params {
|
||||||
|
// /_ @offset(0) _/
|
||||||
|
// offset : vec3f,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var<private> frag_color : vec4f;
|
||||||
|
//
|
||||||
|
// var<private> color : vec4f;
|
||||||
|
//
|
||||||
|
// @group(0) @binding(4) var<uniform> x_16 : fs_params;
|
||||||
|
//
|
||||||
|
// fn main_1() {
|
||||||
|
// let x_12 : vec4f = color;
|
||||||
|
// let x_23 : f32 = x_16.offset.x;
|
||||||
|
// frag_color = (x_12 * x_23);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// struct main_out {
|
||||||
|
// @location(0)
|
||||||
|
// frag_color_1 : vec4f,
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @fragment
|
||||||
|
// fn main(@location(0) color_param : vec4f) -> main_out {
|
||||||
|
// color = color_param;
|
||||||
|
// main_1();
|
||||||
|
// return main_out(frag_color);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
const fs_source_wgsl = [532]u8 {
|
||||||
|
0x64,0x69,0x61,0x67,0x6e,0x6f,0x73,0x74,0x69,0x63,0x28,0x6f,0x66,0x66,0x2c,0x20,
|
||||||
|
0x64,0x65,0x72,0x69,0x76,0x61,0x74,0x69,0x76,0x65,0x5f,0x75,0x6e,0x69,0x66,0x6f,
|
||||||
|
0x72,0x6d,0x69,0x74,0x79,0x29,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,
|
||||||
|
0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x20,0x7b,0x0a,0x20,0x20,0x2f,0x2a,
|
||||||
|
0x20,0x40,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x30,0x29,0x20,0x2a,0x2f,0x0a,0x20,
|
||||||
|
0x20,0x6f,0x66,0x66,0x73,0x65,0x74,0x20,0x3a,0x20,0x76,0x65,0x63,0x33,0x66,0x2c,
|
||||||
|
0x0a,0x7d,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,0x74,0x65,0x3e,
|
||||||
|
0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x76,0x65,
|
||||||
|
0x63,0x34,0x66,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x3c,0x70,0x72,0x69,0x76,0x61,0x74,
|
||||||
|
0x65,0x3e,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,
|
||||||
|
0x3b,0x0a,0x0a,0x40,0x67,0x72,0x6f,0x75,0x70,0x28,0x30,0x29,0x20,0x40,0x62,0x69,
|
||||||
|
0x6e,0x64,0x69,0x6e,0x67,0x28,0x34,0x29,0x20,0x76,0x61,0x72,0x3c,0x75,0x6e,0x69,
|
||||||
|
0x66,0x6f,0x72,0x6d,0x3e,0x20,0x78,0x5f,0x31,0x36,0x20,0x3a,0x20,0x66,0x73,0x5f,
|
||||||
|
0x70,0x61,0x72,0x61,0x6d,0x73,0x3b,0x0a,0x0a,0x66,0x6e,0x20,0x6d,0x61,0x69,0x6e,
|
||||||
|
0x5f,0x31,0x28,0x29,0x20,0x7b,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,0x78,0x5f,0x31,
|
||||||
|
0x32,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x3b,0x0a,0x20,0x20,0x6c,0x65,0x74,0x20,0x78,0x5f,0x32,0x33,0x20,0x3a,0x20,
|
||||||
|
0x66,0x33,0x32,0x20,0x3d,0x20,0x78,0x5f,0x31,0x36,0x2e,0x6f,0x66,0x66,0x73,0x65,
|
||||||
|
0x74,0x2e,0x78,0x3b,0x0a,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,
|
||||||
|
0x72,0x20,0x3d,0x20,0x28,0x78,0x5f,0x31,0x32,0x20,0x2a,0x20,0x78,0x5f,0x32,0x33,
|
||||||
|
0x29,0x3b,0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x3b,0x0a,0x7d,0x0a,0x0a,
|
||||||
|
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x6d,0x61,0x69,0x6e,0x5f,0x6f,0x75,0x74,0x20,
|
||||||
|
0x7b,0x0a,0x20,0x20,0x40,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,0x30,0x29,
|
||||||
|
0x0a,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x31,0x20,
|
||||||
|
0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x2c,0x0a,0x7d,0x0a,0x0a,0x40,0x66,0x72,0x61,
|
||||||
|
0x67,0x6d,0x65,0x6e,0x74,0x0a,0x66,0x6e,0x20,0x6d,0x61,0x69,0x6e,0x28,0x40,0x6c,
|
||||||
|
0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x28,0x30,0x29,0x20,0x63,0x6f,0x6c,0x6f,0x72,
|
||||||
|
0x5f,0x70,0x61,0x72,0x61,0x6d,0x20,0x3a,0x20,0x76,0x65,0x63,0x34,0x66,0x29,0x20,
|
||||||
|
0x2d,0x3e,0x20,0x6d,0x61,0x69,0x6e,0x5f,0x6f,0x75,0x74,0x20,0x7b,0x0a,0x20,0x20,
|
||||||
|
0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x5f,0x70,0x61,
|
||||||
|
0x72,0x61,0x6d,0x3b,0x0a,0x20,0x20,0x6d,0x61,0x69,0x6e,0x5f,0x31,0x28,0x29,0x3b,
|
||||||
|
0x0a,0x20,0x20,0x72,0x65,0x74,0x75,0x72,0x6e,0x20,0x6d,0x61,0x69,0x6e,0x5f,0x6f,
|
||||||
|
0x75,0x74,0x28,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x29,0x3b,0x0a,
|
||||||
|
0x7d,0x0a,0x0a,0x00,
|
||||||
|
};
|
||||||
|
pub fn triangleShaderDesc(backend: sg.Backend) sg.ShaderDesc {
|
||||||
|
var desc: sg.ShaderDesc = .{};
|
||||||
|
desc.label = "triangle_shader";
|
||||||
|
switch (backend) {
|
||||||
|
.GLCORE => {
|
||||||
|
desc.attrs[0].name = "position";
|
||||||
|
desc.attrs[1].name = "color0";
|
||||||
|
desc.vs.source = &vs_source_glsl410;
|
||||||
|
desc.vs.entry = "main";
|
||||||
|
desc.vs.uniform_blocks[0].size = 16;
|
||||||
|
desc.vs.uniform_blocks[0].layout = .STD140;
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].array_count = 1;
|
||||||
|
desc.fs.source = &fs_source_glsl410;
|
||||||
|
desc.fs.entry = "main";
|
||||||
|
desc.fs.uniform_blocks[0].size = 16;
|
||||||
|
desc.fs.uniform_blocks[0].layout = .STD140;
|
||||||
|
desc.fs.uniform_blocks[0].uniforms[0].name = "fs_params";
|
||||||
|
desc.fs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
|
||||||
|
desc.fs.uniform_blocks[0].uniforms[0].array_count = 1;
|
||||||
|
},
|
||||||
|
.GLES3 => {
|
||||||
|
desc.attrs[0].name = "position";
|
||||||
|
desc.attrs[1].name = "color0";
|
||||||
|
desc.vs.source = &vs_source_glsl300es;
|
||||||
|
desc.vs.entry = "main";
|
||||||
|
desc.vs.uniform_blocks[0].size = 16;
|
||||||
|
desc.vs.uniform_blocks[0].layout = .STD140;
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
|
||||||
|
desc.vs.uniform_blocks[0].uniforms[0].array_count = 1;
|
||||||
|
desc.fs.source = &fs_source_glsl300es;
|
||||||
|
desc.fs.entry = "main";
|
||||||
|
desc.fs.uniform_blocks[0].size = 16;
|
||||||
|
desc.fs.uniform_blocks[0].layout = .STD140;
|
||||||
|
desc.fs.uniform_blocks[0].uniforms[0].name = "fs_params";
|
||||||
|
desc.fs.uniform_blocks[0].uniforms[0].type = .FLOAT4;
|
||||||
|
desc.fs.uniform_blocks[0].uniforms[0].array_count = 1;
|
||||||
|
},
|
||||||
|
.D3D11 => {
|
||||||
|
desc.attrs[0].sem_name = "TEXCOORD";
|
||||||
|
desc.attrs[0].sem_index = 0;
|
||||||
|
desc.attrs[1].sem_name = "TEXCOORD";
|
||||||
|
desc.attrs[1].sem_index = 1;
|
||||||
|
desc.vs.source = &vs_source_hlsl5;
|
||||||
|
desc.vs.d3d11_target = "vs_5_0";
|
||||||
|
desc.vs.entry = "main";
|
||||||
|
desc.vs.uniform_blocks[0].size = 16;
|
||||||
|
desc.vs.uniform_blocks[0].layout = .STD140;
|
||||||
|
desc.fs.source = &fs_source_hlsl5;
|
||||||
|
desc.fs.d3d11_target = "ps_5_0";
|
||||||
|
desc.fs.entry = "main";
|
||||||
|
desc.fs.uniform_blocks[0].size = 16;
|
||||||
|
desc.fs.uniform_blocks[0].layout = .STD140;
|
||||||
|
},
|
||||||
|
.METAL_MACOS => {
|
||||||
|
desc.vs.source = &vs_source_metal_macos;
|
||||||
|
desc.vs.entry = "main0";
|
||||||
|
desc.vs.uniform_blocks[0].size = 16;
|
||||||
|
desc.vs.uniform_blocks[0].layout = .STD140;
|
||||||
|
desc.fs.source = &fs_source_metal_macos;
|
||||||
|
desc.fs.entry = "main0";
|
||||||
|
desc.fs.uniform_blocks[0].size = 16;
|
||||||
|
desc.fs.uniform_blocks[0].layout = .STD140;
|
||||||
|
},
|
||||||
|
.WGPU => {
|
||||||
|
desc.vs.source = &vs_source_wgsl;
|
||||||
|
desc.vs.entry = "main";
|
||||||
|
desc.vs.uniform_blocks[0].size = 16;
|
||||||
|
desc.vs.uniform_blocks[0].layout = .STD140;
|
||||||
|
desc.fs.source = &fs_source_wgsl;
|
||||||
|
desc.fs.entry = "main";
|
||||||
|
desc.fs.uniform_blocks[0].size = 16;
|
||||||
|
desc.fs.uniform_blocks[0].layout = .STD140;
|
||||||
|
},
|
||||||
|
else => {},
|
||||||
|
}
|
||||||
|
return desc;
|
||||||
|
}
|
17
todo.todo
Normal file
17
todo.todo
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
What are we doing here?:
|
||||||
|
☐ using sokol in zig
|
||||||
|
☐ part of a gamejam
|
||||||
|
|
||||||
|
Today:
|
||||||
|
☐ Guide through the code
|
||||||
|
|
||||||
|
Draw a circle!:
|
||||||
|
✔ Draw indices instead of triangle elements @done(24-06-12 00:29)
|
||||||
|
✔ Quad @done(24-06-12 00:40)
|
||||||
|
✔ Create a circle vertices @done(24-06-12 01:28)
|
||||||
|
✔ Draw the circle @done(24-06-12 01:28)
|
||||||
|
☐ Make the cirlce not stretch
|
||||||
|
☐ Make the circle move with uniforms
|
Reference in New Issue
Block a user