Triangle shaders and pipeline
This commit is contained in:
parent
2135613c49
commit
baca95edea
29
src/main.zig
29
src/main.zig
@ -1,10 +1,17 @@
|
||||
const std = @import("std");
|
||||
|
||||
const sokol = @import("sokol");
|
||||
|
||||
const sg = sokol.gfx;
|
||||
|
||||
const shader = @import("shaders/triangle.glsl.zig");
|
||||
|
||||
var pass_action: sg.PassAction = .{};
|
||||
|
||||
const state = struct {
|
||||
var bind: sg.Bindings = .{};
|
||||
var pip: sg.Pipeline = .{};
|
||||
};
|
||||
|
||||
export fn init() void {
|
||||
sg.setup(.{
|
||||
.logger = .{ .func = sokol.log.func },
|
||||
@ -13,6 +20,26 @@ export fn init() void {
|
||||
|
||||
sokol.time.setup();
|
||||
|
||||
std.log.info("Vertex buffers len: {}", .{state.bind.vertex_buffers.len});
|
||||
|
||||
state.bind.vertex_buffers[0] = sg.makeBuffer(.{
|
||||
.data = sg.asRange(&[_]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,
|
||||
}),
|
||||
});
|
||||
|
||||
var pip_desc: sg.PipelineDesc = .{
|
||||
.shader = sg.makeShader(shader.triangleShaderDesc(sg.queryBackend())),
|
||||
};
|
||||
|
||||
pip_desc.layout.attrs[0].format = .FLOAT3;
|
||||
pip_desc.layout.attrs[1].format = .FLOAT4;
|
||||
|
||||
state.pip = sg.makePipeline(pip_desc);
|
||||
|
||||
pass_action.colors[0] = .{
|
||||
.load_action = .CLEAR,
|
||||
.clear_value = .{ .r = 0, .g = 1, .b = 0, .a = 1 },
|
||||
|
22
src/shaders/triangle.glsl
Normal file
22
src/shaders/triangle.glsl
Normal file
@ -0,0 +1,22 @@
|
||||
@vs vs
|
||||
in vec4 position;
|
||||
in vec4 color0;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = position;
|
||||
color = color0;
|
||||
}
|
||||
@end
|
||||
|
||||
@fs fs
|
||||
in vec4 color;
|
||||
out vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
frag_color = color;
|
||||
}
|
||||
@end
|
||||
|
||||
@program triangle vs fs
|
542
src/shaders/triangle.glsl.zig
Normal file
542
src/shaders/triangle.glsl.zig
Normal file
@ -0,0 +1,542 @@
|
||||
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/examples/shaders/triangle.glsl -o src/examples/shaders/triangle.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
|
||||
// Fragment shader: fs
|
||||
//
|
||||
pub const ATTR_vs_position = 0;
|
||||
pub const ATTR_vs_color0 = 1;
|
||||
//
|
||||
// #version 410
|
||||
//
|
||||
// layout(location = 0) in vec4 position;
|
||||
// layout(location = 0) out vec4 color;
|
||||
// layout(location = 1) in vec4 color0;
|
||||
//
|
||||
// void main()
|
||||
// {
|
||||
// gl_Position = position;
|
||||
// color = color0;
|
||||
// }
|
||||
//
|
||||
//
|
||||
const vs_source_glsl410 = [194]u8 {
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,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,0x63,0x6f,
|
||||
0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,
|
||||
0x0a,0x00,
|
||||
};
|
||||
//
|
||||
// #version 410
|
||||
//
|
||||
// layout(location = 0) out vec4 frag_color;
|
||||
// layout(location = 0) in vec4 color;
|
||||
//
|
||||
// void main()
|
||||
// {
|
||||
// frag_color = color;
|
||||
// }
|
||||
//
|
||||
//
|
||||
const fs_source_glsl410 = [135]u8 {
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x31,0x30,0x0a,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,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
};
|
||||
//
|
||||
// #version 300 es
|
||||
//
|
||||
// layout(location = 0) in vec4 position;
|
||||
// out vec4 color;
|
||||
// layout(location = 1) in vec4 color0;
|
||||
//
|
||||
// void main()
|
||||
// {
|
||||
// gl_Position = position;
|
||||
// color = color0;
|
||||
// }
|
||||
//
|
||||
//
|
||||
const vs_source_glsl300es = [176]u8 {
|
||||
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a,
|
||||
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,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;
|
||||
//
|
||||
// layout(location = 0) out highp vec4 frag_color;
|
||||
// in highp vec4 color;
|
||||
//
|
||||
// void main()
|
||||
// {
|
||||
// frag_color = color;
|
||||
// }
|
||||
//
|
||||
//
|
||||
const fs_source_glsl300es = [175]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,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,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
|
||||
};
|
||||
//
|
||||
// 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;
|
||||
// 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 = [645]u8 {
|
||||
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,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,
|
||||
};
|
||||
//
|
||||
// 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;
|
||||
// }
|
||||
//
|
||||
// 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 = [435]u8 {
|
||||
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,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 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]])
|
||||
// {
|
||||
// main0_out out = {};
|
||||
// out.gl_Position = in.position;
|
||||
// out.color = in.color0;
|
||||
// return out;
|
||||
// }
|
||||
//
|
||||
//
|
||||
const vs_source_metal_macos = [419]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,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,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,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 main0_out
|
||||
// {
|
||||
// float4 frag_color [[color(0)]];
|
||||
// };
|
||||
//
|
||||
// struct main0_in
|
||||
// {
|
||||
// float4 color [[user(locn0)]];
|
||||
// };
|
||||
//
|
||||
// fragment main0_out main0(main0_in in [[stage_in]])
|
||||
// {
|
||||
// main0_out out = {};
|
||||
// out.frag_color = in.color;
|
||||
// return out;
|
||||
// }
|
||||
//
|
||||
//
|
||||
const fs_source_metal_macos = [315]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,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,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,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);
|
||||
//
|
||||
// var<private> position_1 : vec4f;
|
||||
//
|
||||
// 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_23 : vec4f = color0;
|
||||
// color = x_23;
|
||||
// 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 = [612]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,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,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,0x33,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,0x32,0x33,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);
|
||||
//
|
||||
// var<private> frag_color : vec4f;
|
||||
//
|
||||
// var<private> color : vec4f;
|
||||
//
|
||||
// fn main_1() {
|
||||
// let x_12 : vec4f = color;
|
||||
// frag_color = x_12;
|
||||
// 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 = [376]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,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,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,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,
|
||||
0x20,0x78,0x5f,0x31,0x32,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.fs.source = &fs_source_glsl410;
|
||||
desc.fs.entry = "main";
|
||||
},
|
||||
.GLES3 => {
|
||||
desc.attrs[0].name = "position";
|
||||
desc.attrs[1].name = "color0";
|
||||
desc.vs.source = &vs_source_glsl300es;
|
||||
desc.vs.entry = "main";
|
||||
desc.fs.source = &fs_source_glsl300es;
|
||||
desc.fs.entry = "main";
|
||||
},
|
||||
.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.fs.source = &fs_source_hlsl5;
|
||||
desc.fs.d3d11_target = "ps_5_0";
|
||||
desc.fs.entry = "main";
|
||||
},
|
||||
.METAL_MACOS => {
|
||||
desc.vs.source = &vs_source_metal_macos;
|
||||
desc.vs.entry = "main0";
|
||||
desc.fs.source = &fs_source_metal_macos;
|
||||
desc.fs.entry = "main0";
|
||||
},
|
||||
.WGPU => {
|
||||
desc.vs.source = &vs_source_wgsl;
|
||||
desc.vs.entry = "main";
|
||||
desc.fs.source = &fs_source_wgsl;
|
||||
desc.fs.entry = "main";
|
||||
},
|
||||
else => {},
|
||||
}
|
||||
return desc;
|
||||
}
|
Loading…
Reference in New Issue
Block a user