~eliasnaur/gio-shader

2b825c477157c028550b94d3333253182968141a — Elias Naur 1 year, 9 days ago abcd0e0 v1.0.8
gio: make blit and cover shaders available for FBO rendering

Signed-off-by: Elias Naur <mail@eliasnaur.com>
M README.md => README.md +2 -2
@@ 1,7 1,7 @@
# 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
This repository contains source code for the [Gio](https://gioui.org)
project. It also contains the generators and derived versions for use with the
GPU APIs supported by Gio.

# Generating CPU fallbacks

M gio/blit.vert => gio/blit.vert +7 -1
@@ 13,6 13,8 @@ layout(push_constant) uniform Block {
	vec4 uvTransformR1;
	vec4 uvTransformR2;
	float opacity;
	// fbo is set if blitting to a FBO, otherwise the window.
	float fbo;
} _block;

layout(location = 0) in vec2 pos;


@@ 24,7 26,11 @@ layout(location = 1) out float opacity;

void main() {
	vec2 p = pos*_block.transform.xy + _block.transform.zw;
	gl_Position = vec4(transform3x2(windowTransform, vec3(p, 0)), 1);
	if (_block.fbo != 0.0) {
		gl_Position = vec4(transform3x2(fboTransform, vec3(p, 0)), 1);
	} else {
		gl_Position = vec4(transform3x2(windowTransform, vec3(p, 0)), 1);
	}
	vUV = transform3x2(m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz), vec3(uv,1)).xy;
	opacity = _block.opacity;
}

M gio/cover.vert => gio/cover.vert +7 -1
@@ 13,6 13,8 @@ layout(push_constant) uniform Block {
	vec4 uvCoverTransform;
	vec4 uvTransformR1;
	vec4 uvTransformR2;
	// fbo is set if blitting to a FBO, otherwise the window.
	float fbo;
} _block;

layout(location = 0) in vec2 pos;


@@ 24,7 26,11 @@ 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);
	if (_block.fbo != 0.0) {
		gl_Position = vec4(transform3x2(fboTransform, vec3(p, 0)), 1);
	} else {
		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;

M gio/shaders.go => gio/shaders.go +4 -4
@@ 79,8 79,8 @@ var (
		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}, {Name: "_block.opacity", Type: 0x0, Size: 1, Offset: 48}},
			Size:      52,
			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}, {Name: "_block.opacity", Type: 0x0, Size: 1, Offset: 48}, {Name: "_block.fbo", Type: 0x0, Size: 1, Offset: 52}},
			Size:      56,
		},
	}
	//go:embed zblit.vert.0.spirv


@@ 209,8 209,8 @@ var (
		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,
			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}, {Name: "_block.fbo", Type: 0x0, Size: 1, Offset: 64}},
			Size:      68,
		},
	}
	//go:embed zcover.vert.0.spirv

M gio/zblit.vert.0.dxbc => gio/zblit.vert.0.dxbc +0 -0
M gio/zblit.vert.0.glsl100es => gio/zblit.vert.0.glsl100es +16 -6
@@ 12,6 12,7 @@ struct Block
    vec4 uvTransformR1;
    vec4 uvTransformR2;
    float opacity;
    float fbo;
};

uniform Block _block;


@@ 29,12 30,21 @@ vec3 transform3x2(m3x2 t, vec3 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;
    if (_block.fbo != 0.0)
    {
        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);
    }
    else
    {
        m3x2 param_2 = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0));
        vec3 param_3 = vec3(p, 0.0);
        gl_Position = vec4(transform3x2(param_2, param_3), 1.0);
    }
    m3x2 param_4 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz);
    vec3 param_5 = vec3(uv, 1.0);
    vUV = transform3x2(param_4, param_5).xy;
    opacity = _block.opacity;
}


