-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New attempt at D language generator. #128
Conversation
@kassane can you have a quick look? Example output looks like this. Haven't tried building yet, because PS: ok that problem was fixed by manually installing llvm@17, looks like the homebrew recipe is missing a dependency. module shaders.ssbo;
import sg = sokol.gfx;
extern(C):
/*
#version:1# (machine generated, don't edit!)
Generated by sokol-shdc (https://github.com/floooh/sokol-tools)
Cmdline:
sokol-shdc -i /Users/floh/projects/sokol-tools/test/ssbo.glsl -o /Users/floh/scratch/bla.d -l metal_macos:hlsl5:glsl430 -f sokol_d
Overview:
=========
Shader program: 'ssbo':
Get shader desc: ssbo_shader_desc(sg.query_backend());
Vertex shader: vs
Attributes:
Uniform block 'vs_params':
D struct: VsParams
Bind slot: SLOT_VS_PARAMS => 0
Storage buffer 'ssbo':
D struct: Ssbo
Bind slot: SLOT_SSBO => 0
Fragment shader: fs
*/
enum SLOT_VS_PARAMS = 0;
enum SLOT_SSBO = 0;
struct VsParams {
align(16) float[16] mvp;
}
struct SbVertex {
align(16) float[4] pos;
align(1) float[4] color;
}
/*
#version 430
struct sb_vertex
{
vec4 pos;
vec4 color;
};
uniform vec4 vs_params[4];
layout(binding = 0, std430) readonly buffer ssbo
{
sb_vertex vtx[];
} _27;
layout(location = 0) out vec4 color;
void main()
{
gl_Position = mat4(vs_params[0], vs_params[1], vs_params[2], vs_params[3]) * _27.vtx[gl_VertexID].pos;
color = _27.vtx[gl_VertexID].color;
}
*/
__gshared char[377] VS_SOURCE_GLSL430 = [
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,0x30,0x0a,0x0a,0x73,0x74,
0x72,0x75,0x63,0x74,0x20,0x73,0x62,0x5f,0x76,0x65,0x72,0x74,0x65,0x78,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,
0x3b,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,0x34,0x5d,0x3b,0x0a,0x6c,0x61,
0x79,0x6f,0x75,0x74,0x28,0x62,0x69,0x6e,0x64,0x69,0x6e,0x67,0x20,0x3d,0x20,0x30,
0x2c,0x20,0x73,0x74,0x64,0x34,0x33,0x30,0x29,0x20,0x72,0x65,0x61,0x64,0x6f,0x6e,
0x6c,0x79,0x20,0x62,0x75,0x66,0x66,0x65,0x72,0x20,0x73,0x73,0x62,0x6f,0x0a,0x7b,
0x0a,0x20,0x20,0x20,0x20,0x73,0x62,0x5f,0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x76,
0x74,0x78,0x5b,0x5d,0x3b,0x0a,0x7d,0x20,0x5f,0x32,0x37,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,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,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,
0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,
0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,
0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,
0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,
0x20,0x2a,0x20,0x5f,0x32,0x37,0x2e,0x76,0x74,0x78,0x5b,0x67,0x6c,0x5f,0x56,0x65,
0x72,0x74,0x65,0x78,0x49,0x44,0x5d,0x2e,0x70,0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,
0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x5f,0x32,0x37,0x2e,0x76,0x74,0x78,
0x5b,0x67,0x6c,0x5f,0x56,0x65,0x72,0x74,0x65,0x78,0x49,0x44,0x5d,0x2e,0x63,0x6f,
0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00,
];
/*
#version 430
layout(location = 0) out vec4 frag_color;
layout(location = 0) in vec4 color;
void main()
{
frag_color = color;
}
*/
__gshared char[135] FS_SOURCE_GLSL430 = [
0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x34,0x33,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,
];
/*
struct sb_vertex
{
float4 pos;
float4 color;
};
cbuffer vs_params : register(b0)
{
row_major float4x4 _19_mvp : packoffset(c0);
};
ByteAddressBuffer _27 : register(t16);
static float4 gl_Position;
static int gl_VertexIndex;
static float4 color;
struct SPIRV_Cross_Input
{
uint gl_VertexIndex : SV_VertexID;
};
struct SPIRV_Cross_Output
{
float4 color : TEXCOORD0;
float4 gl_Position : SV_Position;
};
void vert_main()
{
gl_Position = mul(asfloat(_27.Load4(gl_VertexIndex * 32 + 0)), _19_mvp);
color = asfloat(_27.Load4(gl_VertexIndex * 32 + 16));
}
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
{
gl_VertexIndex = int(stage_input.gl_VertexIndex);
vert_main();
SPIRV_Cross_Output stage_output;
stage_output.gl_Position = gl_Position;
stage_output.color = color;
return stage_output;
}
*/
__gshared char[857] VS_SOURCE_HLSL5 = [
0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x73,0x62,0x5f,0x76,0x65,0x72,0x74,0x65,0x78,
0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,0x6f,
0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,0x6f,
0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,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,
0x72,0x6f,0x77,0x5f,0x6d,0x61,0x6a,0x6f,0x72,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,
0x78,0x34,0x20,0x5f,0x31,0x39,0x5f,0x6d,0x76,0x70,0x20,0x3a,0x20,0x70,0x61,0x63,
0x6b,0x6f,0x66,0x66,0x73,0x65,0x74,0x28,0x63,0x30,0x29,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x42,0x79,0x74,0x65,0x41,0x64,0x64,0x72,0x65,0x73,0x73,0x42,0x75,0x66,0x66,
0x65,0x72,0x20,0x5f,0x32,0x37,0x20,0x3a,0x20,0x72,0x65,0x67,0x69,0x73,0x74,0x65,
0x72,0x28,0x74,0x31,0x36,0x29,0x3b,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,0x69,0x6e,0x74,0x20,0x67,
0x6c,0x5f,0x56,0x65,0x72,0x74,0x65,0x78,0x49,0x6e,0x64,0x65,0x78,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,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x56,0x65,0x72,0x74,
0x65,0x78,0x49,0x6e,0x64,0x65,0x78,0x20,0x3a,0x20,0x53,0x56,0x5f,0x56,0x65,0x72,
0x74,0x65,0x78,0x49,0x44,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,0x6d,0x75,0x6c,0x28,0x61,0x73,0x66,0x6c,0x6f,0x61,0x74,0x28,
0x5f,0x32,0x37,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,0x56,0x65,0x72,
0x74,0x65,0x78,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x33,0x32,0x20,0x2b,0x20,
0x30,0x29,0x29,0x2c,0x20,0x5f,0x31,0x39,0x5f,0x6d,0x76,0x70,0x29,0x3b,0x0a,0x20,
0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x61,0x73,0x66,0x6c,0x6f,
0x61,0x74,0x28,0x5f,0x32,0x37,0x2e,0x4c,0x6f,0x61,0x64,0x34,0x28,0x67,0x6c,0x5f,
0x56,0x65,0x72,0x74,0x65,0x78,0x49,0x6e,0x64,0x65,0x78,0x20,0x2a,0x20,0x33,0x32,
0x20,0x2b,0x20,0x31,0x36,0x29,0x29,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,0x67,0x6c,0x5f,0x56,0x65,0x72,0x74,
0x65,0x78,0x49,0x6e,0x64,0x65,0x78,0x20,0x3d,0x20,0x69,0x6e,0x74,0x28,0x73,0x74,
0x61,0x67,0x65,0x5f,0x69,0x6e,0x70,0x75,0x74,0x2e,0x67,0x6c,0x5f,0x56,0x65,0x72,
0x74,0x65,0x78,0x49,0x6e,0x64,0x65,0x78,0x29,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;
}
*/
__gshared char[435] FS_SOURCE_HLSL5 = [
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 vs_params
{
float4x4 mvp;
};
struct sb_vertex
{
float4 pos;
float4 color;
};
struct ssbo
{
sb_vertex vtx[1];
};
struct main0_out
{
float4 color [[user(locn0)]];
float4 gl_Position [[position]];
};
vertex main0_out main0(constant vs_params& _19 [[buffer(0)]], const device ssbo& _27 [[buffer(12)]], uint gl_VertexIndex [[vertex_id]])
{
main0_out out = {};
out.gl_Position = _19.mvp * _27.vtx[int(gl_VertexIndex)].pos;
out.color = _27.vtx[int(gl_VertexIndex)].color;
return out;
}
*/
__gshared char[604] VS_SOURCE_METAL_MACOS = [
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,0x34,0x78,0x34,0x20,0x6d,0x76,0x70,0x3b,0x0a,0x7d,0x3b,0x0a,
0x0a,0x73,0x74,0x72,0x75,0x63,0x74,0x20,0x73,0x62,0x5f,0x76,0x65,0x72,0x74,0x65,
0x78,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x70,
0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x66,0x6c,0x6f,0x61,0x74,0x34,0x20,0x63,
0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x3b,0x0a,0x0a,0x73,0x74,0x72,0x75,0x63,0x74,
0x20,0x73,0x73,0x62,0x6f,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x73,0x62,0x5f,0x76,
0x65,0x72,0x74,0x65,0x78,0x20,0x76,0x74,0x78,0x5b,0x31,0x5d,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,
0x76,0x65,0x72,0x74,0x65,0x78,0x20,0x6d,0x61,0x69,0x6e,0x30,0x5f,0x6f,0x75,0x74,
0x20,0x6d,0x61,0x69,0x6e,0x30,0x28,0x63,0x6f,0x6e,0x73,0x74,0x61,0x6e,0x74,0x20,
0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x26,0x20,0x5f,0x31,0x39,0x20,0x5b,
0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x30,0x29,0x5d,0x5d,0x2c,0x20,0x63,0x6f,
0x6e,0x73,0x74,0x20,0x64,0x65,0x76,0x69,0x63,0x65,0x20,0x73,0x73,0x62,0x6f,0x26,
0x20,0x5f,0x32,0x37,0x20,0x5b,0x5b,0x62,0x75,0x66,0x66,0x65,0x72,0x28,0x31,0x32,
0x29,0x5d,0x5d,0x2c,0x20,0x75,0x69,0x6e,0x74,0x20,0x67,0x6c,0x5f,0x56,0x65,0x72,
0x74,0x65,0x78,0x49,0x6e,0x64,0x65,0x78,0x20,0x5b,0x5b,0x76,0x65,0x72,0x74,0x65,
0x78,0x5f,0x69,0x64,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,0x5f,0x31,0x39,0x2e,0x6d,0x76,0x70,0x20,
0x2a,0x20,0x5f,0x32,0x37,0x2e,0x76,0x74,0x78,0x5b,0x69,0x6e,0x74,0x28,0x67,0x6c,
0x5f,0x56,0x65,0x72,0x74,0x65,0x78,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,0x2e,0x70,
0x6f,0x73,0x3b,0x0a,0x20,0x20,0x20,0x20,0x6f,0x75,0x74,0x2e,0x63,0x6f,0x6c,0x6f,
0x72,0x20,0x3d,0x20,0x5f,0x32,0x37,0x2e,0x76,0x74,0x78,0x5b,0x69,0x6e,0x74,0x28,
0x67,0x6c,0x5f,0x56,0x65,0x72,0x74,0x65,0x78,0x49,0x6e,0x64,0x65,0x78,0x29,0x5d,
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,
];
/*
#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;
}
*/
__gshared char[315] FS_SOURCE_METAL_MACOS = [
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,
];
sg.ShaderDesc ssbo_shader_desc(sg.Backend backend) @trusted @nogc nothrow {
sg.ShaderDesc desc;
desc.label = "ssbo_shader";
switch (backend) {
case sg.Backend.Glcore:
desc.vs.source = &VS_SOURCE_GLSL430[0];
desc.vs.entry = "main";
desc.vs.uniform_blocks[0].size = 64;
desc.vs.uniform_blocks[0].layout = sg.UniformLayout.Std140;
desc.vs.uniform_blocks[0].uniforms[0].name = "vs_params";
desc.vs.uniform_blocks[0].uniforms[0].type = sg.UniformType.Float4;
desc.vs.uniform_blocks[0].uniforms[0].array_count = 4;
desc.vs.storage_buffers[0].used = true;
desc.vs.storage_buffers[0].readonly = true;
desc.fs.source = &FS_SOURCE_GLSL430[0];
desc.fs.entry = "main";
break;
case sg.Backend.D3d11:
desc.vs.source = &VS_SOURCE_HLSL5[0];
desc.vs.d3d11_target = "vs_5_0";
desc.vs.entry = "main";
desc.vs.uniform_blocks[0].size = 64;
desc.vs.uniform_blocks[0].layout = sg.UniformLayout.Std140;
desc.vs.storage_buffers[0].used = true;
desc.vs.storage_buffers[0].readonly = true;
desc.fs.source = &FS_SOURCE_HLSL5[0];
desc.fs.d3d11_target = "ps_5_0";
desc.fs.entry = "main";
break;
case sg.Backend.Metal_macos:
desc.vs.source = &VS_SOURCE_METAL_MACOS[0];
desc.vs.entry = "main0";
desc.vs.uniform_blocks[0].size = 64;
desc.vs.uniform_blocks[0].layout = sg.UniformLayout.Std140;
desc.vs.storage_buffers[0].used = true;
desc.vs.storage_buffers[0].readonly = true;
desc.fs.source = &FS_SOURCE_METAL_MACOS[0];
desc.fs.entry = "main0";
break;
default: break;
}
return desc;
} |
...rewrite of #115 for the new code generator structure.