Skip to content

Instantly share code, notes, and snippets.

@floooh
Last active April 14, 2019 13:50
Show Gist options
  • Save floooh/00aa200f13220e7bbcd13bebad32bfc5 to your computer and use it in GitHub Desktop.
Save floooh/00aa200f13220e7bbcd13bebad32bfc5 to your computer and use it in GitHub Desktop.
cmdline:
sokol-shdc --input /Users/floh/projects/sokol-tools/test/test1.glsl --output bla.h --slang hlsl5:glsl330 --errfmt gcc --dump
output:
args_t:
valid: true
exit_code: 0
input: '/Users/floh/projects/sokol-tools/test/test1.glsl'
output: 'bla.h'
slang: 'glsl330:hlsl5'
byte_code: false
debug_dump: true
error_format: gcc
input_t:
error: not set
lines:
1:
2:
3:
4: @block vs_uniforms
5: uniform params {
6: mat4 mvp;
7: };
8: @end
9:
10: @block vs_inputs
11: layout(location=0) in vec4 position;
12: layout(location=1) in vec4 color0;
13: layout(location=0) out vec4 color;
14: @end
15:
16: @block fs_inputs
17: layout(location=0) in vec4 color;
18: layout(location=0) out vec4 fragColor;
19: @end
20:
21: @vs my_vs
22: @include_block vs_uniforms
23: @include_block vs_inputs
24: void main() {
25: gl_Position = mvp * position;
26: color = color0;
27: }
28: @end
29:
30:
31: @fs my_fs
32: @include_block fs_inputs
33: void main() {
34: fragColor = color;
35: }
36: @end
37:
38:
39: @program my_prog my_vs my_fs
40:
snippets:
snippet 0:
name: vs_uniforms
type: block
lines:
1( 5): uniform params {
2( 6): mat4 mvp;
3( 7): };
snippet 1:
name: vs_inputs
type: block
lines:
1( 11): layout(location=0) in vec4 position;
2( 12): layout(location=1) in vec4 color0;
3( 13): layout(location=0) out vec4 color;
snippet 2:
name: fs_inputs
type: block
lines:
1( 17): layout(location=0) in vec4 color;
2( 18): layout(location=0) out vec4 fragColor;
snippet 3:
name: my_vs
type: vs
lines:
1( 5): uniform params {
2( 6): mat4 mvp;
3( 7): };
4( 11): layout(location=0) in vec4 position;
5( 12): layout(location=1) in vec4 color0;
6( 13): layout(location=0) out vec4 color;
7( 24): void main() {
8( 25): gl_Position = mvp * position;
9( 26): color = color0;
10( 27): }
snippet 4:
name: my_fs
type: fs
lines:
1( 17): layout(location=0) in vec4 color;
2( 18): layout(location=0) out vec4 fragColor;
3( 33): void main() {
4( 34): fragColor = color;
5( 35): }
snippet_map:
fs_inputs => snippet 2
my_fs => snippet 4
my_vs => snippet 3
vs_inputs => snippet 1
vs_uniforms => snippet 0
block_map:
fs_inputs => snippet 2
vs_inputs => snippet 1
vs_uniforms => snippet 0
vs_map:
my_vs => snippet 3
fs_map:
my_fs => snippet 4
programs:
program my_prog:
name: my_prog
vs: my_vs
fs: my_fs
line_index: 38
spirv_t:
SPIR-V for snippet 'my_vs':
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %main "main" %_ %position %color %color0 %gl_VertexID %gl_InstanceID
OpSource GLSL 450
OpName %main "main"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpMemberName %gl_PerVertex 1 "gl_PointSize"
OpMemberName %gl_PerVertex 2 "gl_ClipDistance"
OpMemberName %gl_PerVertex 3 "gl_CullDistance"
OpName %_ ""
OpName %params "params"
OpMemberName %params 0 "mvp"
OpName %__0 ""
OpName %position "position"
OpName %color "color"
OpName %color0 "color0"
OpName %gl_VertexID "gl_VertexID"
OpName %gl_InstanceID "gl_InstanceID"
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpMemberDecorate %gl_PerVertex 1 BuiltIn PointSize
OpMemberDecorate %gl_PerVertex 2 BuiltIn ClipDistance
OpMemberDecorate %gl_PerVertex 3 BuiltIn CullDistance
OpDecorate %gl_PerVertex Block
OpMemberDecorate %params 0 ColMajor
OpMemberDecorate %params 0 Offset 0
OpMemberDecorate %params 0 MatrixStride 16
OpDecorate %params Block
OpDecorate %__0 DescriptorSet 0
OpDecorate %__0 Binding 0
OpDecorate %position Location 0
OpDecorate %color Location 0
OpDecorate %color0 Location 1
OpDecorate %gl_VertexID BuiltIn VertexId
OpDecorate %gl_InstanceID BuiltIn InstanceId
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%uint = OpTypeInt 32 0
%uint_1 = OpConstant %uint 1
%_arr_float_uint_1 = OpTypeArray %float %uint_1
%gl_PerVertex = OpTypeStruct %v4float %float %_arr_float_uint_1 %_arr_float_uint_1
%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
%_ = OpVariable %_ptr_Output_gl_PerVertex Output
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%mat4v4float = OpTypeMatrix %v4float 4
%params = OpTypeStruct %mat4v4float
%_ptr_Uniform_params = OpTypePointer Uniform %params
%__0 = OpVariable %_ptr_Uniform_params Uniform
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float
%_ptr_Input_v4float = OpTypePointer Input %v4float
%position = OpVariable %_ptr_Input_v4float Input
%_ptr_Output_v4float = OpTypePointer Output %v4float
%color = OpVariable %_ptr_Output_v4float Output
%color0 = OpVariable %_ptr_Input_v4float Input
%_ptr_Input_int = OpTypePointer Input %int
%gl_VertexID = OpVariable %_ptr_Input_int Input
%gl_InstanceID = OpVariable %_ptr_Input_int Input
%main = OpFunction %void None %3
%5 = OpLabel
%21 = OpAccessChain %_ptr_Uniform_mat4v4float %__0 %int_0
%22 = OpLoad %mat4v4float %21
%25 = OpLoad %v4float %position
%26 = OpMatrixTimesVector %v4float %22 %25
%28 = OpAccessChain %_ptr_Output_v4float %_ %int_0
OpStore %28 %26
%31 = OpLoad %v4float %color0
OpStore %color %31
OpReturn
OpFunctionEnd
SPIR-V for snippet 'my_fs':
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %fragColor %color
OpExecutionMode %main OriginLowerLeft
OpSource GLSL 450
OpName %main "main"
OpName %fragColor "fragColor"
OpName %color "color"
OpDecorate %fragColor Location 0
OpDecorate %color Location 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%fragColor = OpVariable %_ptr_Output_v4float Output
%_ptr_Input_v4float = OpTypePointer Input %v4float
%color = OpVariable %_ptr_Input_v4float Input
%main = OpFunction %void None %3
%5 = OpLabel
%12 = OpLoad %v4float %color
OpStore %fragColor %12
OpReturn
OpFunctionEnd
spirvcross_t::translate(): FIXME!
spirvcross_t::dump_debug(): FIXME!
bytecode_t::compile(): FIXME!
bytecode_t::dump_debug(): FIXME!
header_t::build(): FIXME!
header_t::dump_debug(): FIXME!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment