diff options
Diffstat (limited to 'vendor/gioui.org/shader')
254 files changed, 6705 insertions, 0 deletions
diff --git a/vendor/gioui.org/shader/LICENSE b/vendor/gioui.org/shader/LICENSE new file mode 100644 index 0000000..81f4733 --- /dev/null +++ b/vendor/gioui.org/shader/LICENSE @@ -0,0 +1,63 @@ +This project is provided under the terms of the UNLICENSE or +the MIT license denoted by the following SPDX identifier: + +SPDX-License-Identifier: Unlicense OR MIT + +You may use the project under the terms of either license. + +Both licenses are reproduced below. + +---- +The MIT License (MIT) + +Copyright (c) 2019 The Gio authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +--- + + + +--- +The UNLICENSE + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or +distribute this software, either in source code form or as a compiled +binary, for any purpose, commercial or non-commercial, and by any +means. + +In jurisdictions that recognize copyright laws, the author or authors +of this software dedicate any and all copyright interest in the +software to the public domain. We make this dedication for the benefit +of the public at large and to the detriment of our heirs and +successors. We intend this dedication to be an overt act of +relinquishment in perpetuity of all present and future rights to this +software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to <https://unlicense.org/> +--- diff --git a/vendor/gioui.org/shader/README.md b/vendor/gioui.org/shader/README.md new file mode 100644 index 0000000..4ea4867 --- /dev/null +++ b/vendor/gioui.org/shader/README.md @@ -0,0 +1,18 @@ +# GPU programs for the Gio project + +This repository contains the source code for the [Gio](https://gioui.org) +project. It also contains the generators and dereived versions for use with the +GPU APIs supported by Gio. + +# Generating CPU fallbacks + +The `piet/gencpu.sh` script updates the piet-gpu binaries: + +``` +$ cd piet +$ ./gencpu.sh +``` + +## Issues and contributions + +See the [Gio contribution guide](https://gioui.org/doc/contribute). diff --git a/vendor/gioui.org/shader/gio/blit.frag b/vendor/gioui.org/shader/gio/blit.frag new file mode 100644 index 0000000..a88f4dc --- /dev/null +++ b/vendor/gioui.org/shader/gio/blit.frag @@ -0,0 +1,15 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +precision mediump float; + +layout(location=0) in highp vec2 vUV; + +{{.Header}} + +layout(location = 0) out vec4 fragColor; + +void main() { + fragColor = {{.FetchColorExpr}}; +} diff --git a/vendor/gioui.org/shader/gio/blit.vert b/vendor/gioui.org/shader/gio/blit.vert new file mode 100644 index 0000000..83d041f --- /dev/null +++ b/vendor/gioui.org/shader/gio/blit.vert @@ -0,0 +1,27 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +#extension GL_GOOGLE_include_directive : enable + +precision highp float; + +#include "common.h" + +layout(push_constant) uniform Block { + vec4 transform; + vec4 uvTransformR1; + vec4 uvTransformR2; +} _block; + +layout(location = 0) in vec2 pos; + +layout(location = 1) in vec2 uv; + +layout(location = 0) out vec2 vUV; + +void main() { + vec2 p = pos*_block.transform.xy + _block.transform.zw; + gl_Position = vec4(transform3x2(windowTransform, vec3(p, 0)), 1); + vUV = transform3x2(m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz), vec3(uv,1)).xy; +} diff --git a/vendor/gioui.org/shader/gio/common.h b/vendor/gioui.org/shader/gio/common.h new file mode 100644 index 0000000..9b6dc59 --- /dev/null +++ b/vendor/gioui.org/shader/gio/common.h @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: Unlicense OR MIT + +struct m3x2 { + vec3 r0; + vec3 r1; +}; + +// fboTransform is the transformation that cancels the implied transformation +// between the clip space and the framebuffer. Only two rows are returned. The +// last is implied to be [0, 0, 1]. +const m3x2 fboTransform = m3x2( +#if defined(LANG_HLSL) || defined(LANG_MSL) || defined(LANG_MSLIOS) + vec3(1.0, 0.0, 0.0), + vec3(0.0, -1.0, 0.0) +#else + vec3(1.0, 0.0, 0.0), + vec3(0.0, 1.0, 0.0) +#endif +); + +// windowTransform is the transformation that cancels the implied transformation +// between framebuffer space and window system coordinates. +const m3x2 windowTransform = m3x2( +#if defined(LANG_VULKAN) + vec3(1.0, 0.0, 0.0), + vec3(0.0, 1.0, 0.0) +#else + vec3(1.0, 0.0, 0.0), + vec3(0.0, -1.0, 0.0) +#endif +); + +vec3 transform3x2(m3x2 t, vec3 v) { + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} diff --git a/vendor/gioui.org/shader/gio/copy.frag b/vendor/gioui.org/shader/gio/copy.frag new file mode 100644 index 0000000..048d9e7 --- /dev/null +++ b/vendor/gioui.org/shader/gio/copy.frag @@ -0,0 +1,24 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +precision mediump float; + +layout(binding = 0) uniform sampler2D tex; + +layout(location = 0) in highp vec2 vUV; + +layout(location = 0) out vec4 fragColor; + +vec3 sRGBtoRGB(vec3 rgb) { + bvec3 cutoff = greaterThanEqual(rgb, vec3(0.04045)); + vec3 below = rgb/vec3(12.92); + vec3 above = pow((rgb + vec3(0.055))/vec3(1.055), vec3(2.4)); + return mix(below, above, cutoff); +} + +void main() { + vec4 texel = texture(tex, vUV); + texel.rgb = sRGBtoRGB(texel.rgb); + fragColor = texel; +} diff --git a/vendor/gioui.org/shader/gio/copy.vert b/vendor/gioui.org/shader/gio/copy.vert new file mode 100644 index 0000000..c079b96 --- /dev/null +++ b/vendor/gioui.org/shader/gio/copy.vert @@ -0,0 +1,26 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +#extension GL_GOOGLE_include_directive : enable + +precision highp float; + +#include "common.h" + +layout(push_constant) 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() { + vUV = vec2(uv*_block.uvScale); + vec2 p = vec2(pos*_block.scale + _block.pos); + gl_Position = vec4(transform3x2(windowTransform, vec3(p, 0)), 1); +} diff --git a/vendor/gioui.org/shader/gio/cover.frag b/vendor/gioui.org/shader/gio/cover.frag new file mode 100644 index 0000000..34c5e4c --- /dev/null +++ b/vendor/gioui.org/shader/gio/cover.frag @@ -0,0 +1,20 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +precision mediump float; + +{{.Header}} + +layout(location = 0) in highp vec2 vCoverUV; +layout(location = 1) in highp vec2 vUV; + +layout(binding = 1) uniform sampler2D cover; + +layout(location = 0) out vec4 fragColor; + +void main() { + fragColor = {{.FetchColorExpr}}; + float c = min(abs(texture(cover, vCoverUV).r), 1.0); + fragColor *= c; +} diff --git a/vendor/gioui.org/shader/gio/cover.vert b/vendor/gioui.org/shader/gio/cover.vert new file mode 100644 index 0000000..02fae50 --- /dev/null +++ b/vendor/gioui.org/shader/gio/cover.vert @@ -0,0 +1,31 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +#extension GL_GOOGLE_include_directive : enable + +precision highp float; + +#include "common.h" + +layout(push_constant) uniform Block { + vec4 transform; + vec4 uvCoverTransform; + vec4 uvTransformR1; + vec4 uvTransformR2; +} _block; + +layout(location = 0) in vec2 pos; + +layout(location = 0) out vec2 vCoverUV; + +layout(location = 1) in vec2 uv; +layout(location = 1) out vec2 vUV; + +void main() { + vec2 p = vec2(pos*_block.transform.xy + _block.transform.zw); + gl_Position = vec4(transform3x2(windowTransform, vec3(p, 0)), 1); + vUV = transform3x2(m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz), vec3(uv,1)).xy; + vec3 uv3 = vec3(uv, 1.0); + vCoverUV = (uv3*vec3(_block.uvCoverTransform.xy, 1.0)+vec3(_block.uvCoverTransform.zw, 0.0)).xy; +} diff --git a/vendor/gioui.org/shader/gio/gen.go b/vendor/gioui.org/shader/gio/gen.go new file mode 100644 index 0000000..f26056a --- /dev/null +++ b/vendor/gioui.org/shader/gio/gen.go @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: Unlicense OR MIT + +package gio + +//go:generate go run ../cmd/convertshaders -package gio -dir . diff --git a/vendor/gioui.org/shader/gio/input.vert b/vendor/gioui.org/shader/gio/input.vert new file mode 100644 index 0000000..3d0cd50 --- /dev/null +++ b/vendor/gioui.org/shader/gio/input.vert @@ -0,0 +1,15 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +#extension GL_GOOGLE_include_directive : enable + +precision highp float; + +#include "common.h" + +layout(location=0) in vec4 position; + +void main() { + gl_Position = vec4(transform3x2(windowTransform, position.xyz), position.w); +} diff --git a/vendor/gioui.org/shader/gio/intersect.frag b/vendor/gioui.org/shader/gio/intersect.frag new file mode 100644 index 0000000..21a126f --- /dev/null +++ b/vendor/gioui.org/shader/gio/intersect.frag @@ -0,0 +1,15 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +precision mediump float; + +layout(location = 0) in highp vec2 vUV; + +layout(binding = 0) uniform sampler2D cover; + +layout(location = 0) out vec4 fragColor; + +void main() { + fragColor.r = abs(texture(cover, vUV).r); +} diff --git a/vendor/gioui.org/shader/gio/intersect.vert b/vendor/gioui.org/shader/gio/intersect.vert new file mode 100644 index 0000000..e7ee2fe --- /dev/null +++ b/vendor/gioui.org/shader/gio/intersect.vert @@ -0,0 +1,26 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +#extension GL_GOOGLE_include_directive : enable + +precision highp float; + +#include "common.h" + +layout(location = 0) in vec2 pos; +layout(location = 1) in vec2 uv; + +layout(push_constant) uniform Block { + vec4 uvTransform; + vec4 subUVTransform; +} _block; + +layout(location = 0) out vec2 vUV; + +void main() { + vec3 p = transform3x2(fboTransform, vec3(pos, 1.0)); + gl_Position = vec4(p, 1); + vUV = uv.xy*_block.subUVTransform.xy + _block.subUVTransform.zw; + vUV = vUV*_block.uvTransform.xy + _block.uvTransform.zw; +} diff --git a/vendor/gioui.org/shader/gio/material.frag b/vendor/gioui.org/shader/gio/material.frag new file mode 100644 index 0000000..489461e --- /dev/null +++ b/vendor/gioui.org/shader/gio/material.frag @@ -0,0 +1,32 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +precision mediump float; + +layout(binding = 0) uniform sampler2D tex; + +layout(location = 0) in highp vec2 vUV; + +layout(location = 0) out vec4 fragColor; + +layout(push_constant) uniform Color { + // If emulateSRGB is set (!= 0), the input texels are sRGB encoded. We save the + // conversion step below, at the cost of texture filtering in sRGB space. + layout(offset=16) float emulateSRGB; +} _color; + +vec3 RGBtosRGB(vec3 rgb) { + bvec3 cutoff = greaterThanEqual(rgb, vec3(0.0031308)); + vec3 below = vec3(12.92)*rgb; + vec3 above = vec3(1.055)*pow(rgb, vec3(0.41666)) - vec3(0.055); + return mix(below, above, cutoff); +} + +void main() { + vec4 texel = texture(tex, vUV); + if (_color.emulateSRGB == 0.0) { + texel.rgb = RGBtosRGB(texel.rgb); + } + fragColor = texel; +} diff --git a/vendor/gioui.org/shader/gio/material.vert b/vendor/gioui.org/shader/gio/material.vert new file mode 100644 index 0000000..22c41a0 --- /dev/null +++ b/vendor/gioui.org/shader/gio/material.vert @@ -0,0 +1,25 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +#extension GL_GOOGLE_include_directive : enable + +precision highp float; + +#include "common.h" + +layout(push_constant) uniform Block { + vec2 scale; + vec2 pos; +} _block; + +layout(location = 0) in vec2 pos; +layout(location = 1) in vec2 uv; + +layout(location = 0) out vec2 vUV; + +void main() { + vUV = uv; + vec2 p = vec2(pos*_block.scale + _block.pos); + gl_Position = vec4(transform3x2(fboTransform, vec3(p, 0)), 1); +} diff --git a/vendor/gioui.org/shader/gio/shaders.go b/vendor/gioui.org/shader/gio/shaders.go new file mode 100644 index 0000000..1166c1c --- /dev/null +++ b/vendor/gioui.org/shader/gio/shaders.go @@ -0,0 +1,796 @@ +// Code generated by build.go. DO NOT EDIT. + +package gio + +import ( + _ "embed" + "runtime" + + "gioui.org/shader" +) + +var ( + Shader_blit_frag = [...]shader.Sources{ + { + Name: "blit.frag", + Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}}, + Uniforms: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_color.color", Type: 0x0, Size: 4, Offset: 112}}, + Size: 16, + }, + }, + { + Name: "blit.frag", + Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}}, + Uniforms: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_gradient.color1", Type: 0x0, Size: 4, Offset: 96}, {Name: "_gradient.color2", Type: 0x0, Size: 4, Offset: 112}}, + Size: 32, + }, + }, + { + Name: "blit.frag", + Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}}, + Textures: []shader.TextureBinding{{Name: "tex", Binding: 0}}, + }, + } + //go:embed zblit.frag.0.spirv + zblit_frag_0_spirv string + //go:embed zblit.frag.0.glsl100es + zblit_frag_0_glsl100es string + //go:embed zblit.frag.0.glsl150 + zblit_frag_0_glsl150 string + //go:embed zblit.frag.0.dxbc + zblit_frag_0_dxbc string + //go:embed zblit.frag.0.metallibmacos + zblit_frag_0_metallibmacos string + //go:embed zblit.frag.0.metallibios + zblit_frag_0_metallibios string + //go:embed zblit.frag.0.metallibiossimulator + zblit_frag_0_metallibiossimulator string + //go:embed zblit.frag.1.spirv + zblit_frag_1_spirv string + //go:embed zblit.frag.1.glsl100es + zblit_frag_1_glsl100es string + //go:embed zblit.frag.1.glsl150 + zblit_frag_1_glsl150 string + //go:embed zblit.frag.1.dxbc + zblit_frag_1_dxbc string + //go:embed zblit.frag.1.metallibmacos + zblit_frag_1_metallibmacos string + //go:embed zblit.frag.1.metallibios + zblit_frag_1_metallibios string + //go:embed zblit.frag.1.metallibiossimulator + zblit_frag_1_metallibiossimulator string + //go:embed zblit.frag.2.spirv + zblit_frag_2_spirv string + //go:embed zblit.frag.2.glsl100es + zblit_frag_2_glsl100es string + //go:embed zblit.frag.2.glsl150 + zblit_frag_2_glsl150 string + //go:embed zblit.frag.2.dxbc + zblit_frag_2_dxbc string + //go:embed zblit.frag.2.metallibmacos + zblit_frag_2_metallibmacos string + //go:embed zblit.frag.2.metallibios + zblit_frag_2_metallibios string + //go:embed zblit.frag.2.metallibiossimulator + zblit_frag_2_metallibiossimulator string + Shader_blit_vert = shader.Sources{ + Name: "blit.vert", + Inputs: []shader.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: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_block.transform", Type: 0x0, Size: 4, Offset: 0}, {Name: "_block.uvTransformR1", Type: 0x0, Size: 4, Offset: 16}, {Name: "_block.uvTransformR2", Type: 0x0, Size: 4, Offset: 32}}, + Size: 48, + }, + } + //go:embed zblit.vert.0.spirv + zblit_vert_0_spirv string + //go:embed zblit.vert.0.glsl100es + zblit_vert_0_glsl100es string + //go:embed zblit.vert.0.glsl150 + zblit_vert_0_glsl150 string + //go:embed zblit.vert.0.dxbc + zblit_vert_0_dxbc string + //go:embed zblit.vert.0.metallibmacos + zblit_vert_0_metallibmacos string + //go:embed zblit.vert.0.metallibios + zblit_vert_0_metallibios string + //go:embed zblit.vert.0.metallibiossimulator + zblit_vert_0_metallibiossimulator string + Shader_copy_frag = shader.Sources{ + Name: "copy.frag", + Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}}, + Textures: []shader.TextureBinding{{Name: "tex", Binding: 0}}, + } + //go:embed zcopy.frag.0.spirv + zcopy_frag_0_spirv string + //go:embed zcopy.frag.0.glsl100es + zcopy_frag_0_glsl100es string + //go:embed zcopy.frag.0.glsl150 + zcopy_frag_0_glsl150 string + //go:embed zcopy.frag.0.dxbc + zcopy_frag_0_dxbc string + //go:embed zcopy.frag.0.metallibmacos + zcopy_frag_0_metallibmacos string + //go:embed zcopy.frag.0.metallibios + zcopy_frag_0_metallibios string + //go:embed zcopy.frag.0.metallibiossimulator + zcopy_frag_0_metallibiossimulator string + Shader_copy_vert = shader.Sources{ + Name: "copy.vert", + Inputs: []shader.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: shader.UniformsReflection{ + Locations: []shader.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, + }, + } + //go:embed zcopy.vert.0.spirv + zcopy_vert_0_spirv string + //go:embed zcopy.vert.0.glsl100es + zcopy_vert_0_glsl100es string + //go:embed zcopy.vert.0.glsl150 + zcopy_vert_0_glsl150 string + //go:embed zcopy.vert.0.dxbc + zcopy_vert_0_dxbc string + //go:embed zcopy.vert.0.metallibmacos + zcopy_vert_0_metallibmacos string + //go:embed zcopy.vert.0.metallibios + zcopy_vert_0_metallibios string + //go:embed zcopy.vert.0.metallibiossimulator + zcopy_vert_0_metallibiossimulator string + Shader_cover_frag = [...]shader.Sources{ + { + Name: "cover.frag", + Inputs: []shader.InputLocation{{Name: "vCoverUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "vUV", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 2}}, + Uniforms: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_color.color", Type: 0x0, Size: 4, Offset: 112}}, + Size: 16, + }, + Textures: []shader.TextureBinding{{Name: "cover", Binding: 1}}, + }, + { + Name: "cover.frag", + Inputs: []shader.InputLocation{{Name: "vCoverUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "vUV", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 2}}, + Uniforms: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_gradient.color1", Type: 0x0, Size: 4, Offset: 96}, {Name: "_gradient.color2", Type: 0x0, Size: 4, Offset: 112}}, + Size: 32, + }, + Textures: []shader.TextureBinding{{Name: "cover", Binding: 1}}, + }, + { + Name: "cover.frag", + Inputs: []shader.InputLocation{{Name: "vCoverUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "vUV", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 2}}, + Textures: []shader.TextureBinding{{Name: "tex", Binding: 0}, {Name: "cover", Binding: 1}}, + }, + } + //go:embed zcover.frag.0.spirv + zcover_frag_0_spirv string + //go:embed zcover.frag.0.glsl100es + zcover_frag_0_glsl100es string + //go:embed zcover.frag.0.glsl150 + zcover_frag_0_glsl150 string + //go:embed zcover.frag.0.dxbc + zcover_frag_0_dxbc string + //go:embed zcover.frag.0.metallibmacos + zcover_frag_0_metallibmacos string + //go:embed zcover.frag.0.metallibios + zcover_frag_0_metallibios string + //go:embed zcover.frag.0.metallibiossimulator + zcover_frag_0_metallibiossimulator string + //go:embed zcover.frag.1.spirv + zcover_frag_1_spirv string + //go:embed zcover.frag.1.glsl100es + zcover_frag_1_glsl100es string + //go:embed zcover.frag.1.glsl150 + zcover_frag_1_glsl150 string + //go:embed zcover.frag.1.dxbc + zcover_frag_1_dxbc string + //go:embed zcover.frag.1.metallibmacos + zcover_frag_1_metallibmacos string + //go:embed zcover.frag.1.metallibios + zcover_frag_1_metallibios string + //go:embed zcover.frag.1.metallibiossimulator + zcover_frag_1_metallibiossimulator string + //go:embed zcover.frag.2.spirv + zcover_frag_2_spirv string + //go:embed zcover.frag.2.glsl100es + zcover_frag_2_glsl100es string + //go:embed zcover.frag.2.glsl150 + zcover_frag_2_glsl150 string + //go:embed zcover.frag.2.dxbc + zcover_frag_2_dxbc string + //go:embed zcover.frag.2.metallibmacos + zcover_frag_2_metallibmacos string + //go:embed zcover.frag.2.metallibios + zcover_frag_2_metallibios string + //go:embed zcover.frag.2.metallibiossimulator + zcover_frag_2_metallibiossimulator string + Shader_cover_vert = shader.Sources{ + Name: "cover.vert", + Inputs: []shader.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: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_block.transform", Type: 0x0, Size: 4, Offset: 0}, {Name: "_block.uvCoverTransform", Type: 0x0, Size: 4, Offset: 16}, {Name: "_block.uvTransformR1", Type: 0x0, Size: 4, Offset: 32}, {Name: "_block.uvTransformR2", Type: 0x0, Size: 4, Offset: 48}}, + Size: 64, + }, + } + //go:embed zcover.vert.0.spirv + zcover_vert_0_spirv string + //go:embed zcover.vert.0.glsl100es + zcover_vert_0_glsl100es string + //go:embed zcover.vert.0.glsl150 + zcover_vert_0_glsl150 string + //go:embed zcover.vert.0.dxbc + zcover_vert_0_dxbc string + //go:embed zcover.vert.0.metallibmacos + zcover_vert_0_metallibmacos string + //go:embed zcover.vert.0.metallibios + zcover_vert_0_metallibios string + //go:embed zcover.vert.0.metallibiossimulator + zcover_vert_0_metallibiossimulator string + Shader_input_vert = shader.Sources{ + Name: "input.vert", + Inputs: []shader.InputLocation{{Name: "position", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 4}}, + } + //go:embed zinput.vert.0.spirv + zinput_vert_0_spirv string + //go:embed zinput.vert.0.glsl100es + zinput_vert_0_glsl100es string + //go:embed zinput.vert.0.glsl150 + zinput_vert_0_glsl150 string + //go:embed zinput.vert.0.dxbc + zinput_vert_0_dxbc string + //go:embed zinput.vert.0.metallibmacos + zinput_vert_0_metallibmacos string + //go:embed zinput.vert.0.metallibios + zinput_vert_0_metallibios string + //go:embed zinput.vert.0.metallibiossimulator + zinput_vert_0_metallibiossimulator string + Shader_intersect_frag = shader.Sources{ + Name: "intersect.frag", + Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}}, + Textures: []shader.TextureBinding{{Name: "cover", Binding: 0}}, + } + //go:embed zintersect.frag.0.spirv + zintersect_frag_0_spirv string + //go:embed zintersect.frag.0.glsl100es + zintersect_frag_0_glsl100es string + //go:embed zintersect.frag.0.glsl150 + zintersect_frag_0_glsl150 string + //go:embed zintersect.frag.0.dxbc + zintersect_frag_0_dxbc string + //go:embed zintersect.frag.0.metallibmacos + zintersect_frag_0_metallibmacos string + //go:embed zintersect.frag.0.metallibios + zintersect_frag_0_metallibios string + //go:embed zintersect.frag.0.metallibiossimulator + zintersect_frag_0_metallibiossimulator string + Shader_intersect_vert = shader.Sources{ + Name: "intersect.vert", + Inputs: []shader.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: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_block.uvTransform", Type: 0x0, Size: 4, Offset: 0}, {Name: "_block.subUVTransform", Type: 0x0, Size: 4, Offset: 16}}, + Size: 32, + }, + } + //go:embed zintersect.vert.0.spirv + zintersect_vert_0_spirv string + //go:embed zintersect.vert.0.glsl100es + zintersect_vert_0_glsl100es string + //go:embed zintersect.vert.0.glsl150 + zintersect_vert_0_glsl150 string + //go:embed zintersect.vert.0.dxbc + zintersect_vert_0_dxbc string + //go:embed zintersect.vert.0.metallibmacos + zintersect_vert_0_metallibmacos string + //go:embed zintersect.vert.0.metallibios + zintersect_vert_0_metallibios string + //go:embed zintersect.vert.0.metallibiossimulator + zintersect_vert_0_metallibiossimulator string + Shader_material_frag = shader.Sources{ + Name: "material.frag", + Inputs: []shader.InputLocation{{Name: "vUV", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}}, + Uniforms: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_color.emulateSRGB", Type: 0x0, Size: 1, Offset: 16}}, + Size: 4, + }, + Textures: []shader.TextureBinding{{Name: "tex", Binding: 0}}, + } + //go:embed zmaterial.frag.0.spirv + zmaterial_frag_0_spirv string + //go:embed zmaterial.frag.0.glsl100es + zmaterial_frag_0_glsl100es string + //go:embed zmaterial.frag.0.glsl150 + zmaterial_frag_0_glsl150 string + //go:embed zmaterial.frag.0.dxbc + zmaterial_frag_0_dxbc string + //go:embed zmaterial.frag.0.metallibmacos + zmaterial_frag_0_metallibmacos string + //go:embed zmaterial.frag.0.metallibios + zmaterial_frag_0_metallibios string + //go:embed zmaterial.frag.0.metallibiossimulator + zmaterial_frag_0_metallibiossimulator string + Shader_material_vert = shader.Sources{ + Name: "material.vert", + Inputs: []shader.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: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_block.scale", Type: 0x0, Size: 2, Offset: 0}, {Name: "_block.pos", Type: 0x0, Size: 2, Offset: 8}}, + Size: 16, + }, + } + //go:embed zmaterial.vert.0.spirv + zmaterial_vert_0_spirv string + //go:embed zmaterial.vert.0.glsl100es + zmaterial_vert_0_glsl100es string + //go:embed zmaterial.vert.0.glsl150 + zmaterial_vert_0_glsl150 string + //go:embed zmaterial.vert.0.dxbc + zmaterial_vert_0_dxbc string + //go:embed zmaterial.vert.0.metallibmacos + zmaterial_vert_0_metallibmacos string + //go:embed zmaterial.vert.0.metallibios + zmaterial_vert_0_metallibios string + //go:embed zmaterial.vert.0.metallibiossimulator + zmaterial_vert_0_metallibiossimulator string + Shader_simple_frag = shader.Sources{ + Name: "simple.frag", + } + //go:embed zsimple.frag.0.spirv + zsimple_frag_0_spirv string + //go:embed zsimple.frag.0.glsl100es + zsimple_frag_0_glsl100es string + //go:embed zsimple.frag.0.glsl150 + zsimple_frag_0_glsl150 string + //go:embed zsimple.frag.0.dxbc + zsimple_frag_0_dxbc string + //go:embed zsimple.frag.0.metallibmacos + zsimple_frag_0_metallibmacos string + //go:embed zsimple.frag.0.metallibios + zsimple_frag_0_metallibios string + //go:embed zsimple.frag.0.metallibiossimulator + zsimple_frag_0_metallibiossimulator string + Shader_stencil_frag = shader.Sources{ + Name: "stencil.frag", + Inputs: []shader.InputLocation{{Name: "vFrom", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 2}, {Name: "vCtrl", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 2}, {Name: "vTo", Location: 2, Semantic: "TEXCOORD", SemanticIndex: 2, Type: 0x0, Size: 2}}, + } + //go:embed zstencil.frag.0.spirv + zstencil_frag_0_spirv string + //go:embed zstencil.frag.0.glsl100es + zstencil_frag_0_glsl100es string + //go:embed zstencil.frag.0.glsl150 + zstencil_frag_0_glsl150 string + //go:embed zstencil.frag.0.dxbc + zstencil_frag_0_dxbc string + //go:embed zstencil.frag.0.metallibmacos + zstencil_frag_0_metallibmacos string + //go:embed zstencil.frag.0.metallibios + zstencil_frag_0_metallibios string + //go:embed zstencil.frag.0.metallibiossimulator + zstencil_frag_0_metallibiossimulator string + Shader_stencil_vert = shader.Sources{ + Name: "stencil.vert", + Inputs: []shader.InputLocation{{Name: "corner", Location: 0, Semantic: "TEXCOORD", SemanticIndex: 0, Type: 0x0, Size: 1}, {Name: "maxy", Location: 1, Semantic: "TEXCOORD", SemanticIndex: 1, Type: 0x0, Size: 1}, {Name: "from", Location: 2, Semantic: "TEXCOORD", SemanticIndex: 2, Type: 0x0, Size: 2}, {Name: "ctrl", Location: 3, Semantic: "TEXCOORD", SemanticIndex: 3, Type: 0x0, Size: 2}, {Name: "to", Location: 4, Semantic: "TEXCOORD", SemanticIndex: 4, Type: 0x0, Size: 2}}, + Uniforms: shader.UniformsReflection{ + Locations: []shader.UniformLocation{{Name: "_block.transform", Type: 0x0, Size: 4, Offset: 0}, {Name: "_block.pathOffset", Type: 0x0, Size: 2, Offset: 16}}, + Size: 24, + }, + } + //go:embed zstencil.vert.0.spirv + zstencil_vert_0_spirv string + //go:embed zstencil.vert.0.glsl100es + zstencil_vert_0_glsl100es string + //go:embed zstencil.vert.0.glsl150 + zstencil_vert_0_glsl150 string + //go:embed zstencil.vert.0.dxbc + zstencil_vert_0_dxbc string + //go:embed zstencil.vert.0.metallibmacos + zstencil_vert_0_metallibmacos string + //go:embed zstencil.vert.0.metallibios + zstencil_vert_0_metallibios string + //go:embed zstencil.vert.0.metallibiossimulator + zstencil_vert_0_metallibiossimulator string +) + +func init() { + const ( + opengles = runtime.GOOS == "linux" || runtime.GOOS == "freebsd" || runtime.GOOS == "openbsd" || runtime.GOOS == "windows" || runtime.GOOS == "js" || runtime.GOOS == "android" || runtime.GOOS == "darwin" || runtime.GOOS == "ios" + opengl = runtime.GOOS == "darwin" + d3d11 = runtime.GOOS == "windows" + vulkan = runtime.GOOS == "linux" || runtime.GOOS == "android" + ) + if vulkan { + Shader_blit_frag[0].SPIRV = zblit_frag_0_spirv + } + if opengles { + Shader_blit_frag[0].GLSL100ES = zblit_frag_0_glsl100es + } + if opengl { + Shader_blit_frag[0].GLSL150 = zblit_frag_0_glsl150 + } + if d3d11 { + Shader_blit_frag[0].DXBC = zblit_frag_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_blit_frag[0].MetalLib = zblit_frag_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_blit_frag[0].MetalLib = zblit_frag_0_metallibiossimulator + } else { + Shader_blit_frag[0].MetalLib = zblit_frag_0_metallibios + } + } + if vulkan { + Shader_blit_frag[1].SPIRV = zblit_frag_1_spirv + } + if opengles { + Shader_blit_frag[1].GLSL100ES = zblit_frag_1_glsl100es + } + if opengl { + Shader_blit_frag[1].GLSL150 = zblit_frag_1_glsl150 + } + if d3d11 { + Shader_blit_frag[1].DXBC = zblit_frag_1_dxbc + } + if runtime.GOOS == "darwin" { + Shader_blit_frag[1].MetalLib = zblit_frag_1_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_blit_frag[1].MetalLib = zblit_frag_1_metallibiossimulator + } else { + Shader_blit_frag[1].MetalLib = zblit_frag_1_metallibios + } + } + if vulkan { + Shader_blit_frag[2].SPIRV = zblit_frag_2_spirv + } + if opengles { + Shader_blit_frag[2].GLSL100ES = zblit_frag_2_glsl100es + } + if opengl { + Shader_blit_frag[2].GLSL150 = zblit_frag_2_glsl150 + } + if d3d11 { + Shader_blit_frag[2].DXBC = zblit_frag_2_dxbc + } + if runtime.GOOS == "darwin" { + Shader_blit_frag[2].MetalLib = zblit_frag_2_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_blit_frag[2].MetalLib = zblit_frag_2_metallibiossimulator + } else { + Shader_blit_frag[2].MetalLib = zblit_frag_2_metallibios + } + } + if vulkan { + Shader_blit_vert.SPIRV = zblit_vert_0_spirv + } + if opengles { + Shader_blit_vert.GLSL100ES = zblit_vert_0_glsl100es + } + if opengl { + Shader_blit_vert.GLSL150 = zblit_vert_0_glsl150 + } + if d3d11 { + Shader_blit_vert.DXBC = zblit_vert_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_blit_vert.MetalLib = zblit_vert_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_blit_vert.MetalLib = zblit_vert_0_metallibiossimulator + } else { + Shader_blit_vert.MetalLib = zblit_vert_0_metallibios + } + } + if vulkan { + Shader_copy_frag.SPIRV = zcopy_frag_0_spirv + } + if opengles { + Shader_copy_frag.GLSL100ES = zcopy_frag_0_glsl100es + } + if opengl { + Shader_copy_frag.GLSL150 = zcopy_frag_0_glsl150 + } + if d3d11 { + Shader_copy_frag.DXBC = zcopy_frag_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_copy_frag.MetalLib = zcopy_frag_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_copy_frag.MetalLib = zcopy_frag_0_metallibiossimulator + } else { + Shader_copy_frag.MetalLib = zcopy_frag_0_metallibios + } + } + if vulkan { + Shader_copy_vert.SPIRV = zcopy_vert_0_spirv + } + if opengles { + Shader_copy_vert.GLSL100ES = zcopy_vert_0_glsl100es + } + if opengl { + Shader_copy_vert.GLSL150 = zcopy_vert_0_glsl150 + } + if d3d11 { + Shader_copy_vert.DXBC = zcopy_vert_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_copy_vert.MetalLib = zcopy_vert_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_copy_vert.MetalLib = zcopy_vert_0_metallibiossimulator + } else { + Shader_copy_vert.MetalLib = zcopy_vert_0_metallibios + } + } + if vulkan { + Shader_cover_frag[0].SPIRV = zcover_frag_0_spirv + } + if opengles { + Shader_cover_frag[0].GLSL100ES = zcover_frag_0_glsl100es + } + if opengl { + Shader_cover_frag[0].GLSL150 = zcover_frag_0_glsl150 + } + if d3d11 { + Shader_cover_frag[0].DXBC = zcover_frag_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_cover_frag[0].MetalLib = zcover_frag_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_cover_frag[0].MetalLib = zcover_frag_0_metallibiossimulator + } else { + Shader_cover_frag[0].MetalLib = zcover_frag_0_metallibios + } + } + if vulkan { + Shader_cover_frag[1].SPIRV = zcover_frag_1_spirv + } + if opengles { + Shader_cover_frag[1].GLSL100ES = zcover_frag_1_glsl100es + } + if opengl { + Shader_cover_frag[1].GLSL150 = zcover_frag_1_glsl150 + } + if d3d11 { + Shader_cover_frag[1].DXBC = zcover_frag_1_dxbc + } + if runtime.GOOS == "darwin" { + Shader_cover_frag[1].MetalLib = zcover_frag_1_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_cover_frag[1].MetalLib = zcover_frag_1_metallibiossimulator + } else { + Shader_cover_frag[1].MetalLib = zcover_frag_1_metallibios + } + } + if vulkan { + Shader_cover_frag[2].SPIRV = zcover_frag_2_spirv + } + if opengles { + Shader_cover_frag[2].GLSL100ES = zcover_frag_2_glsl100es + } + if opengl { + Shader_cover_frag[2].GLSL150 = zcover_frag_2_glsl150 + } + if d3d11 { + Shader_cover_frag[2].DXBC = zcover_frag_2_dxbc + } + if runtime.GOOS == "darwin" { + Shader_cover_frag[2].MetalLib = zcover_frag_2_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_cover_frag[2].MetalLib = zcover_frag_2_metallibiossimulator + } else { + Shader_cover_frag[2].MetalLib = zcover_frag_2_metallibios + } + } + if vulkan { + Shader_cover_vert.SPIRV = zcover_vert_0_spirv + } + if opengles { + Shader_cover_vert.GLSL100ES = zcover_vert_0_glsl100es + } + if opengl { + Shader_cover_vert.GLSL150 = zcover_vert_0_glsl150 + } + if d3d11 { + Shader_cover_vert.DXBC = zcover_vert_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_cover_vert.MetalLib = zcover_vert_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_cover_vert.MetalLib = zcover_vert_0_metallibiossimulator + } else { + Shader_cover_vert.MetalLib = zcover_vert_0_metallibios + } + } + if vulkan { + Shader_input_vert.SPIRV = zinput_vert_0_spirv + } + if opengles { + Shader_input_vert.GLSL100ES = zinput_vert_0_glsl100es + } + if opengl { + Shader_input_vert.GLSL150 = zinput_vert_0_glsl150 + } + if d3d11 { + Shader_input_vert.DXBC = zinput_vert_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_input_vert.MetalLib = zinput_vert_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_input_vert.MetalLib = zinput_vert_0_metallibiossimulator + } else { + Shader_input_vert.MetalLib = zinput_vert_0_metallibios + } + } + if vulkan { + Shader_intersect_frag.SPIRV = zintersect_frag_0_spirv + } + if opengles { + Shader_intersect_frag.GLSL100ES = zintersect_frag_0_glsl100es + } + if opengl { + Shader_intersect_frag.GLSL150 = zintersect_frag_0_glsl150 + } + if d3d11 { + Shader_intersect_frag.DXBC = zintersect_frag_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_intersect_frag.MetalLib = zintersect_frag_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_intersect_frag.MetalLib = zintersect_frag_0_metallibiossimulator + } else { + Shader_intersect_frag.MetalLib = zintersect_frag_0_metallibios + } + } + if vulkan { + Shader_intersect_vert.SPIRV = zintersect_vert_0_spirv + } + if opengles { + Shader_intersect_vert.GLSL100ES = zintersect_vert_0_glsl100es + } + if opengl { + Shader_intersect_vert.GLSL150 = zintersect_vert_0_glsl150 + } + if d3d11 { + Shader_intersect_vert.DXBC = zintersect_vert_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_intersect_vert.MetalLib = zintersect_vert_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_intersect_vert.MetalLib = zintersect_vert_0_metallibiossimulator + } else { + Shader_intersect_vert.MetalLib = zintersect_vert_0_metallibios + } + } + if vulkan { + Shader_material_frag.SPIRV = zmaterial_frag_0_spirv + } + if opengles { + Shader_material_frag.GLSL100ES = zmaterial_frag_0_glsl100es + } + if opengl { + Shader_material_frag.GLSL150 = zmaterial_frag_0_glsl150 + } + if d3d11 { + Shader_material_frag.DXBC = zmaterial_frag_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_material_frag.MetalLib = zmaterial_frag_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_material_frag.MetalLib = zmaterial_frag_0_metallibiossimulator + } else { + Shader_material_frag.MetalLib = zmaterial_frag_0_metallibios + } + } + if vulkan { + Shader_material_vert.SPIRV = zmaterial_vert_0_spirv + } + if opengles { + Shader_material_vert.GLSL100ES = zmaterial_vert_0_glsl100es + } + if opengl { + Shader_material_vert.GLSL150 = zmaterial_vert_0_glsl150 + } + if d3d11 { + Shader_material_vert.DXBC = zmaterial_vert_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_material_vert.MetalLib = zmaterial_vert_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_material_vert.MetalLib = zmaterial_vert_0_metallibiossimulator + } else { + Shader_material_vert.MetalLib = zmaterial_vert_0_metallibios + } + } + if vulkan { + Shader_simple_frag.SPIRV = zsimple_frag_0_spirv + } + if opengles { + Shader_simple_frag.GLSL100ES = zsimple_frag_0_glsl100es + } + if opengl { + Shader_simple_frag.GLSL150 = zsimple_frag_0_glsl150 + } + if d3d11 { + Shader_simple_frag.DXBC = zsimple_frag_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_simple_frag.MetalLib = zsimple_frag_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_simple_frag.MetalLib = zsimple_frag_0_metallibiossimulator + } else { + Shader_simple_frag.MetalLib = zsimple_frag_0_metallibios + } + } + if vulkan { + Shader_stencil_frag.SPIRV = zstencil_frag_0_spirv + } + if opengles { + Shader_stencil_frag.GLSL100ES = zstencil_frag_0_glsl100es + } + if opengl { + Shader_stencil_frag.GLSL150 = zstencil_frag_0_glsl150 + } + if d3d11 { + Shader_stencil_frag.DXBC = zstencil_frag_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_stencil_frag.MetalLib = zstencil_frag_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_stencil_frag.MetalLib = zstencil_frag_0_metallibiossimulator + } else { + Shader_stencil_frag.MetalLib = zstencil_frag_0_metallibios + } + } + if vulkan { + Shader_stencil_vert.SPIRV = zstencil_vert_0_spirv + } + if opengles { + Shader_stencil_vert.GLSL100ES = zstencil_vert_0_glsl100es + } + if opengl { + Shader_stencil_vert.GLSL150 = zstencil_vert_0_glsl150 + } + if d3d11 { + Shader_stencil_vert.DXBC = zstencil_vert_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_stencil_vert.MetalLib = zstencil_vert_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_stencil_vert.MetalLib = zstencil_vert_0_metallibiossimulator + } else { + Shader_stencil_vert.MetalLib = zstencil_vert_0_metallibios + } + } +} diff --git a/vendor/gioui.org/shader/gio/simple.frag b/vendor/gioui.org/shader/gio/simple.frag new file mode 100644 index 0000000..4614f33 --- /dev/null +++ b/vendor/gioui.org/shader/gio/simple.frag @@ -0,0 +1,11 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +precision mediump float; + +layout(location = 0) out vec4 fragColor; + +void main() { + fragColor = vec4(.25, .55, .75, 1.0); +} diff --git a/vendor/gioui.org/shader/gio/stencil.frag b/vendor/gioui.org/shader/gio/stencil.frag new file mode 100644 index 0000000..956dae8 --- /dev/null +++ b/vendor/gioui.org/shader/gio/stencil.frag @@ -0,0 +1,81 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +precision mediump float; + +layout(location=0) in highp vec2 vFrom; +layout(location=1) in highp vec2 vCtrl; +layout(location=2) in highp vec2 vTo; + +layout(location = 0) out vec4 fragCover; + +void main() { + float dx = vTo.x - vFrom.x; + // Sort from and to in increasing order so the root below + // is always the positive square root, if any. + // We need the direction of the curve below, so this can't be + // done from the vertex shader. + bool increasing = vTo.x >= vFrom.x; + vec2 left = increasing ? vFrom : vTo; + vec2 right = increasing ? vTo : vFrom; + + // The signed horizontal extent of the fragment. + vec2 extent = clamp(vec2(vFrom.x, vTo.x), -0.5, 0.5); + // Find the t where the curve crosses the middle of the + // extent, x₀. + // Given the Bézier curve with x coordinates P₀, P₁, P₂ + // where P₀ is at the origin, its x coordinate in t + // is given by: + // + // x(t) = 2(1-t)tP₁ + t²P₂ + // + // Rearranging: + // + // x(t) = (P₂ - 2P₁)t² + 2P₁t + // + // Setting x(t) = x₀ and using Muller's quadratic formula ("Citardauq") + // for robustnesss, + // + // t = 2x₀/(2P₁±√(4P₁²+4(P₂-2P₁)x₀)) + // + // which simplifies to + // + // t = x₀/(P₁±√(P₁²+(P₂-2P₁)x₀)) + // + // Setting v = P₂-P₁, + // + // t = x₀/(P₁±√(P₁²+(v-P₁)x₀)) + // + // t lie in [0; 1]; P₂ ≥ P₁ and P₁ ≥ 0 since we split curves where + // the control point lies before the start point or after the end point. + // It can then be shown that only the positive square root is valid. + float midx = mix(extent.x, extent.y, 0.5); + float x0 = midx - left.x; + vec2 p1 = vCtrl - left; + vec2 v = right - vCtrl; + float t = x0/(p1.x+sqrt(p1.x*p1.x+(v.x-p1.x)*x0)); + // Find y(t) on the curve. + float y = mix(mix(left.y, vCtrl.y, t), mix(vCtrl.y, right.y, t), t); + // And the slope. + vec2 d_half = mix(p1, v, t); + float dy = d_half.y/d_half.x; + // Together, y and dy form a line approximation. + + // Compute the fragment area above the line. + // The area is symmetric around dy = 0. Scale slope with extent width. + float width = extent.y - extent.x; + dy = abs(dy*width); + + vec4 sides = vec4(dy*+0.5 + y, dy*-0.5 + y, (+0.5-y)/dy, (-0.5-y)/dy); + sides = clamp(sides+0.5, 0.0, 1.0); + + float area = 0.5*(sides.z - sides.z*sides.y + 1.0 - sides.x+sides.x*sides.w); + area *= width; + + // Work around issue #13. + if (width == 0.0) + area = 0.0; + + fragCover.r = area; +} diff --git a/vendor/gioui.org/shader/gio/stencil.vert b/vendor/gioui.org/shader/gio/stencil.vert new file mode 100644 index 0000000..fd6f28b --- /dev/null +++ b/vendor/gioui.org/shader/gio/stencil.vert @@ -0,0 +1,57 @@ +#version 310 es + +// SPDX-License-Identifier: Unlicense OR MIT + +#extension GL_GOOGLE_include_directive : enable + +precision highp float; + +#include "common.h" + +layout(push_constant) uniform Block { + vec4 transform; + vec2 pathOffset; +} _block; + +layout(location=0) in float corner; +layout(location=1) in float maxy; +layout(location=2) in vec2 from; +layout(location=3) in vec2 ctrl; +layout(location=4) in vec2 to; + +layout(location=0) out vec2 vFrom; +layout(location=1) out vec2 vCtrl; +layout(location=2) out vec2 vTo; + +void main() { + // Add a one pixel overlap so curve quads cover their + // entire curves. Could use conservative rasterization + // if available. + vec2 from = from + _block.pathOffset; + vec2 ctrl = ctrl + _block.pathOffset; + vec2 to = to + _block.pathOffset; + float maxy = maxy + _block.pathOffset.y; + vec2 pos; + float c = corner; + if (c >= 0.375) { + // North. + c -= 0.5; + pos.y = maxy + 1.0; + } else { + // South. + pos.y = min(min(from.y, ctrl.y), to.y) - 1.0; + } + if (c >= 0.125) { + // East. + pos.x = max(max(from.x, ctrl.x), to.x)+1.0; + } else { + // West. + pos.x = min(min(from.x, ctrl.x), to.x)-1.0; + } + vFrom = from-pos; + vCtrl = ctrl-pos; + vTo = to-pos; + pos = pos*_block.transform.xy + _block.transform.zw; + gl_Position = vec4(transform3x2(fboTransform, vec3(pos, 0)), 1); +} + diff --git a/vendor/gioui.org/shader/gio/zblit.frag.0.dxbc b/vendor/gioui.org/shader/gio/zblit.frag.0.dxbc Binary files differnew file mode 100644 index 0000000..45e8355 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zblit.frag.0.glsl100es b/vendor/gioui.org/shader/gio/zblit.frag.0.glsl100es new file mode 100644 index 0000000..d7ca41a --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.0.glsl100es @@ -0,0 +1,18 @@ +#version 100 +precision mediump float; +precision highp int; + +struct Color +{ + vec4 color; +}; + +uniform Color _color; + +varying highp vec2 vUV; + +void main() +{ + gl_FragData[0] = _color.color; +} + diff --git a/vendor/gioui.org/shader/gio/zblit.frag.0.glsl150 b/vendor/gioui.org/shader/gio/zblit.frag.0.glsl150 new file mode 100644 index 0000000..9559c85 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.0.glsl150 @@ -0,0 +1,17 @@ +#version 150 + +struct Color +{ + vec4 color; +}; + +uniform Color _color; + +out vec4 fragColor; +in vec2 vUV; + +void main() +{ + fragColor = _color.color; +} + diff --git a/vendor/gioui.org/shader/gio/zblit.frag.0.metallibios b/vendor/gioui.org/shader/gio/zblit.frag.0.metallibios Binary files differnew file mode 100644 index 0000000..63e606f --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zblit.frag.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zblit.frag.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..d8d2589 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zblit.frag.0.metallibmacos b/vendor/gioui.org/shader/gio/zblit.frag.0.metallibmacos Binary files differnew file mode 100644 index 0000000..85946aa --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zblit.frag.0.spirv b/vendor/gioui.org/shader/gio/zblit.frag.0.spirv Binary files differnew file mode 100644 index 0000000..c2a88d2 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.0.spirv diff --git a/vendor/gioui.org/shader/gio/zblit.frag.1.dxbc b/vendor/gioui.org/shader/gio/zblit.frag.1.dxbc Binary files differnew file mode 100644 index 0000000..ddb8dad --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.1.dxbc diff --git a/vendor/gioui.org/shader/gio/zblit.frag.1.glsl100es b/vendor/gioui.org/shader/gio/zblit.frag.1.glsl100es new file mode 100644 index 0000000..ccc6d2a --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.1.glsl100es @@ -0,0 +1,19 @@ +#version 100 +precision mediump float; +precision highp int; + +struct Gradient +{ + vec4 color1; + vec4 color2; +}; + +uniform Gradient _gradient; + +varying highp vec2 vUV; + +void main() +{ + gl_FragData[0] = mix(_gradient.color1, _gradient.color2, vec4(clamp(vUV.x, 0.0, 1.0))); +} + diff --git a/vendor/gioui.org/shader/gio/zblit.frag.1.glsl150 b/vendor/gioui.org/shader/gio/zblit.frag.1.glsl150 new file mode 100644 index 0000000..a55f29f --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.1.glsl150 @@ -0,0 +1,18 @@ +#version 150 + +struct Gradient +{ + vec4 color1; + vec4 color2; +}; + +uniform Gradient _gradient; + +out vec4 fragColor; +in vec2 vUV; + +void main() +{ + fragColor = mix(_gradient.color1, _gradient.color2, vec4(clamp(vUV.x, 0.0, 1.0))); +} + diff --git a/vendor/gioui.org/shader/gio/zblit.frag.1.metallibios b/vendor/gioui.org/shader/gio/zblit.frag.1.metallibios Binary files differnew file mode 100644 index 0000000..680c495 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.1.metallibios diff --git a/vendor/gioui.org/shader/gio/zblit.frag.1.metallibiossimulator b/vendor/gioui.org/shader/gio/zblit.frag.1.metallibiossimulator Binary files differnew file mode 100644 index 0000000..ef5ac86 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.1.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zblit.frag.1.metallibmacos b/vendor/gioui.org/shader/gio/zblit.frag.1.metallibmacos Binary files differnew file mode 100644 index 0000000..5fbd2c2 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.1.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zblit.frag.1.spirv b/vendor/gioui.org/shader/gio/zblit.frag.1.spirv Binary files differnew file mode 100644 index 0000000..88128fc --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.1.spirv diff --git a/vendor/gioui.org/shader/gio/zblit.frag.2.dxbc b/vendor/gioui.org/shader/gio/zblit.frag.2.dxbc Binary files differnew file mode 100644 index 0000000..fd95db8 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.2.dxbc diff --git a/vendor/gioui.org/shader/gio/zblit.frag.2.glsl100es b/vendor/gioui.org/shader/gio/zblit.frag.2.glsl100es new file mode 100644 index 0000000..5c2d832 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.2.glsl100es @@ -0,0 +1,13 @@ +#version 100 +precision mediump float; +precision highp int; + +uniform mediump sampler2D tex; + +varying highp vec2 vUV; + +void main() +{ + gl_FragData[0] = texture2D(tex, vUV); +} + diff --git a/vendor/gioui.org/shader/gio/zblit.frag.2.glsl150 b/vendor/gioui.org/shader/gio/zblit.frag.2.glsl150 new file mode 100644 index 0000000..f5df869 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.2.glsl150 @@ -0,0 +1,12 @@ +#version 150 + +uniform sampler2D tex; + +out vec4 fragColor; +in vec2 vUV; + +void main() +{ + fragColor = texture(tex, vUV); +} + diff --git a/vendor/gioui.org/shader/gio/zblit.frag.2.metallibios b/vendor/gioui.org/shader/gio/zblit.frag.2.metallibios Binary files differnew file mode 100644 index 0000000..c4eb922 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.2.metallibios diff --git a/vendor/gioui.org/shader/gio/zblit.frag.2.metallibiossimulator b/vendor/gioui.org/shader/gio/zblit.frag.2.metallibiossimulator Binary files differnew file mode 100644 index 0000000..81f7aa3 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.2.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zblit.frag.2.metallibmacos b/vendor/gioui.org/shader/gio/zblit.frag.2.metallibmacos Binary files differnew file mode 100644 index 0000000..70b3da8 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.2.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zblit.frag.2.spirv b/vendor/gioui.org/shader/gio/zblit.frag.2.spirv Binary files differnew file mode 100644 index 0000000..efa380b --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.frag.2.spirv diff --git a/vendor/gioui.org/shader/gio/zblit.vert.0.dxbc b/vendor/gioui.org/shader/gio/zblit.vert.0.dxbc Binary files differnew file mode 100644 index 0000000..5ad9601 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.vert.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zblit.vert.0.glsl100es b/vendor/gioui.org/shader/gio/zblit.vert.0.glsl100es new file mode 100644 index 0000000..61dee04 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.vert.0.glsl100es @@ -0,0 +1,37 @@ +#version 100 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec4 transform; + vec4 uvTransformR1; + vec4 uvTransformR2; +}; + +uniform Block _block; + +attribute vec2 pos; +varying vec2 vUV; +attribute vec2 uv; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vec2 p = (pos * _block.transform.xy) + _block.transform.zw; + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0)); + vec3 param_1 = vec3(p, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); + m3x2 param_2 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz); + vec3 param_3 = vec3(uv, 1.0); + vUV = transform3x2(param_2, param_3).xy; +} + diff --git a/vendor/gioui.org/shader/gio/zblit.vert.0.glsl150 b/vendor/gioui.org/shader/gio/zblit.vert.0.glsl150 new file mode 100644 index 0000000..eba9f1a --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.vert.0.glsl150 @@ -0,0 +1,37 @@ +#version 150 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec4 transform; + vec4 uvTransformR1; + vec4 uvTransformR2; +}; + +uniform Block _block; + +in vec2 pos; +out vec2 vUV; +in vec2 uv; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vec2 p = (pos * _block.transform.xy) + _block.transform.zw; + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0)); + vec3 param_1 = vec3(p, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); + m3x2 param_2 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz); + vec3 param_3 = vec3(uv, 1.0); + vUV = transform3x2(param_2, param_3).xy; +} + diff --git a/vendor/gioui.org/shader/gio/zblit.vert.0.metallibios b/vendor/gioui.org/shader/gio/zblit.vert.0.metallibios Binary files differnew file mode 100644 index 0000000..2450ec9 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.vert.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zblit.vert.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zblit.vert.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..6b4960b --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.vert.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zblit.vert.0.metallibmacos b/vendor/gioui.org/shader/gio/zblit.vert.0.metallibmacos Binary files differnew file mode 100644 index 0000000..d902b36 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.vert.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zblit.vert.0.spirv b/vendor/gioui.org/shader/gio/zblit.vert.0.spirv Binary files differnew file mode 100644 index 0000000..4f762bb --- /dev/null +++ b/vendor/gioui.org/shader/gio/zblit.vert.0.spirv diff --git a/vendor/gioui.org/shader/gio/zcopy.frag.0.dxbc b/vendor/gioui.org/shader/gio/zcopy.frag.0.dxbc Binary files differnew file mode 100644 index 0000000..a521803 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.frag.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zcopy.frag.0.glsl100es b/vendor/gioui.org/shader/gio/zcopy.frag.0.glsl100es new file mode 100644 index 0000000..b2dd95a --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.frag.0.glsl100es @@ -0,0 +1,27 @@ +#version 100 +precision mediump float; +precision highp int; + +uniform mediump sampler2D tex; + +varying highp 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.x = _59.x; + texel.y = _59.y; + texel.z = _59.z; + gl_FragData[0] = texel; +} + diff --git a/vendor/gioui.org/shader/gio/zcopy.frag.0.glsl150 b/vendor/gioui.org/shader/gio/zcopy.frag.0.glsl150 new file mode 100644 index 0000000..799add1 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.frag.0.glsl150 @@ -0,0 +1,26 @@ +#version 150 + +uniform sampler2D tex; + +in vec2 vUV; +out vec4 fragColor; + +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 = texture(tex, vUV); + vec3 param = texel.xyz; + vec3 _59 = sRGBtoRGB(param); + texel.x = _59.x; + texel.y = _59.y; + texel.z = _59.z; + fragColor = texel; +} + diff --git a/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibios b/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibios Binary files differnew file mode 100644 index 0000000..f143069 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..8fe4c74 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibmacos b/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibmacos Binary files differnew file mode 100644 index 0000000..2e43803 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.frag.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zcopy.frag.0.spirv b/vendor/gioui.org/shader/gio/zcopy.frag.0.spirv Binary files differnew file mode 100644 index 0000000..3299552 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.frag.0.spirv diff --git a/vendor/gioui.org/shader/gio/zcopy.vert.0.dxbc b/vendor/gioui.org/shader/gio/zcopy.vert.0.dxbc Binary files differnew file mode 100644 index 0000000..acce7ab --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.vert.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zcopy.vert.0.glsl100es b/vendor/gioui.org/shader/gio/zcopy.vert.0.glsl100es new file mode 100644 index 0000000..ff0be47 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.vert.0.glsl100es @@ -0,0 +1,35 @@ +#version 100 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec2 scale; + vec2 pos; + vec2 uvScale; +}; + +uniform Block _block; + +varying vec2 vUV; +attribute vec2 uv; +attribute vec2 pos; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vUV = vec2(uv * _block.uvScale); + vec2 p = vec2((pos * _block.scale) + _block.pos); + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0)); + vec3 param_1 = vec3(p, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); +} + diff --git a/vendor/gioui.org/shader/gio/zcopy.vert.0.glsl150 b/vendor/gioui.org/shader/gio/zcopy.vert.0.glsl150 new file mode 100644 index 0000000..036cd39 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.vert.0.glsl150 @@ -0,0 +1,35 @@ +#version 150 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec2 scale; + vec2 pos; + vec2 uvScale; +}; + +uniform Block _block; + +out vec2 vUV; +in vec2 uv; +in vec2 pos; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vUV = vec2(uv * _block.uvScale); + vec2 p = vec2((pos * _block.scale) + _block.pos); + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0)); + vec3 param_1 = vec3(p, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); +} + diff --git a/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibios b/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibios Binary files differnew file mode 100644 index 0000000..25f5e56 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..f696caf --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibmacos b/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibmacos Binary files differnew file mode 100644 index 0000000..d4a5777 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.vert.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zcopy.vert.0.spirv b/vendor/gioui.org/shader/gio/zcopy.vert.0.spirv Binary files differnew file mode 100644 index 0000000..7251754 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcopy.vert.0.spirv diff --git a/vendor/gioui.org/shader/gio/zcover.frag.0.dxbc b/vendor/gioui.org/shader/gio/zcover.frag.0.dxbc Binary files differnew file mode 100644 index 0000000..8b77ae4 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zcover.frag.0.glsl100es b/vendor/gioui.org/shader/gio/zcover.frag.0.glsl100es new file mode 100644 index 0000000..2399901 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.0.glsl100es @@ -0,0 +1,23 @@ +#version 100 +precision mediump float; +precision highp int; + +struct Color +{ + vec4 color; +}; + +uniform Color _color; + +uniform mediump sampler2D cover; + +varying highp vec2 vCoverUV; +varying highp vec2 vUV; + +void main() +{ + gl_FragData[0] = _color.color; + float c = min(abs(texture2D(cover, vCoverUV).x), 1.0); + gl_FragData[0] *= c; +} + diff --git a/vendor/gioui.org/shader/gio/zcover.frag.0.glsl150 b/vendor/gioui.org/shader/gio/zcover.frag.0.glsl150 new file mode 100644 index 0000000..ce1beaa --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.0.glsl150 @@ -0,0 +1,22 @@ +#version 150 + +struct Color +{ + vec4 color; +}; + +uniform Color _color; + +uniform sampler2D cover; + +out vec4 fragColor; +in vec2 vCoverUV; +in vec2 vUV; + +void main() +{ + fragColor = _color.color; + float c = min(abs(texture(cover, vCoverUV).x), 1.0); + fragColor *= c; +} + diff --git a/vendor/gioui.org/shader/gio/zcover.frag.0.metallibios b/vendor/gioui.org/shader/gio/zcover.frag.0.metallibios Binary files differnew file mode 100644 index 0000000..22256c8 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zcover.frag.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zcover.frag.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..c8040ad --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zcover.frag.0.metallibmacos b/vendor/gioui.org/shader/gio/zcover.frag.0.metallibmacos Binary files differnew file mode 100644 index 0000000..fe25160 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zcover.frag.0.spirv b/vendor/gioui.org/shader/gio/zcover.frag.0.spirv Binary files differnew file mode 100644 index 0000000..2061ff1 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.0.spirv diff --git a/vendor/gioui.org/shader/gio/zcover.frag.1.dxbc b/vendor/gioui.org/shader/gio/zcover.frag.1.dxbc Binary files differnew file mode 100644 index 0000000..c9a44cf --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.1.dxbc diff --git a/vendor/gioui.org/shader/gio/zcover.frag.1.glsl100es b/vendor/gioui.org/shader/gio/zcover.frag.1.glsl100es new file mode 100644 index 0000000..01cc88e --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.1.glsl100es @@ -0,0 +1,24 @@ +#version 100 +precision mediump float; +precision highp int; + +struct Gradient +{ + vec4 color1; + vec4 color2; +}; + +uniform Gradient _gradient; + +uniform mediump sampler2D cover; + +varying highp vec2 vUV; +varying highp vec2 vCoverUV; + +void main() +{ + gl_FragData[0] = mix(_gradient.color1, _gradient.color2, vec4(clamp(vUV.x, 0.0, 1.0))); + float c = min(abs(texture2D(cover, vCoverUV).x), 1.0); + gl_FragData[0] *= c; +} + diff --git a/vendor/gioui.org/shader/gio/zcover.frag.1.glsl150 b/vendor/gioui.org/shader/gio/zcover.frag.1.glsl150 new file mode 100644 index 0000000..3f832c3 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.1.glsl150 @@ -0,0 +1,23 @@ +#version 150 + +struct Gradient +{ + vec4 color1; + vec4 color2; +}; + +uniform Gradient _gradient; + +uniform sampler2D cover; + +out vec4 fragColor; +in vec2 vUV; +in vec2 vCoverUV; + +void main() +{ + fragColor = mix(_gradient.color1, _gradient.color2, vec4(clamp(vUV.x, 0.0, 1.0))); + float c = min(abs(texture(cover, vCoverUV).x), 1.0); + fragColor *= c; +} + diff --git a/vendor/gioui.org/shader/gio/zcover.frag.1.metallibios b/vendor/gioui.org/shader/gio/zcover.frag.1.metallibios Binary files differnew file mode 100644 index 0000000..228996a --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.1.metallibios diff --git a/vendor/gioui.org/shader/gio/zcover.frag.1.metallibiossimulator b/vendor/gioui.org/shader/gio/zcover.frag.1.metallibiossimulator Binary files differnew file mode 100644 index 0000000..1c99553 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.1.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zcover.frag.1.metallibmacos b/vendor/gioui.org/shader/gio/zcover.frag.1.metallibmacos Binary files differnew file mode 100644 index 0000000..889e249 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.1.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zcover.frag.1.spirv b/vendor/gioui.org/shader/gio/zcover.frag.1.spirv Binary files differnew file mode 100644 index 0000000..4c48d20 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.1.spirv diff --git a/vendor/gioui.org/shader/gio/zcover.frag.2.dxbc b/vendor/gioui.org/shader/gio/zcover.frag.2.dxbc Binary files differnew file mode 100644 index 0000000..d8c6a80 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.2.dxbc diff --git a/vendor/gioui.org/shader/gio/zcover.frag.2.glsl100es b/vendor/gioui.org/shader/gio/zcover.frag.2.glsl100es new file mode 100644 index 0000000..7cfde4b --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.2.glsl100es @@ -0,0 +1,17 @@ +#version 100 +precision mediump float; +precision highp int; + +uniform mediump sampler2D tex; +uniform mediump sampler2D cover; + +varying highp vec2 vUV; +varying highp vec2 vCoverUV; + +void main() +{ + gl_FragData[0] = texture2D(tex, vUV); + float c = min(abs(texture2D(cover, vCoverUV).x), 1.0); + gl_FragData[0] *= c; +} + diff --git a/vendor/gioui.org/shader/gio/zcover.frag.2.glsl150 b/vendor/gioui.org/shader/gio/zcover.frag.2.glsl150 new file mode 100644 index 0000000..939baee --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.2.glsl150 @@ -0,0 +1,16 @@ +#version 150 + +uniform sampler2D tex; +uniform sampler2D cover; + +out vec4 fragColor; +in vec2 vUV; +in vec2 vCoverUV; + +void main() +{ + fragColor = texture(tex, vUV); + float c = min(abs(texture(cover, vCoverUV).x), 1.0); + fragColor *= c; +} + diff --git a/vendor/gioui.org/shader/gio/zcover.frag.2.metallibios b/vendor/gioui.org/shader/gio/zcover.frag.2.metallibios Binary files differnew file mode 100644 index 0000000..6eba400 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.2.metallibios diff --git a/vendor/gioui.org/shader/gio/zcover.frag.2.metallibiossimulator b/vendor/gioui.org/shader/gio/zcover.frag.2.metallibiossimulator Binary files differnew file mode 100644 index 0000000..09ddb1f --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.2.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zcover.frag.2.metallibmacos b/vendor/gioui.org/shader/gio/zcover.frag.2.metallibmacos Binary files differnew file mode 100644 index 0000000..3ba9105 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.2.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zcover.frag.2.spirv b/vendor/gioui.org/shader/gio/zcover.frag.2.spirv Binary files differnew file mode 100644 index 0000000..cd618ce --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.frag.2.spirv diff --git a/vendor/gioui.org/shader/gio/zcover.vert.0.dxbc b/vendor/gioui.org/shader/gio/zcover.vert.0.dxbc Binary files differnew file mode 100644 index 0000000..3b6cf6b --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.vert.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zcover.vert.0.glsl100es b/vendor/gioui.org/shader/gio/zcover.vert.0.glsl100es new file mode 100644 index 0000000..423ca60 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.vert.0.glsl100es @@ -0,0 +1,41 @@ +#version 100 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec4 transform; + vec4 uvCoverTransform; + vec4 uvTransformR1; + vec4 uvTransformR2; +}; + +uniform Block _block; + +attribute vec2 pos; +varying vec2 vUV; +attribute vec2 uv; +varying vec2 vCoverUV; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vec2 p = vec2((pos * _block.transform.xy) + _block.transform.zw); + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0)); + vec3 param_1 = vec3(p, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); + m3x2 param_2 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz); + vec3 param_3 = vec3(uv, 1.0); + vUV = transform3x2(param_2, param_3).xy; + vec3 uv3 = vec3(uv, 1.0); + vCoverUV = ((uv3 * vec3(_block.uvCoverTransform.xy, 1.0)) + vec3(_block.uvCoverTransform.zw, 0.0)).xy; +} + diff --git a/vendor/gioui.org/shader/gio/zcover.vert.0.glsl150 b/vendor/gioui.org/shader/gio/zcover.vert.0.glsl150 new file mode 100644 index 0000000..a5005d6 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.vert.0.glsl150 @@ -0,0 +1,41 @@ +#version 150 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec4 transform; + vec4 uvCoverTransform; + vec4 uvTransformR1; + vec4 uvTransformR2; +}; + +uniform Block _block; + +in vec2 pos; +out vec2 vUV; +in vec2 uv; +out vec2 vCoverUV; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vec2 p = vec2((pos * _block.transform.xy) + _block.transform.zw); + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0)); + vec3 param_1 = vec3(p, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); + m3x2 param_2 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz); + vec3 param_3 = vec3(uv, 1.0); + vUV = transform3x2(param_2, param_3).xy; + vec3 uv3 = vec3(uv, 1.0); + vCoverUV = ((uv3 * vec3(_block.uvCoverTransform.xy, 1.0)) + vec3(_block.uvCoverTransform.zw, 0.0)).xy; +} + diff --git a/vendor/gioui.org/shader/gio/zcover.vert.0.metallibios b/vendor/gioui.org/shader/gio/zcover.vert.0.metallibios Binary files differnew file mode 100644 index 0000000..335704b --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.vert.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zcover.vert.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zcover.vert.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..96470cd --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.vert.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zcover.vert.0.metallibmacos b/vendor/gioui.org/shader/gio/zcover.vert.0.metallibmacos Binary files differnew file mode 100644 index 0000000..629e82b --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.vert.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zcover.vert.0.spirv b/vendor/gioui.org/shader/gio/zcover.vert.0.spirv Binary files differnew file mode 100644 index 0000000..f9af8ab --- /dev/null +++ b/vendor/gioui.org/shader/gio/zcover.vert.0.spirv diff --git a/vendor/gioui.org/shader/gio/zinput.vert.0.dxbc b/vendor/gioui.org/shader/gio/zinput.vert.0.dxbc Binary files differnew file mode 100644 index 0000000..096bd01 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zinput.vert.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zinput.vert.0.glsl100es b/vendor/gioui.org/shader/gio/zinput.vert.0.glsl100es new file mode 100644 index 0000000..d1d4c8d --- /dev/null +++ b/vendor/gioui.org/shader/gio/zinput.vert.0.glsl100es @@ -0,0 +1,22 @@ +#version 100 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +attribute vec4 position; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0)); + vec3 param_1 = position.xyz; + gl_Position = vec4(transform3x2(param, param_1), position.w); +} + diff --git a/vendor/gioui.org/shader/gio/zinput.vert.0.glsl150 b/vendor/gioui.org/shader/gio/zinput.vert.0.glsl150 new file mode 100644 index 0000000..ab28308 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zinput.vert.0.glsl150 @@ -0,0 +1,22 @@ +#version 150 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +in vec4 position; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0)); + vec3 param_1 = position.xyz; + gl_Position = vec4(transform3x2(param, param_1), position.w); +} + diff --git a/vendor/gioui.org/shader/gio/zinput.vert.0.metallibios b/vendor/gioui.org/shader/gio/zinput.vert.0.metallibios Binary files differnew file mode 100644 index 0000000..6fdc427 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zinput.vert.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zinput.vert.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zinput.vert.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..da28890 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zinput.vert.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zinput.vert.0.metallibmacos b/vendor/gioui.org/shader/gio/zinput.vert.0.metallibmacos Binary files differnew file mode 100644 index 0000000..064c501 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zinput.vert.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zinput.vert.0.spirv b/vendor/gioui.org/shader/gio/zinput.vert.0.spirv Binary files differnew file mode 100644 index 0000000..eb999e5 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zinput.vert.0.spirv diff --git a/vendor/gioui.org/shader/gio/zintersect.frag.0.dxbc b/vendor/gioui.org/shader/gio/zintersect.frag.0.dxbc Binary files differnew file mode 100644 index 0000000..f2081ee --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.frag.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zintersect.frag.0.glsl100es b/vendor/gioui.org/shader/gio/zintersect.frag.0.glsl100es new file mode 100644 index 0000000..90fe2f9 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.frag.0.glsl100es @@ -0,0 +1,13 @@ +#version 100 +precision mediump float; +precision highp int; + +uniform mediump sampler2D cover; + +varying highp vec2 vUV; + +void main() +{ + gl_FragData[0].x = abs(texture2D(cover, vUV).x); +} + diff --git a/vendor/gioui.org/shader/gio/zintersect.frag.0.glsl150 b/vendor/gioui.org/shader/gio/zintersect.frag.0.glsl150 new file mode 100644 index 0000000..f574aae --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.frag.0.glsl150 @@ -0,0 +1,12 @@ +#version 150 + +uniform sampler2D cover; + +out vec4 fragColor; +in vec2 vUV; + +void main() +{ + fragColor.x = abs(texture(cover, vUV).x); +} + diff --git a/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibios b/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibios Binary files differnew file mode 100644 index 0000000..f48da4e --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..b1a40c4 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibmacos b/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibmacos Binary files differnew file mode 100644 index 0000000..f16d190 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.frag.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zintersect.frag.0.spirv b/vendor/gioui.org/shader/gio/zintersect.frag.0.spirv Binary files differnew file mode 100644 index 0000000..6c28644 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.frag.0.spirv diff --git a/vendor/gioui.org/shader/gio/zintersect.vert.0.dxbc b/vendor/gioui.org/shader/gio/zintersect.vert.0.dxbc Binary files differnew file mode 100644 index 0000000..03005ea --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.vert.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zintersect.vert.0.glsl100es b/vendor/gioui.org/shader/gio/zintersect.vert.0.glsl100es new file mode 100644 index 0000000..4441763 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.vert.0.glsl100es @@ -0,0 +1,35 @@ +#version 100 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec4 uvTransform; + vec4 subUVTransform; +}; + +uniform Block _block; + +attribute vec2 pos; +varying vec2 vUV; +attribute vec2 uv; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0)); + vec3 param_1 = vec3(pos, 1.0); + vec3 p = transform3x2(param, param_1); + gl_Position = vec4(p, 1.0); + vUV = (uv * _block.subUVTransform.xy) + _block.subUVTransform.zw; + vUV = (vUV * _block.uvTransform.xy) + _block.uvTransform.zw; +} + diff --git a/vendor/gioui.org/shader/gio/zintersect.vert.0.glsl150 b/vendor/gioui.org/shader/gio/zintersect.vert.0.glsl150 new file mode 100644 index 0000000..656b4c9 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.vert.0.glsl150 @@ -0,0 +1,35 @@ +#version 150 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec4 uvTransform; + vec4 subUVTransform; +}; + +uniform Block _block; + +in vec2 pos; +out vec2 vUV; +in vec2 uv; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0)); + vec3 param_1 = vec3(pos, 1.0); + vec3 p = transform3x2(param, param_1); + gl_Position = vec4(p, 1.0); + vUV = (uv * _block.subUVTransform.xy) + _block.subUVTransform.zw; + vUV = (vUV * _block.uvTransform.xy) + _block.uvTransform.zw; +} + diff --git a/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibios b/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibios Binary files differnew file mode 100644 index 0000000..975fbb8 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..682bad1 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibmacos b/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibmacos Binary files differnew file mode 100644 index 0000000..a43236d --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.vert.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zintersect.vert.0.spirv b/vendor/gioui.org/shader/gio/zintersect.vert.0.spirv Binary files differnew file mode 100644 index 0000000..13e7335 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zintersect.vert.0.spirv diff --git a/vendor/gioui.org/shader/gio/zmaterial.frag.0.dxbc b/vendor/gioui.org/shader/gio/zmaterial.frag.0.dxbc Binary files differnew file mode 100644 index 0000000..e250378 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.frag.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zmaterial.frag.0.glsl100es b/vendor/gioui.org/shader/gio/zmaterial.frag.0.glsl100es new file mode 100644 index 0000000..f2f2a30 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.frag.0.glsl100es @@ -0,0 +1,37 @@ +#version 100 +precision mediump float; +precision highp int; + +struct Color +{ + float emulateSRGB; +}; + +uniform Color _color; + +uniform mediump sampler2D tex; + +varying highp vec2 vUV; + +vec3 RGBtosRGB(vec3 rgb) +{ + bvec3 cutoff = greaterThanEqual(rgb, vec3(0.003130800090730190277099609375)); + vec3 below = vec3(12.9200000762939453125) * rgb; + vec3 above = (vec3(1.05499994754791259765625) * pow(rgb, vec3(0.416660010814666748046875))) - vec3(0.054999999701976776123046875); + 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); + if (_color.emulateSRGB == 0.0) + { + vec3 param = texel.xyz; + vec3 _71 = RGBtosRGB(param); + texel.x = _71.x; + texel.y = _71.y; + texel.z = _71.z; + } + gl_FragData[0] = texel; +} + diff --git a/vendor/gioui.org/shader/gio/zmaterial.frag.0.glsl150 b/vendor/gioui.org/shader/gio/zmaterial.frag.0.glsl150 new file mode 100644 index 0000000..6b8bed3 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.frag.0.glsl150 @@ -0,0 +1,36 @@ +#version 150 + +struct Color +{ + float emulateSRGB; +}; + +uniform Color _color; + +uniform sampler2D tex; + +in vec2 vUV; +out vec4 fragColor; + +vec3 RGBtosRGB(vec3 rgb) +{ + bvec3 cutoff = greaterThanEqual(rgb, vec3(0.003130800090730190277099609375)); + vec3 below = vec3(12.9200000762939453125) * rgb; + vec3 above = (vec3(1.05499994754791259765625) * pow(rgb, vec3(0.416660010814666748046875))) - vec3(0.054999999701976776123046875); + return vec3(cutoff.x ? above.x : below.x, cutoff.y ? above.y : below.y, cutoff.z ? above.z : below.z); +} + +void main() +{ + vec4 texel = texture(tex, vUV); + if (_color.emulateSRGB == 0.0) + { + vec3 param = texel.xyz; + vec3 _71 = RGBtosRGB(param); + texel.x = _71.x; + texel.y = _71.y; + texel.z = _71.z; + } + fragColor = texel; +} + diff --git a/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibios b/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibios Binary files differnew file mode 100644 index 0000000..8679f2a --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..6306d9a --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibmacos b/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibmacos Binary files differnew file mode 100644 index 0000000..911948e --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.frag.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zmaterial.frag.0.spirv b/vendor/gioui.org/shader/gio/zmaterial.frag.0.spirv Binary files differnew file mode 100644 index 0000000..475cfb8 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.frag.0.spirv diff --git a/vendor/gioui.org/shader/gio/zmaterial.vert.0.dxbc b/vendor/gioui.org/shader/gio/zmaterial.vert.0.dxbc Binary files differnew file mode 100644 index 0000000..a5056cc --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.vert.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zmaterial.vert.0.glsl100es b/vendor/gioui.org/shader/gio/zmaterial.vert.0.glsl100es new file mode 100644 index 0000000..39a7b50 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.vert.0.glsl100es @@ -0,0 +1,34 @@ +#version 100 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec2 scale; + vec2 pos; +}; + +uniform Block _block; + +varying vec2 vUV; +attribute vec2 uv; +attribute vec2 pos; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vUV = uv; + vec2 p = vec2((pos * _block.scale) + _block.pos); + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0)); + vec3 param_1 = vec3(p, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); +} + diff --git a/vendor/gioui.org/shader/gio/zmaterial.vert.0.glsl150 b/vendor/gioui.org/shader/gio/zmaterial.vert.0.glsl150 new file mode 100644 index 0000000..be02b44 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.vert.0.glsl150 @@ -0,0 +1,34 @@ +#version 150 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec2 scale; + vec2 pos; +}; + +uniform Block _block; + +out vec2 vUV; +in vec2 uv; +in vec2 pos; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vUV = uv; + vec2 p = vec2((pos * _block.scale) + _block.pos); + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0)); + vec3 param_1 = vec3(p, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); +} + diff --git a/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibios b/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibios Binary files differnew file mode 100644 index 0000000..19cf6d8 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..c710ca9 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibmacos b/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibmacos Binary files differnew file mode 100644 index 0000000..cfbdfbc --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.vert.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zmaterial.vert.0.spirv b/vendor/gioui.org/shader/gio/zmaterial.vert.0.spirv Binary files differnew file mode 100644 index 0000000..18e731f --- /dev/null +++ b/vendor/gioui.org/shader/gio/zmaterial.vert.0.spirv diff --git a/vendor/gioui.org/shader/gio/zsimple.frag.0.dxbc b/vendor/gioui.org/shader/gio/zsimple.frag.0.dxbc Binary files differnew file mode 100644 index 0000000..f4f8894 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zsimple.frag.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zsimple.frag.0.glsl100es b/vendor/gioui.org/shader/gio/zsimple.frag.0.glsl100es new file mode 100644 index 0000000..0f86af5 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zsimple.frag.0.glsl100es @@ -0,0 +1,9 @@ +#version 100 +precision mediump float; +precision highp int; + +void main() +{ + gl_FragData[0] = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0); +} + diff --git a/vendor/gioui.org/shader/gio/zsimple.frag.0.glsl150 b/vendor/gioui.org/shader/gio/zsimple.frag.0.glsl150 new file mode 100644 index 0000000..db4c060 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zsimple.frag.0.glsl150 @@ -0,0 +1,9 @@ +#version 150 + +out vec4 fragColor; + +void main() +{ + fragColor = vec4(0.25, 0.550000011920928955078125, 0.75, 1.0); +} + diff --git a/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibios b/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibios Binary files differnew file mode 100644 index 0000000..05e6329 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..2c87af9 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibmacos b/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibmacos Binary files differnew file mode 100644 index 0000000..407d7ea --- /dev/null +++ b/vendor/gioui.org/shader/gio/zsimple.frag.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zsimple.frag.0.spirv b/vendor/gioui.org/shader/gio/zsimple.frag.0.spirv Binary files differnew file mode 100644 index 0000000..2b2aba3 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zsimple.frag.0.spirv diff --git a/vendor/gioui.org/shader/gio/zstencil.frag.0.dxbc b/vendor/gioui.org/shader/gio/zstencil.frag.0.dxbc Binary files differnew file mode 100644 index 0000000..ded34dc --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.frag.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zstencil.frag.0.glsl100es b/vendor/gioui.org/shader/gio/zstencil.frag.0.glsl100es new file mode 100644 index 0000000..15530e3 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.frag.0.glsl100es @@ -0,0 +1,38 @@ +#version 100 +precision mediump float; +precision highp int; + +varying highp vec2 vTo; +varying highp vec2 vFrom; +varying highp vec2 vCtrl; + +void main() +{ + float dx = vTo.x - vFrom.x; + bool increasing = vTo.x >= vFrom.x; + bvec2 _35 = bvec2(increasing); + vec2 left = vec2(_35.x ? vFrom.x : vTo.x, _35.y ? vFrom.y : vTo.y); + bvec2 _41 = bvec2(increasing); + vec2 right = vec2(_41.x ? vTo.x : vFrom.x, _41.y ? vTo.y : vFrom.y); + vec2 extent = clamp(vec2(vFrom.x, vTo.x), vec2(-0.5), vec2(0.5)); + float midx = mix(extent.x, extent.y, 0.5); + float x0 = midx - left.x; + vec2 p1 = vCtrl - left; + vec2 v = right - vCtrl; + float t = x0 / (p1.x + sqrt((p1.x * p1.x) + ((v.x - p1.x) * x0))); + float y = mix(mix(left.y, vCtrl.y, t), mix(vCtrl.y, right.y, t), t); + vec2 d_half = mix(p1, v, vec2(t)); + float dy = d_half.y / d_half.x; + float width = extent.y - extent.x; + dy = abs(dy * width); + vec4 sides = vec4((dy * 0.5) + y, (dy * (-0.5)) + y, (0.5 - y) / dy, ((-0.5) - y) / dy); + sides = clamp(sides + vec4(0.5), vec4(0.0), vec4(1.0)); + float area = 0.5 * ((((sides.z - (sides.z * sides.y)) + 1.0) - sides.x) + (sides.x * sides.w)); + area *= width; + if (width == 0.0) + { + area = 0.0; + } + gl_FragData[0].x = area; +} + diff --git a/vendor/gioui.org/shader/gio/zstencil.frag.0.glsl150 b/vendor/gioui.org/shader/gio/zstencil.frag.0.glsl150 new file mode 100644 index 0000000..8e2abd8 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.frag.0.glsl150 @@ -0,0 +1,37 @@ +#version 150 + +in vec2 vTo; +in vec2 vFrom; +in vec2 vCtrl; +out vec4 fragCover; + +void main() +{ + float dx = vTo.x - vFrom.x; + bool increasing = vTo.x >= vFrom.x; + bvec2 _35 = bvec2(increasing); + vec2 left = vec2(_35.x ? vFrom.x : vTo.x, _35.y ? vFrom.y : vTo.y); + bvec2 _41 = bvec2(increasing); + vec2 right = vec2(_41.x ? vTo.x : vFrom.x, _41.y ? vTo.y : vFrom.y); + vec2 extent = clamp(vec2(vFrom.x, vTo.x), vec2(-0.5), vec2(0.5)); + float midx = mix(extent.x, extent.y, 0.5); + float x0 = midx - left.x; + vec2 p1 = vCtrl - left; + vec2 v = right - vCtrl; + float t = x0 / (p1.x + sqrt((p1.x * p1.x) + ((v.x - p1.x) * x0))); + float y = mix(mix(left.y, vCtrl.y, t), mix(vCtrl.y, right.y, t), t); + vec2 d_half = mix(p1, v, vec2(t)); + float dy = d_half.y / d_half.x; + float width = extent.y - extent.x; + dy = abs(dy * width); + vec4 sides = vec4((dy * 0.5) + y, (dy * (-0.5)) + y, (0.5 - y) / dy, ((-0.5) - y) / dy); + sides = clamp(sides + vec4(0.5), vec4(0.0), vec4(1.0)); + float area = 0.5 * ((((sides.z - (sides.z * sides.y)) + 1.0) - sides.x) + (sides.x * sides.w)); + area *= width; + if (width == 0.0) + { + area = 0.0; + } + fragCover.x = area; +} + diff --git a/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibios b/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibios Binary files differnew file mode 100644 index 0000000..52f668f --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..3fbfa8f --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibmacos b/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibmacos Binary files differnew file mode 100644 index 0000000..358a02a --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.frag.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zstencil.frag.0.spirv b/vendor/gioui.org/shader/gio/zstencil.frag.0.spirv Binary files differnew file mode 100644 index 0000000..9a22d9e --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.frag.0.spirv diff --git a/vendor/gioui.org/shader/gio/zstencil.vert.0.dxbc b/vendor/gioui.org/shader/gio/zstencil.vert.0.dxbc Binary files differnew file mode 100644 index 0000000..505672f --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.vert.0.dxbc diff --git a/vendor/gioui.org/shader/gio/zstencil.vert.0.glsl100es b/vendor/gioui.org/shader/gio/zstencil.vert.0.glsl100es new file mode 100644 index 0000000..c8e1261 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.vert.0.glsl100es @@ -0,0 +1,64 @@ +#version 100 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec4 transform; + vec2 pathOffset; +}; + +uniform Block _block; + +attribute vec2 from; +attribute vec2 ctrl; +attribute vec2 to; +attribute float maxy; +attribute float corner; +varying vec2 vFrom; +varying vec2 vCtrl; +varying vec2 vTo; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vec2 from_1 = from + _block.pathOffset; + vec2 ctrl_1 = ctrl + _block.pathOffset; + vec2 to_1 = to + _block.pathOffset; + float maxy_1 = maxy + _block.pathOffset.y; + float c = corner; + vec2 pos; + if (c >= 0.375) + { + c -= 0.5; + pos.y = maxy_1 + 1.0; + } + else + { + pos.y = min(min(from_1.y, ctrl_1.y), to_1.y) - 1.0; + } + if (c >= 0.125) + { + pos.x = max(max(from_1.x, ctrl_1.x), to_1.x) + 1.0; + } + else + { + pos.x = min(min(from_1.x, ctrl_1.x), to_1.x) - 1.0; + } + vFrom = from_1 - pos; + vCtrl = ctrl_1 - pos; + vTo = to_1 - pos; + pos = (pos * _block.transform.xy) + _block.transform.zw; + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0)); + vec3 param_1 = vec3(pos, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); +} + diff --git a/vendor/gioui.org/shader/gio/zstencil.vert.0.glsl150 b/vendor/gioui.org/shader/gio/zstencil.vert.0.glsl150 new file mode 100644 index 0000000..9ae6c9b --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.vert.0.glsl150 @@ -0,0 +1,64 @@ +#version 150 + +struct m3x2 +{ + vec3 r0; + vec3 r1; +}; + +struct Block +{ + vec4 transform; + vec2 pathOffset; +}; + +uniform Block _block; + +in vec2 from; +in vec2 ctrl; +in vec2 to; +in float maxy; +in float corner; +out vec2 vFrom; +out vec2 vCtrl; +out vec2 vTo; + +vec3 transform3x2(m3x2 t, vec3 v) +{ + return vec3(dot(t.r0, v), dot(t.r1, v), dot(vec3(0.0, 0.0, 1.0), v)); +} + +void main() +{ + vec2 from_1 = from + _block.pathOffset; + vec2 ctrl_1 = ctrl + _block.pathOffset; + vec2 to_1 = to + _block.pathOffset; + float maxy_1 = maxy + _block.pathOffset.y; + float c = corner; + vec2 pos; + if (c >= 0.375) + { + c -= 0.5; + pos.y = maxy_1 + 1.0; + } + else + { + pos.y = min(min(from_1.y, ctrl_1.y), to_1.y) - 1.0; + } + if (c >= 0.125) + { + pos.x = max(max(from_1.x, ctrl_1.x), to_1.x) + 1.0; + } + else + { + pos.x = min(min(from_1.x, ctrl_1.x), to_1.x) - 1.0; + } + vFrom = from_1 - pos; + vCtrl = ctrl_1 - pos; + vTo = to_1 - pos; + pos = (pos * _block.transform.xy) + _block.transform.zw; + m3x2 param = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0)); + vec3 param_1 = vec3(pos, 0.0); + gl_Position = vec4(transform3x2(param, param_1), 1.0); +} + diff --git a/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibios b/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibios Binary files differnew file mode 100644 index 0000000..75ac068 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibios diff --git a/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibiossimulator b/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..9ba5f58 --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibmacos b/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibmacos Binary files differnew file mode 100644 index 0000000..4de454d --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.vert.0.metallibmacos diff --git a/vendor/gioui.org/shader/gio/zstencil.vert.0.spirv b/vendor/gioui.org/shader/gio/zstencil.vert.0.spirv Binary files differnew file mode 100644 index 0000000..b45803f --- /dev/null +++ b/vendor/gioui.org/shader/gio/zstencil.vert.0.spirv diff --git a/vendor/gioui.org/shader/go.mod b/vendor/gioui.org/shader/go.mod new file mode 100644 index 0000000..4c9167c --- /dev/null +++ b/vendor/gioui.org/shader/go.mod @@ -0,0 +1,5 @@ +module gioui.org/shader + +go 1.16 + +require gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334 diff --git a/vendor/gioui.org/shader/go.sum b/vendor/gioui.org/shader/go.sum new file mode 100644 index 0000000..ec5a47a --- /dev/null +++ b/vendor/gioui.org/shader/go.sum @@ -0,0 +1,2 @@ +gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334 h1:1xK224B5DnjlPKCfVDTl7+olrzgAXn4ym6dum3l34rs= +gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= diff --git a/vendor/gioui.org/shader/piet/abi.h b/vendor/gioui.org/shader/piet/abi.h new file mode 100644 index 0000000..365d936 --- /dev/null +++ b/vendor/gioui.org/shader/piet/abi.h @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: Unlicense OR MIT + +#define ALIGN(bytes, type) type __attribute__((aligned(bytes))) + +typedef ALIGN(8, uint8_t) byte8[8]; +typedef ALIGN(8, uint16_t) word4[4]; +typedef ALIGN(4, uint32_t) dword; +typedef ALIGN(16, uint32_t) dword4[4]; +typedef ALIGN(8, uint64_t) qword; +typedef ALIGN(16, uint64_t) qword2[2]; +typedef ALIGN(16, unsigned int) uint4[4]; +typedef ALIGN(8, uint32_t) dword2[2]; +typedef ALIGN(8, unsigned short) ushort4[4]; +typedef ALIGN(16, float) float4[4]; +typedef ALIGN(16, int) int4[4]; + +typedef unsigned short half; + +typedef unsigned char bool; + +enum { + MAX_BOUND_DESCRIPTOR_SETS = 4, + MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC = 8, + MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC = 4, + MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC = + MAX_DESCRIPTOR_SET_UNIFORM_BUFFERS_DYNAMIC + + MAX_DESCRIPTOR_SET_STORAGE_BUFFERS_DYNAMIC, + MAX_PUSH_CONSTANT_SIZE = 128, + + MIN_STORAGE_BUFFER_OFFSET_ALIGNMENT = 256, + + REQUIRED_MEMORY_ALIGNMENT = 16, + + SIMD_WIDTH = 4, +}; + +struct image_descriptor { + ALIGN(16, void *ptr); + int width; + int height; + int depth; + int row_pitch_bytes; + int slice_pitch_bytes; + int sample_pitch_bytes; + int sample_count; + int size_in_bytes; + + void *stencil_ptr; + int stencil_row_pitch_bytes; + int stencil_slice_pitch_bytes; + int stencil_sample_pitch_bytes; + + // TODO: unused? + void *memoryOwner; +}; + +struct buffer_descriptor { + ALIGN(16, void *ptr); + int size_in_bytes; + int robustness_size; +}; + +struct program_data { + uint8_t *descriptor_sets[MAX_BOUND_DESCRIPTOR_SETS]; + uint32_t descriptor_dynamic_offsets[MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC]; + uint4 num_workgroups; + uint4 workgroup_size; + uint32_t invocations_per_subgroup; + uint32_t subgroups_per_workgroup; + uint32_t invocations_per_workgroup; + unsigned char push_constants[MAX_PUSH_CONSTANT_SIZE]; + // Unused. + void *constants; +}; + +typedef int32_t yield_result; + +typedef void * coroutine; + +typedef coroutine (*routine_begin)(struct program_data *data, + int32_t workgroupX, + int32_t workgroupY, + int32_t workgroupZ, + void *workgroupMemory, + int32_t firstSubgroup, + int32_t subgroupCount); + +typedef bool (*routine_await)(coroutine r, yield_result *res); + +typedef void (*routine_destroy)(coroutine r); + diff --git a/vendor/gioui.org/shader/piet/annotated.h b/vendor/gioui.org/shader/piet/annotated.h new file mode 100644 index 0000000..6b18155 --- /dev/null +++ b/vendor/gioui.org/shader/piet/annotated.h @@ -0,0 +1,225 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Code auto-generated by piet-gpu-derive + +struct AnnoImageRef { + uint offset; +}; + +struct AnnoColorRef { + uint offset; +}; + +struct AnnoBeginClipRef { + uint offset; +}; + +struct AnnoEndClipRef { + uint offset; +}; + +struct AnnotatedRef { + uint offset; +}; + +struct AnnoImage { + vec4 bbox; + float linewidth; + uint index; + ivec2 offset; +}; + +#define AnnoImage_size 28 + +AnnoImageRef AnnoImage_index(AnnoImageRef ref, uint index) { + return AnnoImageRef(ref.offset + index * AnnoImage_size); +} + +struct AnnoColor { + vec4 bbox; + float linewidth; + uint rgba_color; +}; + +#define AnnoColor_size 24 + +AnnoColorRef AnnoColor_index(AnnoColorRef ref, uint index) { + return AnnoColorRef(ref.offset + index * AnnoColor_size); +} + +struct AnnoBeginClip { + vec4 bbox; + float linewidth; +}; + +#define AnnoBeginClip_size 20 + +AnnoBeginClipRef AnnoBeginClip_index(AnnoBeginClipRef ref, uint index) { + return AnnoBeginClipRef(ref.offset + index * AnnoBeginClip_size); +} + +struct AnnoEndClip { + vec4 bbox; +}; + +#define AnnoEndClip_size 16 + +AnnoEndClipRef AnnoEndClip_index(AnnoEndClipRef ref, uint index) { + return AnnoEndClipRef(ref.offset + index * AnnoEndClip_size); +} + +#define Annotated_Nop 0 +#define Annotated_Color 1 +#define Annotated_Image 2 +#define Annotated_BeginClip 3 +#define Annotated_EndClip 4 +#define Annotated_size 32 + +AnnotatedRef Annotated_index(AnnotatedRef ref, uint index) { + return AnnotatedRef(ref.offset + index * Annotated_size); +} + +struct AnnotatedTag { + uint tag; + uint flags; +}; + +AnnoImage AnnoImage_read(Alloc a, AnnoImageRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + uint raw2 = read_mem(a, ix + 2); + uint raw3 = read_mem(a, ix + 3); + uint raw4 = read_mem(a, ix + 4); + uint raw5 = read_mem(a, ix + 5); + uint raw6 = read_mem(a, ix + 6); + AnnoImage s; + s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.linewidth = uintBitsToFloat(raw4); + s.index = raw5; + s.offset = ivec2(int(raw6 << 16) >> 16, int(raw6) >> 16); + return s; +} + +void AnnoImage_write(Alloc a, AnnoImageRef ref, AnnoImage s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, floatBitsToUint(s.bbox.x)); + write_mem(a, ix + 1, floatBitsToUint(s.bbox.y)); + write_mem(a, ix + 2, floatBitsToUint(s.bbox.z)); + write_mem(a, ix + 3, floatBitsToUint(s.bbox.w)); + write_mem(a, ix + 4, floatBitsToUint(s.linewidth)); + write_mem(a, ix + 5, s.index); + write_mem(a, ix + 6, (uint(s.offset.x) & 0xffff) | (uint(s.offset.y) << 16)); +} + +AnnoColor AnnoColor_read(Alloc a, AnnoColorRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + uint raw2 = read_mem(a, ix + 2); + uint raw3 = read_mem(a, ix + 3); + uint raw4 = read_mem(a, ix + 4); + uint raw5 = read_mem(a, ix + 5); + AnnoColor s; + s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.linewidth = uintBitsToFloat(raw4); + s.rgba_color = raw5; + return s; +} + +void AnnoColor_write(Alloc a, AnnoColorRef ref, AnnoColor s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, floatBitsToUint(s.bbox.x)); + write_mem(a, ix + 1, floatBitsToUint(s.bbox.y)); + write_mem(a, ix + 2, floatBitsToUint(s.bbox.z)); + write_mem(a, ix + 3, floatBitsToUint(s.bbox.w)); + write_mem(a, ix + 4, floatBitsToUint(s.linewidth)); + write_mem(a, ix + 5, s.rgba_color); +} + +AnnoBeginClip AnnoBeginClip_read(Alloc a, AnnoBeginClipRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + uint raw2 = read_mem(a, ix + 2); + uint raw3 = read_mem(a, ix + 3); + uint raw4 = read_mem(a, ix + 4); + AnnoBeginClip s; + s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.linewidth = uintBitsToFloat(raw4); + return s; +} + +void AnnoBeginClip_write(Alloc a, AnnoBeginClipRef ref, AnnoBeginClip s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, floatBitsToUint(s.bbox.x)); + write_mem(a, ix + 1, floatBitsToUint(s.bbox.y)); + write_mem(a, ix + 2, floatBitsToUint(s.bbox.z)); + write_mem(a, ix + 3, floatBitsToUint(s.bbox.w)); + write_mem(a, ix + 4, floatBitsToUint(s.linewidth)); +} + +AnnoEndClip AnnoEndClip_read(Alloc a, AnnoEndClipRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + uint raw2 = read_mem(a, ix + 2); + uint raw3 = read_mem(a, ix + 3); + AnnoEndClip s; + s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + return s; +} + +void AnnoEndClip_write(Alloc a, AnnoEndClipRef ref, AnnoEndClip s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, floatBitsToUint(s.bbox.x)); + write_mem(a, ix + 1, floatBitsToUint(s.bbox.y)); + write_mem(a, ix + 2, floatBitsToUint(s.bbox.z)); + write_mem(a, ix + 3, floatBitsToUint(s.bbox.w)); +} + +AnnotatedTag Annotated_tag(Alloc a, AnnotatedRef ref) { + uint tag_and_flags = read_mem(a, ref.offset >> 2); + return AnnotatedTag(tag_and_flags & 0xffff, tag_and_flags >> 16); +} + +AnnoColor Annotated_Color_read(Alloc a, AnnotatedRef ref) { + return AnnoColor_read(a, AnnoColorRef(ref.offset + 4)); +} + +AnnoImage Annotated_Image_read(Alloc a, AnnotatedRef ref) { + return AnnoImage_read(a, AnnoImageRef(ref.offset + 4)); +} + +AnnoBeginClip Annotated_BeginClip_read(Alloc a, AnnotatedRef ref) { + return AnnoBeginClip_read(a, AnnoBeginClipRef(ref.offset + 4)); +} + +AnnoEndClip Annotated_EndClip_read(Alloc a, AnnotatedRef ref) { + return AnnoEndClip_read(a, AnnoEndClipRef(ref.offset + 4)); +} + +void Annotated_Nop_write(Alloc a, AnnotatedRef ref) { + write_mem(a, ref.offset >> 2, Annotated_Nop); +} + +void Annotated_Color_write(Alloc a, AnnotatedRef ref, uint flags, AnnoColor s) { + write_mem(a, ref.offset >> 2, (flags << 16) | Annotated_Color); + AnnoColor_write(a, AnnoColorRef(ref.offset + 4), s); +} + +void Annotated_Image_write(Alloc a, AnnotatedRef ref, uint flags, AnnoImage s) { + write_mem(a, ref.offset >> 2, (flags << 16) | Annotated_Image); + AnnoImage_write(a, AnnoImageRef(ref.offset + 4), s); +} + +void Annotated_BeginClip_write(Alloc a, AnnotatedRef ref, uint flags, AnnoBeginClip s) { + write_mem(a, ref.offset >> 2, (flags << 16) | Annotated_BeginClip); + AnnoBeginClip_write(a, AnnoBeginClipRef(ref.offset + 4), s); +} + +void Annotated_EndClip_write(Alloc a, AnnotatedRef ref, AnnoEndClip s) { + write_mem(a, ref.offset >> 2, Annotated_EndClip); + AnnoEndClip_write(a, AnnoEndClipRef(ref.offset + 4), s); +} + diff --git a/vendor/gioui.org/shader/piet/backdrop.comp b/vendor/gioui.org/shader/piet/backdrop.comp new file mode 100644 index 0000000..12ae5b1 --- /dev/null +++ b/vendor/gioui.org/shader/piet/backdrop.comp @@ -0,0 +1,109 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Propagation of tile backdrop for filling. +// +// Each thread reads one path element and calculates the number of spanned tiles +// based on the bounding box. +// In a further compaction step, the workgroup loops over the corresponding tile rows per element in parallel. +// For each row the per tile backdrop will be read, as calculated in the previous coarse path segment kernel, +// and propagated from the left to the right (prefix summed). +// +// Output state: +// - Each path element has an array of tiles covering the whole path based on boundig box +// - Each tile per path element contains the 'backdrop' and a list of subdivided path segments + +#version 450 +#extension GL_GOOGLE_include_directive : enable + +#include "mem.h" +#include "setup.h" + +#define LG_BACKDROP_WG (7 + LG_WG_FACTOR) +#define BACKDROP_WG (1 << LG_BACKDROP_WG) + +layout(local_size_x = BACKDROP_WG, local_size_y = 1) in; + +layout(set = 0, binding = 1) readonly buffer ConfigBuf { + Config conf; +}; + +#include "annotated.h" +#include "tile.h" + +shared uint sh_row_count[BACKDROP_WG]; +shared Alloc sh_row_alloc[BACKDROP_WG]; +shared uint sh_row_width[BACKDROP_WG]; + +void main() { + uint th_ix = gl_LocalInvocationID.x; + uint element_ix = gl_GlobalInvocationID.x; + AnnotatedRef ref = AnnotatedRef(conf.anno_alloc.offset + element_ix * Annotated_size); + + // Work assignment: 1 thread : 1 path element + uint row_count = 0; + bool mem_ok = mem_error == NO_ERROR; + if (element_ix < conf.n_elements) { + AnnotatedTag tag = Annotated_tag(conf.anno_alloc, ref); + switch (tag.tag) { + case Annotated_Image: + case Annotated_BeginClip: + case Annotated_Color: + if (fill_mode_from_flags(tag.flags) != MODE_NONZERO) { + break; + } + // Fall through. + PathRef path_ref = PathRef(conf.tile_alloc.offset + element_ix * Path_size); + Path path = Path_read(conf.tile_alloc, path_ref); + sh_row_width[th_ix] = path.bbox.z - path.bbox.x; + row_count = path.bbox.w - path.bbox.y; + // Paths that don't cross tile top edges don't have backdrops. + // Don't apply the optimization to paths that may cross the y = 0 + // top edge, but clipped to 1 row. + if (row_count == 1 && path.bbox.y > 0) { + // Note: this can probably be expanded to width = 2 as + // long as it doesn't cross the left edge. + row_count = 0; + } + Alloc path_alloc = new_alloc(path.tiles.offset, (path.bbox.z - path.bbox.x) * (path.bbox.w - path.bbox.y) * Tile_size, mem_ok); + sh_row_alloc[th_ix] = path_alloc; + } + } + + sh_row_count[th_ix] = row_count; + // Prefix sum of sh_row_count + for (uint i = 0; i < LG_BACKDROP_WG; i++) { + barrier(); + if (th_ix >= (1 << i)) { + row_count += sh_row_count[th_ix - (1 << i)]; + } + barrier(); + sh_row_count[th_ix] = row_count; + } + barrier(); + // Work assignment: 1 thread : 1 path element row + uint total_rows = sh_row_count[BACKDROP_WG - 1]; + for (uint row = th_ix; row < total_rows; row += BACKDROP_WG) { + // Binary search to find element + uint el_ix = 0; + for (uint i = 0; i < LG_BACKDROP_WG; i++) { + uint probe = el_ix + ((BACKDROP_WG / 2) >> i); + if (row >= sh_row_count[probe - 1]) { + el_ix = probe; + } + } + uint width = sh_row_width[el_ix]; + if (width > 0 && mem_ok) { + // Process one row sequentially + // Read backdrop value per tile and prefix sum it + Alloc tiles_alloc = sh_row_alloc[el_ix]; + uint seq_ix = row - (el_ix > 0 ? sh_row_count[el_ix - 1] : 0); + uint tile_el_ix = (tiles_alloc.offset >> 2) + 1 + seq_ix * 2 * width; + uint sum = read_mem(tiles_alloc, tile_el_ix); + for (uint x = 1; x < width; x++) { + tile_el_ix += 2; + sum += read_mem(tiles_alloc, tile_el_ix); + write_mem(tiles_alloc, tile_el_ix, sum); + } + } + } +} diff --git a/vendor/gioui.org/shader/piet/backdrop_abi.c b/vendor/gioui.org/shader/piet/backdrop_abi.c new file mode 100644 index 0000000..48a4a30 --- /dev/null +++ b/vendor/gioui.org/shader/piet/backdrop_abi.c @@ -0,0 +1,23 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +#include <stdint.h> +#include <stddef.h> +#include "abi.h" +#include "runtime.h" +#include "backdrop_abi.h" + +const struct program_info backdrop_program_info = { + .has_cbarriers = 1, + .min_memory_size = 100000, + .desc_set_size = sizeof(struct backdrop_descriptor_set_layout), + .workgroup_size_x = 128, + .workgroup_size_y = 1, + .workgroup_size_z = 1, + .begin = backdrop_coroutine_begin, + .await = backdrop_coroutine_await, + .destroy = backdrop_coroutine_destroy, +}; diff --git a/vendor/gioui.org/shader/piet/backdrop_abi.go b/vendor/gioui.org/shader/piet/backdrop_abi.go new file mode 100644 index 0000000..a40a37d --- /dev/null +++ b/vendor/gioui.org/shader/piet/backdrop_abi.go @@ -0,0 +1,35 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +package piet + +import "gioui.org/cpu" +import "unsafe" + +/* +#cgo LDFLAGS: -lm + +#include <stdint.h> +#include <stdlib.h> +#include "abi.h" +#include "runtime.h" +#include "backdrop_abi.h" +*/ +import "C" + +var BackdropProgramInfo = (*cpu.ProgramInfo)(unsafe.Pointer(&C.backdrop_program_info)) + +type BackdropDescriptorSetLayout = C.struct_backdrop_descriptor_set_layout + +const BackdropHash = "6862eaf623d89da635e9d5bc981c77aae4e39aa44047ab47c62d243cf5fe7e73" + +func (l *BackdropDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding0)) +} + +func (l *BackdropDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding1)) +} diff --git a/vendor/gioui.org/shader/piet/backdrop_abi.h b/vendor/gioui.org/shader/piet/backdrop_abi.h new file mode 100644 index 0000000..f5c0303 --- /dev/null +++ b/vendor/gioui.org/shader/piet/backdrop_abi.h @@ -0,0 +1,17 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +struct backdrop_descriptor_set_layout { + struct buffer_descriptor binding0; + struct buffer_descriptor binding1; +}; + +extern coroutine backdrop_coroutine_begin(struct program_data *data, + int32_t workgroupX, int32_t workgroupY, int32_t workgroupZ, + void *workgroupMemory, + int32_t firstSubgroup, + int32_t subgroupCount) ATTR_HIDDEN; + +extern bool backdrop_coroutine_await(coroutine r, yield_result *res) ATTR_HIDDEN; +extern void backdrop_coroutine_destroy(coroutine r) ATTR_HIDDEN; + +extern const struct program_info backdrop_program_info ATTR_HIDDEN; diff --git a/vendor/gioui.org/shader/piet/backdrop_abi_nosupport.go b/vendor/gioui.org/shader/piet/backdrop_abi_nosupport.go new file mode 100644 index 0000000..c60119b --- /dev/null +++ b/vendor/gioui.org/shader/piet/backdrop_abi_nosupport.go @@ -0,0 +1,22 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build !(linux && (arm64 || arm || amd64)) +// +build !linux !arm64,!arm,!amd64 + +package piet + +import "gioui.org/cpu" + +var BackdropProgramInfo *cpu.ProgramInfo + +type BackdropDescriptorSetLayout struct{} + +const BackdropHash = "" + +func (l *BackdropDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *BackdropDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + panic("unsupported") +} diff --git a/vendor/gioui.org/shader/piet/backdrop_linux_amd64.syso b/vendor/gioui.org/shader/piet/backdrop_linux_amd64.syso Binary files differnew file mode 100644 index 0000000..2a71e8a --- /dev/null +++ b/vendor/gioui.org/shader/piet/backdrop_linux_amd64.syso diff --git a/vendor/gioui.org/shader/piet/backdrop_linux_arm.syso b/vendor/gioui.org/shader/piet/backdrop_linux_arm.syso Binary files differnew file mode 100644 index 0000000..c86dada --- /dev/null +++ b/vendor/gioui.org/shader/piet/backdrop_linux_arm.syso diff --git a/vendor/gioui.org/shader/piet/backdrop_linux_arm64.syso b/vendor/gioui.org/shader/piet/backdrop_linux_arm64.syso Binary files differnew file mode 100644 index 0000000..4608a7e --- /dev/null +++ b/vendor/gioui.org/shader/piet/backdrop_linux_arm64.syso diff --git a/vendor/gioui.org/shader/piet/binning.comp b/vendor/gioui.org/shader/piet/binning.comp new file mode 100644 index 0000000..acda83c --- /dev/null +++ b/vendor/gioui.org/shader/piet/binning.comp @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// The binning stage of the pipeline. +// +// Each workgroup processes N_TILE paths. +// Each thread processes one path and calculates a N_TILE_X x N_TILE_Y coverage mask +// based on the path bounding box to bin the paths. + +#version 450 +#extension GL_GOOGLE_include_directive : enable + +#include "mem.h" +#include "setup.h" + +layout(local_size_x = N_TILE, local_size_y = 1) in; + +layout(set = 0, binding = 1) readonly buffer ConfigBuf { + Config conf; +}; + +#include "annotated.h" +#include "bins.h" + +// scale factors useful for converting coordinates to bins +#define SX (1.0 / float(N_TILE_X * TILE_WIDTH_PX)) +#define SY (1.0 / float(N_TILE_Y * TILE_HEIGHT_PX)) + +// Constant not available in GLSL. Also consider uintBitsToFloat(0x7f800000) +#define INFINITY (1.0 / 0.0) + +// Note: cudaraster has N_TILE + 1 to cut down on bank conflicts. +// Bitmaps are sliced (256bit into 8 (N_SLICE) 32bit submaps) +shared uint bitmaps[N_SLICE][N_TILE]; +shared uint count[N_SLICE][N_TILE]; +shared Alloc sh_chunk_alloc[N_TILE]; +// Really a bool, but some Metal devices don't accept shared bools. +shared uint sh_alloc_failed; + +void main() { + uint my_n_elements = conf.n_elements; + uint my_partition = gl_WorkGroupID.x; + + for (uint i = 0; i < N_SLICE; i++) { + bitmaps[i][gl_LocalInvocationID.x] = 0; + } + if (gl_LocalInvocationID.x == 0) { + sh_alloc_failed = 0; + } + barrier(); + + // Read inputs and determine coverage of bins + uint element_ix = my_partition * N_TILE + gl_LocalInvocationID.x; + AnnotatedRef ref = AnnotatedRef(conf.anno_alloc.offset + element_ix * Annotated_size); + uint tag = Annotated_Nop; + if (element_ix < my_n_elements) { + tag = Annotated_tag(conf.anno_alloc, ref).tag; + } + int x0 = 0, y0 = 0, x1 = 0, y1 = 0; + switch (tag) { + case Annotated_Color: + case Annotated_Image: + case Annotated_BeginClip: + case Annotated_EndClip: + // Note: we take advantage of the fact that these drawing elements + // have the bbox at the same place in their layout. + AnnoEndClip clip = Annotated_EndClip_read(conf.anno_alloc, ref); + x0 = int(floor(clip.bbox.x * SX)); + y0 = int(floor(clip.bbox.y * SY)); + x1 = int(ceil(clip.bbox.z * SX)); + y1 = int(ceil(clip.bbox.w * SY)); + break; + } + + // At this point, we run an iterator over the coverage area, + // trying to keep divergence low. + // Right now, it's just a bbox, but we'll get finer with + // segments. + uint width_in_bins = (conf.width_in_tiles + N_TILE_X - 1)/N_TILE_X; + uint height_in_bins = (conf.height_in_tiles + N_TILE_Y - 1)/N_TILE_Y; + x0 = clamp(x0, 0, int(width_in_bins)); + x1 = clamp(x1, x0, int(width_in_bins)); + y0 = clamp(y0, 0, int(height_in_bins)); + y1 = clamp(y1, y0, int(height_in_bins)); + if (x0 == x1) y1 = y0; + int x = x0, y = y0; + uint my_slice = gl_LocalInvocationID.x / 32; + uint my_mask = 1 << (gl_LocalInvocationID.x & 31); + while (y < y1) { + atomicOr(bitmaps[my_slice][y * width_in_bins + x], my_mask); + x++; + if (x == x1) { + x = x0; + y++; + } + } + + barrier(); + // Allocate output segments. + uint element_count = 0; + for (uint i = 0; i < N_SLICE; i++) { + element_count += bitCount(bitmaps[i][gl_LocalInvocationID.x]); + count[i][gl_LocalInvocationID.x] = element_count; + } + // element_count is number of elements covering bin for this invocation. + Alloc chunk_alloc = new_alloc(0, 0, true); + if (element_count != 0) { + // TODO: aggregate atomic adds (subgroup is probably fastest) + MallocResult chunk = malloc(element_count * BinInstance_size); + chunk_alloc = chunk.alloc; + sh_chunk_alloc[gl_LocalInvocationID.x] = chunk_alloc; + if (chunk.failed) { + sh_alloc_failed = 1; + } + } + // Note: it might be more efficient for reading to do this in the + // other order (each bin is a contiguous sequence of partitions) + uint out_ix = (conf.bin_alloc.offset >> 2) + (my_partition * N_TILE + gl_LocalInvocationID.x) * 2; + write_mem(conf.bin_alloc, out_ix, element_count); + write_mem(conf.bin_alloc, out_ix + 1, chunk_alloc.offset); + + barrier(); + if (sh_alloc_failed != 0 || mem_error != NO_ERROR) { + return; + } + + // Use similar strategy as Laine & Karras paper; loop over bbox of bins + // touched by this element + x = x0; + y = y0; + while (y < y1) { + uint bin_ix = y * width_in_bins + x; + uint out_mask = bitmaps[my_slice][bin_ix]; + if ((out_mask & my_mask) != 0) { + uint idx = bitCount(out_mask & (my_mask - 1)); + if (my_slice > 0) { + idx += count[my_slice - 1][bin_ix]; + } + Alloc out_alloc = sh_chunk_alloc[bin_ix]; + uint out_offset = out_alloc.offset + idx * BinInstance_size; + BinInstance_write(out_alloc, BinInstanceRef(out_offset), BinInstance(element_ix)); + } + x++; + if (x == x1) { + x = x0; + y++; + } + } +} diff --git a/vendor/gioui.org/shader/piet/binning_abi.c b/vendor/gioui.org/shader/piet/binning_abi.c new file mode 100644 index 0000000..b28be33 --- /dev/null +++ b/vendor/gioui.org/shader/piet/binning_abi.c @@ -0,0 +1,23 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +#include <stdint.h> +#include <stddef.h> +#include "abi.h" +#include "runtime.h" +#include "binning_abi.h" + +const struct program_info binning_program_info = { + .has_cbarriers = 1, + .min_memory_size = 100000, + .desc_set_size = sizeof(struct binning_descriptor_set_layout), + .workgroup_size_x = 128, + .workgroup_size_y = 1, + .workgroup_size_z = 1, + .begin = binning_coroutine_begin, + .await = binning_coroutine_await, + .destroy = binning_coroutine_destroy, +}; diff --git a/vendor/gioui.org/shader/piet/binning_abi.go b/vendor/gioui.org/shader/piet/binning_abi.go new file mode 100644 index 0000000..7ee361f --- /dev/null +++ b/vendor/gioui.org/shader/piet/binning_abi.go @@ -0,0 +1,35 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +package piet + +import "gioui.org/cpu" +import "unsafe" + +/* +#cgo LDFLAGS: -lm + +#include <stdint.h> +#include <stdlib.h> +#include "abi.h" +#include "runtime.h" +#include "binning_abi.h" +*/ +import "C" + +var BinningProgramInfo = (*cpu.ProgramInfo)(unsafe.Pointer(&C.binning_program_info)) + +type BinningDescriptorSetLayout = C.struct_binning_descriptor_set_layout + +const BinningHash = "84177b6dfb90309a6c054ab9fea42293bd49033c221651c756eb40188f4d6ce8" + +func (l *BinningDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding0)) +} + +func (l *BinningDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding1)) +} diff --git a/vendor/gioui.org/shader/piet/binning_abi.h b/vendor/gioui.org/shader/piet/binning_abi.h new file mode 100644 index 0000000..0152f34 --- /dev/null +++ b/vendor/gioui.org/shader/piet/binning_abi.h @@ -0,0 +1,17 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +struct binning_descriptor_set_layout { + struct buffer_descriptor binding0; + struct buffer_descriptor binding1; +}; + +extern coroutine binning_coroutine_begin(struct program_data *data, + int32_t workgroupX, int32_t workgroupY, int32_t workgroupZ, + void *workgroupMemory, + int32_t firstSubgroup, + int32_t subgroupCount) ATTR_HIDDEN; + +extern bool binning_coroutine_await(coroutine r, yield_result *res) ATTR_HIDDEN; +extern void binning_coroutine_destroy(coroutine r) ATTR_HIDDEN; + +extern const struct program_info binning_program_info ATTR_HIDDEN; diff --git a/vendor/gioui.org/shader/piet/binning_abi_nosupport.go b/vendor/gioui.org/shader/piet/binning_abi_nosupport.go new file mode 100644 index 0000000..81b9b56 --- /dev/null +++ b/vendor/gioui.org/shader/piet/binning_abi_nosupport.go @@ -0,0 +1,22 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build !(linux && (arm64 || arm || amd64)) +// +build !linux !arm64,!arm,!amd64 + +package piet + +import "gioui.org/cpu" + +var BinningProgramInfo *cpu.ProgramInfo + +type BinningDescriptorSetLayout struct{} + +const BinningHash = "" + +func (l *BinningDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *BinningDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + panic("unsupported") +} diff --git a/vendor/gioui.org/shader/piet/binning_linux_amd64.syso b/vendor/gioui.org/shader/piet/binning_linux_amd64.syso Binary files differnew file mode 100644 index 0000000..329d95d --- /dev/null +++ b/vendor/gioui.org/shader/piet/binning_linux_amd64.syso diff --git a/vendor/gioui.org/shader/piet/binning_linux_arm.syso b/vendor/gioui.org/shader/piet/binning_linux_arm.syso Binary files differnew file mode 100644 index 0000000..a8f21a7 --- /dev/null +++ b/vendor/gioui.org/shader/piet/binning_linux_arm.syso diff --git a/vendor/gioui.org/shader/piet/binning_linux_arm64.syso b/vendor/gioui.org/shader/piet/binning_linux_arm64.syso Binary files differnew file mode 100644 index 0000000..02938c5 --- /dev/null +++ b/vendor/gioui.org/shader/piet/binning_linux_arm64.syso diff --git a/vendor/gioui.org/shader/piet/bins.h b/vendor/gioui.org/shader/piet/bins.h new file mode 100644 index 0000000..853adab --- /dev/null +++ b/vendor/gioui.org/shader/piet/bins.h @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Code auto-generated by piet-gpu-derive + +struct BinInstanceRef { + uint offset; +}; + +struct BinInstance { + uint element_ix; +}; + +#define BinInstance_size 4 + +BinInstanceRef BinInstance_index(BinInstanceRef ref, uint index) { + return BinInstanceRef(ref.offset + index * BinInstance_size); +} + +BinInstance BinInstance_read(Alloc a, BinInstanceRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + BinInstance s; + s.element_ix = raw0; + return s; +} + +void BinInstance_write(Alloc a, BinInstanceRef ref, BinInstance s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, s.element_ix); +} + diff --git a/vendor/gioui.org/shader/piet/coarse.comp b/vendor/gioui.org/shader/piet/coarse.comp new file mode 100644 index 0000000..731da97 --- /dev/null +++ b/vendor/gioui.org/shader/piet/coarse.comp @@ -0,0 +1,426 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// The coarse rasterizer stage of the pipeline. +// +// As input we have the ordered partitions of paths from the binning phase and +// the annotated tile list of segments and backdrop per path. +// +// Each workgroup operating on one bin by stream compacting +// the elements corresponding to the bin. +// +// As output we have an ordered command stream per tile. Every tile from a path (backdrop + segment list) will be encoded. + +#version 450 +#extension GL_GOOGLE_include_directive : enable + +#include "mem.h" +#include "setup.h" + +layout(local_size_x = N_TILE, local_size_y = 1) in; + +layout(set = 0, binding = 1) readonly buffer ConfigBuf { + Config conf; +}; + +#include "annotated.h" +#include "bins.h" +#include "tile.h" +#include "ptcl.h" + +#define LG_N_PART_READ (7 + LG_WG_FACTOR) +#define N_PART_READ (1 << LG_N_PART_READ) + +shared uint sh_elements[N_TILE]; + +// Number of elements in the partition; prefix sum. +shared uint sh_part_count[N_PART_READ]; +shared Alloc sh_part_elements[N_PART_READ]; + +shared uint sh_bitmaps[N_SLICE][N_TILE]; + +shared uint sh_tile_count[N_TILE]; +// The width of the tile rect for the element, intersected with this bin +shared uint sh_tile_width[N_TILE]; +shared uint sh_tile_x0[N_TILE]; +shared uint sh_tile_y0[N_TILE]; + +// These are set up so base + tile_y * stride + tile_x points to a Tile. +shared uint sh_tile_base[N_TILE]; +shared uint sh_tile_stride[N_TILE]; + +#ifdef MEM_DEBUG +// Store allocs only when MEM_DEBUG to save shared memory traffic. +shared Alloc sh_tile_alloc[N_TILE]; + +void write_tile_alloc(uint el_ix, Alloc a) { + sh_tile_alloc[el_ix] = a; +} + +Alloc read_tile_alloc(uint el_ix, bool mem_ok) { + return sh_tile_alloc[el_ix]; +} +#else +void write_tile_alloc(uint el_ix, Alloc a) { + // No-op +} + +Alloc read_tile_alloc(uint el_ix, bool mem_ok) { + // All memory. + return new_alloc(0, memory.length()*4, mem_ok); +} +#endif + +// The maximum number of commands per annotated element. +#define ANNO_COMMANDS 2 + +// Perhaps cmd_alloc should be a global? This is a style question. +bool alloc_cmd(inout Alloc cmd_alloc, inout CmdRef cmd_ref, inout uint cmd_limit) { + if (cmd_ref.offset < cmd_limit) { + return true; + } + MallocResult new_cmd = malloc(PTCL_INITIAL_ALLOC); + if (new_cmd.failed) { + return false; + } + CmdJump jump = CmdJump(new_cmd.alloc.offset); + Cmd_Jump_write(cmd_alloc, cmd_ref, jump); + cmd_alloc = new_cmd.alloc; + cmd_ref = CmdRef(cmd_alloc.offset); + // Reserve space for the maximum number of commands and a potential jump. + cmd_limit = cmd_alloc.offset + PTCL_INITIAL_ALLOC - (ANNO_COMMANDS + 1) * Cmd_size; + return true; +} + +void write_fill(Alloc alloc, inout CmdRef cmd_ref, uint flags, Tile tile, float linewidth) { + if (fill_mode_from_flags(flags) == MODE_NONZERO) { + if (tile.tile.offset != 0) { + CmdFill cmd_fill = CmdFill(tile.tile.offset, tile.backdrop); + Cmd_Fill_write(alloc, cmd_ref, cmd_fill); + cmd_ref.offset += 4 + CmdFill_size; + } else { + Cmd_Solid_write(alloc, cmd_ref); + cmd_ref.offset += 4; + } + } else { + CmdStroke cmd_stroke = CmdStroke(tile.tile.offset, 0.5 * linewidth); + Cmd_Stroke_write(alloc, cmd_ref, cmd_stroke); + cmd_ref.offset += 4 + CmdStroke_size; + } +} + +void main() { + // Could use either linear or 2d layouts for both dispatch and + // invocations within the workgroup. We'll use variables to abstract. + uint width_in_bins = (conf.width_in_tiles + N_TILE_X - 1)/N_TILE_X; + uint bin_ix = width_in_bins * gl_WorkGroupID.y + gl_WorkGroupID.x; + uint partition_ix = 0; + uint n_partitions = (conf.n_elements + N_TILE - 1) / N_TILE; + uint th_ix = gl_LocalInvocationID.x; + + // Coordinates of top left of bin, in tiles. + uint bin_tile_x = N_TILE_X * gl_WorkGroupID.x; + uint bin_tile_y = N_TILE_Y * gl_WorkGroupID.y; + + // Per-tile state + uint tile_x = gl_LocalInvocationID.x % N_TILE_X; + uint tile_y = gl_LocalInvocationID.x / N_TILE_X; + uint this_tile_ix = (bin_tile_y + tile_y) * conf.width_in_tiles + bin_tile_x + tile_x; + Alloc cmd_alloc = slice_mem(conf.ptcl_alloc, this_tile_ix * PTCL_INITIAL_ALLOC, PTCL_INITIAL_ALLOC); + CmdRef cmd_ref = CmdRef(cmd_alloc.offset); + // Reserve space for the maximum number of commands and a potential jump. + uint cmd_limit = cmd_ref.offset + PTCL_INITIAL_ALLOC - (ANNO_COMMANDS + 1) * Cmd_size; + // The nesting depth of the clip stack + uint clip_depth = 0; + // State for the "clip zero" optimization. If it's nonzero, then we are + // currently in a clip for which the entire tile has an alpha of zero, and + // the value is the depth after the "begin clip" of that element. + uint clip_zero_depth = 0; + // State for the "clip one" optimization. If bit `i` is set, then that means + // that the clip pushed at depth `i` has an alpha of all one. + uint clip_one_mask = 0; + + // I'm sure we can figure out how to do this with at least one fewer register... + // Items up to rd_ix have been read from sh_elements + uint rd_ix = 0; + // Items up to wr_ix have been written into sh_elements + uint wr_ix = 0; + // Items between part_start_ix and ready_ix are ready to be transferred from sh_part_elements + uint part_start_ix = 0; + uint ready_ix = 0; + + // Leave room for the fine rasterizer scratch allocation. + Alloc scratch_alloc = slice_mem(cmd_alloc, 0, Alloc_size); + cmd_ref.offset += Alloc_size; + + uint num_begin_slots = 0; + uint begin_slot = 0; + bool mem_ok = mem_error == NO_ERROR; + while (true) { + for (uint i = 0; i < N_SLICE; i++) { + sh_bitmaps[i][th_ix] = 0; + } + + // parallel read of input partitions + do { + if (ready_ix == wr_ix && partition_ix < n_partitions) { + part_start_ix = ready_ix; + uint count = 0; + if (th_ix < N_PART_READ && partition_ix + th_ix < n_partitions) { + uint in_ix = (conf.bin_alloc.offset >> 2) + ((partition_ix + th_ix) * N_TILE + bin_ix) * 2; + count = read_mem(conf.bin_alloc, in_ix); + uint offset = read_mem(conf.bin_alloc, in_ix + 1); + sh_part_elements[th_ix] = new_alloc(offset, count*BinInstance_size, mem_ok); + } + // prefix sum of counts + for (uint i = 0; i < LG_N_PART_READ; i++) { + if (th_ix < N_PART_READ) { + sh_part_count[th_ix] = count; + } + barrier(); + if (th_ix < N_PART_READ) { + if (th_ix >= (1 << i)) { + count += sh_part_count[th_ix - (1 << i)]; + } + } + barrier(); + } + if (th_ix < N_PART_READ) { + sh_part_count[th_ix] = part_start_ix + count; + } + barrier(); + ready_ix = sh_part_count[N_PART_READ - 1]; + partition_ix += N_PART_READ; + } + // use binary search to find element to read + uint ix = rd_ix + th_ix; + if (ix >= wr_ix && ix < ready_ix && mem_ok) { + uint part_ix = 0; + for (uint i = 0; i < LG_N_PART_READ; i++) { + uint probe = part_ix + ((N_PART_READ / 2) >> i); + if (ix >= sh_part_count[probe - 1]) { + part_ix = probe; + } + } + ix -= part_ix > 0 ? sh_part_count[part_ix - 1] : part_start_ix; + Alloc bin_alloc = sh_part_elements[part_ix]; + BinInstanceRef inst_ref = BinInstanceRef(bin_alloc.offset); + BinInstance inst = BinInstance_read(bin_alloc, BinInstance_index(inst_ref, ix)); + sh_elements[th_ix] = inst.element_ix; + } + barrier(); + + wr_ix = min(rd_ix + N_TILE, ready_ix); + } while (wr_ix - rd_ix < N_TILE && (wr_ix < ready_ix || partition_ix < n_partitions)); + + // We've done the merge and filled the buffer. + + // Read one element, compute coverage. + uint tag = Annotated_Nop; + uint element_ix; + AnnotatedRef ref; + if (th_ix + rd_ix < wr_ix) { + element_ix = sh_elements[th_ix]; + ref = AnnotatedRef(conf.anno_alloc.offset + element_ix * Annotated_size); + tag = Annotated_tag(conf.anno_alloc, ref).tag; + } + + // Bounding box of element in pixel coordinates. + uint tile_count; + switch (tag) { + case Annotated_Color: + case Annotated_Image: + case Annotated_BeginClip: + case Annotated_EndClip: + // We have one "path" for each element, even if the element isn't + // actually a path (currently EndClip, but images etc in the future). + uint path_ix = element_ix; + Path path = Path_read(conf.tile_alloc, PathRef(conf.tile_alloc.offset + path_ix * Path_size)); + uint stride = path.bbox.z - path.bbox.x; + sh_tile_stride[th_ix] = stride; + int dx = int(path.bbox.x) - int(bin_tile_x); + int dy = int(path.bbox.y) - int(bin_tile_y); + int x0 = clamp(dx, 0, N_TILE_X); + int y0 = clamp(dy, 0, N_TILE_Y); + int x1 = clamp(int(path.bbox.z) - int(bin_tile_x), 0, N_TILE_X); + int y1 = clamp(int(path.bbox.w) - int(bin_tile_y), 0, N_TILE_Y); + sh_tile_width[th_ix] = uint(x1 - x0); + sh_tile_x0[th_ix] = x0; + sh_tile_y0[th_ix] = y0; + tile_count = uint(x1 - x0) * uint(y1 - y0); + // base relative to bin + uint base = path.tiles.offset - uint(dy * stride + dx) * Tile_size; + sh_tile_base[th_ix] = base; + Alloc path_alloc = new_alloc(path.tiles.offset, (path.bbox.z - path.bbox.x) * (path.bbox.w - path.bbox.y) * Tile_size, mem_ok); + write_tile_alloc(th_ix, path_alloc); + break; + default: + tile_count = 0; + break; + } + + // Prefix sum of sh_tile_count + sh_tile_count[th_ix] = tile_count; + for (uint i = 0; i < LG_N_TILE; i++) { + barrier(); + if (th_ix >= (1 << i)) { + tile_count += sh_tile_count[th_ix - (1 << i)]; + } + barrier(); + sh_tile_count[th_ix] = tile_count; + } + barrier(); + uint total_tile_count = sh_tile_count[N_TILE - 1]; + for (uint ix = th_ix; ix < total_tile_count; ix += N_TILE) { + // Binary search to find element + uint el_ix = 0; + for (uint i = 0; i < LG_N_TILE; i++) { + uint probe = el_ix + ((N_TILE / 2) >> i); + if (ix >= sh_tile_count[probe - 1]) { + el_ix = probe; + } + } + AnnotatedRef ref = AnnotatedRef(conf.anno_alloc.offset + sh_elements[el_ix] * Annotated_size); + uint tag = Annotated_tag(conf.anno_alloc, ref).tag; + uint seq_ix = ix - (el_ix > 0 ? sh_tile_count[el_ix - 1] : 0); + uint width = sh_tile_width[el_ix]; + uint x = sh_tile_x0[el_ix] + seq_ix % width; + uint y = sh_tile_y0[el_ix] + seq_ix / width; + bool include_tile = false; + if (tag == Annotated_BeginClip || tag == Annotated_EndClip) { + include_tile = true; + } else if (mem_ok) { + Tile tile = Tile_read(read_tile_alloc(el_ix, mem_ok), TileRef(sh_tile_base[el_ix] + (sh_tile_stride[el_ix] * y + x) * Tile_size)); + // Include the path in the tile if + // - the tile contains at least a segment (tile offset non-zero) + // - the tile is completely covered (backdrop non-zero) + include_tile = tile.tile.offset != 0 || tile.backdrop != 0; + } + if (include_tile) { + uint el_slice = el_ix / 32; + uint el_mask = 1 << (el_ix & 31); + atomicOr(sh_bitmaps[el_slice][y * N_TILE_X + x], el_mask); + } + } + + barrier(); + + // Output non-segment elements for this tile. The thread does a sequential walk + // through the non-segment elements. + uint slice_ix = 0; + uint bitmap = sh_bitmaps[0][th_ix]; + while (mem_ok) { + if (bitmap == 0) { + slice_ix++; + if (slice_ix == N_SLICE) { + break; + } + bitmap = sh_bitmaps[slice_ix][th_ix]; + if (bitmap == 0) { + continue; + } + } + uint element_ref_ix = slice_ix * 32 + findLSB(bitmap); + uint element_ix = sh_elements[element_ref_ix]; + + // Clear LSB + bitmap &= bitmap - 1; + + // At this point, we read the element again from global memory. + // If that turns out to be expensive, maybe we can pack it into + // shared memory (or perhaps just the tag). + ref = AnnotatedRef(conf.anno_alloc.offset + element_ix * Annotated_size); + AnnotatedTag tag = Annotated_tag(conf.anno_alloc, ref); + + if (clip_zero_depth == 0) { + switch (tag.tag) { + case Annotated_Color: + Tile tile = Tile_read(read_tile_alloc(element_ref_ix, mem_ok), TileRef(sh_tile_base[element_ref_ix] + + (sh_tile_stride[element_ref_ix] * tile_y + tile_x) * Tile_size)); + AnnoColor fill = Annotated_Color_read(conf.anno_alloc, ref); + if (!alloc_cmd(cmd_alloc, cmd_ref, cmd_limit)) { + break; + } + write_fill(cmd_alloc, cmd_ref, tag.flags, tile, fill.linewidth); + Cmd_Color_write(cmd_alloc, cmd_ref, CmdColor(fill.rgba_color)); + cmd_ref.offset += 4 + CmdColor_size; + break; + case Annotated_Image: + tile = Tile_read(read_tile_alloc(element_ref_ix, mem_ok), TileRef(sh_tile_base[element_ref_ix] + + (sh_tile_stride[element_ref_ix] * tile_y + tile_x) * Tile_size)); + AnnoImage fill_img = Annotated_Image_read(conf.anno_alloc, ref); + if (!alloc_cmd(cmd_alloc, cmd_ref, cmd_limit)) { + break; + } + write_fill(cmd_alloc, cmd_ref, tag.flags, tile, fill_img.linewidth); + Cmd_Image_write(cmd_alloc, cmd_ref, CmdImage(fill_img.index, fill_img.offset)); + cmd_ref.offset += 4 + CmdImage_size; + break; + case Annotated_BeginClip: + tile = Tile_read(read_tile_alloc(element_ref_ix, mem_ok), TileRef(sh_tile_base[element_ref_ix] + + (sh_tile_stride[element_ref_ix] * tile_y + tile_x) * Tile_size)); + if (tile.tile.offset == 0 && tile.backdrop == 0) { + clip_zero_depth = clip_depth + 1; + } else if (tile.tile.offset == 0 && clip_depth < 32) { + clip_one_mask |= (1 << clip_depth); + } else { + AnnoBeginClip begin_clip = Annotated_BeginClip_read(conf.anno_alloc, ref); + if (!alloc_cmd(cmd_alloc, cmd_ref, cmd_limit)) { + break; + } + write_fill(cmd_alloc, cmd_ref, tag.flags, tile, begin_clip.linewidth); + Cmd_BeginClip_write(cmd_alloc, cmd_ref); + cmd_ref.offset += 4; + if (clip_depth < 32) { + clip_one_mask &= ~(1 << clip_depth); + } + begin_slot++; + num_begin_slots = max(num_begin_slots, begin_slot); + } + clip_depth++; + break; + case Annotated_EndClip: + clip_depth--; + if (clip_depth >= 32 || (clip_one_mask & (1 << clip_depth)) == 0) { + if (!alloc_cmd(cmd_alloc, cmd_ref, cmd_limit)) { + break; + } + Cmd_Solid_write(cmd_alloc, cmd_ref); + cmd_ref.offset += 4; + begin_slot--; + Cmd_EndClip_write(cmd_alloc, cmd_ref); + cmd_ref.offset += 4; + } + break; + } + } else { + // In "clip zero" state, suppress all drawing + switch (tag.tag) { + case Annotated_BeginClip: + clip_depth++; + break; + case Annotated_EndClip: + if (clip_depth == clip_zero_depth) { + clip_zero_depth = 0; + } + clip_depth--; + break; + } + } + } + barrier(); + + rd_ix += N_TILE; + if (rd_ix >= ready_ix && partition_ix >= n_partitions) break; + } + if (bin_tile_x + tile_x < conf.width_in_tiles && bin_tile_y + tile_y < conf.height_in_tiles) { + Cmd_End_write(cmd_alloc, cmd_ref); + if (num_begin_slots > 0) { + // Write scratch allocation: one state per BeginClip per rasterizer chunk. + uint scratch_size = num_begin_slots * TILE_WIDTH_PX * TILE_HEIGHT_PX * CLIP_STATE_SIZE * 4; + MallocResult scratch = malloc(scratch_size); + // Ignore scratch.failed; we don't use the allocation and kernel4 + // checks for memory overflow before using it. + alloc_write(scratch_alloc, scratch_alloc.offset, scratch.alloc); + } + } +} diff --git a/vendor/gioui.org/shader/piet/coarse_abi.c b/vendor/gioui.org/shader/piet/coarse_abi.c new file mode 100644 index 0000000..dbecf9f --- /dev/null +++ b/vendor/gioui.org/shader/piet/coarse_abi.c @@ -0,0 +1,23 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +#include <stdint.h> +#include <stddef.h> +#include "abi.h" +#include "runtime.h" +#include "coarse_abi.h" + +const struct program_info coarse_program_info = { + .has_cbarriers = 1, + .min_memory_size = 100000, + .desc_set_size = sizeof(struct coarse_descriptor_set_layout), + .workgroup_size_x = 128, + .workgroup_size_y = 1, + .workgroup_size_z = 1, + .begin = coarse_coroutine_begin, + .await = coarse_coroutine_await, + .destroy = coarse_coroutine_destroy, +}; diff --git a/vendor/gioui.org/shader/piet/coarse_abi.go b/vendor/gioui.org/shader/piet/coarse_abi.go new file mode 100644 index 0000000..dfd977d --- /dev/null +++ b/vendor/gioui.org/shader/piet/coarse_abi.go @@ -0,0 +1,35 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +package piet + +import "gioui.org/cpu" +import "unsafe" + +/* +#cgo LDFLAGS: -lm + +#include <stdint.h> +#include <stdlib.h> +#include "abi.h" +#include "runtime.h" +#include "coarse_abi.h" +*/ +import "C" + +var CoarseProgramInfo = (*cpu.ProgramInfo)(unsafe.Pointer(&C.coarse_program_info)) + +type CoarseDescriptorSetLayout = C.struct_coarse_descriptor_set_layout + +const CoarseHash = "e7ef250c08701490aed979a889cca73943b988bdb5e4ca4b02735aebcf5e5505" + +func (l *CoarseDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding0)) +} + +func (l *CoarseDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding1)) +} diff --git a/vendor/gioui.org/shader/piet/coarse_abi.h b/vendor/gioui.org/shader/piet/coarse_abi.h new file mode 100644 index 0000000..24d874d --- /dev/null +++ b/vendor/gioui.org/shader/piet/coarse_abi.h @@ -0,0 +1,17 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +struct coarse_descriptor_set_layout { + struct buffer_descriptor binding0; + struct buffer_descriptor binding1; +}; + +extern coroutine coarse_coroutine_begin(struct program_data *data, + int32_t workgroupX, int32_t workgroupY, int32_t workgroupZ, + void *workgroupMemory, + int32_t firstSubgroup, + int32_t subgroupCount) ATTR_HIDDEN; + +extern bool coarse_coroutine_await(coroutine r, yield_result *res) ATTR_HIDDEN; +extern void coarse_coroutine_destroy(coroutine r) ATTR_HIDDEN; + +extern const struct program_info coarse_program_info ATTR_HIDDEN; diff --git a/vendor/gioui.org/shader/piet/coarse_abi_nosupport.go b/vendor/gioui.org/shader/piet/coarse_abi_nosupport.go new file mode 100644 index 0000000..00e2ad8 --- /dev/null +++ b/vendor/gioui.org/shader/piet/coarse_abi_nosupport.go @@ -0,0 +1,22 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build !(linux && (arm64 || arm || amd64)) +// +build !linux !arm64,!arm,!amd64 + +package piet + +import "gioui.org/cpu" + +var CoarseProgramInfo *cpu.ProgramInfo + +type CoarseDescriptorSetLayout struct{} + +const CoarseHash = "" + +func (l *CoarseDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *CoarseDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + panic("unsupported") +} diff --git a/vendor/gioui.org/shader/piet/coarse_linux_amd64.syso b/vendor/gioui.org/shader/piet/coarse_linux_amd64.syso Binary files differnew file mode 100644 index 0000000..1ac8407 --- /dev/null +++ b/vendor/gioui.org/shader/piet/coarse_linux_amd64.syso diff --git a/vendor/gioui.org/shader/piet/coarse_linux_arm.syso b/vendor/gioui.org/shader/piet/coarse_linux_arm.syso Binary files differnew file mode 100644 index 0000000..3f5ee88 --- /dev/null +++ b/vendor/gioui.org/shader/piet/coarse_linux_arm.syso diff --git a/vendor/gioui.org/shader/piet/coarse_linux_arm64.syso b/vendor/gioui.org/shader/piet/coarse_linux_arm64.syso Binary files differnew file mode 100644 index 0000000..da3b563 --- /dev/null +++ b/vendor/gioui.org/shader/piet/coarse_linux_arm64.syso diff --git a/vendor/gioui.org/shader/piet/elements.comp b/vendor/gioui.org/shader/piet/elements.comp new file mode 100644 index 0000000..17ef1ee --- /dev/null +++ b/vendor/gioui.org/shader/piet/elements.comp @@ -0,0 +1,413 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// The element processing stage, first in the pipeline. +// +// This stage is primarily about applying transforms and computing bounding +// boxes. It is organized as a scan over the input elements, producing +// annotated output elements. + +#version 450 +#extension GL_GOOGLE_include_directive : enable + +#include "mem.h" +#include "setup.h" + +#define N_ROWS 4 +#define WG_SIZE 32 +#define LG_WG_SIZE 5 +#define PARTITION_SIZE (WG_SIZE * N_ROWS) + +layout(local_size_x = WG_SIZE, local_size_y = 1) in; + +layout(set = 0, binding = 1) readonly buffer ConfigBuf { + Config conf; +}; + +layout(set = 0, binding = 2) readonly buffer SceneBuf { + uint[] scene; +}; + +// It would be better to use the Vulkan memory model than +// "volatile" but shooting for compatibility here rather +// than doing things right. +layout(set = 0, binding = 3) volatile buffer StateBuf { + uint part_counter; + uint[] state; +}; + +#include "scene.h" +#include "state.h" +#include "annotated.h" +#include "pathseg.h" +#include "tile.h" + +#define StateBuf_stride (4 + 2 * State_size) + +StateRef state_aggregate_ref(uint partition_ix) { + return StateRef(4 + partition_ix * StateBuf_stride); +} + +StateRef state_prefix_ref(uint partition_ix) { + return StateRef(4 + partition_ix * StateBuf_stride + State_size); +} + +uint state_flag_index(uint partition_ix) { + return partition_ix * (StateBuf_stride / 4); +} + +// These correspond to X, A, P respectively in the prefix sum paper. +#define FLAG_NOT_READY 0 +#define FLAG_AGGREGATE_READY 1 +#define FLAG_PREFIX_READY 2 + +#define FLAG_SET_LINEWIDTH 1 +#define FLAG_SET_BBOX 2 +#define FLAG_RESET_BBOX 4 +#define FLAG_SET_FILL_MODE 8 +// Fill modes take up the next bit. Non-zero fill is 0, stroke is 1. +#define LG_FILL_MODE 4 +#define FILL_MODE_BITS 1 +#define FILL_MODE_MASK (FILL_MODE_BITS << LG_FILL_MODE) + +// This is almost like a monoid (the interaction between transformation and +// bounding boxes is approximate) +State combine_state(State a, State b) { + State c; + c.bbox.x = min(a.mat.x * b.bbox.x, a.mat.x * b.bbox.z) + min(a.mat.z * b.bbox.y, a.mat.z * b.bbox.w) + a.translate.x; + c.bbox.y = min(a.mat.y * b.bbox.x, a.mat.y * b.bbox.z) + min(a.mat.w * b.bbox.y, a.mat.w * b.bbox.w) + a.translate.y; + c.bbox.z = max(a.mat.x * b.bbox.x, a.mat.x * b.bbox.z) + max(a.mat.z * b.bbox.y, a.mat.z * b.bbox.w) + a.translate.x; + c.bbox.w = max(a.mat.y * b.bbox.x, a.mat.y * b.bbox.z) + max(a.mat.w * b.bbox.y, a.mat.w * b.bbox.w) + a.translate.y; + if ((a.flags & FLAG_RESET_BBOX) == 0 && b.bbox.z <= b.bbox.x && b.bbox.w <= b.bbox.y) { + c.bbox = a.bbox; + } else if ((a.flags & FLAG_RESET_BBOX) == 0 && (b.flags & FLAG_SET_BBOX) == 0 && + (a.bbox.z > a.bbox.x || a.bbox.w > a.bbox.y)) + { + c.bbox.xy = min(a.bbox.xy, c.bbox.xy); + c.bbox.zw = max(a.bbox.zw, c.bbox.zw); + } + // It would be more concise to cast to matrix types; ah well. + c.mat.x = a.mat.x * b.mat.x + a.mat.z * b.mat.y; + c.mat.y = a.mat.y * b.mat.x + a.mat.w * b.mat.y; + c.mat.z = a.mat.x * b.mat.z + a.mat.z * b.mat.w; + c.mat.w = a.mat.y * b.mat.z + a.mat.w * b.mat.w; + c.translate.x = a.mat.x * b.translate.x + a.mat.z * b.translate.y + a.translate.x; + c.translate.y = a.mat.y * b.translate.x + a.mat.w * b.translate.y + a.translate.y; + c.linewidth = (b.flags & FLAG_SET_LINEWIDTH) == 0 ? a.linewidth : b.linewidth; + c.flags = (a.flags & (FLAG_SET_LINEWIDTH | FLAG_SET_BBOX | FLAG_SET_FILL_MODE)) | b.flags; + c.flags |= (a.flags & FLAG_RESET_BBOX) >> 1; + uint fill_mode = (b.flags & FLAG_SET_FILL_MODE) == 0 ? a.flags : b.flags; + fill_mode &= FILL_MODE_MASK; + c.flags = (c.flags & ~FILL_MODE_MASK) | fill_mode; + c.path_count = a.path_count + b.path_count; + c.pathseg_count = a.pathseg_count + b.pathseg_count; + c.trans_count = a.trans_count + b.trans_count; + return c; +} + +State map_element(ElementRef ref) { + // TODO: it would *probably* be more efficient to make the memory read patterns less + // divergent, though it would be more wasted memory. + uint tag = Element_tag(ref).tag; + State c; + c.bbox = vec4(0.0, 0.0, 0.0, 0.0); + c.mat = vec4(1.0, 0.0, 0.0, 1.0); + c.translate = vec2(0.0, 0.0); + c.linewidth = 1.0; // TODO should be 0.0 + c.flags = 0; + c.path_count = 0; + c.pathseg_count = 0; + c.trans_count = 0; + switch (tag) { + case Element_Line: + LineSeg line = Element_Line_read(ref); + c.bbox.xy = min(line.p0, line.p1); + c.bbox.zw = max(line.p0, line.p1); + c.pathseg_count = 1; + break; + case Element_Quad: + QuadSeg quad = Element_Quad_read(ref); + c.bbox.xy = min(min(quad.p0, quad.p1), quad.p2); + c.bbox.zw = max(max(quad.p0, quad.p1), quad.p2); + c.pathseg_count = 1; + break; + case Element_Cubic: + CubicSeg cubic = Element_Cubic_read(ref); + c.bbox.xy = min(min(cubic.p0, cubic.p1), min(cubic.p2, cubic.p3)); + c.bbox.zw = max(max(cubic.p0, cubic.p1), max(cubic.p2, cubic.p3)); + c.pathseg_count = 1; + break; + case Element_FillColor: + case Element_FillImage: + case Element_BeginClip: + c.flags = FLAG_RESET_BBOX; + c.path_count = 1; + break; + case Element_EndClip: + c.path_count = 1; + break; + case Element_SetLineWidth: + SetLineWidth lw = Element_SetLineWidth_read(ref); + c.linewidth = lw.width; + c.flags = FLAG_SET_LINEWIDTH; + break; + case Element_Transform: + Transform t = Element_Transform_read(ref); + c.mat = t.mat; + c.translate = t.translate; + c.trans_count = 1; + break; + case Element_SetFillMode: + SetFillMode fm = Element_SetFillMode_read(ref); + c.flags = FLAG_SET_FILL_MODE | (fm.fill_mode << LG_FILL_MODE); + break; + } + return c; +} + +// Get the bounding box of a circle transformed by the matrix into an ellipse. +vec2 get_linewidth(State st) { + // See https://www.iquilezles.org/www/articles/ellipses/ellipses.htm + return 0.5 * st.linewidth * vec2(length(st.mat.xz), length(st.mat.yw)); +} + +shared State sh_state[WG_SIZE]; + +shared uint sh_part_ix; +shared State sh_prefix; + +void main() { + State th_state[N_ROWS]; + // Determine partition to process by atomic counter (described in Section + // 4.4 of prefix sum paper). + if (gl_LocalInvocationID.x == 0) { + sh_part_ix = atomicAdd(part_counter, 1); + } + barrier(); + uint part_ix = sh_part_ix; + + uint ix = part_ix * PARTITION_SIZE + gl_LocalInvocationID.x * N_ROWS; + ElementRef ref = ElementRef(ix * Element_size); + + th_state[0] = map_element(ref); + for (uint i = 1; i < N_ROWS; i++) { + // discussion question: would it be faster to load using more coherent patterns + // into thread memory? This is kinda strided. + th_state[i] = combine_state(th_state[i - 1], map_element(Element_index(ref, i))); + } + State agg = th_state[N_ROWS - 1]; + sh_state[gl_LocalInvocationID.x] = agg; + for (uint i = 0; i < LG_WG_SIZE; i++) { + barrier(); + if (gl_LocalInvocationID.x >= (1 << i)) { + State other = sh_state[gl_LocalInvocationID.x - (1 << i)]; + agg = combine_state(other, agg); + } + barrier(); + sh_state[gl_LocalInvocationID.x] = agg; + } + + State exclusive; + exclusive.bbox = vec4(0.0, 0.0, 0.0, 0.0); + exclusive.mat = vec4(1.0, 0.0, 0.0, 1.0); + exclusive.translate = vec2(0.0, 0.0); + exclusive.linewidth = 1.0; //TODO should be 0.0 + exclusive.flags = 0; + exclusive.path_count = 0; + exclusive.pathseg_count = 0; + exclusive.trans_count = 0; + + // Publish aggregate for this partition + if (gl_LocalInvocationID.x == WG_SIZE - 1) { + // Note: with memory model, we'd want to generate the atomic store version of this. + State_write(state_aggregate_ref(part_ix), agg); + } + memoryBarrierBuffer(); + if (gl_LocalInvocationID.x == WG_SIZE - 1) { + uint flag = FLAG_AGGREGATE_READY; + if (part_ix == 0) { + State_write(state_prefix_ref(part_ix), agg); + flag = FLAG_PREFIX_READY; + } + state[state_flag_index(part_ix)] = flag; + if (part_ix != 0) { + // step 4 of paper: decoupled lookback + uint look_back_ix = part_ix - 1; + + State their_agg; + uint their_ix = 0; + while (true) { + flag = state[state_flag_index(look_back_ix)]; + if (flag == FLAG_PREFIX_READY) { + State their_prefix = State_read(state_prefix_ref(look_back_ix)); + exclusive = combine_state(their_prefix, exclusive); + break; + } else if (flag == FLAG_AGGREGATE_READY) { + their_agg = State_read(state_aggregate_ref(look_back_ix)); + exclusive = combine_state(their_agg, exclusive); + look_back_ix--; + their_ix = 0; + continue; + } + // else spin + + // Unfortunately there's no guarantee of forward progress of other + // workgroups, so compute a bit of the aggregate before trying again. + // In the worst case, spinning stops when the aggregate is complete. + ElementRef ref = ElementRef((look_back_ix * PARTITION_SIZE + their_ix) * Element_size); + State s = map_element(ref); + if (their_ix == 0) { + their_agg = s; + } else { + their_agg = combine_state(their_agg, s); + } + their_ix++; + if (their_ix == PARTITION_SIZE) { + exclusive = combine_state(their_agg, exclusive); + if (look_back_ix == 0) { + break; + } + look_back_ix--; + their_ix = 0; + } + } + + // step 5 of paper: compute inclusive prefix + State inclusive_prefix = combine_state(exclusive, agg); + sh_prefix = exclusive; + State_write(state_prefix_ref(part_ix), inclusive_prefix); + } + } + memoryBarrierBuffer(); + if (gl_LocalInvocationID.x == WG_SIZE - 1 && part_ix != 0) { + state[state_flag_index(part_ix)] = FLAG_PREFIX_READY; + } + barrier(); + if (part_ix != 0) { + exclusive = sh_prefix; + } + + State row = exclusive; + if (gl_LocalInvocationID.x > 0) { + State other = sh_state[gl_LocalInvocationID.x - 1]; + row = combine_state(row, other); + } + for (uint i = 0; i < N_ROWS; i++) { + State st = combine_state(row, th_state[i]); + + // Here we read again from the original scene. There may be + // gains to be had from stashing in shared memory or possibly + // registers (though register pressure is an issue). + ElementRef this_ref = Element_index(ref, i); + ElementTag tag = Element_tag(this_ref); + uint fill_mode = fill_mode_from_flags(st.flags >> LG_FILL_MODE); + bool is_stroke = fill_mode == MODE_STROKE; + switch (tag.tag) { + case Element_Line: + LineSeg line = Element_Line_read(this_ref); + PathCubic path_cubic; + path_cubic.p0 = line.p0; + path_cubic.p1 = mix(line.p0, line.p1, 1.0 / 3.0); + path_cubic.p2 = mix(line.p1, line.p0, 1.0 / 3.0); + path_cubic.p3 = line.p1; + path_cubic.path_ix = st.path_count; + path_cubic.trans_ix = st.trans_count; + if (is_stroke) { + path_cubic.stroke = get_linewidth(st); + } else { + path_cubic.stroke = vec2(0.0); + } + PathSegRef path_out_ref = PathSegRef(conf.pathseg_alloc.offset + (st.pathseg_count - 1) * PathSeg_size); + PathSeg_Cubic_write(conf.pathseg_alloc, path_out_ref, fill_mode, path_cubic); + break; + case Element_Quad: + QuadSeg quad = Element_Quad_read(this_ref); + path_cubic.p0 = quad.p0; + path_cubic.p1 = mix(quad.p1, quad.p0, 1.0 / 3.0); + path_cubic.p2 = mix(quad.p1, quad.p2, 1.0 / 3.0); + path_cubic.p3 = quad.p2; + path_cubic.path_ix = st.path_count; + path_cubic.trans_ix = st.trans_count; + if (is_stroke) { + path_cubic.stroke = get_linewidth(st); + } else { + path_cubic.stroke = vec2(0.0); + } + path_out_ref = PathSegRef(conf.pathseg_alloc.offset + (st.pathseg_count - 1) * PathSeg_size); + PathSeg_Cubic_write(conf.pathseg_alloc, path_out_ref, fill_mode, path_cubic); + break; + case Element_Cubic: + CubicSeg cubic = Element_Cubic_read(this_ref); + path_cubic.p0 = cubic.p0; + path_cubic.p1 = cubic.p1; + path_cubic.p2 = cubic.p2; + path_cubic.p3 = cubic.p3; + path_cubic.path_ix = st.path_count; + path_cubic.trans_ix = st.trans_count; + if (is_stroke) { + path_cubic.stroke = get_linewidth(st); + } else { + path_cubic.stroke = vec2(0.0); + } + path_out_ref = PathSegRef(conf.pathseg_alloc.offset + (st.pathseg_count - 1) * PathSeg_size); + PathSeg_Cubic_write(conf.pathseg_alloc, path_out_ref, fill_mode, path_cubic); + break; + case Element_FillColor: + FillColor fill = Element_FillColor_read(this_ref); + AnnoColor anno_fill; + anno_fill.rgba_color = fill.rgba_color; + if (is_stroke) { + vec2 lw = get_linewidth(st); + anno_fill.bbox = st.bbox + vec4(-lw, lw); + anno_fill.linewidth = st.linewidth * sqrt(abs(st.mat.x * st.mat.w - st.mat.y * st.mat.z)); + } else { + anno_fill.bbox = st.bbox; + anno_fill.linewidth = 0.0; + } + AnnotatedRef out_ref = AnnotatedRef(conf.anno_alloc.offset + (st.path_count - 1) * Annotated_size); + Annotated_Color_write(conf.anno_alloc, out_ref, fill_mode, anno_fill); + break; + case Element_FillImage: + FillImage fill_img = Element_FillImage_read(this_ref); + AnnoImage anno_img; + anno_img.index = fill_img.index; + anno_img.offset = fill_img.offset; + if (is_stroke) { + vec2 lw = get_linewidth(st); + anno_img.bbox = st.bbox + vec4(-lw, lw); + anno_img.linewidth = st.linewidth * sqrt(abs(st.mat.x * st.mat.w - st.mat.y * st.mat.z)); + } else { + anno_img.bbox = st.bbox; + anno_img.linewidth = 0.0; + } + out_ref = AnnotatedRef(conf.anno_alloc.offset + (st.path_count - 1) * Annotated_size); + Annotated_Image_write(conf.anno_alloc, out_ref, fill_mode, anno_img); + break; + case Element_BeginClip: + Clip begin_clip = Element_BeginClip_read(this_ref); + AnnoBeginClip anno_begin_clip; + // This is the absolute bbox, it's been transformed during encoding. + anno_begin_clip.bbox = begin_clip.bbox; + if (is_stroke) { + vec2 lw = get_linewidth(st); + anno_begin_clip.linewidth = st.linewidth * sqrt(abs(st.mat.x * st.mat.w - st.mat.y * st.mat.z)); + } else { + anno_fill.linewidth = 0.0; + } + out_ref = AnnotatedRef(conf.anno_alloc.offset + (st.path_count - 1) * Annotated_size); + Annotated_BeginClip_write(conf.anno_alloc, out_ref, fill_mode, anno_begin_clip); + break; + case Element_EndClip: + Clip end_clip = Element_EndClip_read(this_ref); + // This bbox is expected to be the same as the begin one. + AnnoEndClip anno_end_clip = AnnoEndClip(end_clip.bbox); + out_ref = AnnotatedRef(conf.anno_alloc.offset + (st.path_count - 1) * Annotated_size); + Annotated_EndClip_write(conf.anno_alloc, out_ref, anno_end_clip); + break; + case Element_Transform: + TransformSeg transform = TransformSeg(st.mat, st.translate); + TransformSegRef trans_ref = TransformSegRef(conf.trans_alloc.offset + (st.trans_count - 1) * TransformSeg_size); + TransformSeg_write(conf.trans_alloc, trans_ref, transform); + break; + } + } +} diff --git a/vendor/gioui.org/shader/piet/elements_abi.c b/vendor/gioui.org/shader/piet/elements_abi.c new file mode 100644 index 0000000..bacf32d --- /dev/null +++ b/vendor/gioui.org/shader/piet/elements_abi.c @@ -0,0 +1,23 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +#include <stdint.h> +#include <stddef.h> +#include "abi.h" +#include "runtime.h" +#include "elements_abi.h" + +const struct program_info elements_program_info = { + .has_cbarriers = 1, + .min_memory_size = 100000, + .desc_set_size = sizeof(struct elements_descriptor_set_layout), + .workgroup_size_x = 32, + .workgroup_size_y = 1, + .workgroup_size_z = 1, + .begin = elements_coroutine_begin, + .await = elements_coroutine_await, + .destroy = elements_coroutine_destroy, +}; diff --git a/vendor/gioui.org/shader/piet/elements_abi.go b/vendor/gioui.org/shader/piet/elements_abi.go new file mode 100644 index 0000000..a85eeca --- /dev/null +++ b/vendor/gioui.org/shader/piet/elements_abi.go @@ -0,0 +1,43 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +package piet + +import "gioui.org/cpu" +import "unsafe" + +/* +#cgo LDFLAGS: -lm + +#include <stdint.h> +#include <stdlib.h> +#include "abi.h" +#include "runtime.h" +#include "elements_abi.h" +*/ +import "C" + +var ElementsProgramInfo = (*cpu.ProgramInfo)(unsafe.Pointer(&C.elements_program_info)) + +type ElementsDescriptorSetLayout = C.struct_elements_descriptor_set_layout + +const ElementsHash = "0f18de15866045b36217068789c9c8715a63e0f9f120c53ea2d4d76f53e443c3" + +func (l *ElementsDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding0)) +} + +func (l *ElementsDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding1)) +} + +func (l *ElementsDescriptorSetLayout) Binding2() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding2)) +} + +func (l *ElementsDescriptorSetLayout) Binding3() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding3)) +} diff --git a/vendor/gioui.org/shader/piet/elements_abi.h b/vendor/gioui.org/shader/piet/elements_abi.h new file mode 100644 index 0000000..c455224 --- /dev/null +++ b/vendor/gioui.org/shader/piet/elements_abi.h @@ -0,0 +1,19 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +struct elements_descriptor_set_layout { + struct buffer_descriptor binding0; + struct buffer_descriptor binding1; + struct buffer_descriptor binding2; + struct buffer_descriptor binding3; +}; + +extern coroutine elements_coroutine_begin(struct program_data *data, + int32_t workgroupX, int32_t workgroupY, int32_t workgroupZ, + void *workgroupMemory, + int32_t firstSubgroup, + int32_t subgroupCount) ATTR_HIDDEN; + +extern bool elements_coroutine_await(coroutine r, yield_result *res) ATTR_HIDDEN; +extern void elements_coroutine_destroy(coroutine r) ATTR_HIDDEN; + +extern const struct program_info elements_program_info ATTR_HIDDEN; diff --git a/vendor/gioui.org/shader/piet/elements_abi_nosupport.go b/vendor/gioui.org/shader/piet/elements_abi_nosupport.go new file mode 100644 index 0000000..8b30234 --- /dev/null +++ b/vendor/gioui.org/shader/piet/elements_abi_nosupport.go @@ -0,0 +1,30 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build !(linux && (arm64 || arm || amd64)) +// +build !linux !arm64,!arm,!amd64 + +package piet + +import "gioui.org/cpu" + +var ElementsProgramInfo *cpu.ProgramInfo + +type ElementsDescriptorSetLayout struct{} + +const ElementsHash = "" + +func (l *ElementsDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *ElementsDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *ElementsDescriptorSetLayout) Binding2() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *ElementsDescriptorSetLayout) Binding3() *cpu.BufferDescriptor { + panic("unsupported") +} diff --git a/vendor/gioui.org/shader/piet/elements_linux_amd64.syso b/vendor/gioui.org/shader/piet/elements_linux_amd64.syso Binary files differnew file mode 100644 index 0000000..bba953b --- /dev/null +++ b/vendor/gioui.org/shader/piet/elements_linux_amd64.syso diff --git a/vendor/gioui.org/shader/piet/elements_linux_arm.syso b/vendor/gioui.org/shader/piet/elements_linux_arm.syso Binary files differnew file mode 100644 index 0000000..1325ac8 --- /dev/null +++ b/vendor/gioui.org/shader/piet/elements_linux_arm.syso diff --git a/vendor/gioui.org/shader/piet/elements_linux_arm64.syso b/vendor/gioui.org/shader/piet/elements_linux_arm64.syso Binary files differnew file mode 100644 index 0000000..6855eb6 --- /dev/null +++ b/vendor/gioui.org/shader/piet/elements_linux_arm64.syso diff --git a/vendor/gioui.org/shader/piet/gen.go b/vendor/gioui.org/shader/piet/gen.go new file mode 100644 index 0000000..4b80e92 --- /dev/null +++ b/vendor/gioui.org/shader/piet/gen.go @@ -0,0 +1,5 @@ +// SPDX-License-Identifier: Unlicense OR MIT + +package piet + +//go:generate go run ../cmd/convertshaders -package piet -dir . diff --git a/vendor/gioui.org/shader/piet/gencpu.sh b/vendor/gioui.org/shader/piet/gencpu.sh new file mode 100644 index 0000000..d6f6f7d --- /dev/null +++ b/vendor/gioui.org/shader/piet/gencpu.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# SPDX-License-Identifier: Unlicense OR MIT + +set -e + +OBJCOPY_ARM64=$ANDROID_SDK_ROOT/ndk/21.3.6528147/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/objcopy +OBJCOPY_ARM=$ANDROID_SDK_ROOT/ndk/21.3.6528147/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/objcopy +SWIFTSHADER=$HOME/.cache/swiftshader + +export CGO_ENABLED=1 +export GOARCH=386 +export VK_ICD_FILENAMES=$SWIFTSHADER/build.32bit/Linux/vk_swiftshader_icd.json + +export SWIFTSHADER_TRIPLE=armv7a-none-eabi +go run gioui.org/cpu/cmd/compile -arch arm -objcopy $OBJCOPY_ARM -layout "0:buffer,1:buffer,2:image,3:image" kernel4.comp +go run gioui.org/cpu/cmd/compile -arch arm -objcopy $OBJCOPY_ARM -layout "0:buffer,1:buffer" coarse.comp +go run gioui.org/cpu/cmd/compile -arch arm -objcopy $OBJCOPY_ARM -layout "0:buffer,1:buffer" binning.comp +go run gioui.org/cpu/cmd/compile -arch arm -objcopy $OBJCOPY_ARM -layout "0:buffer,1:buffer" backdrop.comp +go run gioui.org/cpu/cmd/compile -arch arm -objcopy $OBJCOPY_ARM -layout "0:buffer,1:buffer" path_coarse.comp +go run gioui.org/cpu/cmd/compile -arch arm -objcopy $OBJCOPY_ARM -layout "0:buffer,1:buffer" tile_alloc.comp +go run gioui.org/cpu/cmd/compile -arch arm -objcopy $OBJCOPY_ARM -layout "0:buffer,1:buffer,2:buffer,3:buffer" elements.comp + +export GOARCH=amd64 +export VK_ICD_FILENAMES=$SWIFTSHADER/build.64bit/Linux/vk_swiftshader_icd.json +export SWIFTSHADER_TRIPLE=x86_64-unknown-none-gnu + +go run gioui.org/cpu/cmd/compile -arch amd64 -layout "0:buffer,1:buffer,2:image,3:image" kernel4.comp +go run gioui.org/cpu/cmd/compile -arch amd64 -layout "0:buffer,1:buffer" coarse.comp +go run gioui.org/cpu/cmd/compile -arch amd64 -layout "0:buffer,1:buffer" binning.comp +go run gioui.org/cpu/cmd/compile -arch amd64 -layout "0:buffer,1:buffer" backdrop.comp +go run gioui.org/cpu/cmd/compile -arch amd64 -layout "0:buffer,1:buffer" path_coarse.comp +go run gioui.org/cpu/cmd/compile -arch amd64 -layout "0:buffer,1:buffer" tile_alloc.comp +go run gioui.org/cpu/cmd/compile -arch amd64 -layout "0:buffer,1:buffer,2:buffer,3:buffer" elements.comp + +export SWIFTSHADER_TRIPLE=aarch64-unknown-linux-gnu + +go run gioui.org/cpu/cmd/compile -arch arm64 -objcopy $OBJCOPY_ARM64 -layout "0:buffer,1:buffer,2:image,3:image" kernel4.comp +go run gioui.org/cpu/cmd/compile -arch arm64 -objcopy $OBJCOPY_ARM64 -layout "0:buffer,1:buffer" coarse.comp +go run gioui.org/cpu/cmd/compile -arch arm64 -objcopy $OBJCOPY_ARM64 -layout "0:buffer,1:buffer" binning.comp +go run gioui.org/cpu/cmd/compile -arch arm64 -objcopy $OBJCOPY_ARM64 -layout "0:buffer,1:buffer" backdrop.comp +go run gioui.org/cpu/cmd/compile -arch arm64 -objcopy $OBJCOPY_ARM64 -layout "0:buffer,1:buffer" path_coarse.comp +go run gioui.org/cpu/cmd/compile -arch arm64 -objcopy $OBJCOPY_ARM64 -layout "0:buffer,1:buffer" tile_alloc.comp +go run gioui.org/cpu/cmd/compile -arch arm64 -objcopy $OBJCOPY_ARM64 -layout "0:buffer,1:buffer,2:buffer,3:buffer" elements.comp diff --git a/vendor/gioui.org/shader/piet/kernel4.comp b/vendor/gioui.org/shader/piet/kernel4.comp new file mode 100644 index 0000000..3f8ef65 --- /dev/null +++ b/vendor/gioui.org/shader/piet/kernel4.comp @@ -0,0 +1,248 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// This is "kernel 4" in a 4-kernel pipeline. It renders the commands +// in the per-tile command list to an image. + +// Right now, this kernel stores the image in a buffer, but a better +// plan is to use a texture. This is because of limited support. + +#version 450 +#extension GL_GOOGLE_include_directive : enable +#ifdef ENABLE_IMAGE_INDICES +#extension GL_EXT_nonuniform_qualifier : enable +#endif + +#include "mem.h" +#include "setup.h" + +#define CHUNK_X 2 +#define CHUNK_Y 4 +#define CHUNK CHUNK_X * CHUNK_Y +#define CHUNK_DX (TILE_WIDTH_PX / CHUNK_X) +#define CHUNK_DY (TILE_HEIGHT_PX / CHUNK_Y) +layout(local_size_x = CHUNK_DX, local_size_y = CHUNK_DY) in; + +layout(set = 0, binding = 1) restrict readonly buffer ConfigBuf { + Config conf; +}; + +layout(rgba8, set = 0, binding = 2) uniform restrict writeonly image2D image; + +#ifdef ENABLE_IMAGE_INDICES +layout(rgba8, set = 0, binding = 3) uniform restrict readonly image2D images[]; +#else +layout(rgba8, set = 0, binding = 3) uniform restrict readonly image2D images; +#endif + +#include "ptcl.h" +#include "tile.h" + +mediump vec3 tosRGB(mediump vec3 rgb) { + bvec3 cutoff = greaterThanEqual(rgb, vec3(0.0031308)); + mediump vec3 below = vec3(12.92)*rgb; + mediump vec3 above = vec3(1.055)*pow(rgb, vec3(0.41666)) - vec3(0.055); + return mix(below, above, cutoff); +} + +mediump vec3 fromsRGB(mediump vec3 srgb) { + // Formula from EXT_sRGB. + bvec3 cutoff = greaterThanEqual(srgb, vec3(0.04045)); + mediump vec3 below = srgb/vec3(12.92); + mediump vec3 above = pow((srgb + vec3(0.055))/vec3(1.055), vec3(2.4)); + return mix(below, above, cutoff); +} + +// unpacksRGB unpacks a color in the sRGB color space to a vec4 in the linear color +// space. +mediump vec4 unpacksRGB(uint srgba) { + mediump vec4 color = unpackUnorm4x8(srgba).wzyx; + return vec4(fromsRGB(color.rgb), color.a); +} + +// packsRGB packs a color in the linear color space into its 8-bit sRGB equivalent. +uint packsRGB(mediump vec4 rgba) { + rgba = vec4(tosRGB(rgba.rgb), rgba.a); + return packUnorm4x8(rgba.wzyx); +} + +uvec2 chunk_offset(uint i) { + return uvec2(i % CHUNK_X * CHUNK_DX, i / CHUNK_X * CHUNK_DY); +} + +mediump vec4[CHUNK] fillImage(uvec2 xy, CmdImage cmd_img) { + mediump vec4 rgba[CHUNK]; + for (uint i = 0; i < CHUNK; i++) { + ivec2 uv = ivec2(xy + chunk_offset(i)) + cmd_img.offset; + mediump vec4 fg_rgba; +#ifdef ENABLE_IMAGE_INDICES + fg_rgba = imageLoad(images[cmd_img.index], uv); +#else + fg_rgba = imageLoad(images, uv); +#endif + fg_rgba.rgb = fromsRGB(fg_rgba.rgb); + rgba[i] = fg_rgba; + } + return rgba; +} + +void main() { + uint tile_ix = gl_WorkGroupID.y * conf.width_in_tiles + gl_WorkGroupID.x; + Alloc cmd_alloc = slice_mem(conf.ptcl_alloc, tile_ix * PTCL_INITIAL_ALLOC, PTCL_INITIAL_ALLOC); + CmdRef cmd_ref = CmdRef(cmd_alloc.offset); + + // Read scrach space allocation, written first in the command list. + Alloc scratch_alloc = alloc_read(cmd_alloc, cmd_ref.offset); + cmd_ref.offset += Alloc_size; + + uvec2 xy_uint = uvec2(gl_LocalInvocationID.x + TILE_WIDTH_PX * gl_WorkGroupID.x, gl_LocalInvocationID.y + TILE_HEIGHT_PX * gl_WorkGroupID.y); + vec2 xy = vec2(xy_uint); + mediump vec4 rgba[CHUNK]; + for (uint i = 0; i < CHUNK; i++) { + rgba[i] = vec4(0.0); + // TODO: remove this debug image support when the actual image method is plumbed. +#ifdef DEBUG_IMAGES +#ifdef ENABLE_IMAGE_INDICES + if (xy_uint.x < 1024 && xy_uint.y < 1024) { + rgba[i] = imageLoad(images[gl_WorkGroupID.x / 64], ivec2(xy_uint + chunk_offset(i))/4); + } +#else + if (xy_uint.x < 1024 && xy_uint.y < 1024) { + rgb[i] = imageLoad(images[0], ivec2(xy_uint + chunk_offset(i))/4).rgb; + } +#endif +#endif + } + + mediump float area[CHUNK]; + uint clip_depth = 0; + bool mem_ok = mem_error == NO_ERROR; + while (mem_ok) { + uint tag = Cmd_tag(cmd_alloc, cmd_ref).tag; + if (tag == Cmd_End) { + break; + } + switch (tag) { + case Cmd_Stroke: + // Calculate distance field from all the line segments in this tile. + CmdStroke stroke = Cmd_Stroke_read(cmd_alloc, cmd_ref); + mediump float df[CHUNK]; + for (uint k = 0; k < CHUNK; k++) df[k] = 1e9; + TileSegRef tile_seg_ref = TileSegRef(stroke.tile_ref); + do { + TileSeg seg = TileSeg_read(new_alloc(tile_seg_ref.offset, TileSeg_size, mem_ok), tile_seg_ref); + vec2 line_vec = seg.vector; + for (uint k = 0; k < CHUNK; k++) { + vec2 dpos = xy + vec2(0.5, 0.5) - seg.origin; + dpos += vec2(chunk_offset(k)); + float t = clamp(dot(line_vec, dpos) / dot(line_vec, line_vec), 0.0, 1.0); + df[k] = min(df[k], length(line_vec * t - dpos)); + } + tile_seg_ref = seg.next; + } while (tile_seg_ref.offset != 0); + for (uint k = 0; k < CHUNK; k++) { + area[k] = clamp(stroke.half_width + 0.5 - df[k], 0.0, 1.0); + } + cmd_ref.offset += 4 + CmdStroke_size; + break; + case Cmd_Fill: + CmdFill fill = Cmd_Fill_read(cmd_alloc, cmd_ref); + for (uint k = 0; k < CHUNK; k++) area[k] = float(fill.backdrop); + tile_seg_ref = TileSegRef(fill.tile_ref); + // Calculate coverage based on backdrop + coverage of each line segment + do { + TileSeg seg = TileSeg_read(new_alloc(tile_seg_ref.offset, TileSeg_size, mem_ok), tile_seg_ref); + for (uint k = 0; k < CHUNK; k++) { + vec2 my_xy = xy + vec2(chunk_offset(k)); + vec2 start = seg.origin - my_xy; + vec2 end = start + seg.vector; + vec2 window = clamp(vec2(start.y, end.y), 0.0, 1.0); + if (window.x != window.y) { + vec2 t = (window - start.y) / seg.vector.y; + vec2 xs = vec2(mix(start.x, end.x, t.x), mix(start.x, end.x, t.y)); + float xmin = min(min(xs.x, xs.y), 1.0) - 1e-6; + float xmax = max(xs.x, xs.y); + float b = min(xmax, 1.0); + float c = max(b, 0.0); + float d = max(xmin, 0.0); + float a = (b + 0.5 * (d * d - c * c) - xmin) / (xmax - xmin); + area[k] += a * (window.x - window.y); + } + area[k] += sign(seg.vector.x) * clamp(my_xy.y - seg.y_edge + 1.0, 0.0, 1.0); + } + tile_seg_ref = seg.next; + } while (tile_seg_ref.offset != 0); + for (uint k = 0; k < CHUNK; k++) { + area[k] = min(abs(area[k]), 1.0); + } + cmd_ref.offset += 4 + CmdFill_size; + break; + case Cmd_Solid: + for (uint k = 0; k < CHUNK; k++) { + area[k] = 1.0; + } + cmd_ref.offset += 4; + break; + case Cmd_Alpha: + CmdAlpha alpha = Cmd_Alpha_read(cmd_alloc, cmd_ref); + for (uint k = 0; k < CHUNK; k++) { + area[k] = alpha.alpha; + } + cmd_ref.offset += 4 + CmdAlpha_size; + break; + case Cmd_Color: + CmdColor color = Cmd_Color_read(cmd_alloc, cmd_ref); + mediump vec4 fg = unpacksRGB(color.rgba_color); + for (uint k = 0; k < CHUNK; k++) { + mediump vec4 fg_k = fg * area[k]; + rgba[k] = rgba[k] * (1.0 - fg_k.a) + fg_k; + } + cmd_ref.offset += 4 + CmdColor_size; + break; + case Cmd_Image: + CmdImage fill_img = Cmd_Image_read(cmd_alloc, cmd_ref); + mediump vec4 img[CHUNK] = fillImage(xy_uint, fill_img); + for (uint k = 0; k < CHUNK; k++) { + mediump vec4 fg_k = img[k] * area[k]; + rgba[k] = rgba[k] * (1.0 - fg_k.a) + fg_k; + } + cmd_ref.offset += 4 + CmdImage_size; + break; + case Cmd_BeginClip: + uint base_ix = (scratch_alloc.offset >> 2) + CLIP_STATE_SIZE * (clip_depth * TILE_WIDTH_PX * TILE_HEIGHT_PX + + gl_LocalInvocationID.x + TILE_WIDTH_PX * gl_LocalInvocationID.y); + for (uint k = 0; k < CHUNK; k++) { + uvec2 offset = chunk_offset(k); + uint srgb = packsRGB(vec4(rgba[k])); + mediump float alpha = clamp(abs(area[k]), 0.0, 1.0); + write_mem(scratch_alloc, base_ix + 0 + CLIP_STATE_SIZE * (offset.x + offset.y * TILE_WIDTH_PX), srgb); + write_mem(scratch_alloc, base_ix + 1 + CLIP_STATE_SIZE * (offset.x + offset.y * TILE_WIDTH_PX), floatBitsToUint(alpha)); + rgba[k] = vec4(0.0); + } + clip_depth++; + cmd_ref.offset += 4; + break; + case Cmd_EndClip: + clip_depth--; + base_ix = (scratch_alloc.offset >> 2) + CLIP_STATE_SIZE * (clip_depth * TILE_WIDTH_PX * TILE_HEIGHT_PX + + gl_LocalInvocationID.x + TILE_WIDTH_PX * gl_LocalInvocationID.y); + for (uint k = 0; k < CHUNK; k++) { + uvec2 offset = chunk_offset(k); + uint srgb = read_mem(scratch_alloc, base_ix + 0 + CLIP_STATE_SIZE * (offset.x + offset.y * TILE_WIDTH_PX)); + uint alpha = read_mem(scratch_alloc, base_ix + 1 + CLIP_STATE_SIZE * (offset.x + offset.y * TILE_WIDTH_PX)); + mediump vec4 bg = unpacksRGB(srgb); + mediump vec4 fg = rgba[k] * area[k] * uintBitsToFloat(alpha); + rgba[k] = bg * (1.0 - fg.a) + fg; + } + cmd_ref.offset += 4; + break; + case Cmd_Jump: + cmd_ref = CmdRef(Cmd_Jump_read(cmd_alloc, cmd_ref).new_ref); + cmd_alloc.offset = cmd_ref.offset; + break; + } + } + + for (uint i = 0; i < CHUNK; i++) { + imageStore(image, ivec2(xy_uint + chunk_offset(i)), vec4(tosRGB(rgba[i].rgb), rgba[i].a)); + } +} diff --git a/vendor/gioui.org/shader/piet/kernel4_abi.c b/vendor/gioui.org/shader/piet/kernel4_abi.c new file mode 100644 index 0000000..81c4ac4 --- /dev/null +++ b/vendor/gioui.org/shader/piet/kernel4_abi.c @@ -0,0 +1,23 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +#include <stdint.h> +#include <stddef.h> +#include "abi.h" +#include "runtime.h" +#include "kernel4_abi.h" + +const struct program_info kernel4_program_info = { + .has_cbarriers = 0, + .min_memory_size = 100000, + .desc_set_size = sizeof(struct kernel4_descriptor_set_layout), + .workgroup_size_x = 16, + .workgroup_size_y = 8, + .workgroup_size_z = 1, + .begin = kernel4_coroutine_begin, + .await = kernel4_coroutine_await, + .destroy = kernel4_coroutine_destroy, +}; diff --git a/vendor/gioui.org/shader/piet/kernel4_abi.go b/vendor/gioui.org/shader/piet/kernel4_abi.go new file mode 100644 index 0000000..9804647 --- /dev/null +++ b/vendor/gioui.org/shader/piet/kernel4_abi.go @@ -0,0 +1,43 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +package piet + +import "gioui.org/cpu" +import "unsafe" + +/* +#cgo LDFLAGS: -lm + +#include <stdint.h> +#include <stdlib.h> +#include "abi.h" +#include "runtime.h" +#include "kernel4_abi.h" +*/ +import "C" + +var Kernel4ProgramInfo = (*cpu.ProgramInfo)(unsafe.Pointer(&C.kernel4_program_info)) + +type Kernel4DescriptorSetLayout = C.struct_kernel4_descriptor_set_layout + +const Kernel4Hash = "88ae29cf53c1819fad9680e85faaee30fcc934d1a978a717695c966ef051bf1d" + +func (l *Kernel4DescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding0)) +} + +func (l *Kernel4DescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding1)) +} + +func (l *Kernel4DescriptorSetLayout) Binding2() *cpu.ImageDescriptor { + return (*cpu.ImageDescriptor)(unsafe.Pointer(&l.binding2)) +} + +func (l *Kernel4DescriptorSetLayout) Binding3() *cpu.ImageDescriptor { + return (*cpu.ImageDescriptor)(unsafe.Pointer(&l.binding3)) +} diff --git a/vendor/gioui.org/shader/piet/kernel4_abi.h b/vendor/gioui.org/shader/piet/kernel4_abi.h new file mode 100644 index 0000000..0d3b4c9 --- /dev/null +++ b/vendor/gioui.org/shader/piet/kernel4_abi.h @@ -0,0 +1,19 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +struct kernel4_descriptor_set_layout { + struct buffer_descriptor binding0; + struct buffer_descriptor binding1; + struct image_descriptor binding2; + struct image_descriptor binding3; +}; + +extern coroutine kernel4_coroutine_begin(struct program_data *data, + int32_t workgroupX, int32_t workgroupY, int32_t workgroupZ, + void *workgroupMemory, + int32_t firstSubgroup, + int32_t subgroupCount) ATTR_HIDDEN; + +extern bool kernel4_coroutine_await(coroutine r, yield_result *res) ATTR_HIDDEN; +extern void kernel4_coroutine_destroy(coroutine r) ATTR_HIDDEN; + +extern const struct program_info kernel4_program_info ATTR_HIDDEN; diff --git a/vendor/gioui.org/shader/piet/kernel4_abi_nosupport.go b/vendor/gioui.org/shader/piet/kernel4_abi_nosupport.go new file mode 100644 index 0000000..6cff47f --- /dev/null +++ b/vendor/gioui.org/shader/piet/kernel4_abi_nosupport.go @@ -0,0 +1,30 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build !(linux && (arm64 || arm || amd64)) +// +build !linux !arm64,!arm,!amd64 + +package piet + +import "gioui.org/cpu" + +var Kernel4ProgramInfo *cpu.ProgramInfo + +type Kernel4DescriptorSetLayout struct{} + +const Kernel4Hash = "" + +func (l *Kernel4DescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *Kernel4DescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *Kernel4DescriptorSetLayout) Binding2() *cpu.ImageDescriptor { + panic("unsupported") +} + +func (l *Kernel4DescriptorSetLayout) Binding3() *cpu.ImageDescriptor { + panic("unsupported") +} diff --git a/vendor/gioui.org/shader/piet/kernel4_linux_amd64.syso b/vendor/gioui.org/shader/piet/kernel4_linux_amd64.syso Binary files differnew file mode 100644 index 0000000..bdf0e46 --- /dev/null +++ b/vendor/gioui.org/shader/piet/kernel4_linux_amd64.syso diff --git a/vendor/gioui.org/shader/piet/kernel4_linux_arm.syso b/vendor/gioui.org/shader/piet/kernel4_linux_arm.syso Binary files differnew file mode 100644 index 0000000..6fab185 --- /dev/null +++ b/vendor/gioui.org/shader/piet/kernel4_linux_arm.syso diff --git a/vendor/gioui.org/shader/piet/kernel4_linux_arm64.syso b/vendor/gioui.org/shader/piet/kernel4_linux_arm64.syso Binary files differnew file mode 100644 index 0000000..b7994d7 --- /dev/null +++ b/vendor/gioui.org/shader/piet/kernel4_linux_arm64.syso diff --git a/vendor/gioui.org/shader/piet/mem.h b/vendor/gioui.org/shader/piet/mem.h new file mode 100644 index 0000000..9e81f04 --- /dev/null +++ b/vendor/gioui.org/shader/piet/mem.h @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +layout(set = 0, binding = 0) buffer Memory { + // offset into memory of the next allocation, initialized by the user. + uint mem_offset; + // mem_error tracks the status of memory accesses, initialized to NO_ERROR + // by the user. ERR_MALLOC_FAILED is reported for insufficient memory. + // If MEM_DEBUG is defined the following errors are reported: + // - ERR_OUT_OF_BOUNDS is reported for out of bounds writes. + // - ERR_UNALIGNED_ACCESS for memory access not aligned to 32-bit words. + uint mem_error; + uint[] memory; +}; + +// Uncomment this line to add the size field to Alloc and enable memory checks. +// Note that the Config struct in setup.h grows size fields as well. +//#define MEM_DEBUG + +#define NO_ERROR 0 +#define ERR_MALLOC_FAILED 1 +#define ERR_OUT_OF_BOUNDS 2 +#define ERR_UNALIGNED_ACCESS 3 + +#ifdef MEM_DEBUG +#define Alloc_size 16 +#else +#define Alloc_size 8 +#endif + +// Alloc represents a memory allocation. +struct Alloc { + // offset in bytes into memory. + uint offset; +#ifdef MEM_DEBUG + // size in bytes of the allocation. + uint size; +#endif +}; + +struct MallocResult { + Alloc alloc; + // failed is true if the allocation overflowed memory. + bool failed; +}; + +// new_alloc synthesizes an Alloc from an offset and size. +Alloc new_alloc(uint offset, uint size, bool mem_ok) { + Alloc a; + a.offset = offset; +#ifdef MEM_DEBUG + if (mem_ok) { + a.size = size; + } else { + a.size = 0; + } +#endif + return a; +} + +// malloc allocates size bytes of memory. +MallocResult malloc(uint size) { + MallocResult r; + uint offset = atomicAdd(mem_offset, size); + r.failed = offset + size > memory.length() * 4; + r.alloc = new_alloc(offset, size, !r.failed); + if (r.failed) { + atomicMax(mem_error, ERR_MALLOC_FAILED); + return r; + } +#ifdef MEM_DEBUG + if ((size & 3) != 0) { + r.failed = true; + atomicMax(mem_error, ERR_UNALIGNED_ACCESS); + return r; + } +#endif + return r; +} + +// touch_mem checks whether access to the memory word at offset is valid. +// If MEM_DEBUG is defined, touch_mem returns false if offset is out of bounds. +// Offset is in words. +bool touch_mem(Alloc alloc, uint offset) { +#ifdef MEM_DEBUG + if (offset < alloc.offset/4 || offset >= (alloc.offset + alloc.size)/4) { + atomicMax(mem_error, ERR_OUT_OF_BOUNDS); + return false; + } +#endif + return true; +} + +// write_mem writes val to memory at offset. +// Offset is in words. +void write_mem(Alloc alloc, uint offset, uint val) { + if (!touch_mem(alloc, offset)) { + return; + } + memory[offset] = val; +} + +// read_mem reads the value from memory at offset. +// Offset is in words. +uint read_mem(Alloc alloc, uint offset) { + if (!touch_mem(alloc, offset)) { + return 0; + } + uint v = memory[offset]; + return v; +} + +// slice_mem returns a sub-allocation inside another. Offset and size are in +// bytes, relative to a.offset. +Alloc slice_mem(Alloc a, uint offset, uint size) { +#ifdef MEM_DEBUG + if ((offset & 3) != 0 || (size & 3) != 0) { + atomicMax(mem_error, ERR_UNALIGNED_ACCESS); + return Alloc(0, 0); + } + if (offset + size > a.size) { + // slice_mem is sometimes used for slices outside bounds, + // but never written. + return Alloc(0, 0); + } + return Alloc(a.offset + offset, size); +#else + return Alloc(a.offset + offset); +#endif +} + +// alloc_write writes alloc to memory at offset bytes. +void alloc_write(Alloc a, uint offset, Alloc alloc) { + write_mem(a, offset >> 2, alloc.offset); +#ifdef MEM_DEBUG + write_mem(a, (offset >> 2) + 1, alloc.size); +#endif +} + +// alloc_read reads an Alloc from memory at offset bytes. +Alloc alloc_read(Alloc a, uint offset) { + Alloc alloc; + alloc.offset = read_mem(a, offset >> 2); +#ifdef MEM_DEBUG + alloc.size = read_mem(a, (offset >> 2) + 1); +#endif + return alloc; +} diff --git a/vendor/gioui.org/shader/piet/path_coarse.comp b/vendor/gioui.org/shader/piet/path_coarse.comp new file mode 100644 index 0000000..ea525f5 --- /dev/null +++ b/vendor/gioui.org/shader/piet/path_coarse.comp @@ -0,0 +1,294 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Coarse rasterization of path segments. + +// Allocation and initialization of tiles for paths. + +#version 450 +#extension GL_GOOGLE_include_directive : enable + +#include "mem.h" +#include "setup.h" + +#define LG_COARSE_WG 5 +#define COARSE_WG (1 << LG_COARSE_WG) + +layout(local_size_x = COARSE_WG, local_size_y = 1) in; + +layout(set = 0, binding = 1) readonly buffer ConfigBuf { + Config conf; +}; + +#include "pathseg.h" +#include "tile.h" + +// scale factors useful for converting coordinates to tiles +#define SX (1.0 / float(TILE_WIDTH_PX)) +#define SY (1.0 / float(TILE_HEIGHT_PX)) + +#define ACCURACY 0.25 +#define Q_ACCURACY (ACCURACY * 0.1) +#define REM_ACCURACY (ACCURACY - Q_ACCURACY) +#define MAX_HYPOT2 (432.0 * Q_ACCURACY * Q_ACCURACY) +#define MAX_QUADS 16 + +vec2 eval_quad(vec2 p0, vec2 p1, vec2 p2, float t) { + float mt = 1.0 - t; + return p0 * (mt * mt) + (p1 * (mt * 2.0) + p2 * t) * t; +} + +vec2 eval_cubic(vec2 p0, vec2 p1, vec2 p2, vec2 p3, float t) { + float mt = 1.0 - t; + return p0 * (mt * mt * mt) + (p1 * (mt * mt * 3.0) + (p2 * (mt * 3.0) + p3 * t) * t) * t; +} + +struct SubdivResult { + float val; + float a0; + float a2; +}; + +/// An approximation to $\int (1 + 4x^2) ^ -0.25 dx$ +/// +/// This is used for flattening curves. +#define D 0.67 +float approx_parabola_integral(float x) { + return x * inversesqrt(sqrt(1.0 - D + (D * D * D * D + 0.25 * x * x))); +} + +/// An approximation to the inverse parabola integral. +#define B 0.39 +float approx_parabola_inv_integral(float x) { + return x * sqrt(1.0 - B + (B * B + 0.25 * x * x)); +} + +SubdivResult estimate_subdiv(vec2 p0, vec2 p1, vec2 p2, float sqrt_tol) { + vec2 d01 = p1 - p0; + vec2 d12 = p2 - p1; + vec2 dd = d01 - d12; + float cross = (p2.x - p0.x) * dd.y - (p2.y - p0.y) * dd.x; + float x0 = (d01.x * dd.x + d01.y * dd.y) / cross; + float x2 = (d12.x * dd.x + d12.y * dd.y) / cross; + float scale = abs(cross / (length(dd) * (x2 - x0))); + + float a0 = approx_parabola_integral(x0); + float a2 = approx_parabola_integral(x2); + float val = 0.0; + if (scale < 1e9) { + float da = abs(a2 - a0); + float sqrt_scale = sqrt(scale); + if (sign(x0) == sign(x2)) { + val = da * sqrt_scale; + } else { + float xmin = sqrt_tol / sqrt_scale; + val = sqrt_tol * da / approx_parabola_integral(xmin); + } + } + return SubdivResult(val, a0, a2); +} + +void main() { + uint element_ix = gl_GlobalInvocationID.x; + PathSegRef ref = PathSegRef(conf.pathseg_alloc.offset + element_ix * PathSeg_size); + + PathSegTag tag = PathSegTag(PathSeg_Nop, 0); + if (element_ix < conf.n_pathseg) { + tag = PathSeg_tag(conf.pathseg_alloc, ref); + } + bool mem_ok = mem_error == NO_ERROR; + switch (tag.tag) { + case PathSeg_Cubic: + PathCubic cubic = PathSeg_Cubic_read(conf.pathseg_alloc, ref); + + uint trans_ix = cubic.trans_ix; + if (trans_ix > 0) { + TransformSegRef trans_ref = TransformSegRef(conf.trans_alloc.offset + (trans_ix - 1) * TransformSeg_size); + TransformSeg trans = TransformSeg_read(conf.trans_alloc, trans_ref); + cubic.p0 = trans.mat.xy * cubic.p0.x + trans.mat.zw * cubic.p0.y + trans.translate; + cubic.p1 = trans.mat.xy * cubic.p1.x + trans.mat.zw * cubic.p1.y + trans.translate; + cubic.p2 = trans.mat.xy * cubic.p2.x + trans.mat.zw * cubic.p2.y + trans.translate; + cubic.p3 = trans.mat.xy * cubic.p3.x + trans.mat.zw * cubic.p3.y + trans.translate; + } + + vec2 err_v = 3.0 * (cubic.p2 - cubic.p1) + cubic.p0 - cubic.p3; + float err = err_v.x * err_v.x + err_v.y * err_v.y; + // The number of quadratics. + uint n_quads = max(uint(ceil(pow(err * (1.0 / MAX_HYPOT2), 1.0 / 6.0))), 1); + n_quads = min(n_quads, MAX_QUADS); + SubdivResult keep_params[MAX_QUADS]; + // Iterate over quadratics and tote up the estimated number of segments. + float val = 0.0; + vec2 qp0 = cubic.p0; + float step = 1.0 / float(n_quads); + for (uint i = 0; i < n_quads; i++) { + float t = float(i + 1) * step; + vec2 qp2 = eval_cubic(cubic.p0, cubic.p1, cubic.p2, cubic.p3, t); + vec2 qp1 = eval_cubic(cubic.p0, cubic.p1, cubic.p2, cubic.p3, t - 0.5 * step); + qp1 = 2.0 * qp1 - 0.5 * (qp0 + qp2); + SubdivResult params = estimate_subdiv(qp0, qp1, qp2, sqrt(REM_ACCURACY)); + keep_params[i] = params; + val += params.val; + + qp0 = qp2; + } + uint n = max(uint(ceil(val * 0.5 / sqrt(REM_ACCURACY))), 1); + + bool is_stroke = fill_mode_from_flags(tag.flags) == MODE_STROKE; + uint path_ix = cubic.path_ix; + Path path = Path_read(conf.tile_alloc, PathRef(conf.tile_alloc.offset + path_ix * Path_size)); + Alloc path_alloc = new_alloc(path.tiles.offset, (path.bbox.z - path.bbox.x) * (path.bbox.w - path.bbox.y) * Tile_size, mem_ok); + ivec4 bbox = ivec4(path.bbox); + vec2 p0 = cubic.p0; + qp0 = cubic.p0; + float v_step = val / float(n); + int n_out = 1; + float val_sum = 0.0; + for (uint i = 0; i < n_quads; i++) { + float t = float(i + 1) * step; + vec2 qp2 = eval_cubic(cubic.p0, cubic.p1, cubic.p2, cubic.p3, t); + vec2 qp1 = eval_cubic(cubic.p0, cubic.p1, cubic.p2, cubic.p3, t - 0.5 * step); + qp1 = 2.0 * qp1 - 0.5 * (qp0 + qp2); + SubdivResult params = keep_params[i]; + float u0 = approx_parabola_inv_integral(params.a0); + float u2 = approx_parabola_inv_integral(params.a2); + float uscale = 1.0 / (u2 - u0); + float target = float(n_out) * v_step; + while (n_out == n || target < val_sum + params.val) { + vec2 p1; + if (n_out == n) { + p1 = cubic.p3; + } else { + float u = (target - val_sum) / params.val; + float a = mix(params.a0, params.a2, u); + float au = approx_parabola_inv_integral(a); + float t = (au - u0) * uscale; + p1 = eval_quad(qp0, qp1, qp2, t); + } + + // Output line segment + + // Bounding box of element in pixel coordinates. + float xmin = min(p0.x, p1.x) - cubic.stroke.x; + float xmax = max(p0.x, p1.x) + cubic.stroke.x; + float ymin = min(p0.y, p1.y) - cubic.stroke.y; + float ymax = max(p0.y, p1.y) + cubic.stroke.y; + float dx = p1.x - p0.x; + float dy = p1.y - p0.y; + // Set up for per-scanline coverage formula, below. + float invslope = abs(dy) < 1e-9 ? 1e9 : dx / dy; + float c = (cubic.stroke.x + abs(invslope) * (0.5 * float(TILE_HEIGHT_PX) + cubic.stroke.y)) * SX; + float b = invslope; // Note: assumes square tiles, otherwise scale. + float a = (p0.x - (p0.y - 0.5 * float(TILE_HEIGHT_PX)) * b) * SX; + + int x0 = int(floor(xmin * SX)); + int x1 = int(floor(xmax * SX) + 1); + int y0 = int(floor(ymin * SY)); + int y1 = int(floor(ymax * SY) + 1); + + x0 = clamp(x0, bbox.x, bbox.z); + y0 = clamp(y0, bbox.y, bbox.w); + x1 = clamp(x1, bbox.x, bbox.z); + y1 = clamp(y1, bbox.y, bbox.w); + float xc = a + b * float(y0); + int stride = bbox.z - bbox.x; + int base = (y0 - bbox.y) * stride - bbox.x; + // TODO: can be tighter, use c to bound width + uint n_tile_alloc = uint((x1 - x0) * (y1 - y0)); + // Consider using subgroups to aggregate atomic add. + MallocResult tile_alloc = malloc(n_tile_alloc * TileSeg_size); + if (tile_alloc.failed || !mem_ok) { + return; + } + uint tile_offset = tile_alloc.alloc.offset; + + TileSeg tile_seg; + + int xray = int(floor(p0.x*SX)); + int last_xray = int(floor(p1.x*SX)); + if (p0.y > p1.y) { + int tmp = xray; + xray = last_xray; + last_xray = tmp; + } + for (int y = y0; y < y1; y++) { + float tile_y0 = float(y * TILE_HEIGHT_PX); + int xbackdrop = max(xray + 1, bbox.x); + if (!is_stroke && min(p0.y, p1.y) < tile_y0 && xbackdrop < bbox.z) { + int backdrop = p1.y < p0.y ? 1 : -1; + TileRef tile_ref = Tile_index(path.tiles, uint(base + xbackdrop)); + uint tile_el = tile_ref.offset >> 2; + if (touch_mem(path_alloc, tile_el + 1)) { + atomicAdd(memory[tile_el + 1], backdrop); + } + } + + // next_xray is the xray for the next scanline; the line segment intersects + // all tiles between xray and next_xray. + int next_xray = last_xray; + if (y < y1 - 1) { + float tile_y1 = float((y + 1) * TILE_HEIGHT_PX); + float x_edge = mix(p0.x, p1.x, (tile_y1 - p0.y) / dy); + next_xray = int(floor(x_edge*SX)); + } + + int min_xray = min(xray, next_xray); + int max_xray = max(xray, next_xray); + int xx0 = min(int(floor(xc - c)), min_xray); + int xx1 = max(int(ceil(xc + c)), max_xray + 1); + xx0 = clamp(xx0, x0, x1); + xx1 = clamp(xx1, x0, x1); + + for (int x = xx0; x < xx1; x++) { + float tile_x0 = float(x * TILE_WIDTH_PX); + TileRef tile_ref = Tile_index(TileRef(path.tiles.offset), uint(base + x)); + uint tile_el = tile_ref.offset >> 2; + uint old = 0; + if (touch_mem(path_alloc, tile_el)) { + old = atomicExchange(memory[tile_el], tile_offset); + } + tile_seg.origin = p0; + tile_seg.vector = p1 - p0; + float y_edge = 0.0; + if (!is_stroke) { + y_edge = mix(p0.y, p1.y, (tile_x0 - p0.x) / dx); + if (min(p0.x, p1.x) < tile_x0) { + vec2 p = vec2(tile_x0, y_edge); + if (p0.x > p1.x) { + tile_seg.vector = p - p0; + } else { + tile_seg.origin = p; + tile_seg.vector = p1 - p; + } + // kernel4 uses sign(vector.x) for the sign of the intersection backdrop. + // Nudge zeroes towards the intended sign. + if (tile_seg.vector.x == 0) { + tile_seg.vector.x = sign(p1.x - p0.x)*1e-9; + } + } + if (x <= min_xray || max_xray < x) { + // Reject inconsistent intersections. + y_edge = 1e9; + } + } + tile_seg.y_edge = y_edge; + tile_seg.next.offset = old; + TileSeg_write(tile_alloc.alloc, TileSegRef(tile_offset), tile_seg); + tile_offset += TileSeg_size; + } + xc += b; + base += stride; + xray = next_xray; + } + + n_out += 1; + target += v_step; + p0 = p1; + } + val_sum += params.val; + + qp0 = qp2; + } + + break; + } +} diff --git a/vendor/gioui.org/shader/piet/path_coarse_abi.c b/vendor/gioui.org/shader/piet/path_coarse_abi.c new file mode 100644 index 0000000..575d260 --- /dev/null +++ b/vendor/gioui.org/shader/piet/path_coarse_abi.c @@ -0,0 +1,23 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +#include <stdint.h> +#include <stddef.h> +#include "abi.h" +#include "runtime.h" +#include "path_coarse_abi.h" + +const struct program_info path_coarse_program_info = { + .has_cbarriers = 0, + .min_memory_size = 100000, + .desc_set_size = sizeof(struct path_coarse_descriptor_set_layout), + .workgroup_size_x = 32, + .workgroup_size_y = 1, + .workgroup_size_z = 1, + .begin = path_coarse_coroutine_begin, + .await = path_coarse_coroutine_await, + .destroy = path_coarse_coroutine_destroy, +}; diff --git a/vendor/gioui.org/shader/piet/path_coarse_abi.go b/vendor/gioui.org/shader/piet/path_coarse_abi.go new file mode 100644 index 0000000..34d8ac3 --- /dev/null +++ b/vendor/gioui.org/shader/piet/path_coarse_abi.go @@ -0,0 +1,35 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +package piet + +import "gioui.org/cpu" +import "unsafe" + +/* +#cgo LDFLAGS: -lm + +#include <stdint.h> +#include <stdlib.h> +#include "abi.h" +#include "runtime.h" +#include "path_coarse_abi.h" +*/ +import "C" + +var Path_coarseProgramInfo = (*cpu.ProgramInfo)(unsafe.Pointer(&C.path_coarse_program_info)) + +type Path_coarseDescriptorSetLayout = C.struct_path_coarse_descriptor_set_layout + +const Path_coarseHash = "ed67e14c880cf92bdd7a9d520610e8c8b139907ff8b55df20464d353a7f58e79" + +func (l *Path_coarseDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding0)) +} + +func (l *Path_coarseDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding1)) +} diff --git a/vendor/gioui.org/shader/piet/path_coarse_abi.h b/vendor/gioui.org/shader/piet/path_coarse_abi.h new file mode 100644 index 0000000..9e43e8e --- /dev/null +++ b/vendor/gioui.org/shader/piet/path_coarse_abi.h @@ -0,0 +1,17 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +struct path_coarse_descriptor_set_layout { + struct buffer_descriptor binding0; + struct buffer_descriptor binding1; +}; + +extern coroutine path_coarse_coroutine_begin(struct program_data *data, + int32_t workgroupX, int32_t workgroupY, int32_t workgroupZ, + void *workgroupMemory, + int32_t firstSubgroup, + int32_t subgroupCount) ATTR_HIDDEN; + +extern bool path_coarse_coroutine_await(coroutine r, yield_result *res) ATTR_HIDDEN; +extern void path_coarse_coroutine_destroy(coroutine r) ATTR_HIDDEN; + +extern const struct program_info path_coarse_program_info ATTR_HIDDEN; diff --git a/vendor/gioui.org/shader/piet/path_coarse_abi_nosupport.go b/vendor/gioui.org/shader/piet/path_coarse_abi_nosupport.go new file mode 100644 index 0000000..f67a16a --- /dev/null +++ b/vendor/gioui.org/shader/piet/path_coarse_abi_nosupport.go @@ -0,0 +1,22 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build !(linux && (arm64 || arm || amd64)) +// +build !linux !arm64,!arm,!amd64 + +package piet + +import "gioui.org/cpu" + +var Path_coarseProgramInfo *cpu.ProgramInfo + +type Path_coarseDescriptorSetLayout struct{} + +const Path_coarseHash = "" + +func (l *Path_coarseDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *Path_coarseDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + panic("unsupported") +} diff --git a/vendor/gioui.org/shader/piet/path_coarse_linux_amd64.syso b/vendor/gioui.org/shader/piet/path_coarse_linux_amd64.syso Binary files differnew file mode 100644 index 0000000..a9f91d5 --- /dev/null +++ b/vendor/gioui.org/shader/piet/path_coarse_linux_amd64.syso diff --git a/vendor/gioui.org/shader/piet/path_coarse_linux_arm.syso b/vendor/gioui.org/shader/piet/path_coarse_linux_arm.syso Binary files differnew file mode 100644 index 0000000..2fcd6a0 --- /dev/null +++ b/vendor/gioui.org/shader/piet/path_coarse_linux_arm.syso diff --git a/vendor/gioui.org/shader/piet/path_coarse_linux_arm64.syso b/vendor/gioui.org/shader/piet/path_coarse_linux_arm64.syso Binary files differnew file mode 100644 index 0000000..95f731a --- /dev/null +++ b/vendor/gioui.org/shader/piet/path_coarse_linux_arm64.syso diff --git a/vendor/gioui.org/shader/piet/pathseg.h b/vendor/gioui.org/shader/piet/pathseg.h new file mode 100644 index 0000000..749771e --- /dev/null +++ b/vendor/gioui.org/shader/piet/pathseg.h @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Code auto-generated by piet-gpu-derive + +struct PathCubicRef { + uint offset; +}; + +struct PathSegRef { + uint offset; +}; + +struct PathCubic { + vec2 p0; + vec2 p1; + vec2 p2; + vec2 p3; + uint path_ix; + uint trans_ix; + vec2 stroke; +}; + +#define PathCubic_size 48 + +PathCubicRef PathCubic_index(PathCubicRef ref, uint index) { + return PathCubicRef(ref.offset + index * PathCubic_size); +} + +#define PathSeg_Nop 0 +#define PathSeg_Cubic 1 +#define PathSeg_size 52 + +PathSegRef PathSeg_index(PathSegRef ref, uint index) { + return PathSegRef(ref.offset + index * PathSeg_size); +} + +struct PathSegTag { + uint tag; + uint flags; +}; + +PathCubic PathCubic_read(Alloc a, PathCubicRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + uint raw2 = read_mem(a, ix + 2); + uint raw3 = read_mem(a, ix + 3); + uint raw4 = read_mem(a, ix + 4); + uint raw5 = read_mem(a, ix + 5); + uint raw6 = read_mem(a, ix + 6); + uint raw7 = read_mem(a, ix + 7); + uint raw8 = read_mem(a, ix + 8); + uint raw9 = read_mem(a, ix + 9); + uint raw10 = read_mem(a, ix + 10); + uint raw11 = read_mem(a, ix + 11); + PathCubic s; + s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1)); + s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5)); + s.p3 = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7)); + s.path_ix = raw8; + s.trans_ix = raw9; + s.stroke = vec2(uintBitsToFloat(raw10), uintBitsToFloat(raw11)); + return s; +} + +void PathCubic_write(Alloc a, PathCubicRef ref, PathCubic s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, floatBitsToUint(s.p0.x)); + write_mem(a, ix + 1, floatBitsToUint(s.p0.y)); + write_mem(a, ix + 2, floatBitsToUint(s.p1.x)); + write_mem(a, ix + 3, floatBitsToUint(s.p1.y)); + write_mem(a, ix + 4, floatBitsToUint(s.p2.x)); + write_mem(a, ix + 5, floatBitsToUint(s.p2.y)); + write_mem(a, ix + 6, floatBitsToUint(s.p3.x)); + write_mem(a, ix + 7, floatBitsToUint(s.p3.y)); + write_mem(a, ix + 8, s.path_ix); + write_mem(a, ix + 9, s.trans_ix); + write_mem(a, ix + 10, floatBitsToUint(s.stroke.x)); + write_mem(a, ix + 11, floatBitsToUint(s.stroke.y)); +} + +PathSegTag PathSeg_tag(Alloc a, PathSegRef ref) { + uint tag_and_flags = read_mem(a, ref.offset >> 2); + return PathSegTag(tag_and_flags & 0xffff, tag_and_flags >> 16); +} + +PathCubic PathSeg_Cubic_read(Alloc a, PathSegRef ref) { + return PathCubic_read(a, PathCubicRef(ref.offset + 4)); +} + +void PathSeg_Nop_write(Alloc a, PathSegRef ref) { + write_mem(a, ref.offset >> 2, PathSeg_Nop); +} + +void PathSeg_Cubic_write(Alloc a, PathSegRef ref, uint flags, PathCubic s) { + write_mem(a, ref.offset >> 2, (flags << 16) | PathSeg_Cubic); + PathCubic_write(a, PathCubicRef(ref.offset + 4), s); +} + diff --git a/vendor/gioui.org/shader/piet/ptcl.h b/vendor/gioui.org/shader/piet/ptcl.h new file mode 100644 index 0000000..6267fc5 --- /dev/null +++ b/vendor/gioui.org/shader/piet/ptcl.h @@ -0,0 +1,278 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Code auto-generated by piet-gpu-derive + +struct CmdStrokeRef { + uint offset; +}; + +struct CmdFillRef { + uint offset; +}; + +struct CmdColorRef { + uint offset; +}; + +struct CmdImageRef { + uint offset; +}; + +struct CmdAlphaRef { + uint offset; +}; + +struct CmdJumpRef { + uint offset; +}; + +struct CmdRef { + uint offset; +}; + +struct CmdStroke { + uint tile_ref; + float half_width; +}; + +#define CmdStroke_size 8 + +CmdStrokeRef CmdStroke_index(CmdStrokeRef ref, uint index) { + return CmdStrokeRef(ref.offset + index * CmdStroke_size); +} + +struct CmdFill { + uint tile_ref; + int backdrop; +}; + +#define CmdFill_size 8 + +CmdFillRef CmdFill_index(CmdFillRef ref, uint index) { + return CmdFillRef(ref.offset + index * CmdFill_size); +} + +struct CmdColor { + uint rgba_color; +}; + +#define CmdColor_size 4 + +CmdColorRef CmdColor_index(CmdColorRef ref, uint index) { + return CmdColorRef(ref.offset + index * CmdColor_size); +} + +struct CmdImage { + uint index; + ivec2 offset; +}; + +#define CmdImage_size 8 + +CmdImageRef CmdImage_index(CmdImageRef ref, uint index) { + return CmdImageRef(ref.offset + index * CmdImage_size); +} + +struct CmdAlpha { + float alpha; +}; + +#define CmdAlpha_size 4 + +CmdAlphaRef CmdAlpha_index(CmdAlphaRef ref, uint index) { + return CmdAlphaRef(ref.offset + index * CmdAlpha_size); +} + +struct CmdJump { + uint new_ref; +}; + +#define CmdJump_size 4 + +CmdJumpRef CmdJump_index(CmdJumpRef ref, uint index) { + return CmdJumpRef(ref.offset + index * CmdJump_size); +} + +#define Cmd_End 0 +#define Cmd_Fill 1 +#define Cmd_Stroke 2 +#define Cmd_Solid 3 +#define Cmd_Alpha 4 +#define Cmd_Color 5 +#define Cmd_Image 6 +#define Cmd_BeginClip 7 +#define Cmd_EndClip 8 +#define Cmd_Jump 9 +#define Cmd_size 12 + +CmdRef Cmd_index(CmdRef ref, uint index) { + return CmdRef(ref.offset + index * Cmd_size); +} + +struct CmdTag { + uint tag; + uint flags; +}; + +CmdStroke CmdStroke_read(Alloc a, CmdStrokeRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + CmdStroke s; + s.tile_ref = raw0; + s.half_width = uintBitsToFloat(raw1); + return s; +} + +void CmdStroke_write(Alloc a, CmdStrokeRef ref, CmdStroke s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, s.tile_ref); + write_mem(a, ix + 1, floatBitsToUint(s.half_width)); +} + +CmdFill CmdFill_read(Alloc a, CmdFillRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + CmdFill s; + s.tile_ref = raw0; + s.backdrop = int(raw1); + return s; +} + +void CmdFill_write(Alloc a, CmdFillRef ref, CmdFill s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, s.tile_ref); + write_mem(a, ix + 1, uint(s.backdrop)); +} + +CmdColor CmdColor_read(Alloc a, CmdColorRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + CmdColor s; + s.rgba_color = raw0; + return s; +} + +void CmdColor_write(Alloc a, CmdColorRef ref, CmdColor s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, s.rgba_color); +} + +CmdImage CmdImage_read(Alloc a, CmdImageRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + CmdImage s; + s.index = raw0; + s.offset = ivec2(int(raw1 << 16) >> 16, int(raw1) >> 16); + return s; +} + +void CmdImage_write(Alloc a, CmdImageRef ref, CmdImage s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, s.index); + write_mem(a, ix + 1, (uint(s.offset.x) & 0xffff) | (uint(s.offset.y) << 16)); +} + +CmdAlpha CmdAlpha_read(Alloc a, CmdAlphaRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + CmdAlpha s; + s.alpha = uintBitsToFloat(raw0); + return s; +} + +void CmdAlpha_write(Alloc a, CmdAlphaRef ref, CmdAlpha s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, floatBitsToUint(s.alpha)); +} + +CmdJump CmdJump_read(Alloc a, CmdJumpRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + CmdJump s; + s.new_ref = raw0; + return s; +} + +void CmdJump_write(Alloc a, CmdJumpRef ref, CmdJump s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, s.new_ref); +} + +CmdTag Cmd_tag(Alloc a, CmdRef ref) { + uint tag_and_flags = read_mem(a, ref.offset >> 2); + return CmdTag(tag_and_flags & 0xffff, tag_and_flags >> 16); +} + +CmdFill Cmd_Fill_read(Alloc a, CmdRef ref) { + return CmdFill_read(a, CmdFillRef(ref.offset + 4)); +} + +CmdStroke Cmd_Stroke_read(Alloc a, CmdRef ref) { + return CmdStroke_read(a, CmdStrokeRef(ref.offset + 4)); +} + +CmdAlpha Cmd_Alpha_read(Alloc a, CmdRef ref) { + return CmdAlpha_read(a, CmdAlphaRef(ref.offset + 4)); +} + +CmdColor Cmd_Color_read(Alloc a, CmdRef ref) { + return CmdColor_read(a, CmdColorRef(ref.offset + 4)); +} + +CmdImage Cmd_Image_read(Alloc a, CmdRef ref) { + return CmdImage_read(a, CmdImageRef(ref.offset + 4)); +} + +CmdJump Cmd_Jump_read(Alloc a, CmdRef ref) { + return CmdJump_read(a, CmdJumpRef(ref.offset + 4)); +} + +void Cmd_End_write(Alloc a, CmdRef ref) { + write_mem(a, ref.offset >> 2, Cmd_End); +} + +void Cmd_Fill_write(Alloc a, CmdRef ref, CmdFill s) { + write_mem(a, ref.offset >> 2, Cmd_Fill); + CmdFill_write(a, CmdFillRef(ref.offset + 4), s); +} + +void Cmd_Stroke_write(Alloc a, CmdRef ref, CmdStroke s) { + write_mem(a, ref.offset >> 2, Cmd_Stroke); + CmdStroke_write(a, CmdStrokeRef(ref.offset + 4), s); +} + +void Cmd_Solid_write(Alloc a, CmdRef ref) { + write_mem(a, ref.offset >> 2, Cmd_Solid); +} + +void Cmd_Alpha_write(Alloc a, CmdRef ref, CmdAlpha s) { + write_mem(a, ref.offset >> 2, Cmd_Alpha); + CmdAlpha_write(a, CmdAlphaRef(ref.offset + 4), s); +} + +void Cmd_Color_write(Alloc a, CmdRef ref, CmdColor s) { + write_mem(a, ref.offset >> 2, Cmd_Color); + CmdColor_write(a, CmdColorRef(ref.offset + 4), s); +} + +void Cmd_Image_write(Alloc a, CmdRef ref, CmdImage s) { + write_mem(a, ref.offset >> 2, Cmd_Image); + CmdImage_write(a, CmdImageRef(ref.offset + 4), s); +} + +void Cmd_BeginClip_write(Alloc a, CmdRef ref) { + write_mem(a, ref.offset >> 2, Cmd_BeginClip); +} + +void Cmd_EndClip_write(Alloc a, CmdRef ref) { + write_mem(a, ref.offset >> 2, Cmd_EndClip); +} + +void Cmd_Jump_write(Alloc a, CmdRef ref, CmdJump s) { + write_mem(a, ref.offset >> 2, Cmd_Jump); + CmdJump_write(a, CmdJumpRef(ref.offset + 4), s); +} + diff --git a/vendor/gioui.org/shader/piet/runtime.h b/vendor/gioui.org/shader/piet/runtime.h new file mode 100644 index 0000000..cfae912 --- /dev/null +++ b/vendor/gioui.org/shader/piet/runtime.h @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: Unlicense OR MIT + +#define ATTR_HIDDEN __attribute__ ((visibility ("hidden"))) + +// program_info contains constant parameters for a program. +struct program_info { + // MinMemorySize is the minimum size of memory passed to dispatch. + size_t min_memory_size; + // has_cbarriers is 1 when the program contains control barriers. + bool has_cbarriers; + // desc_set_size is the size of the first descriptor set for the program. + size_t desc_set_size; + int workgroup_size_x; + int workgroup_size_y; + int workgroup_size_z; + // Program entrypoints. + routine_begin begin; + routine_await await; + routine_destroy destroy; +}; + +// dispatch_context contains the information a program dispatch. +struct dispatch_context; + +// thread_context contains the working memory of a batch. It may be +// reused, but not concurrently. +struct thread_context; + +extern struct buffer_descriptor alloc_buffer(size_t size) ATTR_HIDDEN; +extern struct image_descriptor alloc_image_rgba(int width, int height) ATTR_HIDDEN; + +extern struct dispatch_context *alloc_dispatch_context(void) ATTR_HIDDEN; + +extern void free_dispatch_context(struct dispatch_context *c) ATTR_HIDDEN; + +extern struct thread_context *alloc_thread_context(void) ATTR_HIDDEN; + +extern void free_thread_context(struct thread_context *c) ATTR_HIDDEN; + +// prepare_dispatch initializes ctx to run a dispatch of a program distributed +// among nthreads threads. +extern void prepare_dispatch(struct dispatch_context *ctx, int nthreads, struct program_info *info, uint8_t *desc_set, int ngroupx, int ngroupy, int ngroupz) ATTR_HIDDEN; + +// dispatch_batch executes a dispatch batch. +extern void dispatch_thread(struct dispatch_context *ctx, int thread_idx, struct thread_context *thread) ATTR_HIDDEN; diff --git a/vendor/gioui.org/shader/piet/scene.h b/vendor/gioui.org/shader/piet/scene.h new file mode 100644 index 0000000..38c2549 --- /dev/null +++ b/vendor/gioui.org/shader/piet/scene.h @@ -0,0 +1,313 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Code auto-generated by piet-gpu-derive + +struct LineSegRef { + uint offset; +}; + +struct QuadSegRef { + uint offset; +}; + +struct CubicSegRef { + uint offset; +}; + +struct FillColorRef { + uint offset; +}; + +struct FillImageRef { + uint offset; +}; + +struct SetLineWidthRef { + uint offset; +}; + +struct TransformRef { + uint offset; +}; + +struct ClipRef { + uint offset; +}; + +struct SetFillModeRef { + uint offset; +}; + +struct ElementRef { + uint offset; +}; + +struct LineSeg { + vec2 p0; + vec2 p1; +}; + +#define LineSeg_size 16 + +LineSegRef LineSeg_index(LineSegRef ref, uint index) { + return LineSegRef(ref.offset + index * LineSeg_size); +} + +struct QuadSeg { + vec2 p0; + vec2 p1; + vec2 p2; +}; + +#define QuadSeg_size 24 + +QuadSegRef QuadSeg_index(QuadSegRef ref, uint index) { + return QuadSegRef(ref.offset + index * QuadSeg_size); +} + +struct CubicSeg { + vec2 p0; + vec2 p1; + vec2 p2; + vec2 p3; +}; + +#define CubicSeg_size 32 + +CubicSegRef CubicSeg_index(CubicSegRef ref, uint index) { + return CubicSegRef(ref.offset + index * CubicSeg_size); +} + +struct FillColor { + uint rgba_color; +}; + +#define FillColor_size 4 + +FillColorRef FillColor_index(FillColorRef ref, uint index) { + return FillColorRef(ref.offset + index * FillColor_size); +} + +struct FillImage { + uint index; + ivec2 offset; +}; + +#define FillImage_size 8 + +FillImageRef FillImage_index(FillImageRef ref, uint index) { + return FillImageRef(ref.offset + index * FillImage_size); +} + +struct SetLineWidth { + float width; +}; + +#define SetLineWidth_size 4 + +SetLineWidthRef SetLineWidth_index(SetLineWidthRef ref, uint index) { + return SetLineWidthRef(ref.offset + index * SetLineWidth_size); +} + +struct Transform { + vec4 mat; + vec2 translate; +}; + +#define Transform_size 24 + +TransformRef Transform_index(TransformRef ref, uint index) { + return TransformRef(ref.offset + index * Transform_size); +} + +struct Clip { + vec4 bbox; +}; + +#define Clip_size 16 + +ClipRef Clip_index(ClipRef ref, uint index) { + return ClipRef(ref.offset + index * Clip_size); +} + +struct SetFillMode { + uint fill_mode; +}; + +#define SetFillMode_size 4 + +SetFillModeRef SetFillMode_index(SetFillModeRef ref, uint index) { + return SetFillModeRef(ref.offset + index * SetFillMode_size); +} + +#define Element_Nop 0 +#define Element_Line 1 +#define Element_Quad 2 +#define Element_Cubic 3 +#define Element_FillColor 4 +#define Element_SetLineWidth 5 +#define Element_Transform 6 +#define Element_BeginClip 7 +#define Element_EndClip 8 +#define Element_FillImage 9 +#define Element_SetFillMode 10 +#define Element_size 36 + +ElementRef Element_index(ElementRef ref, uint index) { + return ElementRef(ref.offset + index * Element_size); +} + +struct ElementTag { + uint tag; + uint flags; +}; + +LineSeg LineSeg_read(LineSegRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + uint raw1 = scene[ix + 1]; + uint raw2 = scene[ix + 2]; + uint raw3 = scene[ix + 3]; + LineSeg s; + s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1)); + s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + return s; +} + +QuadSeg QuadSeg_read(QuadSegRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + uint raw1 = scene[ix + 1]; + uint raw2 = scene[ix + 2]; + uint raw3 = scene[ix + 3]; + uint raw4 = scene[ix + 4]; + uint raw5 = scene[ix + 5]; + QuadSeg s; + s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1)); + s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5)); + return s; +} + +CubicSeg CubicSeg_read(CubicSegRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + uint raw1 = scene[ix + 1]; + uint raw2 = scene[ix + 2]; + uint raw3 = scene[ix + 3]; + uint raw4 = scene[ix + 4]; + uint raw5 = scene[ix + 5]; + uint raw6 = scene[ix + 6]; + uint raw7 = scene[ix + 7]; + CubicSeg s; + s.p0 = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1)); + s.p1 = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.p2 = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5)); + s.p3 = vec2(uintBitsToFloat(raw6), uintBitsToFloat(raw7)); + return s; +} + +FillColor FillColor_read(FillColorRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + FillColor s; + s.rgba_color = raw0; + return s; +} + +FillImage FillImage_read(FillImageRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + uint raw1 = scene[ix + 1]; + FillImage s; + s.index = raw0; + s.offset = ivec2(int(raw1 << 16) >> 16, int(raw1) >> 16); + return s; +} + +SetLineWidth SetLineWidth_read(SetLineWidthRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + SetLineWidth s; + s.width = uintBitsToFloat(raw0); + return s; +} + +Transform Transform_read(TransformRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + uint raw1 = scene[ix + 1]; + uint raw2 = scene[ix + 2]; + uint raw3 = scene[ix + 3]; + uint raw4 = scene[ix + 4]; + uint raw5 = scene[ix + 5]; + Transform s; + s.mat = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.translate = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5)); + return s; +} + +Clip Clip_read(ClipRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + uint raw1 = scene[ix + 1]; + uint raw2 = scene[ix + 2]; + uint raw3 = scene[ix + 3]; + Clip s; + s.bbox = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + return s; +} + +SetFillMode SetFillMode_read(SetFillModeRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = scene[ix + 0]; + SetFillMode s; + s.fill_mode = raw0; + return s; +} + +ElementTag Element_tag(ElementRef ref) { + uint tag_and_flags = scene[ref.offset >> 2]; + return ElementTag(tag_and_flags & 0xffff, tag_and_flags >> 16); +} + +LineSeg Element_Line_read(ElementRef ref) { + return LineSeg_read(LineSegRef(ref.offset + 4)); +} + +QuadSeg Element_Quad_read(ElementRef ref) { + return QuadSeg_read(QuadSegRef(ref.offset + 4)); +} + +CubicSeg Element_Cubic_read(ElementRef ref) { + return CubicSeg_read(CubicSegRef(ref.offset + 4)); +} + +FillColor Element_FillColor_read(ElementRef ref) { + return FillColor_read(FillColorRef(ref.offset + 4)); +} + +SetLineWidth Element_SetLineWidth_read(ElementRef ref) { + return SetLineWidth_read(SetLineWidthRef(ref.offset + 4)); +} + +Transform Element_Transform_read(ElementRef ref) { + return Transform_read(TransformRef(ref.offset + 4)); +} + +Clip Element_BeginClip_read(ElementRef ref) { + return Clip_read(ClipRef(ref.offset + 4)); +} + +Clip Element_EndClip_read(ElementRef ref) { + return Clip_read(ClipRef(ref.offset + 4)); +} + +FillImage Element_FillImage_read(ElementRef ref) { + return FillImage_read(FillImageRef(ref.offset + 4)); +} + +SetFillMode Element_SetFillMode_read(ElementRef ref) { + return SetFillMode_read(SetFillModeRef(ref.offset + 4)); +} + diff --git a/vendor/gioui.org/shader/piet/setup.h b/vendor/gioui.org/shader/piet/setup.h new file mode 100644 index 0000000..83b6d1d --- /dev/null +++ b/vendor/gioui.org/shader/piet/setup.h @@ -0,0 +1,51 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Various constants for the sizes of groups and tiles. + +// Much of this will be made dynamic in various ways, but for now it's easiest +// to hardcode and keep all in one place. + +// A LG_WG_FACTOR of n scales workgroup sizes by 2^n. Use 0 for a +// maximum workgroup size of 128, or 1 for a maximum size of 256. +#define LG_WG_FACTOR 0 +#define WG_FACTOR (1<<LG_WG_FACTOR) + +#define TILE_WIDTH_PX 32 +#define TILE_HEIGHT_PX 32 + +#define PTCL_INITIAL_ALLOC 1024 + +// These should probably be renamed and/or reworked. In the binning +// kernel, they represent the number of bins. Also, the workgroup size +// of that kernel is equal to the number of bins, but should probably +// be more flexible (it's 512 in the K&L paper). +#define N_TILE_X 16 +#define N_TILE_Y (8 * WG_FACTOR) +#define N_TILE (N_TILE_X * N_TILE_Y) +#define LG_N_TILE (7 + LG_WG_FACTOR) +#define N_SLICE (N_TILE / 32) + +struct Config { + uint n_elements; // paths + uint n_pathseg; + uint width_in_tiles; + uint height_in_tiles; + Alloc tile_alloc; + Alloc bin_alloc; + Alloc ptcl_alloc; + Alloc pathseg_alloc; + Alloc anno_alloc; + Alloc trans_alloc; +}; + +// Fill modes. +#define MODE_NONZERO 0 +#define MODE_STROKE 1 + +// Size of kernel4 clip state, in words. +#define CLIP_STATE_SIZE 2 + +// fill_mode_from_flags extracts the fill mode from tag flags. +uint fill_mode_from_flags(uint flags) { + return flags & 0x1; +} diff --git a/vendor/gioui.org/shader/piet/shaders.go b/vendor/gioui.org/shader/piet/shaders.go new file mode 100644 index 0000000..b4b6996 --- /dev/null +++ b/vendor/gioui.org/shader/piet/shaders.go @@ -0,0 +1,268 @@ +// Code generated by build.go. DO NOT EDIT. + +package piet + +import ( + _ "embed" + "runtime" + + "gioui.org/shader" +) + +var ( + Shader_backdrop_comp = shader.Sources{ + Name: "backdrop.comp", + StorageBuffers: []shader.BufferBinding{{Name: "Memory", Binding: 0}, {Name: "ConfigBuf", Binding: 1}}, + WorkgroupSize: [3]int{128, 1, 1}, + } + //go:embed zbackdrop.comp.0.spirv + zbackdrop_comp_0_spirv string + //go:embed zbackdrop.comp.0.dxbc + zbackdrop_comp_0_dxbc string + //go:embed zbackdrop.comp.0.metallibmacos + zbackdrop_comp_0_metallibmacos string + //go:embed zbackdrop.comp.0.metallibios + zbackdrop_comp_0_metallibios string + //go:embed zbackdrop.comp.0.metallibiossimulator + zbackdrop_comp_0_metallibiossimulator string + Shader_binning_comp = shader.Sources{ + Name: "binning.comp", + StorageBuffers: []shader.BufferBinding{{Name: "Memory", Binding: 0}, {Name: "ConfigBuf", Binding: 1}}, + WorkgroupSize: [3]int{128, 1, 1}, + } + //go:embed zbinning.comp.0.spirv + zbinning_comp_0_spirv string + //go:embed zbinning.comp.0.dxbc + zbinning_comp_0_dxbc string + //go:embed zbinning.comp.0.metallibmacos + zbinning_comp_0_metallibmacos string + //go:embed zbinning.comp.0.metallibios + zbinning_comp_0_metallibios string + //go:embed zbinning.comp.0.metallibiossimulator + zbinning_comp_0_metallibiossimulator string + Shader_coarse_comp = shader.Sources{ + Name: "coarse.comp", + StorageBuffers: []shader.BufferBinding{{Name: "Memory", Binding: 0}, {Name: "ConfigBuf", Binding: 1}}, + WorkgroupSize: [3]int{128, 1, 1}, + } + //go:embed zcoarse.comp.0.spirv + zcoarse_comp_0_spirv string + //go:embed zcoarse.comp.0.dxbc + zcoarse_comp_0_dxbc string + //go:embed zcoarse.comp.0.metallibmacos + zcoarse_comp_0_metallibmacos string + //go:embed zcoarse.comp.0.metallibios + zcoarse_comp_0_metallibios string + //go:embed zcoarse.comp.0.metallibiossimulator + zcoarse_comp_0_metallibiossimulator string + Shader_elements_comp = shader.Sources{ + Name: "elements.comp", + StorageBuffers: []shader.BufferBinding{{Name: "Memory", Binding: 0}, {Name: "SceneBuf", Binding: 2}, {Name: "StateBuf", Binding: 3}, {Name: "ConfigBuf", Binding: 1}}, + WorkgroupSize: [3]int{32, 1, 1}, + } + //go:embed zelements.comp.0.spirv + zelements_comp_0_spirv string + //go:embed zelements.comp.0.dxbc + zelements_comp_0_dxbc string + //go:embed zelements.comp.0.metallibmacos + zelements_comp_0_metallibmacos string + //go:embed zelements.comp.0.metallibios + zelements_comp_0_metallibios string + //go:embed zelements.comp.0.metallibiossimulator + zelements_comp_0_metallibiossimulator string + Shader_kernel4_comp = shader.Sources{ + Name: "kernel4.comp", + Images: []shader.ImageBinding{{Name: "images", Binding: 3}, {Name: "image", Binding: 2}}, + StorageBuffers: []shader.BufferBinding{{Name: "Memory", Binding: 0}, {Name: "ConfigBuf", Binding: 1}}, + WorkgroupSize: [3]int{16, 8, 1}, + } + //go:embed zkernel4.comp.0.spirv + zkernel4_comp_0_spirv string + //go:embed zkernel4.comp.0.dxbc + zkernel4_comp_0_dxbc string + //go:embed zkernel4.comp.0.metallibmacos + zkernel4_comp_0_metallibmacos string + //go:embed zkernel4.comp.0.metallibios + zkernel4_comp_0_metallibios string + //go:embed zkernel4.comp.0.metallibiossimulator + zkernel4_comp_0_metallibiossimulator string + Shader_path_coarse_comp = shader.Sources{ + Name: "path_coarse.comp", + StorageBuffers: []shader.BufferBinding{{Name: "Memory", Binding: 0}, {Name: "ConfigBuf", Binding: 1}}, + WorkgroupSize: [3]int{32, 1, 1}, + } + //go:embed zpath_coarse.comp.0.spirv + zpath_coarse_comp_0_spirv string + //go:embed zpath_coarse.comp.0.dxbc + zpath_coarse_comp_0_dxbc string + //go:embed zpath_coarse.comp.0.metallibmacos + zpath_coarse_comp_0_metallibmacos string + //go:embed zpath_coarse.comp.0.metallibios + zpath_coarse_comp_0_metallibios string + //go:embed zpath_coarse.comp.0.metallibiossimulator + zpath_coarse_comp_0_metallibiossimulator string + Shader_tile_alloc_comp = shader.Sources{ + Name: "tile_alloc.comp", + StorageBuffers: []shader.BufferBinding{{Name: "Memory", Binding: 0}, {Name: "ConfigBuf", Binding: 1}}, + WorkgroupSize: [3]int{128, 1, 1}, + } + //go:embed ztile_alloc.comp.0.spirv + ztile_alloc_comp_0_spirv string + //go:embed ztile_alloc.comp.0.dxbc + ztile_alloc_comp_0_dxbc string + //go:embed ztile_alloc.comp.0.metallibmacos + ztile_alloc_comp_0_metallibmacos string + //go:embed ztile_alloc.comp.0.metallibios + ztile_alloc_comp_0_metallibios string + //go:embed ztile_alloc.comp.0.metallibiossimulator + ztile_alloc_comp_0_metallibiossimulator string +) + +func init() { + const ( + opengles = runtime.GOOS == "linux" || runtime.GOOS == "freebsd" || runtime.GOOS == "openbsd" || runtime.GOOS == "windows" || runtime.GOOS == "js" || runtime.GOOS == "android" || runtime.GOOS == "darwin" || runtime.GOOS == "ios" + opengl = runtime.GOOS == "darwin" + d3d11 = runtime.GOOS == "windows" + vulkan = runtime.GOOS == "linux" || runtime.GOOS == "android" + ) + if vulkan { + Shader_backdrop_comp.SPIRV = zbackdrop_comp_0_spirv + } + if opengles { + } + if opengl { + } + if d3d11 { + Shader_backdrop_comp.DXBC = zbackdrop_comp_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_backdrop_comp.MetalLib = zbackdrop_comp_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_backdrop_comp.MetalLib = zbackdrop_comp_0_metallibiossimulator + } else { + Shader_backdrop_comp.MetalLib = zbackdrop_comp_0_metallibios + } + } + if vulkan { + Shader_binning_comp.SPIRV = zbinning_comp_0_spirv + } + if opengles { + } + if opengl { + } + if d3d11 { + Shader_binning_comp.DXBC = zbinning_comp_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_binning_comp.MetalLib = zbinning_comp_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_binning_comp.MetalLib = zbinning_comp_0_metallibiossimulator + } else { + Shader_binning_comp.MetalLib = zbinning_comp_0_metallibios + } + } + if vulkan { + Shader_coarse_comp.SPIRV = zcoarse_comp_0_spirv + } + if opengles { + } + if opengl { + } + if d3d11 { + Shader_coarse_comp.DXBC = zcoarse_comp_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_coarse_comp.MetalLib = zcoarse_comp_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_coarse_comp.MetalLib = zcoarse_comp_0_metallibiossimulator + } else { + Shader_coarse_comp.MetalLib = zcoarse_comp_0_metallibios + } + } + if vulkan { + Shader_elements_comp.SPIRV = zelements_comp_0_spirv + } + if opengles { + } + if opengl { + } + if d3d11 { + Shader_elements_comp.DXBC = zelements_comp_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_elements_comp.MetalLib = zelements_comp_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_elements_comp.MetalLib = zelements_comp_0_metallibiossimulator + } else { + Shader_elements_comp.MetalLib = zelements_comp_0_metallibios + } + } + if vulkan { + Shader_kernel4_comp.SPIRV = zkernel4_comp_0_spirv + } + if opengles { + } + if opengl { + } + if d3d11 { + Shader_kernel4_comp.DXBC = zkernel4_comp_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_kernel4_comp.MetalLib = zkernel4_comp_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_kernel4_comp.MetalLib = zkernel4_comp_0_metallibiossimulator + } else { + Shader_kernel4_comp.MetalLib = zkernel4_comp_0_metallibios + } + } + if vulkan { + Shader_path_coarse_comp.SPIRV = zpath_coarse_comp_0_spirv + } + if opengles { + } + if opengl { + } + if d3d11 { + Shader_path_coarse_comp.DXBC = zpath_coarse_comp_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_path_coarse_comp.MetalLib = zpath_coarse_comp_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_path_coarse_comp.MetalLib = zpath_coarse_comp_0_metallibiossimulator + } else { + Shader_path_coarse_comp.MetalLib = zpath_coarse_comp_0_metallibios + } + } + if vulkan { + Shader_tile_alloc_comp.SPIRV = ztile_alloc_comp_0_spirv + } + if opengles { + } + if opengl { + } + if d3d11 { + Shader_tile_alloc_comp.DXBC = ztile_alloc_comp_0_dxbc + } + if runtime.GOOS == "darwin" { + Shader_tile_alloc_comp.MetalLib = ztile_alloc_comp_0_metallibmacos + } + if runtime.GOOS == "ios" { + if runtime.GOARCH == "amd64" { + Shader_tile_alloc_comp.MetalLib = ztile_alloc_comp_0_metallibiossimulator + } else { + Shader_tile_alloc_comp.MetalLib = ztile_alloc_comp_0_metallibios + } + } +} diff --git a/vendor/gioui.org/shader/piet/state.h b/vendor/gioui.org/shader/piet/state.h new file mode 100644 index 0000000..d2df804 --- /dev/null +++ b/vendor/gioui.org/shader/piet/state.h @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Code auto-generated by piet-gpu-derive + +struct StateRef { + uint offset; +}; + +struct State { + vec4 mat; + vec2 translate; + vec4 bbox; + float linewidth; + uint flags; + uint path_count; + uint pathseg_count; + uint trans_count; +}; + +#define State_size 60 + +StateRef State_index(StateRef ref, uint index) { + return StateRef(ref.offset + index * State_size); +} + +State State_read(StateRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = state[ix + 0]; + uint raw1 = state[ix + 1]; + uint raw2 = state[ix + 2]; + uint raw3 = state[ix + 3]; + uint raw4 = state[ix + 4]; + uint raw5 = state[ix + 5]; + uint raw6 = state[ix + 6]; + uint raw7 = state[ix + 7]; + uint raw8 = state[ix + 8]; + uint raw9 = state[ix + 9]; + uint raw10 = state[ix + 10]; + uint raw11 = state[ix + 11]; + uint raw12 = state[ix + 12]; + uint raw13 = state[ix + 13]; + uint raw14 = state[ix + 14]; + State s; + s.mat = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.translate = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5)); + s.bbox = vec4(uintBitsToFloat(raw6), uintBitsToFloat(raw7), uintBitsToFloat(raw8), uintBitsToFloat(raw9)); + s.linewidth = uintBitsToFloat(raw10); + s.flags = raw11; + s.path_count = raw12; + s.pathseg_count = raw13; + s.trans_count = raw14; + return s; +} + +void State_write(StateRef ref, State s) { + uint ix = ref.offset >> 2; + state[ix + 0] = floatBitsToUint(s.mat.x); + state[ix + 1] = floatBitsToUint(s.mat.y); + state[ix + 2] = floatBitsToUint(s.mat.z); + state[ix + 3] = floatBitsToUint(s.mat.w); + state[ix + 4] = floatBitsToUint(s.translate.x); + state[ix + 5] = floatBitsToUint(s.translate.y); + state[ix + 6] = floatBitsToUint(s.bbox.x); + state[ix + 7] = floatBitsToUint(s.bbox.y); + state[ix + 8] = floatBitsToUint(s.bbox.z); + state[ix + 9] = floatBitsToUint(s.bbox.w); + state[ix + 10] = floatBitsToUint(s.linewidth); + state[ix + 11] = s.flags; + state[ix + 12] = s.path_count; + state[ix + 13] = s.pathseg_count; + state[ix + 14] = s.trans_count; +} + diff --git a/vendor/gioui.org/shader/piet/support.c b/vendor/gioui.org/shader/piet/support.c new file mode 100644 index 0000000..1b7dd42 --- /dev/null +++ b/vendor/gioui.org/shader/piet/support.c @@ -0,0 +1,27 @@ +// SPDX-License-Identifier: Unlicense OR MIT + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +#include <stdint.h> +#include <stdlib.h> +#include <assert.h> +#include "abi.h" +#include "runtime.h" + +static void *malloc_align(size_t alignment, size_t size) { + void *ptr; + int ret = posix_memalign(&ptr, alignment, size); + assert(ret == 0); + return ptr; +} + +ATTR_HIDDEN void *coroutine_alloc_frame(size_t size) { + void *ptr = malloc_align(16, size); + return ptr; +} + +ATTR_HIDDEN void coroutine_free_frame(void *ptr) { + free(ptr); +} diff --git a/vendor/gioui.org/shader/piet/tile.h b/vendor/gioui.org/shader/piet/tile.h new file mode 100644 index 0000000..e11329c --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile.h @@ -0,0 +1,150 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Code auto-generated by piet-gpu-derive + +struct PathRef { + uint offset; +}; + +struct TileRef { + uint offset; +}; + +struct TileSegRef { + uint offset; +}; + +struct TransformSegRef { + uint offset; +}; + +struct Path { + uvec4 bbox; + TileRef tiles; +}; + +#define Path_size 12 + +PathRef Path_index(PathRef ref, uint index) { + return PathRef(ref.offset + index * Path_size); +} + +struct Tile { + TileSegRef tile; + int backdrop; +}; + +#define Tile_size 8 + +TileRef Tile_index(TileRef ref, uint index) { + return TileRef(ref.offset + index * Tile_size); +} + +struct TileSeg { + vec2 origin; + vec2 vector; + float y_edge; + TileSegRef next; +}; + +#define TileSeg_size 24 + +TileSegRef TileSeg_index(TileSegRef ref, uint index) { + return TileSegRef(ref.offset + index * TileSeg_size); +} + +struct TransformSeg { + vec4 mat; + vec2 translate; +}; + +#define TransformSeg_size 24 + +TransformSegRef TransformSeg_index(TransformSegRef ref, uint index) { + return TransformSegRef(ref.offset + index * TransformSeg_size); +} + +Path Path_read(Alloc a, PathRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + uint raw2 = read_mem(a, ix + 2); + Path s; + s.bbox = uvec4(raw0 & 0xffff, raw0 >> 16, raw1 & 0xffff, raw1 >> 16); + s.tiles = TileRef(raw2); + return s; +} + +void Path_write(Alloc a, PathRef ref, Path s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, s.bbox.x | (s.bbox.y << 16)); + write_mem(a, ix + 1, s.bbox.z | (s.bbox.w << 16)); + write_mem(a, ix + 2, s.tiles.offset); +} + +Tile Tile_read(Alloc a, TileRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + Tile s; + s.tile = TileSegRef(raw0); + s.backdrop = int(raw1); + return s; +} + +void Tile_write(Alloc a, TileRef ref, Tile s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, s.tile.offset); + write_mem(a, ix + 1, uint(s.backdrop)); +} + +TileSeg TileSeg_read(Alloc a, TileSegRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + uint raw2 = read_mem(a, ix + 2); + uint raw3 = read_mem(a, ix + 3); + uint raw4 = read_mem(a, ix + 4); + uint raw5 = read_mem(a, ix + 5); + TileSeg s; + s.origin = vec2(uintBitsToFloat(raw0), uintBitsToFloat(raw1)); + s.vector = vec2(uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.y_edge = uintBitsToFloat(raw4); + s.next = TileSegRef(raw5); + return s; +} + +void TileSeg_write(Alloc a, TileSegRef ref, TileSeg s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, floatBitsToUint(s.origin.x)); + write_mem(a, ix + 1, floatBitsToUint(s.origin.y)); + write_mem(a, ix + 2, floatBitsToUint(s.vector.x)); + write_mem(a, ix + 3, floatBitsToUint(s.vector.y)); + write_mem(a, ix + 4, floatBitsToUint(s.y_edge)); + write_mem(a, ix + 5, s.next.offset); +} + +TransformSeg TransformSeg_read(Alloc a, TransformSegRef ref) { + uint ix = ref.offset >> 2; + uint raw0 = read_mem(a, ix + 0); + uint raw1 = read_mem(a, ix + 1); + uint raw2 = read_mem(a, ix + 2); + uint raw3 = read_mem(a, ix + 3); + uint raw4 = read_mem(a, ix + 4); + uint raw5 = read_mem(a, ix + 5); + TransformSeg s; + s.mat = vec4(uintBitsToFloat(raw0), uintBitsToFloat(raw1), uintBitsToFloat(raw2), uintBitsToFloat(raw3)); + s.translate = vec2(uintBitsToFloat(raw4), uintBitsToFloat(raw5)); + return s; +} + +void TransformSeg_write(Alloc a, TransformSegRef ref, TransformSeg s) { + uint ix = ref.offset >> 2; + write_mem(a, ix + 0, floatBitsToUint(s.mat.x)); + write_mem(a, ix + 1, floatBitsToUint(s.mat.y)); + write_mem(a, ix + 2, floatBitsToUint(s.mat.z)); + write_mem(a, ix + 3, floatBitsToUint(s.mat.w)); + write_mem(a, ix + 4, floatBitsToUint(s.translate.x)); + write_mem(a, ix + 5, floatBitsToUint(s.translate.y)); +} + diff --git a/vendor/gioui.org/shader/piet/tile_alloc.comp b/vendor/gioui.org/shader/piet/tile_alloc.comp new file mode 100644 index 0000000..0b6eca4 --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile_alloc.comp @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: Apache-2.0 OR MIT OR Unlicense + +// Allocation and initialization of tiles for paths. + +#version 450 +#extension GL_GOOGLE_include_directive : enable + +#include "mem.h" +#include "setup.h" + +#define LG_TILE_ALLOC_WG (7 + LG_WG_FACTOR) +#define TILE_ALLOC_WG (1 << LG_TILE_ALLOC_WG) + +layout(local_size_x = TILE_ALLOC_WG, local_size_y = 1) in; + +layout(set = 0, binding = 1) readonly buffer ConfigBuf { + Config conf; +}; + +#include "annotated.h" +#include "tile.h" + +// scale factors useful for converting coordinates to tiles +#define SX (1.0 / float(TILE_WIDTH_PX)) +#define SY (1.0 / float(TILE_HEIGHT_PX)) + +shared uint sh_tile_count[TILE_ALLOC_WG]; +shared Alloc sh_tile_alloc; +// Really a bool, but some Metal devices don't accept shared bools. +shared uint sh_tile_alloc_failed; + +void main() { + uint th_ix = gl_LocalInvocationID.x; + uint element_ix = gl_GlobalInvocationID.x; + PathRef path_ref = PathRef(conf.tile_alloc.offset + element_ix * Path_size); + AnnotatedRef ref = AnnotatedRef(conf.anno_alloc.offset + element_ix * Annotated_size); + + uint tag = Annotated_Nop; + if (element_ix < conf.n_elements) { + tag = Annotated_tag(conf.anno_alloc, ref).tag; + } + int x0 = 0, y0 = 0, x1 = 0, y1 = 0; + switch (tag) { + case Annotated_Color: + case Annotated_Image: + case Annotated_BeginClip: + case Annotated_EndClip: + // Note: we take advantage of the fact that fills, strokes, and + // clips have compatible layout. + AnnoEndClip clip = Annotated_EndClip_read(conf.anno_alloc, ref); + x0 = int(floor(clip.bbox.x * SX)); + y0 = int(floor(clip.bbox.y * SY)); + x1 = int(ceil(clip.bbox.z * SX)); + y1 = int(ceil(clip.bbox.w * SY)); + break; + } + x0 = clamp(x0, 0, int(conf.width_in_tiles)); + y0 = clamp(y0, 0, int(conf.height_in_tiles)); + x1 = clamp(x1, 0, int(conf.width_in_tiles)); + y1 = clamp(y1, 0, int(conf.height_in_tiles)); + + Path path; + path.bbox = uvec4(x0, y0, x1, y1); + uint tile_count = (x1 - x0) * (y1 - y0); + if (tag == Annotated_EndClip) { + // Don't actually allocate tiles for an end clip, but we do want + // the path structure (especially bbox) allocated for it. + tile_count = 0; + } + + sh_tile_count[th_ix] = tile_count; + uint total_tile_count = tile_count; + // Prefix sum of sh_tile_count + for (uint i = 0; i < LG_TILE_ALLOC_WG; i++) { + barrier(); + if (th_ix >= (1 << i)) { + total_tile_count += sh_tile_count[th_ix - (1 << i)]; + } + barrier(); + sh_tile_count[th_ix] = total_tile_count; + } + if (th_ix == TILE_ALLOC_WG - 1) { + MallocResult res = malloc(total_tile_count * Tile_size); + sh_tile_alloc = res.alloc; + sh_tile_alloc_failed = res.failed ? 1 : 0; + } + barrier(); + if (sh_tile_alloc_failed != 0 || mem_error != NO_ERROR) { + return; + } + Alloc alloc_start = sh_tile_alloc; + + if (element_ix < conf.n_elements) { + uint tile_subix = th_ix > 0 ? sh_tile_count[th_ix - 1] : 0; + Alloc tiles_alloc = slice_mem(alloc_start, Tile_size * tile_subix, Tile_size * tile_count); + path.tiles = TileRef(tiles_alloc.offset); + Path_write(conf.tile_alloc, path_ref, path); + } + + // Zero out allocated tiles efficiently + uint total_count = sh_tile_count[TILE_ALLOC_WG - 1] * (Tile_size / 4); + uint start_ix = alloc_start.offset >> 2; + for (uint i = th_ix; i < total_count; i += TILE_ALLOC_WG) { + // Note: this interleaving is faster than using Tile_write + // by a significant amount. + write_mem(alloc_start, start_ix + i, 0); + } +} diff --git a/vendor/gioui.org/shader/piet/tile_alloc_abi.c b/vendor/gioui.org/shader/piet/tile_alloc_abi.c new file mode 100644 index 0000000..0cffe2c --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile_alloc_abi.c @@ -0,0 +1,23 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +#include <stdint.h> +#include <stddef.h> +#include "abi.h" +#include "runtime.h" +#include "tile_alloc_abi.h" + +const struct program_info tile_alloc_program_info = { + .has_cbarriers = 1, + .min_memory_size = 100000, + .desc_set_size = sizeof(struct tile_alloc_descriptor_set_layout), + .workgroup_size_x = 128, + .workgroup_size_y = 1, + .workgroup_size_z = 1, + .begin = tile_alloc_coroutine_begin, + .await = tile_alloc_coroutine_await, + .destroy = tile_alloc_coroutine_destroy, +}; diff --git a/vendor/gioui.org/shader/piet/tile_alloc_abi.go b/vendor/gioui.org/shader/piet/tile_alloc_abi.go new file mode 100644 index 0000000..8d0414e --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile_alloc_abi.go @@ -0,0 +1,35 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build linux && (arm64 || arm || amd64) +// +build linux +// +build arm64 arm amd64 + +package piet + +import "gioui.org/cpu" +import "unsafe" + +/* +#cgo LDFLAGS: -lm + +#include <stdint.h> +#include <stdlib.h> +#include "abi.h" +#include "runtime.h" +#include "tile_alloc_abi.h" +*/ +import "C" + +var Tile_allocProgramInfo = (*cpu.ProgramInfo)(unsafe.Pointer(&C.tile_alloc_program_info)) + +type Tile_allocDescriptorSetLayout = C.struct_tile_alloc_descriptor_set_layout + +const Tile_allocHash = "364b3cf559d02a86c751292bedc571d5ceef2df899de39ad483b4176294e9857" + +func (l *Tile_allocDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding0)) +} + +func (l *Tile_allocDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + return (*cpu.BufferDescriptor)(unsafe.Pointer(&l.binding1)) +} diff --git a/vendor/gioui.org/shader/piet/tile_alloc_abi.h b/vendor/gioui.org/shader/piet/tile_alloc_abi.h new file mode 100644 index 0000000..aac2706 --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile_alloc_abi.h @@ -0,0 +1,17 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +struct tile_alloc_descriptor_set_layout { + struct buffer_descriptor binding0; + struct buffer_descriptor binding1; +}; + +extern coroutine tile_alloc_coroutine_begin(struct program_data *data, + int32_t workgroupX, int32_t workgroupY, int32_t workgroupZ, + void *workgroupMemory, + int32_t firstSubgroup, + int32_t subgroupCount) ATTR_HIDDEN; + +extern bool tile_alloc_coroutine_await(coroutine r, yield_result *res) ATTR_HIDDEN; +extern void tile_alloc_coroutine_destroy(coroutine r) ATTR_HIDDEN; + +extern const struct program_info tile_alloc_program_info ATTR_HIDDEN; diff --git a/vendor/gioui.org/shader/piet/tile_alloc_abi_nosupport.go b/vendor/gioui.org/shader/piet/tile_alloc_abi_nosupport.go new file mode 100644 index 0000000..fb3a023 --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile_alloc_abi_nosupport.go @@ -0,0 +1,22 @@ +// Code generated by gioui.org/cpu/cmd/compile DO NOT EDIT. + +//go:build !(linux && (arm64 || arm || amd64)) +// +build !linux !arm64,!arm,!amd64 + +package piet + +import "gioui.org/cpu" + +var Tile_allocProgramInfo *cpu.ProgramInfo + +type Tile_allocDescriptorSetLayout struct{} + +const Tile_allocHash = "" + +func (l *Tile_allocDescriptorSetLayout) Binding0() *cpu.BufferDescriptor { + panic("unsupported") +} + +func (l *Tile_allocDescriptorSetLayout) Binding1() *cpu.BufferDescriptor { + panic("unsupported") +} diff --git a/vendor/gioui.org/shader/piet/tile_alloc_linux_amd64.syso b/vendor/gioui.org/shader/piet/tile_alloc_linux_amd64.syso Binary files differnew file mode 100644 index 0000000..0f37c87 --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile_alloc_linux_amd64.syso diff --git a/vendor/gioui.org/shader/piet/tile_alloc_linux_arm.syso b/vendor/gioui.org/shader/piet/tile_alloc_linux_arm.syso Binary files differnew file mode 100644 index 0000000..ab62099 --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile_alloc_linux_arm.syso diff --git a/vendor/gioui.org/shader/piet/tile_alloc_linux_arm64.syso b/vendor/gioui.org/shader/piet/tile_alloc_linux_arm64.syso Binary files differnew file mode 100644 index 0000000..0c968b0 --- /dev/null +++ b/vendor/gioui.org/shader/piet/tile_alloc_linux_arm64.syso diff --git a/vendor/gioui.org/shader/piet/zbackdrop.comp.0.dxbc b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.dxbc Binary files differnew file mode 100644 index 0000000..a255faf --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.dxbc diff --git a/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibios b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibios Binary files differnew file mode 100644 index 0000000..349eb6e --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibios diff --git a/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibiossimulator b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..2d9f890 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibmacos b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibmacos Binary files differnew file mode 100644 index 0000000..a72cd7b --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.metallibmacos diff --git a/vendor/gioui.org/shader/piet/zbackdrop.comp.0.spirv b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.spirv Binary files differnew file mode 100644 index 0000000..e3ffcfb --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbackdrop.comp.0.spirv diff --git a/vendor/gioui.org/shader/piet/zbinning.comp.0.dxbc b/vendor/gioui.org/shader/piet/zbinning.comp.0.dxbc Binary files differnew file mode 100644 index 0000000..ba04622 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbinning.comp.0.dxbc diff --git a/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibios b/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibios Binary files differnew file mode 100644 index 0000000..862042e --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibios diff --git a/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibiossimulator b/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..c1e8019 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibmacos b/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibmacos Binary files differnew file mode 100644 index 0000000..27508e1 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbinning.comp.0.metallibmacos diff --git a/vendor/gioui.org/shader/piet/zbinning.comp.0.spirv b/vendor/gioui.org/shader/piet/zbinning.comp.0.spirv Binary files differnew file mode 100644 index 0000000..7cfcb0c --- /dev/null +++ b/vendor/gioui.org/shader/piet/zbinning.comp.0.spirv diff --git a/vendor/gioui.org/shader/piet/zcoarse.comp.0.dxbc b/vendor/gioui.org/shader/piet/zcoarse.comp.0.dxbc Binary files differnew file mode 100644 index 0000000..94a3259 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zcoarse.comp.0.dxbc diff --git a/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibios b/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibios Binary files differnew file mode 100644 index 0000000..29c8dbf --- /dev/null +++ b/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibios diff --git a/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibiossimulator b/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..12b533d --- /dev/null +++ b/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibmacos b/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibmacos Binary files differnew file mode 100644 index 0000000..c9a781b --- /dev/null +++ b/vendor/gioui.org/shader/piet/zcoarse.comp.0.metallibmacos diff --git a/vendor/gioui.org/shader/piet/zcoarse.comp.0.spirv b/vendor/gioui.org/shader/piet/zcoarse.comp.0.spirv Binary files differnew file mode 100644 index 0000000..23e652a --- /dev/null +++ b/vendor/gioui.org/shader/piet/zcoarse.comp.0.spirv diff --git a/vendor/gioui.org/shader/piet/zelements.comp.0.dxbc b/vendor/gioui.org/shader/piet/zelements.comp.0.dxbc Binary files differnew file mode 100644 index 0000000..e4916b7 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zelements.comp.0.dxbc diff --git a/vendor/gioui.org/shader/piet/zelements.comp.0.metallibios b/vendor/gioui.org/shader/piet/zelements.comp.0.metallibios Binary files differnew file mode 100644 index 0000000..1d5097f --- /dev/null +++ b/vendor/gioui.org/shader/piet/zelements.comp.0.metallibios diff --git a/vendor/gioui.org/shader/piet/zelements.comp.0.metallibiossimulator b/vendor/gioui.org/shader/piet/zelements.comp.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..367e234 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zelements.comp.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/piet/zelements.comp.0.metallibmacos b/vendor/gioui.org/shader/piet/zelements.comp.0.metallibmacos Binary files differnew file mode 100644 index 0000000..b405013 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zelements.comp.0.metallibmacos diff --git a/vendor/gioui.org/shader/piet/zelements.comp.0.spirv b/vendor/gioui.org/shader/piet/zelements.comp.0.spirv Binary files differnew file mode 100644 index 0000000..84057ac --- /dev/null +++ b/vendor/gioui.org/shader/piet/zelements.comp.0.spirv diff --git a/vendor/gioui.org/shader/piet/zkernel4.comp.0.dxbc b/vendor/gioui.org/shader/piet/zkernel4.comp.0.dxbc Binary files differnew file mode 100644 index 0000000..f459a5d --- /dev/null +++ b/vendor/gioui.org/shader/piet/zkernel4.comp.0.dxbc diff --git a/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibios b/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibios Binary files differnew file mode 100644 index 0000000..a979d51 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibios diff --git a/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibiossimulator b/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..1dbb051 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibmacos b/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibmacos Binary files differnew file mode 100644 index 0000000..99a823b --- /dev/null +++ b/vendor/gioui.org/shader/piet/zkernel4.comp.0.metallibmacos diff --git a/vendor/gioui.org/shader/piet/zkernel4.comp.0.spirv b/vendor/gioui.org/shader/piet/zkernel4.comp.0.spirv Binary files differnew file mode 100644 index 0000000..d558185 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zkernel4.comp.0.spirv diff --git a/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.dxbc b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.dxbc Binary files differnew file mode 100644 index 0000000..70eaf00 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.dxbc diff --git a/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibios b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibios Binary files differnew file mode 100644 index 0000000..e6c2985 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibios diff --git a/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibiossimulator b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..edde25c --- /dev/null +++ b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibmacos b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibmacos Binary files differnew file mode 100644 index 0000000..d1c5653 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.metallibmacos diff --git a/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.spirv b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.spirv Binary files differnew file mode 100644 index 0000000..078ea61 --- /dev/null +++ b/vendor/gioui.org/shader/piet/zpath_coarse.comp.0.spirv diff --git a/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.dxbc b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.dxbc Binary files differnew file mode 100644 index 0000000..309a77a --- /dev/null +++ b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.dxbc diff --git a/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibios b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibios Binary files differnew file mode 100644 index 0000000..0e165cf --- /dev/null +++ b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibios diff --git a/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibiossimulator b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibiossimulator Binary files differnew file mode 100644 index 0000000..a95ef45 --- /dev/null +++ b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibiossimulator diff --git a/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibmacos b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibmacos Binary files differnew file mode 100644 index 0000000..be6ab47 --- /dev/null +++ b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.metallibmacos diff --git a/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.spirv b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.spirv Binary files differnew file mode 100644 index 0000000..06f9b60 --- /dev/null +++ b/vendor/gioui.org/shader/piet/ztile_alloc.comp.0.spirv diff --git a/vendor/gioui.org/shader/shader.go b/vendor/gioui.org/shader/shader.go new file mode 100644 index 0000000..e1263c1 --- /dev/null +++ b/vendor/gioui.org/shader/shader.go @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: Unlicense OR MIT + +package shader + +type Sources struct { + Name string + SPIRV string + GLSL100ES string + GLSL150 string + DXBC string + MetalLib string + Uniforms UniformsReflection + Inputs []InputLocation + Textures []TextureBinding + StorageBuffers []BufferBinding + Images []ImageBinding + WorkgroupSize [3]int +} + +type UniformsReflection struct { + Locations []UniformLocation + Size int +} + +type ImageBinding struct { + Name string + Binding int +} + +type BufferBinding struct { + Name string + Binding int +} + +type TextureBinding struct { + Name string + Binding int +} + +type UniformLocation struct { + Name string + Type DataType + Size int + Offset int +} + +type InputLocation struct { + // For GLSL. + Name string + Location int + // For HLSL. + Semantic string + SemanticIndex int + + Type DataType + Size int +} + +type DataType uint8 + +const ( + DataTypeFloat DataType = iota + DataTypeInt + DataTypeShort +) |