forked from joejulian/gio
gpu: [compute] cache and re-use drawing operations from the previous frame
The compute renderer is more expensive to run than the old renderer on low-end GPUs, and even more so on CPUs. To ensure good performance regardless of the end-user device, this change implements automatic re-use of content rendered in the frame before the current. The basic idea is that every drawing operation (PaintOp), along with its transform and clipping, can be hashed and efficiently looked up. A naïve caching approach is then to rasterize every operation to separate sections of several large texture atlases, turning a cache hit into a very cheap texture copy. However, for scenes with lots of overlapping operations, the resulting texture memory from separating the operations would be much larger than the memory for just the window framebuffer. So instead of caching individual operations, this change caches layers, which are sequences of drawing operations. It starts by putting all operations into a single layer. Then, if the subsequent frame re-uses a sub-sequence of that larger layer, it is split. For example, consider a UI similar to the kitchen sample: Hello, Gio <Editor> <Line Editor> <Button> <Button> <Button> <ProgressBar> <Checkbox> <Toggle> In the first frame, all of the drawing operations comprising the UI will be stored and cached in a single layer. In the second frame the progress bar will have moved and the renderer splits the UI into three layers: layer A for everything up to (but not including) the progress bar, layer B with just the progress bar, and layer C for the rest. Note that nothing has been re-used yet. In the third frame, the progress bar moves again, and this time layer A and C can be copied from the cache only the progress bar needs redrawing through the compute programs. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+658
-212
File diff suppressed because it is too large
Load Diff
+108
-105
@@ -2175,14 +2175,42 @@ void main()
|
||||
}
|
||||
shader_copy_frag = driver.ShaderSources{
|
||||
Name: "copy.frag",
|
||||
Inputs: []driver.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}},
|
||||
Textures: []driver.TextureBinding{{Name: "tex", Binding: 0}},
|
||||
GLSL100ES: `#version 100
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform mediump sampler2D tex;
|
||||
|
||||
varying vec2 vUV;
|
||||
|
||||
vec3 sRGBtoRGB(vec3 rgb)
|
||||
{
|
||||
bvec3 cutoff = greaterThanEqual(rgb, vec3(0.040449999272823333740234375));
|
||||
vec3 below = rgb / vec3(12.9200000762939453125);
|
||||
vec3 above = pow((rgb + vec3(0.054999999701976776123046875)) / vec3(1.05499994754791259765625), vec3(2.400000095367431640625));
|
||||
return vec3(cutoff.x ? above.x : below.x, cutoff.y ? above.y : below.y, cutoff.z ? above.z : below.z);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texture2D(tex, vUV);
|
||||
vec3 param = texel.xyz;
|
||||
vec3 _59 = sRGBtoRGB(param);
|
||||
texel = vec4(_59.x, _59.y, _59.z, texel.w);
|
||||
gl_FragData[0] = texel;
|
||||
}
|
||||
|
||||
`,
|
||||
GLSL300ES: `#version 300 es
|
||||
precision mediump float;
|
||||
precision highp int;
|
||||
|
||||
uniform mediump sampler2D tex;
|
||||
|
||||
layout(location = 0) out highp vec4 fragColor;
|
||||
in vec2 vUV;
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
vec3 sRGBtoRGB(vec3 rgb)
|
||||
{
|
||||
@@ -2194,10 +2222,11 @@ vec3 sRGBtoRGB(vec3 rgb)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texelFetch(tex, ivec2(gl_FragCoord.xy), 0);
|
||||
vec4 texel = texture(tex, vUV);
|
||||
vec3 param = texel.xyz;
|
||||
vec3 rgb = sRGBtoRGB(param);
|
||||
fragColor = vec4(rgb, texel.w);
|
||||
vec3 _59 = sRGBtoRGB(param);
|
||||
texel = vec4(_59.x, _59.y, _59.z, texel.w);
|
||||
fragColor = texel;
|
||||
}
|
||||
|
||||
`,
|
||||
@@ -2205,6 +2234,7 @@ void main()
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
vec3 sRGBtoRGB(vec3 rgb)
|
||||
@@ -2217,10 +2247,11 @@ vec3 sRGBtoRGB(vec3 rgb)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texelFetch(tex, ivec2(gl_FragCoord.xy), 0);
|
||||
vec4 texel = texture(tex, vUV);
|
||||
vec3 param = texel.xyz;
|
||||
vec3 rgb = sRGBtoRGB(param);
|
||||
fragColor = vec4(rgb, texel.w);
|
||||
vec3 _59 = sRGBtoRGB(param);
|
||||
texel = vec4(_59.x, _59.y, _59.z, texel.w);
|
||||
fragColor = texel;
|
||||
}
|
||||
|
||||
`,
|
||||
@@ -2228,6 +2259,7 @@ void main()
|
||||
|
||||
uniform sampler2D tex;
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
vec3 sRGBtoRGB(vec3 rgb)
|
||||
@@ -2240,138 +2272,109 @@ vec3 sRGBtoRGB(vec3 rgb)
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 texel = texelFetch(tex, ivec2(gl_FragCoord.xy), 0);
|
||||
vec4 texel = texture(tex, vUV);
|
||||
vec3 param = texel.xyz;
|
||||
vec3 rgb = sRGBtoRGB(param);
|
||||
fragColor = vec4(rgb, texel.w);
|
||||
vec3 _59 = sRGBtoRGB(param);
|
||||
texel = vec4(_59.x, _59.y, _59.z, texel.w);
|
||||
fragColor = texel;
|
||||
}
|
||||
|
||||
`,
|
||||
HLSL: "DXBC\xe6\x89_t\x8b\xfc\xea8\xd9'\xad5.Èk\x01\x00\x00\x00H\x03\x00\x00\x05\x00\x00\x004\x00\x00\x00\xa4\x00\x00\x00\xd8\x00\x00\x00\f\x01\x00\x00\xcc\x02\x00\x00RDEFh\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x1c\x00\x00\x00\x00\x04\xff\xff\x00\x01\x00\x00@\x00\x00\x00<\x00\x00\x00\x02\x00\x00\x00\x05\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x01\x00\x00\x00\r\x00\x00\x00tex\x00Microsoft (R) HLSL Shader Compiler 10.1\x00ISGN,\x00\x00\x00\x01\x00\x00\x00\b\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x0f\x03\x00\x00SV_Position\x00OSGN,\x00\x00\x00\x01\x00\x00\x00\b\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00SV_Target\x00\xab\xabSHDR\xb8\x01\x00\x00@\x00\x00\x00n\x00\x00\x00X\x18\x00\x04\x00p\x10\x00\x00\x00\x00\x00UU\x00\x00d \x00\x042\x10\x10\x00\x00\x00\x00\x00\x01\x00\x00\x00e\x00\x00\x03\xf2 \x10\x00\x00\x00\x00\x00h\x00\x00\x02\x03\x00\x00\x00\x1b\x00\x00\x052\x00\x10\x00\x00\x00\x00\x00F\x10\x10\x00\x00\x00\x00\x006\x00\x00\b\xc2\x00\x10\x00\x00\x00\x00\x00\x02@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00-\x00\x00\a\xf2\x00\x10\x00\x00\x00\x00\x00F\x0e\x10\x00\x00\x00\x00\x00F~\x10\x00\x00\x00\x00\x00\x00\x00\x00\nr\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x00\x00\x00\x00\x02@\x00\x00\xaeGa=\xaeGa=\xaeGa=\x00\x00\x00\x008\x00\x00\nr\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x00\x02@\x00\x00o\xa7r?o\xa7r?o\xa7r?\x00\x00\x00\x00/\x00\x00\x05r\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x008\x00\x00\nr\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x00\x02@\x00\x00\x9a\x99\x19@\x9a\x99\x19@\x9a\x99\x19@\x00\x00\x00\x00\x19\x00\x00\x05r\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x00\x1d\x00\x00\nr\x00\x10\x00\x02\x00\x00\x00F\x02\x10\x00\x00\x00\x00\x00\x02@\x00\x00\xe6\xae%=\xe6\xae%=\xe6\xae%=\x00\x00\x00\x008\x00\x00\nr\x00\x10\x00\x00\x00\x00\x00F\x02\x10\x00\x00\x00\x00\x00\x02@\x00\x00\x91\x83\x9e=\x91\x83\x9e=\x91\x83\x9e=\x00\x00\x00\x006\x00\x00\x05\x82 \x10\x00\x00\x00\x00\x00:\x00\x10\x00\x00\x00\x00\x007\x00\x00\tr \x10\x00\x00\x00\x00\x00F\x02\x10\x00\x02\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x00\x00\x00\x00>\x00\x00\x01STATt\x00\x00\x00\r\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
HLSL: "DXBCNNg\x84\xf9.<\u05c9a\xcf,\xf7\xcb\xeb\xb9\x01\x00\x00\x00\xe8\x04\x00\x00\x06\x00\x00\x008\x00\x00\x00\xc8\x01\x00\x00d\x03\x00\x00\xe0\x03\x00\x00\x80\x04\x00\x00\xb4\x04\x00\x00Aon9\x88\x01\x00\x00\x88\x01\x00\x00\x00\x02\xff\xff`\x01\x00\x00(\x00\x00\x00\x00\x00(\x00\x00\x00(\x00\x00\x00(\x00\x01\x00$\x00\x00\x00(\x00\x00\x00\x00\x00\x00\x02\xff\xffQ\x00\x00\x05\x00\x00\x0f\xa0\xe6\xae%\xbd\x91\x83\x9e=\xaeGa=o\xa7r?Q\x00\x00\x05\x01\x00\x0f\xa0\x9a\x99\x19@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x02\x00\x00\x00\x80\x00\x00\x03\xb0\x1f\x00\x00\x02\x00\x00\x00\x90\x00\b\x0f\xa0B\x00\x00\x03\x00\x00\x0f\x80\x00\x00\xe4\xb0\x00\b\xe4\xa0\x02\x00\x00\x03\x01\x00\a\x80\x00\x00\xe4\x80\x00\x00\xaa\xa0\x05\x00\x00\x03\x01\x00\a\x80\x01\x00\xe4\x80\x00\x00\xff\xa0\x0f\x00\x00\x02\x02\x00\x01\x80\x01\x00\x00\x80\x0f\x00\x00\x02\x02\x00\x02\x80\x01\x00U\x80\x0f\x00\x00\x02\x02\x00\x04\x80\x01\x00\xaa\x80\x05\x00\x00\x03\x01\x00\a\x80\x02\x00\xe4\x80\x01\x00\x00\xa0\x0e\x00\x00\x02\x01\x00\x01\x80\x01\x00\x00\x80\x02\x00\x00\x03\x01\x00\b\x80\x00\x00\x00\x80\x00\x00\x00\xa0\x05\x00\x00\x03\x02\x00\a\x80\x00\x00\xe4\x80\x00\x00U\xa0X\x00\x00\x04\x00\x00\x01\x80\x01\x00\xff\x80\x01\x00\x00\x80\x02\x00\x00\x80\x0e\x00\x00\x02\x01\x00\x01\x80\x01\x00U\x80\x0e\x00\x00\x02\x01\x00\x02\x80\x01\x00\xaa\x80\x02\x00\x00\x03\x01\x00\x04\x80\x00\x00U\x80\x00\x00\x00\xa0X\x00\x00\x04\x00\x00\x02\x80\x01\x00\xaa\x80\x01\x00\x00\x80\x02\x00U\x80\x02\x00\x00\x03\x01\x00\x01\x80\x00\x00\xaa\x80\x00\x00\x00\xa0X\x00\x00\x04\x00\x00\x04\x80\x01\x00\x00\x80\x01\x00U\x80\x02\x00\xaa\x80\x01\x00\x00\x02\x00\b\x0f\x80\x00\x00\xe4\x80\xff\xff\x00\x00SHDR\x94\x01\x00\x00@\x00\x00\x00e\x00\x00\x00Z\x00\x00\x03\x00`\x10\x00\x00\x00\x00\x00X\x18\x00\x04\x00p\x10\x00\x00\x00\x00\x00UU\x00\x00b\x10\x00\x032\x10\x10\x00\x00\x00\x00\x00e\x00\x00\x03\xf2 \x10\x00\x00\x00\x00\x00h\x00\x00\x02\x03\x00\x00\x00E\x00\x00\t\xf2\x00\x10\x00\x00\x00\x00\x00F\x10\x10\x00\x00\x00\x00\x00F~\x10\x00\x00\x00\x00\x00\x00`\x10\x00\x00\x00\x00\x00\x00\x00\x00\nr\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x00\x00\x00\x00\x02@\x00\x00\xaeGa=\xaeGa=\xaeGa=\x00\x00\x00\x008\x00\x00\nr\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x00\x02@\x00\x00o\xa7r?o\xa7r?o\xa7r?\x00\x00\x00\x00/\x00\x00\x05r\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x008\x00\x00\nr\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x00\x02@\x00\x00\x9a\x99\x19@\x9a\x99\x19@\x9a\x99\x19@\x00\x00\x00\x00\x19\x00\x00\x05r\x00\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x00\x1d\x00\x00\nr\x00\x10\x00\x02\x00\x00\x00F\x02\x10\x00\x00\x00\x00\x00\x02@\x00\x00\xe6\xae%=\xe6\xae%=\xe6\xae%=\x00\x00\x00\x008\x00\x00\nr\x00\x10\x00\x00\x00\x00\x00F\x02\x10\x00\x00\x00\x00\x00\x02@\x00\x00\x91\x83\x9e=\x91\x83\x9e=\x91\x83\x9e=\x00\x00\x00\x006\x00\x00\x05\x82 \x10\x00\x00\x00\x00\x00:\x00\x10\x00\x00\x00\x00\x007\x00\x00\tr \x10\x00\x00\x00\x00\x00F\x02\x10\x00\x02\x00\x00\x00F\x02\x10\x00\x01\x00\x00\x00F\x02\x10\x00\x00\x00\x00\x00>\x00\x00\x01STATt\x00\x00\x00\v\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00RDEF\x98\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x1c\x00\x00\x00\x00\x04\xff\xff\x00\x01\x00\x00m\x00\x00\x00\\\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00i\x00\x00\x00\x02\x00\x00\x00\x05\x00\x00\x00\x04\x00\x00\x00\xff\xff\xff\xff\x00\x00\x00\x00\x01\x00\x00\x00\r\x00\x00\x00_tex_sampler\x00tex\x00Microsoft (R) HLSL Shader Compiler 10.1\x00\xab\xab\xabISGN,\x00\x00\x00\x01\x00\x00\x00\b\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x03\x03\x00\x00TEXCOORD\x00\xab\xab\xabOSGN,\x00\x00\x00\x01\x00\x00\x00\b\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00SV_Target\x00\xab\xab",
|
||||
}
|
||||
shader_copy_vert = driver.ShaderSources{
|
||||
Name: "copy.vert",
|
||||
Name: "copy.vert",
|
||||
Inputs: []driver.InputLocation{{Name: "pos", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "uv", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 2}},
|
||||
Uniforms: driver.UniformsReflection{
|
||||
Blocks: []driver.UniformBlock{{Name: "Block", Binding: 0}},
|
||||
Locations: []driver.UniformLocation{{Name: "_block.scale", Type: 0x0, Size: 2, Offset: 0}, {Name: "_block.pos", Type: 0x0, Size: 2, Offset: 8}, {Name: "_block.uvScale", Type: 0x0, Size: 2, Offset: 16}},
|
||||
Size: 24,
|
||||
},
|
||||
GLSL100ES: `#version 100
|
||||
|
||||
struct Block
|
||||
{
|
||||
vec2 scale;
|
||||
vec2 pos;
|
||||
vec2 uvScale;
|
||||
};
|
||||
|
||||
uniform Block _block;
|
||||
|
||||
varying vec2 vUV;
|
||||
attribute vec2 uv;
|
||||
attribute vec2 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
for (int spvDummy6 = 0; spvDummy6 < 1; spvDummy6++)
|
||||
{
|
||||
if (gl_VertexID == 0)
|
||||
{
|
||||
gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
else if (gl_VertexID == 1)
|
||||
{
|
||||
gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
else if (gl_VertexID == 2)
|
||||
{
|
||||
gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
else if (gl_VertexID == 3)
|
||||
{
|
||||
gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
vUV = uv * _block.uvScale;
|
||||
gl_Position = vec4((pos * _block.scale) + _block.pos, 0.0, 1.0);
|
||||
}
|
||||
|
||||
`,
|
||||
GLSL300ES: `#version 300 es
|
||||
|
||||
layout(std140) uniform Block
|
||||
{
|
||||
vec2 scale;
|
||||
vec2 pos;
|
||||
vec2 uvScale;
|
||||
} _block;
|
||||
|
||||
out vec2 vUV;
|
||||
layout(location = 1) in vec2 uv;
|
||||
layout(location = 0) in vec2 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
switch (gl_VertexID)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
vUV = uv * _block.uvScale;
|
||||
gl_Position = vec4((pos * _block.scale) + _block.pos, 0.0, 1.0);
|
||||
}
|
||||
|
||||
`,
|
||||
GLSL130: `#version 130
|
||||
|
||||
struct Block
|
||||
{
|
||||
vec2 scale;
|
||||
vec2 pos;
|
||||
vec2 uvScale;
|
||||
};
|
||||
|
||||
uniform Block _block;
|
||||
|
||||
out vec2 vUV;
|
||||
in vec2 uv;
|
||||
in vec2 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
switch (gl_VertexID)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
vUV = uv * _block.uvScale;
|
||||
gl_Position = vec4((pos * _block.scale) + _block.pos, 0.0, 1.0);
|
||||
}
|
||||
|
||||
`,
|
||||
GLSL150: `#version 150
|
||||
|
||||
layout(std140) uniform Block
|
||||
{
|
||||
vec2 scale;
|
||||
vec2 pos;
|
||||
vec2 uvScale;
|
||||
} _block;
|
||||
|
||||
out vec2 vUV;
|
||||
in vec2 uv;
|
||||
in vec2 pos;
|
||||
|
||||
void main()
|
||||
{
|
||||
switch (gl_VertexID)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
gl_Position = vec4(-1.0, 1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
gl_Position = vec4(1.0, 1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
gl_Position = vec4(1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
vUV = uv * _block.uvScale;
|
||||
gl_Position = vec4((pos * _block.scale) + _block.pos, 0.0, 1.0);
|
||||
}
|
||||
|
||||
`,
|
||||
HLSL: "DXBC\x99\xb4[\xef]IX\xa2Qh\x9f\xb6!\x1cR\xe7\x01\x00\x00\x00\xc0\x02\x00\x00\x05\x00\x00\x004\x00\x00\x00\x80\x00\x00\x00\xb4\x00\x00\x00\xe8\x00\x00\x00D\x02\x00\x00RDEFD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x00\x00\x00\x00\x04\xfe\xff\x00\x01\x00\x00\x1c\x00\x00\x00Microsoft (R) HLSL Shader Compiler 10.1\x00ISGN,\x00\x00\x00\x01\x00\x00\x00\b\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x01\x01\x00\x00SV_VertexID\x00OSGN,\x00\x00\x00\x01\x00\x00\x00\b\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x0f\x00\x00\x00SV_Position\x00SHDRT\x01\x00\x00@\x00\x01\x00U\x00\x00\x00`\x00\x00\x04\x12\x10\x10\x00\x00\x00\x00\x00\x06\x00\x00\x00g\x00\x00\x04\xf2 \x10\x00\x00\x00\x00\x00\x01\x00\x00\x00h\x00\x00\x02\x01\x00\x00\x00L\x00\x00\x03\n\x10\x10\x00\x00\x00\x00\x00\x06\x00\x00\x03\x01@\x00\x00\x00\x00\x00\x006\x00\x00\br\x00\x10\x00\x00\x00\x00\x00\x02@\x00\x00\x00\x00\x80\xbf\x00\x00\x80?\x00\x00\x80?\x00\x00\x00\x00\x02\x00\x00\x01\x06\x00\x00\x03\x01@\x00\x00\x01\x00\x00\x006\x00\x00\br\x00\x10\x00\x00\x00\x00\x00\x02@\x00\x00\x00\x00\x80?\x00\x00\x80?\x00\x00\x80?\x00\x00\x00\x00\x02\x00\x00\x01\x06\x00\x00\x03\x01@\x00\x00\x02\x00\x00\x006\x00\x00\br\x00\x10\x00\x00\x00\x00\x00\x02@\x00\x00\x00\x00\x80\xbf\x00\x00\x80\xbf\x00\x00\x80?\x00\x00\x00\x00\x02\x00\x00\x01\x06\x00\x00\x03\x01@\x00\x00\x03\x00\x00\x006\x00\x00\br\x00\x10\x00\x00\x00\x00\x00\x02@\x00\x00\x00\x00\x80?\x00\x00\x80\xbf\x00\x00\x80?\x00\x00\x00\x00\x02\x00\x00\x01\n\x00\x00\x016\x00\x00\br\x00\x10\x00\x00\x00\x00\x00\x02@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x01\x17\x00\x00\x016\x00\x00\x05\xb2 \x10\x00\x00\x00\x00\x00F\b\x10\x00\x00\x00\x00\x006\x00\x00\x05B \x10\x00\x00\x00\x00\x00\x01@\x00\x00\x00\x00\x00\x00>\x00\x00\x01STATt\x00\x00\x00\x14\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
|
||||
HLSL: "DXBC\xb9\xf6\xad\xbb&\xfbz$V\x8dy\xc5u\xb9\xc1\xda\x01\x00\x00\x00\xe0\x03\x00\x00\x06\x00\x00\x008\x00\x00\x00\xec\x00\x00\x00\xb0\x01\x00\x00,\x02\x00\x00<\x03\x00\x00\x88\x03\x00\x00Aon9\xac\x00\x00\x00\xac\x00\x00\x00\x00\x02\xfe\xffx\x00\x00\x004\x00\x00\x00\x01\x00$\x00\x00\x000\x00\x00\x000\x00\x00\x00$\x00\x01\x000\x00\x00\x00\x00\x00\x02\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\xfe\xffQ\x00\x00\x05\x03\x00\x0f\xa0\x00\x00\x00\x00\x00\x00\x80?\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x00\x00\x02\x05\x00\x00\x80\x00\x00\x0f\x90\x1f\x00\x00\x02\x05\x00\x01\x80\x01\x00\x0f\x90\x05\x00\x00\x03\x00\x00\x03\xe0\x01\x00\xe4\x90\x02\x00\xe4\xa0\x04\x00\x00\x04\x00\x00\x03\x80\x00\x00\xe4\x90\x01\x00\xe4\xa0\x01\x00\xee\xa0\x02\x00\x00\x03\x00\x00\x03\xc0\x00\x00\xe4\x80\x00\x00\xe4\xa0\x01\x00\x00\x02\x00\x00\f\xc0\x03\x00D\xa0\xff\xff\x00\x00SHDR\xbc\x00\x00\x00@\x00\x01\x00/\x00\x00\x00Y\x00\x00\x04F\x8e \x00\x00\x00\x00\x00\x02\x00\x00\x00_\x00\x00\x032\x10\x10\x00\x00\x00\x00\x00_\x00\x00\x032\x10\x10\x00\x01\x00\x00\x00e\x00\x00\x032 \x10\x00\x00\x00\x00\x00g\x00\x00\x04\xf2 \x10\x00\x01\x00\x00\x00\x01\x00\x00\x008\x00\x00\b2 \x10\x00\x00\x00\x00\x00F\x10\x10\x00\x01\x00\x00\x00F\x80 \x00\x00\x00\x00\x00\x01\x00\x00\x002\x00\x00\v2 \x10\x00\x01\x00\x00\x00F\x10\x10\x00\x00\x00\x00\x00F\x80 \x00\x00\x00\x00\x00\x00\x00\x00\x00\xe6\x8a \x00\x00\x00\x00\x00\x00\x00\x00\x006\x00\x00\b\xc2 \x10\x00\x01\x00\x00\x00\x02@\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80?>\x00\x00\x01STATt\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00RDEF\b\x01\x00\x00\x01\x00\x00\x00D\x00\x00\x00\x01\x00\x00\x00\x1c\x00\x00\x00\x00\x04\xfe\xff\x00\x01\x00\x00\xde\x00\x00\x00<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00Block\x00\xab\xab<\x00\x00\x00\x03\x00\x00\x00\\\x00\x00\x00 \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa4\x00\x00\x00\x00\x00\x00\x00\b\x00\x00\x00\x02\x00\x00\x00\xb4\x00\x00\x00\x00\x00\x00\x00\xc4\x00\x00\x00\b\x00\x00\x00\b\x00\x00\x00\x02\x00\x00\x00\xb4\x00\x00\x00\x00\x00\x00\x00\xcf\x00\x00\x00\x10\x00\x00\x00\b\x00\x00\x00\x02\x00\x00\x00\xb4\x00\x00\x00\x00\x00\x00\x00_block_scale\x00\xab\xab\xab\x01\x00\x03\x00\x01\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00_block_pos\x00_block_uvScale\x00Microsoft (R) HLSL Shader Compiler 10.1\x00\xab\xabISGND\x00\x00\x00\x02\x00\x00\x00\b\x00\x00\x008\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x03\x03\x00\x008\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\x03\x03\x00\x00TEXCOORD\x00\xab\xab\xabOSGNP\x00\x00\x00\x02\x00\x00\x00\b\x00\x00\x008\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x03\f\x00\x00A\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x03\x00\x00\x00\x01\x00\x00\x00\x0f\x00\x00\x00TEXCOORD\x00SV_Position\x00\xab\xab\xab",
|
||||
}
|
||||
shader_cover_frag = [...]driver.ShaderSources{
|
||||
{
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
// SPDX-License-Identifier: Unlicense OR MIT
|
||||
|
||||
precision highp float;
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
precision mediump float;
|
||||
|
||||
layout(binding = 0) uniform sampler2D tex;
|
||||
|
||||
precision mediump float;
|
||||
layout(location = 0) in vec2 vUV;
|
||||
|
||||
layout(location = 0) out vec4 fragColor;
|
||||
|
||||
vec3 sRGBtoRGB(vec3 rgb) {
|
||||
bvec3 cutoff = greaterThanEqual(rgb, vec3(0.04045));
|
||||
@@ -18,7 +18,7 @@ vec3 sRGBtoRGB(vec3 rgb) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec4 texel = texelFetch(tex, ivec2(gl_FragCoord.xy), 0);
|
||||
vec3 rgb = sRGBtoRGB(texel.rgb);
|
||||
fragColor = vec4(rgb, texel.a);
|
||||
vec4 texel = texture(tex, vUV);
|
||||
texel.rgb = sRGBtoRGB(texel.rgb);
|
||||
fragColor = texel;
|
||||
}
|
||||
|
||||
+13
-14
@@ -4,19 +4,18 @@
|
||||
|
||||
precision highp float;
|
||||
|
||||
layout(binding = 0) uniform Block {
|
||||
vec2 scale;
|
||||
vec2 pos;
|
||||
vec2 uvScale;
|
||||
} _block;
|
||||
|
||||
layout(location = 0) in vec2 pos;
|
||||
layout(location = 1) in vec2 uv;
|
||||
|
||||
layout(location = 0) out vec2 vUV;
|
||||
|
||||
void main() {
|
||||
switch (gl_VertexIndex) {
|
||||
case 0:
|
||||
gl_Position = vec4(-1.0, +1.0, 0.0, 1.0);
|
||||
break;
|
||||
case 1:
|
||||
gl_Position = vec4(+1.0, +1.0, 0.0, 1.0);
|
||||
break;
|
||||
case 2:
|
||||
gl_Position = vec4(-1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
case 3:
|
||||
gl_Position = vec4(+1.0, -1.0, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
vUV = uv*_block.uvScale;
|
||||
gl_Position = vec4(pos*_block.scale + _block.pos, 0, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user