mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 09:55:40 +00:00
gpu/internal/convertshaders,gpu: represent converted shaders with raw literals
Raw strings with linebreaks are easier to read and produce smaller diffs. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+219
-19
@@ -6,28 +6,228 @@ import "gioui.org/gpu/internal/driver"
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
shader_input_vert = driver.ShaderSources{
|
shader_input_vert = driver.ShaderSources{
|
||||||
Name: "input.vert",
|
Name: "input.vert",
|
||||||
Inputs: []driver.InputLocation{{Name: "position", Location: 0, Semantic: "POSITION", SemanticIndex: 0, Type: 0x0, Size: 4}},
|
Inputs: []driver.InputLocation{{Name: "position", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 4}},
|
||||||
GLSL100ES: "\nattribute vec4 position;\n\nvoid main()\n{\n gl_Position = position;\n}\n\n",
|
GLSL100ES: `#version 100
|
||||||
GLSL300ES: "#version 300 es\n\nlayout(location = 0) in vec4 position;\n\nvoid main()\n{\n gl_Position = position;\n}\n\n",
|
|
||||||
GLSL130: "#version 130\n\nin vec4 position;\n\nvoid main()\n{\n gl_Position = position;\n}\n\n",
|
attribute vec4 position;
|
||||||
GLSL150: "#version 150\n\nin vec4 position;\n\nvoid main()\n{\n gl_Position = position;\n}\n\n",
|
|
||||||
HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0x35, 0xe9, 0xae, 0x29, 0x96, 0x7e, 0x7c, 0xe6, 0x40, 0xb0, 0x4e, 0x29, 0xd9, 0x98, 0x51, 0x7c, 0x1, 0x0, 0x0, 0x0, 0x10, 0x2, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x9c, 0x0, 0x0, 0x0, 0xe0, 0x0, 0x0, 0x0, 0x5c, 0x1, 0x0, 0x0, 0xa8, 0x1, 0x0, 0x0, 0xdc, 0x1, 0x0, 0x0, 0x41, 0x6f, 0x6e,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0x0, 0x0, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x0, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x0},
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL300ES: `#version 300 es
|
||||||
|
|
||||||
|
layout(location = 0) in vec4 position;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL130: `#version 130
|
||||||
|
#ifdef GL_ARB_shading_language_420pack
|
||||||
|
#extension GL_ARB_shading_language_420pack : require
|
||||||
|
#endif
|
||||||
|
|
||||||
|
in vec4 position;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL150: `#version 150
|
||||||
|
#ifdef GL_ARB_shading_language_420pack
|
||||||
|
#extension GL_ARB_shading_language_420pack : require
|
||||||
|
#endif
|
||||||
|
|
||||||
|
in vec4 position;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0x1e, 0xc2, 0xbb, 0x11, 0xd3, 0x69, 0x58, 0x37, 0xd4, 0x46, 0xb9, 0xa4, 0xf4, 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0x31, 0x30, 0x2e, 0x31, 0x0, 0x49, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0xf, 0x0, 0x0, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x0, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x0},
|
||||||
}
|
}
|
||||||
shader_simple_frag = driver.ShaderSources{
|
shader_simple_frag = driver.ShaderSources{
|
||||||
Name: "simple.frag",
|
Name: "simple.frag",
|
||||||
GLSL100ES: "precision mediump float;\nprecision highp int;\n\nvoid main()\n{\n gl_FragData[0] = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);\n}\n\n",
|
GLSL100ES: `#version 100
|
||||||
GLSL300ES: "#version 300 es\nprecision mediump float;\nprecision highp int;\n\nlayout(location = 0) out vec4 fragColor;\n\nvoid main()\n{\n fragColor = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);\n}\n\n",
|
precision mediump float;
|
||||||
GLSL130: "#version 130\n\nout vec4 fragColor;\n\nvoid main()\n{\n fragColor = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);\n}\n\n",
|
precision highp int;
|
||||||
GLSL150: "#version 150\n\nout vec4 fragColor;\n\nvoid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, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x0, 0x49, 0x53, 0x47, 0x4e, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x0, 0xab, 0xab},
|
void main()
|
||||||
|
{
|
||||||
|
gl_FragData[0] = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL300ES: `#version 300 es
|
||||||
|
precision mediump float;
|
||||||
|
precision highp int;
|
||||||
|
|
||||||
|
layout(location = 0) out vec4 fragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fragColor = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL130: `#version 130
|
||||||
|
#ifdef GL_ARB_shading_language_420pack
|
||||||
|
#extension GL_ARB_shading_language_420pack : require
|
||||||
|
#endif
|
||||||
|
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fragColor = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL150: `#version 150
|
||||||
|
#ifdef GL_ARB_shading_language_420pack
|
||||||
|
#extension GL_ARB_shading_language_420pack : require
|
||||||
|
#endif
|
||||||
|
|
||||||
|
out vec4 fragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
fragColor = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0xf5, 0x46, 0xde, 0x66, 0x24, 0x29, 0xa8, 0xbb, 0x56, 0xea, 0x73, 0xb5, 0x6b, 0x73, 0x12, 0x72, 0x1, 0x0, 0x0, 0x0, 0xdc, 0x1, 0x0, 0x0, 0x6, 0x0, 0x0, 0x0, 0x38, 0x0, 0x0, 0x0, 0x90, 0x0, 0x0, 0x0, 0xd0, 0x0, 0x0, 0x0, 0x4c, 0x1, 0x0, 0x0, 0x98, 0x1, 0x0, 0x0, 0xa8, 0x1, 0x0, 0x0, 0x41, 0x6f, 0x6e, 0x39, 0x50, 0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x0, 0x2, 0xff, 0xff, 0x2c, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x0, 0x24, 0x0, 0x0, 0x2, 0xff, 0xff, 0x51, 0x0, 0x0, 0x5, 0x0, 0x0, 0xf, 0xa0, 0x0, 0x0, 0x80, 0x3e, 0xcd, 0xcc, 0xc, 0x3f, 0x0, 0x0, 0x40, 0x3f, 0x0, 0x0, 0x80, 0x3f, 0x1, 0x0, 0x0, 0x2, 0x0, 0x8, 0xf, 0x80, 0x0, 0x0, 0xe4, 0xa0, 0xff, 0xff, 0x0, 0x0, 0x53, 0x48, 0x44, 0x52, 0x38, 0x0, 0x0, 0x0, 0x40, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x65, 0x0, 0x0, 0x3, 0xf2, 0x20, 0x10, 0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 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x31, 0x0, 0x49, 0x53, 0x47, 0x4e, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xf, 0x0, 0x0, 0x0, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x0, 0xab, 0xab},
|
||||||
}
|
}
|
||||||
shader_simple_vert = driver.ShaderSources{
|
shader_simple_vert = driver.ShaderSources{
|
||||||
Name: "simple.vert",
|
Name: "simple.vert",
|
||||||
GLSL100ES: "\nvoid main()\n{\n float x;\n float y;\n if (gl_VertexID == 0)\n {\n x = 0.0;\n y = 0.5;\n }\n else\n {\n if (gl_VertexID == 1)\n {\n x = 0.5;\n y = -0.5;\n }\n else\n {\n x = -0.5;\n y = -0.5;\n }\n }\n gl_Position = vec4(x, y, 0.5, 1.0);\n}\n\n",
|
GLSL100ES: `#version 100
|
||||||
GLSL300ES: "#version 300 es\n\nvoid main()\n{\n float x;\n float y;\n if (gl_VertexID == 0)\n {\n x = 0.0;\n y = 0.5;\n }\n else\n {\n if (gl_VertexID == 1)\n {\n x = 0.5;\n y = -0.5;\n }\n else\n {\n x = -0.5;\n y = -0.5;\n }\n }\n gl_Position = vec4(x, y, 0.5, 1.0);\n}\n\n",
|
|
||||||
GLSL130: "#version 130\n\nvoid main()\n{\n float x;\n float y;\n if (gl_VertexID == 0)\n {\n x = 0.0;\n y = 0.5;\n }\n else\n {\n if (gl_VertexID == 1)\n {\n x = 0.5;\n y = -0.5;\n }\n else\n {\n x = -0.5;\n y = -0.5;\n }\n }\n gl_Position = vec4(x, y, 0.5, 1.0);\n}\n\n",
|
void main()
|
||||||
GLSL150: "#version 150\n\nvoid main()\n{\n float x;\n float y;\n if (gl_VertexID == 0)\n {\n x = 0.0;\n y = 0.5;\n }\n else\n {\n if (gl_VertexID == 1)\n {\n x = 0.5;\n y = -0.5;\n }\n else\n {\n x = -0.5;\n y = -0.5;\n }\n }\n gl_Position = vec4(x, y, 0.5, 1.0);\n}\n\n",
|
{
|
||||||
HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0xc8, 0x20, 0x5c, 0x22, 0xec, 0xe9, 0xb2, 0x29, 0x40, 0xdf, 0x7c, 0x5a, 0x28, 0xea, 0xc, 0xb8, 0x1, 0x0, 0x0, 0x0, 0x48, 0x2, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x34, 0x0, 0x0, 0x0, 0x80, 0x0, 0x0, 0x0, 0xb4, 0x0, 0x0, 0x0, 0xe8, 0x0, 0x0, 0x0, 0xcc, 0x1, 0x0, 0x0, 0x52, 0x44, 0x45, 0x46, 0x44, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1c, 0x0, 0x0, 0x0, 0x0, 0x4, 0xfe, 0xff, 0x0, 0x1, 0x0, 0x0, 0x1c, 0x0, 0x0, 0x0, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6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, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
|
float x;
|
||||||
|
float y;
|
||||||
|
if (gl_VertexID == 0)
|
||||||
|
{
|
||||||
|
x = 0.0;
|
||||||
|
y = 0.5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gl_VertexID == 1)
|
||||||
|
{
|
||||||
|
x = 0.5;
|
||||||
|
y = -0.5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = -0.5;
|
||||||
|
y = -0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gl_Position = vec4(x, y, 0.5, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL300ES: `#version 300 es
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
if (gl_VertexID == 0)
|
||||||
|
{
|
||||||
|
x = 0.0;
|
||||||
|
y = 0.5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gl_VertexID == 1)
|
||||||
|
{
|
||||||
|
x = 0.5;
|
||||||
|
y = -0.5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = -0.5;
|
||||||
|
y = -0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gl_Position = vec4(x, y, 0.5, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL130: `#version 130
|
||||||
|
#ifdef GL_ARB_shading_language_420pack
|
||||||
|
#extension GL_ARB_shading_language_420pack : require
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
if (gl_VertexID == 0)
|
||||||
|
{
|
||||||
|
x = 0.0;
|
||||||
|
y = 0.5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gl_VertexID == 1)
|
||||||
|
{
|
||||||
|
x = 0.5;
|
||||||
|
y = -0.5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = -0.5;
|
||||||
|
y = -0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gl_Position = vec4(x, y, 0.5, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
GLSL150: `#version 150
|
||||||
|
#ifdef GL_ARB_shading_language_420pack
|
||||||
|
#extension GL_ARB_shading_language_420pack : require
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
float x;
|
||||||
|
float y;
|
||||||
|
if (gl_VertexID == 0)
|
||||||
|
{
|
||||||
|
x = 0.0;
|
||||||
|
y = 0.5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (gl_VertexID == 1)
|
||||||
|
{
|
||||||
|
x = 0.5;
|
||||||
|
y = -0.5;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
x = -0.5;
|
||||||
|
y = -0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gl_Position = vec4(x, y, 0.5, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
`,
|
||||||
|
HLSL: []byte{0x44, 0x58, 0x42, 0x43, 0xc8, 0x20, 0x5c, 0x22, 0xec, 0xe9, 0xb2, 0x29, 0x40, 0xdf, 0x7c, 0x5a, 0x28, 0xea, 0xc, 0xb8, 0x1, 0x0, 0x0, 0x0, 0x48, 0x2, 0x0,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 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3f, 0x0, 0x0, 0x80, 0x3f, 0x3e, 0x0, 0x0, 0x1, 0x53, 0x54, 0x41, 0x54, 0x74, 0x0, 0x0, 0x0, 0x5, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,249 +0,0 @@
|
|||||||
// SPDX-License-Identifier: Unlicense OR MIT
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"gioui.org/gpu/internal/driver"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GLSLCC is a shader cross-compilation tool.
|
|
||||||
type GLSLCC struct {
|
|
||||||
Bin string
|
|
||||||
IncludeDir string
|
|
||||||
WorkDir WorkDir
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewGLSLCC() *GLSLCC { return &GLSLCC{Bin: "glslcc"} }
|
|
||||||
|
|
||||||
// Metadata contains reflection data about the shader.
|
|
||||||
type Metadata struct {
|
|
||||||
Uniforms driver.UniformsReflection
|
|
||||||
Inputs []driver.InputLocation
|
|
||||||
Textures []driver.TextureBinding
|
|
||||||
StorageBuffers []driver.StorageBufferBinding
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert converts input data to the target shader.
|
|
||||||
func (glslcc *GLSLCC) Convert(path, variant string, input []byte, lang, profile string) (_ string, _ Metadata, err error) {
|
|
||||||
base := glslcc.WorkDir.Path(filepath.Base(path), variant, lang, profile)
|
|
||||||
pathin := base + ".in"
|
|
||||||
pathout := base + ".out"
|
|
||||||
reflectout := base + ".json"
|
|
||||||
|
|
||||||
if err := glslcc.WorkDir.WriteFile(pathin, input); err != nil {
|
|
||||||
return "", Metadata{}, fmt.Errorf("unable to write shader to disk: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
var progFlag, progSuffix string
|
|
||||||
switch filepath.Ext(path) {
|
|
||||||
case ".vert":
|
|
||||||
progFlag = "--vert"
|
|
||||||
progSuffix = "vs"
|
|
||||||
case ".frag":
|
|
||||||
progFlag = "--frag"
|
|
||||||
progSuffix = "fs"
|
|
||||||
case ".comp":
|
|
||||||
progFlag = "--compute"
|
|
||||||
progSuffix = "cs"
|
|
||||||
default:
|
|
||||||
return "", Metadata{}, fmt.Errorf("unrecognized shader type: %q", path)
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd := exec.Command(glslcc.Bin,
|
|
||||||
"--silent",
|
|
||||||
"--optimize",
|
|
||||||
"--include-dirs", glslcc.IncludeDir,
|
|
||||||
"--reflect="+reflectout,
|
|
||||||
"--output", pathout,
|
|
||||||
"--lang", lang,
|
|
||||||
"--profile", profile,
|
|
||||||
progFlag, pathin,
|
|
||||||
)
|
|
||||||
if lang == "hlsl" {
|
|
||||||
cmd.Args = append(cmd.Args, "--defines=HLSL")
|
|
||||||
}
|
|
||||||
|
|
||||||
output, err := cmd.Output()
|
|
||||||
if err != nil {
|
|
||||||
return "", Metadata{}, fmt.Errorf("%s\nfailed to run %v: %w", output, cmd.Args, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// glslcc modifies the output path
|
|
||||||
p := strings.IndexByte(pathout, '.')
|
|
||||||
pathout = pathout[:p] + "_" + progSuffix + pathout[p:]
|
|
||||||
shader, err := ioutil.ReadFile(pathout)
|
|
||||||
if err != nil {
|
|
||||||
return "", Metadata{}, fmt.Errorf("missing shader output %q: %w", pathout, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
reflectdata, err := ioutil.ReadFile(reflectout)
|
|
||||||
if err != nil {
|
|
||||||
return "", Metadata{}, fmt.Errorf("missing reflection output %q: %w", pathout, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
metadata, err := glslcc.parseReflection(reflectdata)
|
|
||||||
if err != nil {
|
|
||||||
return "", Metadata{}, fmt.Errorf("invalid reflection output %q: %w", reflectout, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return string(shader), metadata, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseReflection parses glslcc -reflect output.
|
|
||||||
func (glslcc *GLSLCC) parseReflection(jsonData []byte) (Metadata, error) {
|
|
||||||
type (
|
|
||||||
Input struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Location int `json:"location"`
|
|
||||||
Semantic string `json:"semantic"`
|
|
||||||
SemanticIndex int `json:"semantic_index"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
}
|
|
||||||
UniformMember struct {
|
|
||||||
Name string `json:"name"`
|
|
||||||
Type string `json:"type"`
|
|
||||||
Offset int `json:"offset"`
|
|
||||||
Size int `json:"size"`
|
|
||||||
}
|
|
||||||
UniformBuffer struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Set int `json:"set"`
|
|
||||||
Binding int `json:"binding"`
|
|
||||||
Size int `json:"block_size"`
|
|
||||||
Members []UniformMember `json:"members"`
|
|
||||||
}
|
|
||||||
Texture struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Set int `json:"set"`
|
|
||||||
Binding int `json:"binding"`
|
|
||||||
Dimension string `json:"dimension"`
|
|
||||||
Format string `json:"format"`
|
|
||||||
}
|
|
||||||
StorageBuffer struct {
|
|
||||||
ID int `json:"id"`
|
|
||||||
Name string `json:"name"`
|
|
||||||
Set int `json:"set"`
|
|
||||||
Binding int `json:"binding"`
|
|
||||||
BlockSize int `json:"block_size"`
|
|
||||||
}
|
|
||||||
Shader struct {
|
|
||||||
Inputs []Input `json:"inputs"`
|
|
||||||
UniformBuffers []UniformBuffer `json:"uniform_buffers"`
|
|
||||||
Textures []Texture `json:"textures"`
|
|
||||||
StorageBuffers []StorageBuffer `json:"storage_buffers"`
|
|
||||||
}
|
|
||||||
ReflectMetadata struct {
|
|
||||||
VS Shader `json:"vs"`
|
|
||||||
FS Shader `json:"fs"`
|
|
||||||
CS Shader `json:"cs"`
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
var info Metadata
|
|
||||||
|
|
||||||
var reflect ReflectMetadata
|
|
||||||
if err := json.Unmarshal(jsonData, &reflect); err != nil {
|
|
||||||
return info, fmt.Errorf("parseReflection: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
inputRef := reflect.VS.Inputs
|
|
||||||
for _, input := range inputRef {
|
|
||||||
dataType, dataSize, err := parseDataType(input.Type)
|
|
||||||
if err != nil {
|
|
||||||
return info, fmt.Errorf("parseReflection: %v", err)
|
|
||||||
}
|
|
||||||
info.Inputs = append(info.Inputs, driver.InputLocation{
|
|
||||||
Name: input.Name,
|
|
||||||
Location: input.Location,
|
|
||||||
Semantic: input.Semantic,
|
|
||||||
SemanticIndex: input.SemanticIndex,
|
|
||||||
Type: dataType,
|
|
||||||
Size: dataSize,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
sort.Slice(info.Inputs, func(i, j int) bool {
|
|
||||||
return info.Inputs[i].Location < info.Inputs[j].Location
|
|
||||||
})
|
|
||||||
|
|
||||||
shaderBlocks := reflect.VS.UniformBuffers
|
|
||||||
if len(shaderBlocks) == 0 {
|
|
||||||
shaderBlocks = reflect.FS.UniformBuffers
|
|
||||||
}
|
|
||||||
|
|
||||||
blockOffset := 0
|
|
||||||
for _, block := range shaderBlocks {
|
|
||||||
info.Uniforms.Blocks = append(info.Uniforms.Blocks, driver.UniformBlock{
|
|
||||||
Name: block.Name,
|
|
||||||
Binding: block.Binding,
|
|
||||||
})
|
|
||||||
for _, member := range block.Members {
|
|
||||||
dataType, size, err := parseDataType(member.Type)
|
|
||||||
if err != nil {
|
|
||||||
return info, fmt.Errorf("parseReflection: %v", err)
|
|
||||||
}
|
|
||||||
info.Uniforms.Locations = append(info.Uniforms.Locations, driver.UniformLocation{
|
|
||||||
// Synthetic name generated by glslcc.
|
|
||||||
Name: fmt.Sprintf("_%d.%s", block.ID, member.Name),
|
|
||||||
Type: dataType,
|
|
||||||
Size: size,
|
|
||||||
Offset: blockOffset + member.Offset,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
blockOffset += block.Size
|
|
||||||
}
|
|
||||||
info.Uniforms.Size = blockOffset
|
|
||||||
|
|
||||||
textures := reflect.VS.Textures
|
|
||||||
if len(textures) == 0 {
|
|
||||||
textures = reflect.FS.Textures
|
|
||||||
}
|
|
||||||
for _, texture := range textures {
|
|
||||||
info.Textures = append(info.Textures, driver.TextureBinding{
|
|
||||||
Name: texture.Name,
|
|
||||||
Binding: texture.Binding,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, sb := range reflect.CS.StorageBuffers {
|
|
||||||
info.StorageBuffers = append(info.StorageBuffers, driver.StorageBufferBinding{
|
|
||||||
Binding: sb.Binding,
|
|
||||||
BlockSize: sb.BlockSize,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
return info, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func parseDataType(t string) (driver.DataType, int, error) {
|
|
||||||
switch t {
|
|
||||||
case "float":
|
|
||||||
return driver.DataTypeFloat, 1, nil
|
|
||||||
case "float2":
|
|
||||||
return driver.DataTypeFloat, 2, nil
|
|
||||||
case "float3":
|
|
||||||
return driver.DataTypeFloat, 3, nil
|
|
||||||
case "float4":
|
|
||||||
return driver.DataTypeFloat, 4, nil
|
|
||||||
case "int":
|
|
||||||
return driver.DataTypeInt, 1, nil
|
|
||||||
case "int2":
|
|
||||||
return driver.DataTypeInt, 2, nil
|
|
||||||
case "int3":
|
|
||||||
return driver.DataTypeInt, 3, nil
|
|
||||||
case "int4":
|
|
||||||
return driver.DataTypeInt, 4, nil
|
|
||||||
default:
|
|
||||||
return 0, 0, fmt.Errorf("unsupported input data type: %s", t)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -18,18 +18,22 @@ type GLSLValidator struct {
|
|||||||
|
|
||||||
func NewGLSLValidator() *GLSLValidator { return &GLSLValidator{Bin: "glslangValidator"} }
|
func NewGLSLValidator() *GLSLValidator { return &GLSLValidator{Bin: "glslangValidator"} }
|
||||||
|
|
||||||
// ConvertCompute converts glsl compute shader to spirv.
|
// Convert converts a glsl shader to spirv.
|
||||||
func (glsl *GLSLValidator) ConvertCompute(path string, input []byte) ([]byte, error) {
|
func (glsl *GLSLValidator) Convert(path, variant string, hlsl bool, input []byte) ([]byte, error) {
|
||||||
base := glsl.WorkDir.Path(filepath.Base(path))
|
base := glsl.WorkDir.Path(filepath.Base(path), variant)
|
||||||
pathout := base + ".out"
|
pathout := base + ".out"
|
||||||
|
|
||||||
cmd := exec.Command(glsl.Bin,
|
cmd := exec.Command(glsl.Bin,
|
||||||
"-G100", // OpenGL ES 3.1.
|
"--stdin",
|
||||||
"-w", // Suppress warnings.
|
"-I"+filepath.Dir(path),
|
||||||
"-S", "comp",
|
"-V", // OpenGL ES 3.1.
|
||||||
|
"-w", // Suppress warnings.
|
||||||
|
"-S", filepath.Ext(path)[1:],
|
||||||
"-o", pathout,
|
"-o", pathout,
|
||||||
path,
|
|
||||||
)
|
)
|
||||||
|
if hlsl {
|
||||||
|
cmd.Args = append(cmd.Args, "-DHLSL")
|
||||||
|
}
|
||||||
cmd.Stdin = bytes.NewBuffer(input)
|
cmd.Stdin = bytes.NewBuffer(input)
|
||||||
|
|
||||||
out, err := cmd.Output()
|
out, err := cmd.Output()
|
||||||
|
|||||||
@@ -78,7 +78,6 @@ type Converter struct {
|
|||||||
|
|
||||||
packageName string
|
packageName string
|
||||||
|
|
||||||
glslcc *GLSLCC
|
|
||||||
glslvalidator *GLSLValidator
|
glslvalidator *GLSLValidator
|
||||||
spirv *SPIRVCross
|
spirv *SPIRVCross
|
||||||
fxc *FXC
|
fxc *FXC
|
||||||
@@ -97,22 +96,19 @@ func NewConverter(workDir WorkDir, packageName, shadersDir string, directCompute
|
|||||||
|
|
||||||
conv.packageName = packageName
|
conv.packageName = packageName
|
||||||
|
|
||||||
conv.glslcc = NewGLSLCC()
|
|
||||||
conv.glslvalidator = NewGLSLValidator()
|
conv.glslvalidator = NewGLSLValidator()
|
||||||
conv.spirv = NewSPIRVCross()
|
conv.spirv = NewSPIRVCross()
|
||||||
conv.fxc = NewFXC()
|
conv.fxc = NewFXC()
|
||||||
conv.dxc = NewDXC()
|
conv.dxc = NewDXC()
|
||||||
|
|
||||||
verifyBinaryPath(&conv.glslcc.Bin)
|
|
||||||
verifyBinaryPath(&conv.glslvalidator.Bin)
|
verifyBinaryPath(&conv.glslvalidator.Bin)
|
||||||
verifyBinaryPath(&conv.spirv.Bin)
|
verifyBinaryPath(&conv.spirv.Bin)
|
||||||
// we cannot check fxc/dxc, since they may depend on wine
|
// we cannot check fxc/dxc, since they may depend on wine
|
||||||
|
|
||||||
conv.glslcc.IncludeDir = shadersDir
|
|
||||||
conv.glslcc.WorkDir = workDir.Dir("glslcc")
|
|
||||||
conv.glslvalidator.WorkDir = workDir.Dir("glslvalidator")
|
conv.glslvalidator.WorkDir = workDir.Dir("glslvalidator")
|
||||||
conv.fxc.WorkDir = workDir.Dir("fxc")
|
conv.fxc.WorkDir = workDir.Dir("fxc")
|
||||||
conv.dxc.WorkDir = workDir.Dir("dxc")
|
conv.dxc.WorkDir = workDir.Dir("dxc")
|
||||||
|
conv.spirv.WorkDir = workDir.Dir("spirv")
|
||||||
|
|
||||||
return conv
|
return conv
|
||||||
}
|
}
|
||||||
@@ -222,19 +218,19 @@ func (conv *Converter) Run(out io.Writer) error {
|
|||||||
fmt.Fprintf(out, "Textures: %#v,\n", src.Textures)
|
fmt.Fprintf(out, "Textures: %#v,\n", src.Textures)
|
||||||
}
|
}
|
||||||
if len(src.GLSL100ES) > 0 {
|
if len(src.GLSL100ES) > 0 {
|
||||||
fmt.Fprintf(out, "GLSL100ES: %#v,\n", src.GLSL100ES)
|
fmt.Fprintf(out, "GLSL100ES: `%s`,\n", src.GLSL100ES)
|
||||||
}
|
}
|
||||||
if len(src.GLSL300ES) > 0 {
|
if len(src.GLSL300ES) > 0 {
|
||||||
fmt.Fprintf(out, "GLSL300ES: %#v,\n", src.GLSL300ES)
|
fmt.Fprintf(out, "GLSL300ES: `%s`,\n", src.GLSL300ES)
|
||||||
}
|
}
|
||||||
if len(src.GLSL310ES) > 0 {
|
if len(src.GLSL310ES) > 0 {
|
||||||
fmt.Fprintf(out, "GLSL310ES: %#v,\n", src.GLSL310ES)
|
fmt.Fprintf(out, "GLSL310ES: `%s`,\n", src.GLSL310ES)
|
||||||
}
|
}
|
||||||
if len(src.GLSL130) > 0 {
|
if len(src.GLSL130) > 0 {
|
||||||
fmt.Fprintf(out, "GLSL130: %#v,\n", src.GLSL130)
|
fmt.Fprintf(out, "GLSL130: `%s`,\n", src.GLSL130)
|
||||||
}
|
}
|
||||||
if len(src.GLSL150) > 0 {
|
if len(src.GLSL150) > 0 {
|
||||||
fmt.Fprintf(out, "GLSL150: %#v,\n", src.GLSL150)
|
fmt.Fprintf(out, "GLSL150: `%s`,\n", src.GLSL150)
|
||||||
}
|
}
|
||||||
if len(src.HLSL) > 0 {
|
if len(src.HLSL) > 0 {
|
||||||
fmt.Fprintf(out, "HLSL: %#v,\n", src.HLSL)
|
fmt.Fprintf(out, "HLSL: %#v,\n", src.HLSL)
|
||||||
@@ -261,12 +257,12 @@ func (conv *Converter) Shader(shaderPath string) ([]driver.ShaderSources, error)
|
|||||||
}
|
}
|
||||||
variantArgs := [...]Variant{
|
variantArgs := [...]Variant{
|
||||||
{
|
{
|
||||||
FetchColorExpr: `_color`,
|
FetchColorExpr: `_color.color`,
|
||||||
Header: `layout(binding=0) uniform Color { vec4 _color; };`,
|
Header: `layout(binding=0) uniform Color { vec4 color; } _color;`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
FetchColorExpr: `mix(_color1, _color2, clamp(vUV.x, 0.0, 1.0))`,
|
FetchColorExpr: `mix(_gradient.color1, _gradient.color2, clamp(vUV.x, 0.0, 1.0))`,
|
||||||
Header: `layout(binding=0) uniform Gradient { vec4 _color1; vec4 _color2; };`,
|
Header: `layout(binding=0) uniform Gradient { vec4 color1; vec4 color2; } _gradient;`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
FetchColorExpr: `texture(tex, vUV)`,
|
FetchColorExpr: `texture(tex, vUV)`,
|
||||||
@@ -292,27 +288,26 @@ func (conv *Converter) Shader(shaderPath string) ([]driver.ShaderSources, error)
|
|||||||
sources.Name = filepath.Base(shaderPath)
|
sources.Name = filepath.Base(shaderPath)
|
||||||
|
|
||||||
// Ignore error; some shaders are not meant to run in GLSL 1.00.
|
// Ignore error; some shaders are not meant to run in GLSL 1.00.
|
||||||
sources.GLSL100ES, _, _ = conv.glslcc.Convert(shaderPath, variantName, buf.Bytes(), "gles", "100")
|
sources.GLSL100ES, _, _ = conv.ShaderVariant(shaderPath, variantName, buf.Bytes(), "es", "100")
|
||||||
|
|
||||||
var metadata Metadata
|
var metadata Metadata
|
||||||
sources.GLSL300ES, metadata, err = conv.glslcc.Convert(shaderPath, variantName, buf.Bytes(), "gles", "300")
|
sources.GLSL300ES, metadata, err = conv.ShaderVariant(shaderPath, variantName, buf.Bytes(), "es", "300")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to convert GLSL300ES:\n%w", err)
|
return nil, fmt.Errorf("failed to convert GLSL300ES:\n%w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sources.GLSL130, _, err = conv.glslcc.Convert(shaderPath, variantName, buf.Bytes(), "glsl", "130")
|
sources.GLSL130, _, err = conv.ShaderVariant(shaderPath, variantName, buf.Bytes(), "glsl", "130")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to convert GLSL130:\n%w", err)
|
return nil, fmt.Errorf("failed to convert GLSL130:\n%w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
hlsl, _, err := conv.glslcc.Convert(shaderPath, variantName, buf.Bytes(), "hlsl", "40")
|
hlsl, _, err := conv.ShaderVariant(shaderPath, variantName, buf.Bytes(), "hlsl", "40")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to convert HLSL:\n%w", err)
|
return nil, fmt.Errorf("failed to convert HLSL:\n%w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sources.HLSL, err = conv.fxc.Compile(shaderPath, variantName, []byte(hlsl), "main", "4_0_level_9_1")
|
sources.HLSL, err = conv.fxc.Compile(shaderPath, variantName, []byte(hlsl), "main", "4_0_level_9_1")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Attempt shader model 4.0. Only the app/headless
|
// Attempt shader model 4.0. Only the gpu/headless
|
||||||
// test shaders use features not supported by level
|
// test shaders use features not supported by level
|
||||||
// 9.1.
|
// 9.1.
|
||||||
sources.HLSL, err = conv.fxc.Compile(shaderPath, variantName, []byte(hlsl), "main", "4_0")
|
sources.HLSL, err = conv.fxc.Compile(shaderPath, variantName, []byte(hlsl), "main", "4_0")
|
||||||
@@ -321,14 +316,14 @@ func (conv *Converter) Shader(shaderPath string) ([]driver.ShaderSources, error)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// OpenGL 3.2 Core only accepts GLSL version 1.50, but is
|
sources.GLSL150, _, err = conv.ShaderVariant(shaderPath, variantName, buf.Bytes(), "glsl", "150")
|
||||||
// otherwise compatible with version 1.30.
|
if err != nil {
|
||||||
sources.GLSL150 = strings.Replace(sources.GLSL130, "#version 130", "#version 150", 1)
|
return nil, fmt.Errorf("failed to convert GLSL150:\n%w", err)
|
||||||
|
}
|
||||||
|
|
||||||
sources.Uniforms = metadata.Uniforms
|
sources.Uniforms = metadata.Uniforms
|
||||||
sources.Inputs = metadata.Inputs
|
sources.Inputs = metadata.Inputs
|
||||||
sources.Textures = metadata.Textures
|
sources.Textures = metadata.Textures
|
||||||
sources.StorageBuffers = metadata.StorageBuffers
|
|
||||||
|
|
||||||
variants = append(variants, sources)
|
variants = append(variants, sources)
|
||||||
}
|
}
|
||||||
@@ -341,13 +336,32 @@ func (conv *Converter) Shader(shaderPath string) ([]driver.ShaderSources, error)
|
|||||||
return variants, nil
|
return variants, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (conv *Converter) ShaderVariant(shaderPath, variant string, src []byte, lang, profile string) (string, Metadata, error) {
|
||||||
|
spirv, err := conv.glslvalidator.Convert(shaderPath, variant, lang == "hlsl", src)
|
||||||
|
if err != nil {
|
||||||
|
return "", Metadata{}, fmt.Errorf("failed to generate SPIR-V for %q: %w", shaderPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dst, err := conv.spirv.Convert(shaderPath, variant, spirv, lang, profile)
|
||||||
|
if err != nil {
|
||||||
|
return "", Metadata{}, fmt.Errorf("failed to convert shader %q: %w", shaderPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
meta, err := conv.spirv.Metadata(shaderPath, variant, spirv)
|
||||||
|
if err != nil {
|
||||||
|
return "", Metadata{}, fmt.Errorf("failed to extract metadata for shader %q: %w", shaderPath, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return dst, meta, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (conv *Converter) ComputeShader(shaderPath string) ([]driver.ShaderSources, error) {
|
func (conv *Converter) ComputeShader(shaderPath string) ([]driver.ShaderSources, error) {
|
||||||
shader, err := ioutil.ReadFile(shaderPath)
|
shader, err := ioutil.ReadFile(shaderPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to load shader %q: %w", shaderPath, err)
|
return nil, fmt.Errorf("failed to load shader %q: %w", shaderPath, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
spirv, err := conv.glslvalidator.ConvertCompute(shaderPath, shader)
|
spirv, err := conv.glslvalidator.Convert(shaderPath, "", false, shader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to convert compute shader %q: %w", shaderPath, err)
|
return nil, fmt.Errorf("failed to convert compute shader %q: %w", shaderPath, err)
|
||||||
}
|
}
|
||||||
@@ -355,14 +369,14 @@ func (conv *Converter) ComputeShader(shaderPath string) ([]driver.ShaderSources,
|
|||||||
var sources driver.ShaderSources
|
var sources driver.ShaderSources
|
||||||
sources.Name = filepath.Base(shaderPath)
|
sources.Name = filepath.Base(shaderPath)
|
||||||
|
|
||||||
sources.GLSL310ES, err = conv.spirv.Convert(spirv, "es", "310")
|
sources.GLSL310ES, err = conv.spirv.Convert(shaderPath, "", spirv, "es", "310")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to convert es compute shader %q: %w", shaderPath, err)
|
return nil, fmt.Errorf("failed to convert es compute shader %q: %w", shaderPath, err)
|
||||||
}
|
}
|
||||||
sources.GLSL310ES = unixLineEnding(sources.GLSL310ES)
|
sources.GLSL310ES = unixLineEnding(sources.GLSL310ES)
|
||||||
|
|
||||||
if conv.directCompute {
|
if conv.directCompute {
|
||||||
hlslSource, err := conv.spirv.Convert(spirv, "hlsl", "50")
|
hlslSource, err := conv.spirv.Convert(shaderPath, "", spirv, "hlsl", "50")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to convert hlsl compute shader %q: %w", shaderPath, err)
|
return nil, fmt.Errorf("failed to convert hlsl compute shader %q: %w", shaderPath, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,43 +3,210 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"gioui.org/gpu/internal/driver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Metadata contains reflection data about a shader.
|
||||||
|
type Metadata struct {
|
||||||
|
Uniforms driver.UniformsReflection
|
||||||
|
Inputs []driver.InputLocation
|
||||||
|
Textures []driver.TextureBinding
|
||||||
|
}
|
||||||
|
|
||||||
// SPIRVCross cross-compiles spirv shaders to es, hlsl and others.
|
// SPIRVCross cross-compiles spirv shaders to es, hlsl and others.
|
||||||
type SPIRVCross struct {
|
type SPIRVCross struct {
|
||||||
Bin string
|
Bin string
|
||||||
|
WorkDir WorkDir
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSPIRVCross() *SPIRVCross { return &SPIRVCross{Bin: "spirv-cross"} }
|
func NewSPIRVCross() *SPIRVCross { return &SPIRVCross{Bin: "spirv-cross"} }
|
||||||
|
|
||||||
// Convert converts compute shader from spirv format to a target format.
|
// Convert converts compute shader from spirv format to a target format.
|
||||||
func (spirv *SPIRVCross) Convert(input []byte, target, version string) (string, error) {
|
func (spirv *SPIRVCross) Convert(path, variant string, shader []byte, target, version string) (string, error) {
|
||||||
|
base := spirv.WorkDir.Path(filepath.Base(path), variant)
|
||||||
|
|
||||||
|
if err := spirv.WorkDir.WriteFile(base, shader); err != nil {
|
||||||
|
return "", fmt.Errorf("unable to write shader to disk: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
var cmd *exec.Cmd
|
var cmd *exec.Cmd
|
||||||
switch target {
|
switch target {
|
||||||
|
case "glsl":
|
||||||
|
cmd = exec.Command(spirv.Bin,
|
||||||
|
"--no-es",
|
||||||
|
"--version", version,
|
||||||
|
)
|
||||||
case "es":
|
case "es":
|
||||||
cmd = exec.Command(spirv.Bin,
|
cmd = exec.Command(spirv.Bin,
|
||||||
"--es",
|
"--es",
|
||||||
"--version", version,
|
"--version", version,
|
||||||
"-",
|
|
||||||
)
|
)
|
||||||
case "hlsl":
|
case "hlsl":
|
||||||
cmd = exec.Command(spirv.Bin,
|
cmd = exec.Command(spirv.Bin,
|
||||||
"--hlsl",
|
"--hlsl",
|
||||||
"--shader-model", version,
|
"--shader-model", version,
|
||||||
"-",
|
|
||||||
)
|
)
|
||||||
default:
|
default:
|
||||||
return "", fmt.Errorf("unknown target %q", target)
|
return "", fmt.Errorf("unknown target %q", target)
|
||||||
}
|
}
|
||||||
|
cmd.Args = append(cmd.Args, base)
|
||||||
|
|
||||||
cmd.Stdin = bytes.NewBuffer(input)
|
out, err := cmd.CombinedOutput()
|
||||||
out, err := cmd.Output()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", fmt.Errorf("failed to run %v: %w", cmd.Args, err)
|
return "", fmt.Errorf("%s\nfailed to run %v: %w", out, cmd.Args, err)
|
||||||
|
}
|
||||||
|
s := string(out)
|
||||||
|
if target != "hlsl" {
|
||||||
|
// Strip Windows \r in line endings.
|
||||||
|
s = unixLineEnding(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
return string(out), nil
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metadata extracts metadata for a SPIR-V shader.
|
||||||
|
func (spirv *SPIRVCross) Metadata(path, variant string, shader []byte) (Metadata, error) {
|
||||||
|
base := spirv.WorkDir.Path(filepath.Base(path), variant)
|
||||||
|
|
||||||
|
if err := spirv.WorkDir.WriteFile(base, shader); err != nil {
|
||||||
|
return Metadata{}, fmt.Errorf("unable to write shader to disk: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd := exec.Command(spirv.Bin,
|
||||||
|
base,
|
||||||
|
"--reflect",
|
||||||
|
)
|
||||||
|
|
||||||
|
out, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
return Metadata{}, fmt.Errorf("failed to run %v: %w", cmd.Args, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
meta, err := parseMetadata(out)
|
||||||
|
if err != nil {
|
||||||
|
return Metadata{}, fmt.Errorf("%s\nfailed to parse metadata: %w", out, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return meta, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseMetadata(data []byte) (Metadata, error) {
|
||||||
|
var reflect struct {
|
||||||
|
Types map[string]struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Members []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Offset int `json:"offset"`
|
||||||
|
} `json:"members"`
|
||||||
|
} `json:"types"`
|
||||||
|
Inputs []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Location int `json:"location"`
|
||||||
|
} `json:"inputs"`
|
||||||
|
Textures []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Set int `json:"set"`
|
||||||
|
Binding int `json:"binding"`
|
||||||
|
} `json:"textures"`
|
||||||
|
UBOs []struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
BlockSize int `json:"block_size"`
|
||||||
|
Set int `json:"set"`
|
||||||
|
Binding int `json:"binding"`
|
||||||
|
} `json:"ubos"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(data, &reflect); err != nil {
|
||||||
|
return Metadata{}, fmt.Errorf("failed to parse reflection data: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var m Metadata
|
||||||
|
|
||||||
|
for _, input := range reflect.Inputs {
|
||||||
|
dataType, dataSize, err := parseDataType(input.Type)
|
||||||
|
if err != nil {
|
||||||
|
return Metadata{}, fmt.Errorf("parseReflection: %v", err)
|
||||||
|
}
|
||||||
|
m.Inputs = append(m.Inputs, driver.InputLocation{
|
||||||
|
Name: input.Name,
|
||||||
|
Location: input.Location,
|
||||||
|
Semantic: "TEXCOORD",
|
||||||
|
SemanticIndex: input.Location,
|
||||||
|
Type: dataType,
|
||||||
|
Size: dataSize,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(m.Inputs, func(i, j int) bool {
|
||||||
|
return m.Inputs[i].Location < m.Inputs[j].Location
|
||||||
|
})
|
||||||
|
|
||||||
|
blockOffset := 0
|
||||||
|
for _, block := range reflect.UBOs {
|
||||||
|
m.Uniforms.Blocks = append(m.Uniforms.Blocks, driver.UniformBlock{
|
||||||
|
Name: block.Name,
|
||||||
|
Binding: block.Binding,
|
||||||
|
})
|
||||||
|
t := reflect.Types[block.Type]
|
||||||
|
// By convention uniform block variables are named by prepending an underscore
|
||||||
|
// and converting to lowercase.
|
||||||
|
blockVar := "_" + strings.ToLower(block.Name)
|
||||||
|
for _, member := range t.Members {
|
||||||
|
dataType, size, err := parseDataType(member.Type)
|
||||||
|
if err != nil {
|
||||||
|
return Metadata{}, fmt.Errorf("failed to parse reflection data: %v", err)
|
||||||
|
}
|
||||||
|
m.Uniforms.Locations = append(m.Uniforms.Locations, driver.UniformLocation{
|
||||||
|
Name: fmt.Sprintf("%s.%s", blockVar, member.Name),
|
||||||
|
Type: dataType,
|
||||||
|
Size: size,
|
||||||
|
Offset: blockOffset + member.Offset,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
blockOffset += block.BlockSize
|
||||||
|
}
|
||||||
|
m.Uniforms.Size = blockOffset
|
||||||
|
|
||||||
|
for _, texture := range reflect.Textures {
|
||||||
|
m.Textures = append(m.Textures, driver.TextureBinding{
|
||||||
|
Name: texture.Name,
|
||||||
|
Binding: texture.Binding,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//return m, fmt.Errorf("not yet!: %+v", reflect)
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseDataType(t string) (driver.DataType, int, error) {
|
||||||
|
switch t {
|
||||||
|
case "float":
|
||||||
|
return driver.DataTypeFloat, 1, nil
|
||||||
|
case "vec2":
|
||||||
|
return driver.DataTypeFloat, 2, nil
|
||||||
|
case "vec3":
|
||||||
|
return driver.DataTypeFloat, 3, nil
|
||||||
|
case "vec4":
|
||||||
|
return driver.DataTypeFloat, 4, nil
|
||||||
|
case "int":
|
||||||
|
return driver.DataTypeInt, 1, nil
|
||||||
|
case "int2":
|
||||||
|
return driver.DataTypeInt, 2, nil
|
||||||
|
case "int3":
|
||||||
|
return driver.DataTypeInt, 3, nil
|
||||||
|
case "int4":
|
||||||
|
return driver.DataTypeInt, 4, nil
|
||||||
|
default:
|
||||||
|
return 0, 0, fmt.Errorf("unsupported input data type: %s", t)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -324,7 +324,7 @@ func (b *Backend) NewInputLayout(vertexShader driver.ShaderSources, layout []dri
|
|||||||
case 4:
|
case 4:
|
||||||
format = d3d11.DXGI_FORMAT_R32G32B32A32_FLOAT
|
format = d3d11.DXGI_FORMAT_R32G32B32A32_FLOAT
|
||||||
default:
|
default:
|
||||||
panic("unsupported float data size")
|
panic("unsupported data size")
|
||||||
}
|
}
|
||||||
case driver.DataTypeShort:
|
case driver.DataTypeShort:
|
||||||
switch l.Size {
|
switch l.Size {
|
||||||
@@ -333,7 +333,7 @@ func (b *Backend) NewInputLayout(vertexShader driver.ShaderSources, layout []dri
|
|||||||
case 2:
|
case 2:
|
||||||
format = d3d11.DXGI_FORMAT_R16G16_SINT
|
format = d3d11.DXGI_FORMAT_R16G16_SINT
|
||||||
default:
|
default:
|
||||||
panic("unsupported float data size")
|
panic("unsupported data size")
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
panic("unsupported data type")
|
panic("unsupported data type")
|
||||||
|
|||||||
@@ -53,22 +53,16 @@ type Device interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type ShaderSources struct {
|
type ShaderSources struct {
|
||||||
Name string
|
Name string
|
||||||
GLSL100ES string
|
GLSL100ES string
|
||||||
GLSL300ES string
|
GLSL300ES string
|
||||||
GLSL310ES string
|
GLSL310ES string
|
||||||
GLSL130 string
|
GLSL130 string
|
||||||
GLSL150 string
|
GLSL150 string
|
||||||
HLSL []byte
|
HLSL []byte
|
||||||
Uniforms UniformsReflection
|
Uniforms UniformsReflection
|
||||||
Inputs []InputLocation
|
Inputs []InputLocation
|
||||||
Textures []TextureBinding
|
Textures []TextureBinding
|
||||||
StorageBuffers []StorageBufferBinding
|
|
||||||
}
|
|
||||||
|
|
||||||
type StorageBufferBinding struct {
|
|
||||||
Binding int
|
|
||||||
BlockSize int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type UniformsReflection struct {
|
type UniformsReflection struct {
|
||||||
|
|||||||
+6601
-125
File diff suppressed because one or more lines are too long
@@ -2,16 +2,18 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: Unlicense OR MIT
|
// SPDX-License-Identifier: Unlicense OR MIT
|
||||||
|
|
||||||
|
#extension GL_GOOGLE_include_directive : enable
|
||||||
|
|
||||||
precision highp float;
|
precision highp float;
|
||||||
|
|
||||||
#include <common.inc>
|
#include "common.h"
|
||||||
|
|
||||||
layout(binding = 0) uniform Block {
|
layout(binding = 0) uniform Block {
|
||||||
vec4 transform;
|
vec4 transform;
|
||||||
vec4 uvTransformR1;
|
vec4 uvTransformR1;
|
||||||
vec4 uvTransformR2;
|
vec4 uvTransformR2;
|
||||||
float z;
|
float z;
|
||||||
};
|
} _block;
|
||||||
|
|
||||||
layout(location = 0) in vec2 pos;
|
layout(location = 0) in vec2 pos;
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ layout(location = 1) in vec2 uv;
|
|||||||
layout(location = 0) out vec2 vUV;
|
layout(location = 0) out vec2 vUV;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 p = pos*transform.xy + transform.zw;
|
vec2 p = pos*_block.transform.xy + _block.transform.zw;
|
||||||
gl_Position = toClipSpace(vec4(p, z, 1));
|
gl_Position = toClipSpace(vec4(p, _block.z, 1));
|
||||||
vUV = transform3x2(m3x2(uvTransformR1.xyz, uvTransformR2.xyz), vec3(uv,1)).xy;
|
vUV = transform3x2(m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz), vec3(uv,1)).xy;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: Unlicense OR MIT
|
// SPDX-License-Identifier: Unlicense OR MIT
|
||||||
|
|
||||||
|
#extension GL_GOOGLE_include_directive : enable
|
||||||
|
|
||||||
precision highp float;
|
precision highp float;
|
||||||
|
|
||||||
#include <common.inc>
|
#include "common.h"
|
||||||
|
|
||||||
layout(binding = 0) uniform Block {
|
layout(binding = 0) uniform Block {
|
||||||
vec4 transform;
|
vec4 transform;
|
||||||
@@ -12,7 +14,7 @@ layout(binding = 0) uniform Block {
|
|||||||
vec4 uvTransformR1;
|
vec4 uvTransformR1;
|
||||||
vec4 uvTransformR2;
|
vec4 uvTransformR2;
|
||||||
float z;
|
float z;
|
||||||
};
|
} _block;
|
||||||
|
|
||||||
layout(location = 0) in vec2 pos;
|
layout(location = 0) in vec2 pos;
|
||||||
|
|
||||||
@@ -22,8 +24,8 @@ layout(location = 1) in vec2 uv;
|
|||||||
layout(location = 1) out vec2 vUV;
|
layout(location = 1) out vec2 vUV;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = toClipSpace(vec4(pos*transform.xy + transform.zw, z, 1));
|
gl_Position = toClipSpace(vec4(pos*_block.transform.xy + _block.transform.zw, _block.z, 1));
|
||||||
vUV = transform3x2(m3x2(uvTransformR1.xyz, uvTransformR2.xyz), vec3(uv,1)).xy;
|
vUV = transform3x2(m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz), vec3(uv,1)).xy;
|
||||||
vec3 uv3 = transform3x2(fboTextureTransform, vec3(uv, 1.0));
|
vec3 uv3 = transform3x2(fboTextureTransform, vec3(uv, 1.0));
|
||||||
vCoverUV = (uv3*vec3(uvCoverTransform.xy, 1.0)+vec3(uvCoverTransform.zw, 0.0)).xy;
|
vCoverUV = (uv3*vec3(_block.uvCoverTransform.xy, 1.0)+vec3(_block.uvCoverTransform.zw, 0.0)).xy;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
// SPDX-License-Identifier: Unlicense OR MIT
|
// SPDX-License-Identifier: Unlicense OR MIT
|
||||||
|
|
||||||
|
#extension GL_GOOGLE_include_directive : enable
|
||||||
|
|
||||||
precision highp float;
|
precision highp float;
|
||||||
|
|
||||||
#include <common.inc>
|
#include "common.h"
|
||||||
|
|
||||||
layout(location = 0) in vec2 pos;
|
layout(location = 0) in vec2 pos;
|
||||||
layout(location = 1) in vec2 uv;
|
layout(location = 1) in vec2 uv;
|
||||||
@@ -12,7 +14,7 @@ layout(location = 1) in vec2 uv;
|
|||||||
layout(binding = 0) uniform Block {
|
layout(binding = 0) uniform Block {
|
||||||
vec4 uvTransform;
|
vec4 uvTransform;
|
||||||
vec4 subUVTransform;
|
vec4 subUVTransform;
|
||||||
};
|
} _block;
|
||||||
|
|
||||||
layout(location = 0) out vec2 vUV;
|
layout(location = 0) out vec2 vUV;
|
||||||
|
|
||||||
@@ -20,7 +22,7 @@ void main() {
|
|||||||
vec3 p = transform3x2(fboTransform, vec3(pos, 1.0));
|
vec3 p = transform3x2(fboTransform, vec3(pos, 1.0));
|
||||||
gl_Position = vec4(p, 1);
|
gl_Position = vec4(p, 1);
|
||||||
vec3 uv3 = transform3x2(fboTextureTransform, vec3(uv, 1.0));
|
vec3 uv3 = transform3x2(fboTextureTransform, vec3(uv, 1.0));
|
||||||
vUV = uv3.xy*subUVTransform.xy + subUVTransform.zw;
|
vUV = uv3.xy*_block.subUVTransform.xy + _block.subUVTransform.zw;
|
||||||
vUV = transform3x2(fboTextureTransform, vec3(vUV, 1.0)).xy;
|
vUV = transform3x2(fboTextureTransform, vec3(vUV, 1.0)).xy;
|
||||||
vUV = vUV*uvTransform.xy + uvTransform.zw;
|
vUV = vUV*_block.uvTransform.xy + _block.uvTransform.zw;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ precision highp float;
|
|||||||
layout(binding = 0) uniform Block {
|
layout(binding = 0) uniform Block {
|
||||||
vec4 transform;
|
vec4 transform;
|
||||||
vec2 pathOffset;
|
vec2 pathOffset;
|
||||||
};
|
} _block;
|
||||||
|
|
||||||
layout(location=0) in float corner;
|
layout(location=0) in float corner;
|
||||||
layout(location=1) in float maxy;
|
layout(location=1) in float maxy;
|
||||||
@@ -23,10 +23,10 @@ void main() {
|
|||||||
// Add a one pixel overlap so curve quads cover their
|
// Add a one pixel overlap so curve quads cover their
|
||||||
// entire curves. Could use conservative rasterization
|
// entire curves. Could use conservative rasterization
|
||||||
// if available.
|
// if available.
|
||||||
vec2 from = from + pathOffset;
|
vec2 from = from + _block.pathOffset;
|
||||||
vec2 ctrl = ctrl + pathOffset;
|
vec2 ctrl = ctrl + _block.pathOffset;
|
||||||
vec2 to = to + pathOffset;
|
vec2 to = to + _block.pathOffset;
|
||||||
float maxy = maxy + pathOffset.y;
|
float maxy = maxy + _block.pathOffset.y;
|
||||||
vec2 pos;
|
vec2 pos;
|
||||||
float c = corner;
|
float c = corner;
|
||||||
if (c >= 0.375) {
|
if (c >= 0.375) {
|
||||||
@@ -47,7 +47,7 @@ void main() {
|
|||||||
vFrom = from-pos;
|
vFrom = from-pos;
|
||||||
vCtrl = ctrl-pos;
|
vCtrl = ctrl-pos;
|
||||||
vTo = to-pos;
|
vTo = to-pos;
|
||||||
pos = pos*transform.xy + transform.zw;
|
pos = pos*_block.transform.xy + _block.transform.zw;
|
||||||
gl_Position = vec4(pos, 1, 1);
|
gl_Position = vec4(pos, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user