M gio/zblit.vert.0.glsl150 => gio/zblit.vert.0.glsl150 +16 -6
@@ 12,6 12,7 @@ struct Block
    vec4 uvTransformR1;
    vec4 uvTransformR2;
    float opacity;
    float fbo;
};

uniform Block _block;


@@ 29,12 30,21 @@ vec3 transform3x2(m3x2 t, vec3 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;
    if (_block.fbo != 0.0)
    {
        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);
    }
    else
    {
        m3x2 param_2 = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0));
        vec3 param_3 = vec3(p, 0.0);
        gl_Position = vec4(transform3x2(param_2, param_3), 1.0);
    }
    m3x2 param_4 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz);
    vec3 param_5 = vec3(uv, 1.0);
    vUV = transform3x2(param_4, param_5).xy;
    opacity = _block.opacity;
}


M gio/zblit.vert.0.metallibios => gio/zblit.vert.0.metallibios +0 -0
M gio/zblit.vert.0.metallibiossimulator => gio/zblit.vert.0.metallibiossimulator +0 -0
M gio/zblit.vert.0.metallibmacos => gio/zblit.vert.0.metallibmacos +0 -0
M gio/zblit.vert.0.spirv => gio/zblit.vert.0.spirv +0 -0
M gio/zcover.vert.0.glsl100es => gio/zcover.vert.0.glsl100es +16 -6
@@ 12,6 12,7 @@ struct Block
    vec4 uvCoverTransform;
    vec4 uvTransformR1;
    vec4 uvTransformR2;
    float fbo;
};

uniform Block _block;


@@ 29,12 30,21 @@ vec3 transform3x2(m3x2 t, vec3 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;
    if (_block.fbo != 0.0)
    {
        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);
    }
    else
    {
        m3x2 param_2 = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0));
        vec3 param_3 = vec3(p, 0.0);
        gl_Position = vec4(transform3x2(param_2, param_3), 1.0);
    }
    m3x2 param_4 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz);
    vec3 param_5 = vec3(uv, 1.0);
    vUV = transform3x2(param_4, param_5).xy;
    vec3 uv3 = vec3(uv, 1.0);
    vCoverUV = ((uv3 * vec3(_block.uvCoverTransform.xy, 1.0)) + vec3(_block.uvCoverTransform.zw, 0.0)).xy;
}

M gio/zcover.vert.0.glsl150 => gio/zcover.vert.0.glsl150 +16 -6
@@ 12,6 12,7 @@ struct Block
    vec4 uvCoverTransform;
    vec4 uvTransformR1;
    vec4 uvTransformR2;
    float fbo;
};

uniform Block _block;


@@ 29,12 30,21 @@ vec3 transform3x2(m3x2 t, vec3 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;
    if (_block.fbo != 0.0)
    {
        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);
    }
    else
    {
        m3x2 param_2 = m3x2(vec3(1.0, 0.0, 0.0), vec3(0.0, -1.0, 0.0));
        vec3 param_3 = vec3(p, 0.0);
        gl_Position = vec4(transform3x2(param_2, param_3), 1.0);
    }
    m3x2 param_4 = m3x2(_block.uvTransformR1.xyz, _block.uvTransformR2.xyz);
    vec3 param_5 = vec3(uv, 1.0);
    vUV = transform3x2(param_4, param_5).xy;
    vec3 uv3 = vec3(uv, 1.0);
    vCoverUV = ((uv3 * vec3(_block.uvCoverTransform.xy, 1.0)) + vec3(_block.uvCoverTransform.zw, 0.0)).xy;
}

M gio/zcover.vert.0.metallibios => gio/zcover.vert.0.metallibios +0 -0
M gio/zcover.vert.0.metallibiossimulator => gio/zcover.vert.0.metallibiossimulator +0 -0
M gio/zcover.vert.0.metallibmacos => gio/zcover.vert.0.metallibmacos +0 -0
M gio/zcover.vert.0.spirv => gio/zcover.vert.0.spirv +0 -0