diff --git a/gl/src/lib.rs b/gl/src/lib.rs index dabfec0ca..13ea36b25 100644 --- a/gl/src/lib.rs +++ b/gl/src/lib.rs @@ -148,16 +148,16 @@ impl GLDevice { unsafe { match *data { UniformData::Float(value) => { - gl::Uniform1f(uniform.location, value); ck(); + gl::Uniform4f(uniform.location, value, 0.0, 0.0, 0.0); ck(); } UniformData::IVec2(value) => { - gl::Uniform2i(uniform.location, value[0], value[1]); ck(); + gl::Uniform4i(uniform.location, value[0], value[1], 0, 0); ck(); } UniformData::IVec3(value) => { - gl::Uniform3i(uniform.location, value[0], value[1], value[2]); ck(); + gl::Uniform4i(uniform.location, value[0], value[1], value[2], 0); ck(); } UniformData::Int(value) => { - gl::Uniform1i(uniform.location, value); ck(); + gl::Uniform4i(uniform.location, value, 0, 0, 0); ck(); } UniformData::Mat2(data) => { assert_eq!(mem::size_of::(), 4 * 4); @@ -168,17 +168,16 @@ impl GLDevice { } UniformData::Mat4(data) => { assert_eq!(mem::size_of::<[F32x4; 4]>(), 4 * 4 * 4); - let data_ptr: *const F32x4 = data.as_ptr(); - gl::UniformMatrix4fv(uniform.location, - 1, - gl::FALSE, - data_ptr as *const GLfloat); + gl::Uniform4f(uniform.location, data[0].x(), data[0].y(), data[0].z(), data[0].w()); ck(); + gl::Uniform4f(uniform.location + 1, data[1].x(), data[1].y(), data[1].z(), data[1].w()); ck(); + gl::Uniform4f(uniform.location + 2, data[2].x(), data[2].y(), data[2].z(), data[2].w()); ck(); + gl::Uniform4f(uniform.location + 3, data[3].x(), data[3].y(), data[3].z(), data[3].w()); ck(); } UniformData::Vec2(data) => { - gl::Uniform2f(uniform.location, data.x(), data.y()); ck(); + gl::Uniform4f(uniform.location, data.x(), data.y(), 0.0, 0.0); ck(); } UniformData::Vec3(data) => { - gl::Uniform3f(uniform.location, data[0], data[1], data[2]); ck(); + gl::Uniform4f(uniform.location, data[0], data[1], data[2], 0.0); ck(); } UniformData::Vec4(data) => { gl::Uniform4f(uniform.location, data.x(), data.y(), data.z(), data.w()); ck(); @@ -432,10 +431,17 @@ impl Device for GLDevice { } fn get_uniform(&self, program: &GLProgram, name: &str) -> GLUniform { - let name = CString::new(format!("u{}", name)).unwrap(); - let location = unsafe { - gl::GetUniformLocation(program.gl_program, name.as_ptr() as *const GLchar) + let uniform_name = CString::new(format!("u{}", name)).unwrap(); + let mut location = unsafe { + gl::GetUniformLocation(program.gl_program, uniform_name.as_ptr() as *const GLchar) }; ck(); + if location < 0 { + let uniform_name = CString::new(format!("SPIRV_Cross_Combinedu{}uSampler", name)).unwrap(); + location = unsafe { + gl::GetUniformLocation(program.gl_program, uniform_name.as_ptr() as *const GLchar) + }; + ck(); + }; GLUniform { location } } diff --git a/metal/src/lib.rs b/metal/src/lib.rs index 6e85722b0..4ceff48d0 100644 --- a/metal/src/lib.rs +++ b/metal/src/lib.rs @@ -848,7 +848,7 @@ impl MetalDevice { None => panic!("get_uniform_index() called before reflection!"), Some(ref arguments) => arguments, }; - let (main_name, sampler_name) = (format!("u{}", name), format!("u{}Smplr", name)); + let (main_name, sampler_name) = (format!("u{}", name), format!("u{}Sampler", name)); let (mut main_argument, mut sampler_argument) = (None, None); for argument_index in 0..arguments.len() { let argument = arguments.object_at(argument_index); diff --git a/resources/shaders/gl3/blit.fs.glsl b/resources/shaders/gl3/blit.fs.glsl index b32fc956f..806d71495 100644 --- a/resources/shaders/gl3/blit.fs.glsl +++ b/resources/shaders/gl3/blit.fs.glsl @@ -2,30 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform sampler2D uSrc; +uniform sampler2D SPIRV_Cross_CombineduSrcuSampler; in vec2 vTexCoord; +layout(location = 0) out vec4 oFragColor; -out vec4 oFragColor; - -void main(){ - vec4 color = texture(uSrc, vTexCoord); - oFragColor = vec4(color . rgb * color . a, color . a); +void main() +{ + vec4 color = texture(SPIRV_Cross_CombineduSrcuSampler, vTexCoord); + oFragColor = vec4(color.xyz * color.w, color.w); } diff --git a/resources/shaders/gl3/blit.vs.glsl b/resources/shaders/gl3/blit.vs.glsl index 6c9391d50..7efaa8cdc 100644 --- a/resources/shaders/gl3/blit.vs.glsl +++ b/resources/shaders/gl3/blit.vs.glsl @@ -2,32 +2,13 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -in ivec2 aPosition; - +layout(location = 0) in ivec2 aPosition; out vec2 vTexCoord; -void main(){ +void main() +{ vec2 texCoord = vec2(aPosition); - - - vTexCoord = texCoord; - gl_Position = vec4(mix(vec2(- 1.0), vec2(1.0), vec2(aPosition)), 0.0, 1.0); + gl_Position = vec4(mix(vec2(-1.0), vec2(1.0), vec2(aPosition)), 0.0, 1.0); } diff --git a/resources/shaders/gl3/clear.fs.glsl b/resources/shaders/gl3/clear.fs.glsl index 447e4d838..bfc45445d 100644 --- a/resources/shaders/gl3/clear.fs.glsl +++ b/resources/shaders/gl3/clear.fs.glsl @@ -2,27 +2,11 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uColor[1]; +layout(location = 0) out vec4 oFragColor; - - - - - - - - - -precision highp float; - - - - - -uniform vec4 uColor; - -out vec4 oFragColor; - -void main(){ - oFragColor = vec4(uColor . rgb, 1.0)* uColor . a; +void main() +{ + oFragColor = vec4(uColor[0].xyz, 1.0) * uColor[0].w; } diff --git a/resources/shaders/gl3/clear.vs.glsl b/resources/shaders/gl3/clear.vs.glsl index 2dd02b1ce..76b85239b 100644 --- a/resources/shaders/gl3/clear.vs.glsl +++ b/resources/shaders/gl3/clear.vs.glsl @@ -2,29 +2,13 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform vec4 uRect; -uniform vec2 uFramebufferSize; - -in ivec2 aPosition; - -void main(){ - vec2 position = mix(uRect . xy, uRect . zw, vec2(aPosition))/ uFramebufferSize * 2.0 - 1.0; - gl_Position = vec4(position . x, - position . y, 0.0, 1.0); +uniform vec4 uRect[1]; +uniform vec4 uFramebufferSize[1]; +layout(location = 0) in ivec2 aPosition; + +void main() +{ + vec2 position = ((mix(uRect[0].xy, uRect[0].zw, vec2(aPosition)) / uFramebufferSize[0].xy) * 2.0) - vec2(1.0); + gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/resources/shaders/gl3/debug_solid.fs.glsl b/resources/shaders/gl3/debug_solid.fs.glsl index 447e4d838..bfc45445d 100644 --- a/resources/shaders/gl3/debug_solid.fs.glsl +++ b/resources/shaders/gl3/debug_solid.fs.glsl @@ -2,27 +2,11 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uColor[1]; +layout(location = 0) out vec4 oFragColor; - - - - - - - - - -precision highp float; - - - - - -uniform vec4 uColor; - -out vec4 oFragColor; - -void main(){ - oFragColor = vec4(uColor . rgb, 1.0)* uColor . a; +void main() +{ + oFragColor = vec4(uColor[0].xyz, 1.0) * uColor[0].w; } diff --git a/resources/shaders/gl3/debug_solid.vs.glsl b/resources/shaders/gl3/debug_solid.vs.glsl index de155484a..705fbc5ef 100644 --- a/resources/shaders/gl3/debug_solid.vs.glsl +++ b/resources/shaders/gl3/debug_solid.vs.glsl @@ -2,28 +2,12 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uFramebufferSize[1]; +layout(location = 0) in ivec2 aPosition; - - - - - - - - - -precision highp float; - - - - - -uniform vec2 uFramebufferSize; - -in ivec2 aPosition; - -void main(){ - vec2 position = vec2(aPosition)/ uFramebufferSize * 2.0 - 1.0; - gl_Position = vec4(position . x, - position . y, 0.0, 1.0); +void main() +{ + vec2 position = ((vec2(aPosition) / uFramebufferSize[0].xy) * 2.0) - vec2(1.0); + gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/resources/shaders/gl3/debug_texture.fs.glsl b/resources/shaders/gl3/debug_texture.fs.glsl index c786f3520..7a23aec86 100644 --- a/resources/shaders/gl3/debug_texture.fs.glsl +++ b/resources/shaders/gl3/debug_texture.fs.glsl @@ -2,31 +2,15 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform sampler2D uTexture; -uniform vec4 uColor; +uniform vec4 uColor[1]; +uniform sampler2D SPIRV_Cross_CombineduTextureuSampler; in vec2 vTexCoord; +layout(location = 0) out vec4 oFragColor; -out vec4 oFragColor; - -void main(){ - float alpha = texture(uTexture, vTexCoord). r * uColor . a; - oFragColor = alpha * vec4(uColor . rgb, 1.0); +void main() +{ + float alpha = texture(SPIRV_Cross_CombineduTextureuSampler, vTexCoord).x * uColor[0].w; + oFragColor = vec4(uColor[0].xyz, 1.0) * alpha; } diff --git a/resources/shaders/gl3/debug_texture.vs.glsl b/resources/shaders/gl3/debug_texture.vs.glsl index e073da211..e8965d26f 100644 --- a/resources/shaders/gl3/debug_texture.vs.glsl +++ b/resources/shaders/gl3/debug_texture.vs.glsl @@ -2,33 +2,16 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform vec2 uFramebufferSize; -uniform vec2 uTextureSize; - -in ivec2 aPosition; -in ivec2 aTexCoord; - +uniform vec4 uTextureSize[1]; +uniform vec4 uFramebufferSize[1]; out vec2 vTexCoord; - -void main(){ - vTexCoord = vec2(aTexCoord)/ uTextureSize; - vec2 position = vec2(aPosition)/ uFramebufferSize * 2.0 - 1.0; - gl_Position = vec4(position . x, - position . y, 0.0, 1.0); +layout(location = 1) in ivec2 aTexCoord; +layout(location = 0) in ivec2 aPosition; + +void main() +{ + vTexCoord = vec2(aTexCoord) / uTextureSize[0].xy; + vec2 position = ((vec2(aPosition) / uFramebufferSize[0].xy) * 2.0) - vec2(1.0); + gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/resources/shaders/gl3/demo_ground.fs.glsl b/resources/shaders/gl3/demo_ground.fs.glsl index 63c0883ea..f33c5b98b 100644 --- a/resources/shaders/gl3/demo_ground.fs.glsl +++ b/resources/shaders/gl3/demo_ground.fs.glsl @@ -2,31 +2,23 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform vec4 uGroundColor; -uniform vec4 uGridlineColor; - +uniform vec4 uGridlineColor[1]; +uniform vec4 uGroundColor[1]; in vec2 vTexCoord; - -out vec4 oFragColor; - -void main(){ - vec2 texCoordPx = fract(vTexCoord)/ fwidth(vTexCoord); - oFragColor = any(lessThanEqual(texCoordPx, vec2(1.0)))? uGridlineColor : uGroundColor; +layout(location = 0) out vec4 oFragColor; + +void main() +{ + vec2 texCoordPx = fract(vTexCoord) / fwidth(vTexCoord); + vec4 _28; + if (any(lessThanEqual(texCoordPx, vec2(1.0)))) + { + _28 = uGridlineColor[0]; + } + else + { + _28 = uGroundColor[0]; + } + oFragColor = _28; } diff --git a/resources/shaders/gl3/demo_ground.vs.glsl b/resources/shaders/gl3/demo_ground.vs.glsl index cb3a47421..c87472bea 100644 --- a/resources/shaders/gl3/demo_ground.vs.glsl +++ b/resources/shaders/gl3/demo_ground.vs.glsl @@ -2,31 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uTransform; -uniform int uGridlineCount; - -in ivec2 aPosition; - +uniform ivec4 uGridlineCount[1]; +uniform vec4 uTransform[4]; out vec2 vTexCoord; +layout(location = 0) in ivec2 aPosition; -void main(){ - vTexCoord = vec2(aPosition * uGridlineCount); - gl_Position = uTransform * vec4(ivec4(aPosition . x, 0, aPosition . y, 1)); +void main() +{ + vTexCoord = vec2(aPosition * ivec2(uGridlineCount[0].x)); + gl_Position = mat4(uTransform[0], uTransform[1], uTransform[2], uTransform[3]) * vec4(ivec4(aPosition.x, 0, aPosition.y, 1)); } diff --git a/resources/shaders/gl3/fill.fs.glsl b/resources/shaders/gl3/fill.fs.glsl index e56cbaebb..b7c0dee33 100644 --- a/resources/shaders/gl3/fill.fs.glsl +++ b/resources/shaders/gl3/fill.fs.glsl @@ -2,62 +2,31 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform sampler2D SPIRV_Cross_CombineduAreaLUTuSampler; - - - - - - - - - -#extension GL_GOOGLE_include_directive : enable - -precision highp float; - - - - - - - - - - - - - - - - -vec4 computeCoverage(vec2 from, vec2 to, sampler2D areaLUT){ - - vec2 left = from . x < to . x ? from : to, right = from . x < to . x ? to : from; - - - vec2 window = clamp(vec2(from . x, to . x), - 0.5, 0.5); - float offset = mix(window . x, window . y, 0.5)- left . x; - float t = offset /(right . x - left . x); - - - float y = mix(left . y, right . y, t); - float d =(right . y - left . y)/(right . x - left . x); - - - float dX = window . x - window . y; - return texture(areaLUT, vec2(y + 8.0, abs(d * dX))/ 16.0)* dX; -} - - -uniform sampler2D uAreaLUT; - +layout(location = 0) out vec4 oFragColor; in vec2 vFrom; in vec2 vTo; -out vec4 oFragColor; +vec4 computeCoverage(vec2 from, vec2 to, sampler2D SPIRV_Cross_CombinedareaLUTareaLUTSampler) +{ + bvec2 _34 = bvec2(from.x < to.x); + vec2 left = vec2(_34.x ? from.x : to.x, _34.y ? from.y : to.y); + bvec2 _44 = bvec2(from.x < to.x); + vec2 right = vec2(_44.x ? to.x : from.x, _44.y ? to.y : from.y); + vec2 window = clamp(vec2(from.x, to.x), vec2(-0.5), vec2(0.5)); + float offset = mix(window.x, window.y, 0.5) - left.x; + float t = offset / (right.x - left.x); + float y = mix(left.y, right.y, t); + float d = (right.y - left.y) / (right.x - left.x); + float dX = window.x - window.y; + return texture(SPIRV_Cross_CombinedareaLUTareaLUTSampler, vec2(y + 8.0, abs(d * dX)) / vec2(16.0)) * dX; +} -void main(){ - oFragColor = computeCoverage(vFrom, vTo, uAreaLUT); +void main() +{ + vec2 param = vFrom; + vec2 param_1 = vTo; + oFragColor = computeCoverage(param, param_1, SPIRV_Cross_CombineduAreaLUTuSampler); } diff --git a/resources/shaders/gl3/fill.vs.glsl b/resources/shaders/gl3/fill.vs.glsl index 58b0b7f02..6db1875b7 100644 --- a/resources/shaders/gl3/fill.vs.glsl +++ b/resources/shaders/gl3/fill.vs.glsl @@ -2,70 +2,53 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform vec2 uFramebufferSize; -uniform vec2 uTileSize; - -in uvec2 aTessCoord; -in uint aFromPx; -in uint aToPx; -in vec2 aFromSubpx; -in vec2 aToSubpx; -in uint aTileIndex; - +uniform vec4 uTileSize[1]; +uniform vec4 uFramebufferSize[1]; +layout(location = 5) in uint aTileIndex; +layout(location = 1) in uint aFromPx; +layout(location = 3) in vec2 aFromSubpx; +layout(location = 2) in uint aToPx; +layout(location = 4) in vec2 aToSubpx; +layout(location = 0) in uvec2 aTessCoord; out vec2 vFrom; out vec2 vTo; -vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth){ - uint tilesPerRow = uint(stencilTextureWidth / uTileSize . x); +vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth) +{ + uint tilesPerRow = uint(stencilTextureWidth / uTileSize[0].x); uvec2 tileOffset = uvec2(tileIndex % tilesPerRow, tileIndex / tilesPerRow); - return vec2(tileOffset)* uTileSize * vec2(1.0, 0.25); + return (vec2(tileOffset) * uTileSize[0].xy) * vec2(1.0, 0.25); } -void main(){ - vec2 tileOrigin = computeTileOffset(aTileIndex, uFramebufferSize . x); - - vec2 from = vec2(aFromPx & 15u, aFromPx >> 4u)+ aFromSubpx; - vec2 to = vec2(aToPx & 15u, aToPx >> 4u)+ aToSubpx; - +void main() +{ + uint param = aTileIndex; + float param_1 = uFramebufferSize[0].x; + vec2 tileOrigin = computeTileOffset(param, param_1); + vec2 from = vec2(float(aFromPx & 15u), float(aFromPx >> 4u)) + aFromSubpx; + vec2 to = vec2(float(aToPx & 15u), float(aToPx >> 4u)) + aToSubpx; vec2 position; - if(aTessCoord . x == 0u) - position . x = floor(min(from . x, to . x)); + if (aTessCoord.x == 0u) + { + position.x = floor(min(from.x, to.x)); + } else - position . x = ceil(max(from . x, to . x)); - if(aTessCoord . y == 0u) - position . y = floor(min(from . y, to . y)); + { + position.x = ceil(max(from.x, to.x)); + } + if (aTessCoord.y == 0u) + { + position.y = floor(min(from.y, to.y)); + } else - position . y = uTileSize . y; - position . y = floor(position . y * 0.25); - - - - - - vec2 offset = vec2(0.0, 1.5)- position * vec2(1.0, 4.0); + { + position.y = uTileSize[0].y; + } + position.y = floor(position.y * 0.25); + vec2 offset = vec2(0.0, 1.5) - (position * vec2(1.0, 4.0)); vFrom = from + offset; vTo = to + offset; - - vec2 globalPosition =(tileOrigin + position)/ uFramebufferSize * 2.0 - 1.0; - - - + vec2 globalPosition = (((tileOrigin + position) / uFramebufferSize[0].xy) * 2.0) - vec2(1.0); gl_Position = vec4(globalPosition, 0.0, 1.0); } diff --git a/resources/shaders/gl3/reproject.fs.glsl b/resources/shaders/gl3/reproject.fs.glsl index a2fe1643d..5803ed2bc 100644 --- a/resources/shaders/gl3/reproject.fs.glsl +++ b/resources/shaders/gl3/reproject.fs.glsl @@ -2,32 +2,16 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uOldTransform; -uniform sampler2D uTexture; +uniform vec4 uOldTransform[4]; +uniform sampler2D SPIRV_Cross_CombineduTextureuSampler; in vec2 vTexCoord; +layout(location = 0) out vec4 oFragColor; -out vec4 oFragColor; - -void main(){ - vec4 normTexCoord = uOldTransform * vec4(vTexCoord, 0.0, 1.0); - vec2 texCoord =((normTexCoord . xy / normTexCoord . w)+ 1.0)* 0.5; - oFragColor = texture(uTexture, texCoord); +void main() +{ + vec4 normTexCoord = mat4(uOldTransform[0], uOldTransform[1], uOldTransform[2], uOldTransform[3]) * vec4(vTexCoord, 0.0, 1.0); + vec2 texCoord = ((normTexCoord.xy / vec2(normTexCoord.w)) + vec2(1.0)) * 0.5; + oFragColor = texture(SPIRV_Cross_CombineduTextureuSampler, texCoord); } diff --git a/resources/shaders/gl3/reproject.vs.glsl b/resources/shaders/gl3/reproject.vs.glsl index 539e30e15..8cb538d47 100644 --- a/resources/shaders/gl3/reproject.vs.glsl +++ b/resources/shaders/gl3/reproject.vs.glsl @@ -2,36 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uNewTransform; - -in ivec2 aPosition; - +uniform vec4 uNewTransform[4]; +layout(location = 0) in ivec2 aPosition; out vec2 vTexCoord; -void main(){ +void main() +{ vec2 position = vec2(aPosition); vTexCoord = position; - - - - - - gl_Position = uNewTransform * vec4(position, 0.0, 1.0); + gl_Position = mat4(uNewTransform[0], uNewTransform[1], uNewTransform[2], uNewTransform[3]) * vec4(position, 0.0, 1.0); } diff --git a/resources/shaders/gl3/stencil.fs.glsl b/resources/shaders/gl3/stencil.fs.glsl index 2174f77ac..c9a19890d 100644 --- a/resources/shaders/gl3/stencil.fs.glsl +++ b/resources/shaders/gl3/stencil.fs.glsl @@ -2,26 +2,10 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +layout(location = 0) out vec4 oFragColor; - - - - - - - - - -precision highp float; - - - - - -out vec4 oFragColor; - -void main(){ - +void main() +{ oFragColor = vec4(1.0, 0.0, 0.0, 1.0); } diff --git a/resources/shaders/gl3/stencil.vs.glsl b/resources/shaders/gl3/stencil.vs.glsl index e42111876..f56fba14e 100644 --- a/resources/shaders/gl3/stencil.vs.glsl +++ b/resources/shaders/gl3/stencil.vs.glsl @@ -2,25 +2,10 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +layout(location = 0) in vec3 aPosition; - - - - - - - - - -precision highp float; - - - - - -in vec3 aPosition; - -void main(){ +void main() +{ gl_Position = vec4(aPosition, 1.0); } diff --git a/resources/shaders/gl3/tile.fs.glsl b/resources/shaders/gl3/tile.fs.glsl index 33815bd91..ad5011885 100644 --- a/resources/shaders/gl3/tile.fs.glsl +++ b/resources/shaders/gl3/tile.fs.glsl @@ -2,613 +2,570 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#extension GL_GOOGLE_include_directive : enable - -precision highp float; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uniform sampler2D uColorTexture0; -uniform sampler2D uMaskTexture0; -uniform sampler2D uDestTexture; -uniform sampler2D uGammaLUT; -uniform vec2 uColorTextureSize0; -uniform vec2 uMaskTextureSize0; -uniform vec4 uFilterParams0; -uniform vec4 uFilterParams1; -uniform vec4 uFilterParams2; -uniform vec2 uFramebufferSize; -uniform int uCtrl; +uniform vec4 uMaskTextureSize0[1]; +uniform vec4 uColorTextureSize0[1]; +uniform vec4 uFramebufferSize[1]; +uniform vec4 uFilterParams0[1]; +uniform vec4 uFilterParams1[1]; +uniform vec4 uFilterParams2[1]; +uniform ivec4 uCtrl[1]; +uniform sampler2D SPIRV_Cross_CombineduMaskTexture0uSampler; +uniform sampler2D SPIRV_Cross_CombineduColorTexture0uSampler; +uniform sampler2D SPIRV_Cross_CombineduGammaLUTuSampler; +uniform sampler2D SPIRV_Cross_CombineduDestTextureuSampler; in vec3 vMaskTexCoord0; -in vec2 vColorTexCoord0; in vec4 vBaseColor; +in vec2 vColorTexCoord0; +layout(location = 0) out vec4 oFragColor; in float vTileCtrl; -out vec4 oFragColor; - - - -vec4 sampleColor(sampler2D colorTexture, vec2 colorTexCoord){ - return texture(colorTexture, colorTexCoord); +float sampleMask(float maskAlpha, vec2 maskTextureSize, vec3 maskTexCoord, int maskCtrl, sampler2D SPIRV_Cross_CombinedmaskTextureuSampler) +{ + if (maskCtrl == 0) + { + return maskAlpha; + } + ivec2 maskTexCoordI = ivec2(floor(maskTexCoord.xy)); + vec4 texel = texture(SPIRV_Cross_CombinedmaskTextureuSampler, (vec2(maskTexCoordI / ivec2(1, 4)) + vec2(0.5)) / maskTextureSize); + float coverage = texel[maskTexCoordI.y % 4] + maskTexCoord.z; + if ((maskCtrl & 1) != 0) + { + coverage = abs(coverage); + } + else + { + coverage = 1.0 - abs(1.0 - mod(coverage, 2.0)); + } + return min(maskAlpha, coverage); } - - -vec4 combineColor0(vec4 destColor, vec4 srcColor, int op){ - switch(op){ - case 0x1 : - return vec4(srcColor . rgb, srcColor . a * destColor . a); - case 0x2 : - return vec4(destColor . rgb, srcColor . a * destColor . a); +vec4 filterRadialGradient(vec2 colorTexCoord, vec2 colorTextureSize, vec2 fragCoord, vec2 framebufferSize, vec4 filterParams0, vec4 filterParams1, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + vec2 lineFrom = filterParams0.xy; + vec2 lineVector = filterParams0.zw; + vec2 radii = filterParams1.xy; + vec2 uvOrigin = filterParams1.zw; + vec2 dP = colorTexCoord - lineFrom; + vec2 dC = lineVector; + float dR = radii.y - radii.x; + float a = dot(dC, dC) - (dR * dR); + float b = dot(dP, dC) + (radii.x * dR); + float c = dot(dP, dP) - (radii.x * radii.x); + float discrim = (b * b) - (a * c); + vec4 color = vec4(0.0); + if (abs(discrim) >= 9.9999997473787516355514526367188e-06) + { + vec2 ts = vec2((vec2(1.0, -1.0) * sqrt(discrim)) + vec2(b)) / vec2(a); + if (ts.x > ts.y) + { + ts = ts.yx; + } + float _566; + if (ts.x >= 0.0) + { + _566 = ts.x; + } + else + { + _566 = ts.y; + } + float t = _566; + color = texture(SPIRV_Cross_CombinedcolorTextureuSampler, uvOrigin + vec2(clamp(t, 0.0, 1.0), 0.0)); } - return destColor; + return color; } - - -float filterTextSample1Tap(float offset, sampler2D colorTexture, vec2 colorTexCoord){ - return texture(colorTexture, colorTexCoord + vec2(offset, 0.0)). r; +vec4 filterBlur(vec2 colorTexCoord, vec2 colorTextureSize, vec4 filterParams0, vec4 filterParams1, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + vec2 srcOffsetScale = filterParams0.xy / colorTextureSize; + int support = int(filterParams0.z); + vec3 gaussCoeff = filterParams1.xyz; + float gaussSum = gaussCoeff.x; + vec4 color = texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord) * gaussCoeff.x; + vec2 _615 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = vec3(_615.x, _615.y, gaussCoeff.z); + for (int i = 1; i <= support; i += 2) + { + float gaussPartialSum = gaussCoeff.x; + vec2 _635 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = vec3(_635.x, _635.y, gaussCoeff.z); + gaussPartialSum += gaussCoeff.x; + vec2 srcOffset = srcOffsetScale * (float(i) + (gaussCoeff.x / gaussPartialSum)); + color += ((texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord - srcOffset) + texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord + srcOffset)) * gaussPartialSum); + gaussSum += (2.0 * gaussPartialSum); + vec2 _679 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = vec3(_679.x, _679.y, gaussCoeff.z); + } + return color / vec4(gaussSum); } - -void filterTextSample9Tap(out vec4 outAlphaLeft, - out float outAlphaCenter, - out vec4 outAlphaRight, - sampler2D colorTexture, - vec2 colorTexCoord, - vec4 kernel, - float onePixel){ - bool wide = kernel . x > 0.0; - outAlphaLeft = - vec4(wide ? filterTextSample1Tap(- 4.0 * onePixel, colorTexture, colorTexCoord): 0.0, - filterTextSample1Tap(- 3.0 * onePixel, colorTexture, colorTexCoord), - filterTextSample1Tap(- 2.0 * onePixel, colorTexture, colorTexCoord), - filterTextSample1Tap(- 1.0 * onePixel, colorTexture, colorTexCoord)); - outAlphaCenter = filterTextSample1Tap(0.0, colorTexture, colorTexCoord); - outAlphaRight = - vec4(filterTextSample1Tap(1.0 * onePixel, colorTexture, colorTexCoord), - filterTextSample1Tap(2.0 * onePixel, colorTexture, colorTexCoord), - filterTextSample1Tap(3.0 * onePixel, colorTexture, colorTexCoord), - wide ? filterTextSample1Tap(4.0 * onePixel, colorTexture, colorTexCoord): 0.0); +float filterTextSample1Tap(float offset, vec2 colorTexCoord, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + return texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord + vec2(offset, 0.0)).x; } -float filterTextConvolve7Tap(vec4 alpha0, vec3 alpha1, vec4 kernel){ - return dot(alpha0, kernel)+ dot(alpha1, kernel . zyx); +void filterTextSample9Tap(out vec4 outAlphaLeft, out float outAlphaCenter, out vec4 outAlphaRight, vec2 colorTexCoord, vec4 kernel, float onePixel, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + bool wide = kernel.x > 0.0; + float _243; + if (wide) + { + float param = (-4.0) * onePixel; + vec2 param_1 = colorTexCoord; + _243 = filterTextSample1Tap(param, param_1, SPIRV_Cross_CombinedcolorTextureuSampler); + } + else + { + _243 = 0.0; + } + float param_2 = (-3.0) * onePixel; + vec2 param_3 = colorTexCoord; + float param_4 = (-2.0) * onePixel; + vec2 param_5 = colorTexCoord; + float param_6 = (-1.0) * onePixel; + vec2 param_7 = colorTexCoord; + outAlphaLeft = vec4(_243, filterTextSample1Tap(param_2, param_3, SPIRV_Cross_CombinedcolorTextureuSampler), filterTextSample1Tap(param_4, param_5, SPIRV_Cross_CombinedcolorTextureuSampler), filterTextSample1Tap(param_6, param_7, SPIRV_Cross_CombinedcolorTextureuSampler)); + float param_8 = 0.0; + vec2 param_9 = colorTexCoord; + outAlphaCenter = filterTextSample1Tap(param_8, param_9, SPIRV_Cross_CombinedcolorTextureuSampler); + float param_10 = 1.0 * onePixel; + vec2 param_11 = colorTexCoord; + float param_12 = 2.0 * onePixel; + vec2 param_13 = colorTexCoord; + float param_14 = 3.0 * onePixel; + vec2 param_15 = colorTexCoord; + float _303; + if (wide) + { + float param_16 = 4.0 * onePixel; + vec2 param_17 = colorTexCoord; + _303 = filterTextSample1Tap(param_16, param_17, SPIRV_Cross_CombinedcolorTextureuSampler); + } + else + { + _303 = 0.0; + } + outAlphaRight = vec4(filterTextSample1Tap(param_10, param_11, SPIRV_Cross_CombinedcolorTextureuSampler), filterTextSample1Tap(param_12, param_13, SPIRV_Cross_CombinedcolorTextureuSampler), filterTextSample1Tap(param_14, param_15, SPIRV_Cross_CombinedcolorTextureuSampler), _303); } -float filterTextGammaCorrectChannel(float bgColor, float fgColor, sampler2D gammaLUT){ - return texture(gammaLUT, vec2(fgColor, 1.0 - bgColor)). r; +float filterTextConvolve7Tap(vec4 alpha0, vec3 alpha1, vec4 kernel) +{ + return dot(alpha0, kernel) + dot(alpha1, kernel.zyx); } - -vec3 filterTextGammaCorrect(vec3 bgColor, vec3 fgColor, sampler2D gammaLUT){ - return vec3(filterTextGammaCorrectChannel(bgColor . r, fgColor . r, gammaLUT), - filterTextGammaCorrectChannel(bgColor . g, fgColor . g, gammaLUT), - filterTextGammaCorrectChannel(bgColor . b, fgColor . b, gammaLUT)); +float filterTextGammaCorrectChannel(float bgColor, float fgColor, sampler2D SPIRV_Cross_CombinedgammaLUTuSampler) +{ + return texture(SPIRV_Cross_CombinedgammaLUTuSampler, vec2(fgColor, 1.0 - bgColor)).x; } +vec3 filterTextGammaCorrect(vec3 bgColor, vec3 fgColor, sampler2D SPIRV_Cross_CombinedgammaLUTuSampler) +{ + float param = bgColor.x; + float param_1 = fgColor.x; + float param_2 = bgColor.y; + float param_3 = fgColor.y; + float param_4 = bgColor.z; + float param_5 = fgColor.z; + return vec3(filterTextGammaCorrectChannel(param, param_1, SPIRV_Cross_CombinedgammaLUTuSampler), filterTextGammaCorrectChannel(param_2, param_3, SPIRV_Cross_CombinedgammaLUTuSampler), filterTextGammaCorrectChannel(param_4, param_5, SPIRV_Cross_CombinedgammaLUTuSampler)); +} - - - - -vec4 filterText(vec2 colorTexCoord, - sampler2D colorTexture, - sampler2D gammaLUT, - vec2 colorTextureSize, - vec4 filterParams0, - vec4 filterParams1, - vec4 filterParams2){ - +vec4 filterText(vec2 colorTexCoord, vec2 colorTextureSize, vec4 filterParams0, vec4 filterParams1, vec4 filterParams2, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler, sampler2D SPIRV_Cross_CombinedgammaLUTuSampler) +{ vec4 kernel = filterParams0; - vec3 bgColor = filterParams1 . rgb; - vec3 fgColor = filterParams2 . rgb; - bool gammaCorrectionEnabled = filterParams2 . a != 0.0; - - + vec3 bgColor = filterParams1.xyz; + vec3 fgColor = filterParams2.xyz; + bool gammaCorrectionEnabled = filterParams2.w != 0.0; vec3 alpha; - if(kernel . w == 0.0){ - alpha = texture(colorTexture, colorTexCoord). rrr; - } else { - vec4 alphaLeft, alphaRight; - float alphaCenter; - filterTextSample9Tap(alphaLeft, - alphaCenter, - alphaRight, - colorTexture, - colorTexCoord, - kernel, - 1.0 / colorTextureSize . x); - - float r = filterTextConvolve7Tap(alphaLeft, vec3(alphaCenter, alphaRight . xy), kernel); - float g = filterTextConvolve7Tap(vec4(alphaLeft . yzw, alphaCenter), alphaRight . xyz, kernel); - float b = filterTextConvolve7Tap(vec4(alphaLeft . zw, alphaCenter, alphaRight . x), - alphaRight . yzw, - kernel); - + if (kernel.w == 0.0) + { + alpha = texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord).xxx; + } + else + { + vec2 param_3 = colorTexCoord; + vec4 param_4 = kernel; + float param_5 = 1.0 / colorTextureSize.x; + vec4 param; + float param_1; + vec4 param_2; + filterTextSample9Tap(param, param_1, param_2, param_3, param_4, param_5, SPIRV_Cross_CombinedcolorTextureuSampler); + vec4 alphaLeft = param; + float alphaCenter = param_1; + vec4 alphaRight = param_2; + vec4 param_6 = alphaLeft; + vec3 param_7 = vec3(alphaCenter, alphaRight.xy); + vec4 param_8 = kernel; + float r = filterTextConvolve7Tap(param_6, param_7, param_8); + vec4 param_9 = vec4(alphaLeft.yzw, alphaCenter); + vec3 param_10 = alphaRight.xyz; + vec4 param_11 = kernel; + float g = filterTextConvolve7Tap(param_9, param_10, param_11); + vec4 param_12 = vec4(alphaLeft.zw, alphaCenter, alphaRight.x); + vec3 param_13 = alphaRight.yzw; + vec4 param_14 = kernel; + float b = filterTextConvolve7Tap(param_12, param_13, param_14); alpha = vec3(r, g, b); } - - - if(gammaCorrectionEnabled) - alpha = filterTextGammaCorrect(bgColor, alpha, gammaLUT); - - + if (gammaCorrectionEnabled) + { + vec3 param_15 = bgColor; + vec3 param_16 = alpha; + alpha = filterTextGammaCorrect(param_15, param_16, SPIRV_Cross_CombinedgammaLUTuSampler); + } return vec4(mix(bgColor, fgColor, alpha), 1.0); } +vec4 sampleColor(vec2 colorTexCoord, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + return texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord); +} +vec4 filterNone(vec2 colorTexCoord, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + vec2 param = colorTexCoord; + return sampleColor(param, SPIRV_Cross_CombinedcolorTextureuSampler); +} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -vec4 filterRadialGradient(vec2 colorTexCoord, - sampler2D colorTexture, - vec2 colorTextureSize, - vec2 fragCoord, - vec2 framebufferSize, - vec4 filterParams0, - vec4 filterParams1){ - vec2 lineFrom = filterParams0 . xy, lineVector = filterParams0 . zw; - vec2 radii = filterParams1 . xy, uvOrigin = filterParams1 . zw; - - vec2 dP = colorTexCoord - lineFrom, dC = lineVector; - float dR = radii . y - radii . x; - - float a = dot(dC, dC)- dR * dR; - float b = dot(dP, dC)+ radii . x * dR; - float c = dot(dP, dP)- radii . x * radii . x; - float discrim = b * b - a * c; - - vec4 color = vec4(0.0); - if(abs(discrim)>= 0.00001){ - vec2 ts = vec2(sqrt(discrim)* vec2(1.0, - 1.0)+ vec2(b))/ vec2(a); - if(ts . x > ts . y) - ts = ts . yx; - float t = ts . x >= 0.0 ? ts . x : ts . y; - color = texture(colorTexture, uvOrigin + vec2(clamp(t, 0.0, 1.0), 0.0)); +vec4 filterColor(vec2 colorTexCoord, vec2 colorTextureSize, vec2 fragCoord, vec2 framebufferSize, vec4 filterParams0, vec4 filterParams1, vec4 filterParams2, int colorFilter, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler, sampler2D SPIRV_Cross_CombinedgammaLUTuSampler) +{ + switch (colorFilter) + { + case 1: + { + vec2 param = colorTexCoord; + vec2 param_1 = colorTextureSize; + vec2 param_2 = fragCoord; + vec2 param_3 = framebufferSize; + vec4 param_4 = filterParams0; + vec4 param_5 = filterParams1; + return filterRadialGradient(param, param_1, param_2, param_3, param_4, param_5, SPIRV_Cross_CombinedcolorTextureuSampler); + } + case 3: + { + vec2 param_6 = colorTexCoord; + vec2 param_7 = colorTextureSize; + vec4 param_8 = filterParams0; + vec4 param_9 = filterParams1; + return filterBlur(param_6, param_7, param_8, param_9, SPIRV_Cross_CombinedcolorTextureuSampler); + } + case 2: + { + vec2 param_10 = colorTexCoord; + vec2 param_11 = colorTextureSize; + vec4 param_12 = filterParams0; + vec4 param_13 = filterParams1; + vec4 param_14 = filterParams2; + return filterText(param_10, param_11, param_12, param_13, param_14, SPIRV_Cross_CombinedcolorTextureuSampler, SPIRV_Cross_CombinedgammaLUTuSampler); + } } - - return color; + vec2 param_15 = colorTexCoord; + return filterNone(param_15, SPIRV_Cross_CombinedcolorTextureuSampler); } - - - - - -vec4 filterBlur(vec2 colorTexCoord, - sampler2D colorTexture, - vec2 colorTextureSize, - vec4 filterParams0, - vec4 filterParams1){ - - vec2 srcOffsetScale = filterParams0 . xy / colorTextureSize; - int support = int(filterParams0 . z); - vec3 gaussCoeff = filterParams1 . xyz; - - - float gaussSum = gaussCoeff . x; - vec4 color = texture(colorTexture, colorTexCoord)* gaussCoeff . x; - gaussCoeff . xy *= gaussCoeff . yz; - - - - - - - - - - for(int i = 1;i <= support;i += 2){ - float gaussPartialSum = gaussCoeff . x; - gaussCoeff . xy *= gaussCoeff . yz; - gaussPartialSum += gaussCoeff . x; - - vec2 srcOffset = srcOffsetScale *(float(i)+ gaussCoeff . x / gaussPartialSum); - color +=(texture(colorTexture, colorTexCoord - srcOffset)+ - texture(colorTexture, colorTexCoord + srcOffset))* gaussPartialSum; - - gaussSum += 2.0 * gaussPartialSum; - gaussCoeff . xy *= gaussCoeff . yz; +vec4 combineColor0(vec4 destColor, vec4 srcColor, int op) +{ + switch (op) + { + case 1: + { + return vec4(srcColor.xyz, srcColor.w * destColor.w); + } + case 2: + { + return vec4(destColor.xyz, srcColor.w * destColor.w); + } } - - - return color / gaussSum; + return destColor; } -vec4 filterNone(vec2 colorTexCoord, sampler2D colorTexture){ - return sampleColor(colorTexture, colorTexCoord); +vec3 compositeScreen(vec3 destColor, vec3 srcColor) +{ + return (destColor + srcColor) - (destColor * srcColor); } -vec4 filterColor(vec2 colorTexCoord, - sampler2D colorTexture, - sampler2D gammaLUT, - vec2 colorTextureSize, - vec2 fragCoord, - vec2 framebufferSize, - vec4 filterParams0, - vec4 filterParams1, - vec4 filterParams2, - int colorFilter){ - switch(colorFilter){ - case 0x1 : - return filterRadialGradient(colorTexCoord, - colorTexture, - colorTextureSize, - fragCoord, - framebufferSize, - filterParams0, - filterParams1); - case 0x3 : - return filterBlur(colorTexCoord, - colorTexture, - colorTextureSize, - filterParams0, - filterParams1); - case 0x2 : - return filterText(colorTexCoord, - colorTexture, - gammaLUT, - colorTextureSize, - filterParams0, - filterParams1, - filterParams2); +vec3 compositeSelect(bvec3 cond, vec3 ifTrue, vec3 ifFalse) +{ + float _745; + if (cond.x) + { + _745 = ifTrue.x; + } + else + { + _745 = ifFalse.x; + } + float _756; + if (cond.y) + { + _756 = ifTrue.y; + } + else + { + _756 = ifFalse.y; + } + float _767; + if (cond.z) + { + _767 = ifTrue.z; + } + else + { + _767 = ifFalse.z; } - return filterNone(colorTexCoord, colorTexture); + return vec3(_745, _756, _767); } - - -vec3 compositeSelect(bvec3 cond, vec3 ifTrue, vec3 ifFalse){ - return vec3(cond . x ? ifTrue . x : ifFalse . x, - cond . y ? ifTrue . y : ifFalse . y, - cond . z ? ifTrue . z : ifFalse . z); +vec3 compositeHardLight(vec3 destColor, vec3 srcColor) +{ + vec3 param = destColor; + vec3 param_1 = (vec3(2.0) * srcColor) - vec3(1.0); + bvec3 param_2 = lessThanEqual(srcColor, vec3(0.5)); + vec3 param_3 = (destColor * vec3(2.0)) * srcColor; + vec3 param_4 = compositeScreen(param, param_1); + return compositeSelect(param_2, param_3, param_4); } -float compositeDivide(float num, float denom){ - return denom != 0.0 ? num / denom : 0.0; +vec3 compositeColorDodge(vec3 destColor, vec3 srcColor) +{ + bvec3 destZero = equal(destColor, vec3(0.0)); + bvec3 srcOne = equal(srcColor, vec3(1.0)); + bvec3 param = srcOne; + vec3 param_1 = vec3(1.0); + vec3 param_2 = destColor / (vec3(1.0) - srcColor); + bvec3 param_3 = destZero; + vec3 param_4 = vec3(0.0); + vec3 param_5 = compositeSelect(param, param_1, param_2); + return compositeSelect(param_3, param_4, param_5); } -vec3 compositeColorDodge(vec3 destColor, vec3 srcColor){ - bvec3 destZero = equal(destColor, vec3(0.0)), srcOne = equal(srcColor, vec3(1.0)); - return compositeSelect(destZero, - vec3(0.0), - compositeSelect(srcOne, vec3(1.0), destColor /(vec3(1.0)- srcColor))); +vec3 compositeSoftLight(vec3 destColor, vec3 srcColor) +{ + bvec3 param = lessThanEqual(destColor, vec3(0.25)); + vec3 param_1 = ((((vec3(16.0) * destColor) - vec3(12.0)) * destColor) + vec3(4.0)) * destColor; + vec3 param_2 = sqrt(destColor); + vec3 darkenedDestColor = compositeSelect(param, param_1, param_2); + bvec3 param_3 = lessThanEqual(srcColor, vec3(0.5)); + vec3 param_4 = destColor * (vec3(1.0) - destColor); + vec3 param_5 = darkenedDestColor - destColor; + vec3 factor = compositeSelect(param_3, param_4, param_5); + return destColor + (((srcColor * 2.0) - vec3(1.0)) * factor); } - -vec3 compositeHSLToRGB(vec3 hsl){ - float a = hsl . y * min(hsl . z, 1.0 - hsl . z); - vec3 ks = mod(vec3(0.0, 8.0, 4.0)+ vec3(hsl . x * 1.9098593171027443), 12.0); - return hsl . zzz - clamp(min(ks - vec3(3.0), vec3(9.0)- ks), - 1.0, 1.0)* a; +float compositeDivide(float num, float denom) +{ + float _781; + if (denom != 0.0) + { + _781 = num / denom; + } + else + { + _781 = 0.0; + } + return _781; } - -vec3 compositeRGBToHSL(vec3 rgb){ - float v = max(max(rgb . r, rgb . g), rgb . b), xMin = min(min(rgb . r, rgb . g), rgb . b); - float c = v - xMin, l = mix(xMin, v, 0.5); - vec3 terms = rgb . r == v ? vec3(0.0, rgb . gb): - rgb . g == v ? vec3(2.0, rgb . br): - vec3(4.0, rgb . rg); - float h = 1.0471975511965976 * compositeDivide(terms . x * c + terms . y - terms . z, c); - float s = compositeDivide(c, v); +vec3 compositeRGBToHSL(vec3 rgb) +{ + float v = max(max(rgb.x, rgb.y), rgb.z); + float xMin = min(min(rgb.x, rgb.y), rgb.z); + float c = v - xMin; + float l = mix(xMin, v, 0.5); + vec3 _887; + if (rgb.x == v) + { + _887 = vec3(0.0, rgb.yz); + } + else + { + vec3 _900; + if (rgb.y == v) + { + _900 = vec3(2.0, rgb.zx); + } + else + { + _900 = vec3(4.0, rgb.xy); + } + _887 = _900; + } + vec3 terms = _887; + float param = ((terms.x * c) + terms.y) - terms.z; + float param_1 = c; + float h = 1.0471975803375244140625 * compositeDivide(param, param_1); + float param_2 = c; + float param_3 = v; + float s = compositeDivide(param_2, param_3); return vec3(h, s, l); } -vec3 compositeScreen(vec3 destColor, vec3 srcColor){ - return destColor + srcColor - destColor * srcColor; -} - -vec3 compositeHardLight(vec3 destColor, vec3 srcColor){ - return compositeSelect(lessThanEqual(srcColor, vec3(0.5)), - destColor * vec3(2.0)* srcColor, - compositeScreen(destColor, vec3(2.0)* srcColor - vec3(1.0))); -} - -vec3 compositeSoftLight(vec3 destColor, vec3 srcColor){ - vec3 darkenedDestColor = - compositeSelect(lessThanEqual(destColor, vec3(0.25)), - ((vec3(16.0)* destColor - 12.0)* destColor + 4.0)* destColor, - sqrt(destColor)); - vec3 factor = compositeSelect(lessThanEqual(srcColor, vec3(0.5)), - destColor *(vec3(1.0)- destColor), - darkenedDestColor - destColor); - return destColor +(srcColor * 2.0 - 1.0)* factor; +vec3 compositeHSL(vec3 destColor, vec3 srcColor, int op) +{ + switch (op) + { + case 12: + { + return vec3(srcColor.x, destColor.y, destColor.z); + } + case 13: + { + return vec3(destColor.x, srcColor.y, destColor.z); + } + case 14: + { + return vec3(srcColor.x, srcColor.y, destColor.z); + } + default: + { + return vec3(destColor.x, destColor.y, srcColor.z); + } + } } -vec3 compositeHSL(vec3 destColor, vec3 srcColor, int op){ - switch(op){ - case 0xc : - return vec3(srcColor . x, destColor . y, destColor . z); - case 0xd : - return vec3(destColor . x, srcColor . y, destColor . z); - case 0xe : - return vec3(srcColor . x, srcColor . y, destColor . z); - default : - return vec3(destColor . x, destColor . y, srcColor . z); - } +vec3 compositeHSLToRGB(vec3 hsl) +{ + float a = hsl.y * min(hsl.z, 1.0 - hsl.z); + vec3 ks = mod(vec3(0.0, 8.0, 4.0) + vec3(hsl.x * 1.90985929965972900390625), vec3(12.0)); + return hsl.zzz - (clamp(min(ks - vec3(3.0), vec3(9.0) - ks), vec3(-1.0), vec3(1.0)) * a); } -vec3 compositeRGB(vec3 destColor, vec3 srcColor, int op){ - switch(op){ - case 0x1 : - return destColor * srcColor; - case 0x2 : - return compositeScreen(destColor, srcColor); - case 0x3 : - return compositeHardLight(srcColor, destColor); - case 0x4 : - return min(destColor, srcColor); - case 0x5 : - return max(destColor, srcColor); - case 0x6 : - return compositeColorDodge(destColor, srcColor); - case 0x7 : - return vec3(1.0)- compositeColorDodge(vec3(1.0)- destColor, vec3(1.0)- srcColor); - case 0x8 : - return compositeHardLight(destColor, srcColor); - case 0x9 : - return compositeSoftLight(destColor, srcColor); - case 0xa : - return abs(destColor - srcColor); - case 0xb : - return destColor + srcColor - vec3(2.0)* destColor * srcColor; - case 0xc : - case 0xd : - case 0xe : - case 0xf : - return compositeHSLToRGB(compositeHSL(compositeRGBToHSL(destColor), - compositeRGBToHSL(srcColor), - op)); +vec3 compositeRGB(vec3 destColor, vec3 srcColor, int op) +{ + switch (op) + { + case 1: + { + return destColor * srcColor; + } + case 2: + { + vec3 param = destColor; + vec3 param_1 = srcColor; + return compositeScreen(param, param_1); + } + case 3: + { + vec3 param_2 = srcColor; + vec3 param_3 = destColor; + return compositeHardLight(param_2, param_3); + } + case 4: + { + return min(destColor, srcColor); + } + case 5: + { + return max(destColor, srcColor); + } + case 6: + { + vec3 param_4 = destColor; + vec3 param_5 = srcColor; + return compositeColorDodge(param_4, param_5); + } + case 7: + { + vec3 param_6 = vec3(1.0) - destColor; + vec3 param_7 = vec3(1.0) - srcColor; + return vec3(1.0) - compositeColorDodge(param_6, param_7); + } + case 8: + { + vec3 param_8 = destColor; + vec3 param_9 = srcColor; + return compositeHardLight(param_8, param_9); + } + case 9: + { + vec3 param_10 = destColor; + vec3 param_11 = srcColor; + return compositeSoftLight(param_10, param_11); + } + case 10: + { + return abs(destColor - srcColor); + } + case 11: + { + return (destColor + srcColor) - ((vec3(2.0) * destColor) * srcColor); + } + case 12: + case 13: + case 14: + case 15: + { + vec3 param_12 = destColor; + vec3 param_13 = srcColor; + vec3 param_14 = compositeRGBToHSL(param_12); + vec3 param_15 = compositeRGBToHSL(param_13); + int param_16 = op; + vec3 param_17 = compositeHSL(param_14, param_15, param_16); + return compositeHSLToRGB(param_17); + } } return srcColor; } -vec4 composite(vec4 srcColor, - sampler2D destTexture, - vec2 destTextureSize, - vec2 fragCoord, - int op){ - if(op == 0x0) +vec4 composite(vec4 srcColor, vec2 destTextureSize, vec2 fragCoord, int op, sampler2D SPIRV_Cross_CombineddestTextureuSampler) +{ + if (op == 0) + { return srcColor; - - + } vec2 destTexCoord = fragCoord / destTextureSize; - vec4 destColor = texture(destTexture, destTexCoord); - vec3 blendedRGB = compositeRGB(destColor . rgb, srcColor . rgb, op); - return vec4(srcColor . a *(1.0 - destColor . a)* srcColor . rgb + - srcColor . a * destColor . a * blendedRGB + - (1.0 - srcColor . a)* destColor . rgb, - 1.0); + vec4 destColor = texture(SPIRV_Cross_CombineddestTextureuSampler, destTexCoord); + vec3 param = destColor.xyz; + vec3 param_1 = srcColor.xyz; + int param_2 = op; + vec3 blendedRGB = compositeRGB(param, param_1, param_2); + return vec4(((srcColor.xyz * (srcColor.w * (1.0 - destColor.w))) + (blendedRGB * (srcColor.w * destColor.w))) + (destColor.xyz * (1.0 - srcColor.w)), 1.0); } - - -float sampleMask(float maskAlpha, - sampler2D maskTexture, - vec2 maskTextureSize, - vec3 maskTexCoord, - int maskCtrl){ - if(maskCtrl == 0) - return maskAlpha; - - ivec2 maskTexCoordI = ivec2(floor(maskTexCoord . xy)); - vec4 texel = texture(maskTexture,(vec2(maskTexCoordI / ivec2(1, 4))+ 0.5)/ maskTextureSize); - float coverage = texel[maskTexCoordI . y % 4]+ maskTexCoord . z; - - if((maskCtrl & 0x1)!= 0) - coverage = abs(coverage); - else - coverage = 1.0 - abs(1.0 - mod(coverage, 2.0)); - return min(maskAlpha, coverage); -} - - - -void calculateColor(int tileCtrl, int ctrl){ - - int maskCtrl0 =(tileCtrl >> 0)& 0x3; +void calculateColor(int tileCtrl, int ctrl) +{ + int maskCtrl0 = (tileCtrl >> 0) & 3; float maskAlpha = 1.0; - maskAlpha = sampleMask(maskAlpha, uMaskTexture0, uMaskTextureSize0, vMaskTexCoord0, maskCtrl0); - - + float param = maskAlpha; + vec2 param_1 = uMaskTextureSize0[0].xy; + vec3 param_2 = vMaskTexCoord0; + int param_3 = maskCtrl0; + maskAlpha = sampleMask(param, param_1, param_2, param_3, SPIRV_Cross_CombineduMaskTexture0uSampler); vec4 color = vBaseColor; - int color0Combine =(ctrl >> 6)& - 0x3; - if(color0Combine != 0){ - int color0Filter =(ctrl >> 4)& 0x3; - vec4 color0 = filterColor(vColorTexCoord0, - uColorTexture0, - uGammaLUT, - uColorTextureSize0, - gl_FragCoord . xy, - uFramebufferSize, - uFilterParams0, - uFilterParams1, - uFilterParams2, - color0Filter); - color = combineColor0(color, color0, color0Combine); + int color0Combine = (ctrl >> 6) & 3; + if (color0Combine != 0) + { + int color0Filter = (ctrl >> 4) & 3; + vec2 param_4 = vColorTexCoord0; + vec2 param_5 = uColorTextureSize0[0].xy; + vec2 param_6 = gl_FragCoord.xy; + vec2 param_7 = uFramebufferSize[0].xy; + vec4 param_8 = uFilterParams0[0]; + vec4 param_9 = uFilterParams1[0]; + vec4 param_10 = uFilterParams2[0]; + int param_11 = color0Filter; + vec4 color0 = filterColor(param_4, param_5, param_6, param_7, param_8, param_9, param_10, param_11, SPIRV_Cross_CombineduColorTexture0uSampler, SPIRV_Cross_CombineduGammaLUTuSampler); + vec4 param_12 = color; + vec4 param_13 = color0; + int param_14 = color0Combine; + color = combineColor0(param_12, param_13, param_14); } - - - color . a *= maskAlpha; - - - int compositeOp =(ctrl >> 8)& 0xf; - color = composite(color, uDestTexture, uFramebufferSize, gl_FragCoord . xy, compositeOp); - - - color . rgb *= color . a; + color.w *= maskAlpha; + int compositeOp = (ctrl >> 8) & 15; + vec4 param_15 = color; + vec2 param_16 = uFramebufferSize[0].xy; + vec2 param_17 = gl_FragCoord.xy; + int param_18 = compositeOp; + color = composite(param_15, param_16, param_17, param_18, SPIRV_Cross_CombineduDestTextureuSampler); + vec3 _1389 = color.xyz * color.w; + color = vec4(_1389.x, _1389.y, _1389.z, color.w); oFragColor = color; } - - - - -void main(){ - calculateColor(int(vTileCtrl), uCtrl); +void main() +{ + int param = int(vTileCtrl); + int param_1 = uCtrl[0].x; + calculateColor(param, param_1); } diff --git a/resources/shaders/gl3/tile.vs.glsl b/resources/shaders/gl3/tile.vs.glsl index 6f3819c00..39df49168 100644 --- a/resources/shaders/gl3/tile.vs.glsl +++ b/resources/shaders/gl3/tile.vs.glsl @@ -2,58 +2,40 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uTransform; -uniform vec2 uTileSize; -uniform sampler2D uTextureMetadata; -uniform ivec2 uTextureMetadataSize; - -in ivec2 aTileOffset; -in ivec2 aTileOrigin; -in uvec2 aMaskTexCoord0; -in ivec2 aMaskBackdrop; -in int aColor; -in int aTileCtrl; - -out vec3 vMaskTexCoord0; +uniform vec4 uTileSize[1]; +uniform ivec4 uTextureMetadataSize[1]; +uniform vec4 uTransform[4]; +uniform sampler2D SPIRV_Cross_CombineduTextureMetadatauSampler; + +layout(location = 1) in ivec2 aTileOrigin; +layout(location = 0) in ivec2 aTileOffset; +layout(location = 2) in uvec2 aMaskTexCoord0; +layout(location = 4) in int aColor; out vec2 vColorTexCoord0; +out vec3 vMaskTexCoord0; +layout(location = 3) in ivec2 aMaskBackdrop; out vec4 vBaseColor; out float vTileCtrl; - -void main(){ - vec2 tileOrigin = vec2(aTileOrigin), tileOffset = vec2(aTileOffset); - vec2 position =(tileOrigin + tileOffset)* uTileSize; - - vec2 maskTexCoord0 =(vec2(aMaskTexCoord0)+ tileOffset)* uTileSize; - - vec2 textureMetadataScale = vec2(1.0)/ vec2(uTextureMetadataSize); - vec2 metadataEntryCoord = vec2(aColor % 128 * 4, aColor / 128); - vec2 colorTexMatrix0Coord =(metadataEntryCoord + vec2(0.5, 0.5))* textureMetadataScale; - vec2 colorTexOffsetsCoord =(metadataEntryCoord + vec2(1.5, 0.5))* textureMetadataScale; - vec2 baseColorCoord =(metadataEntryCoord + vec2(2.5, 0.5))* textureMetadataScale; - vec4 colorTexMatrix0 = texture(uTextureMetadata, colorTexMatrix0Coord); - vec4 colorTexOffsets = texture(uTextureMetadata, colorTexOffsetsCoord); - vec4 baseColor = texture(uTextureMetadata, baseColorCoord); - - vColorTexCoord0 = mat2(colorTexMatrix0)* position + colorTexOffsets . xy; - vMaskTexCoord0 = vec3(maskTexCoord0, float(aMaskBackdrop . x)); +layout(location = 5) in int aTileCtrl; + +void main() +{ + vec2 tileOrigin = vec2(aTileOrigin); + vec2 tileOffset = vec2(aTileOffset); + vec2 position = (tileOrigin + tileOffset) * uTileSize[0].xy; + vec2 maskTexCoord0 = (vec2(aMaskTexCoord0) + tileOffset) * uTileSize[0].xy; + vec2 textureMetadataScale = vec2(1.0) / vec2(uTextureMetadataSize[0].xy); + vec2 metadataEntryCoord = vec2(float((aColor % 128) * 4), float(aColor / 128)); + vec2 colorTexMatrix0Coord = (metadataEntryCoord + vec2(0.5)) * textureMetadataScale; + vec2 colorTexOffsetsCoord = (metadataEntryCoord + vec2(1.5, 0.5)) * textureMetadataScale; + vec2 baseColorCoord = (metadataEntryCoord + vec2(2.5, 0.5)) * textureMetadataScale; + vec4 colorTexMatrix0 = textureLod(SPIRV_Cross_CombineduTextureMetadatauSampler, colorTexMatrix0Coord, 0.0); + vec4 colorTexOffsets = textureLod(SPIRV_Cross_CombineduTextureMetadatauSampler, colorTexOffsetsCoord, 0.0); + vec4 baseColor = textureLod(SPIRV_Cross_CombineduTextureMetadatauSampler, baseColorCoord, 0.0); + vColorTexCoord0 = (mat2(vec2(colorTexMatrix0.xy), vec2(colorTexMatrix0.zw)) * position) + colorTexOffsets.xy; + vMaskTexCoord0 = vec3(maskTexCoord0, float(aMaskBackdrop.x)); vBaseColor = baseColor; vTileCtrl = float(aTileCtrl); - gl_Position = uTransform * vec4(position, 0.0, 1.0); + gl_Position = mat4(uTransform[0], uTransform[1], uTransform[2], uTransform[3]) * vec4(position, 0.0, 1.0); } diff --git a/resources/shaders/gl3/tile_clip.fs.glsl b/resources/shaders/gl3/tile_clip.fs.glsl index 9b8b6cd3f..5bbb7a259 100644 --- a/resources/shaders/gl3/tile_clip.fs.glsl +++ b/resources/shaders/gl3/tile_clip.fs.glsl @@ -2,30 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform sampler2D SPIRV_Cross_CombineduSrcuSampler; - - - - - - - - - -precision highp float; - - - - - -uniform sampler2D uSrc; - +layout(location = 0) out vec4 oFragColor; in vec2 vTexCoord; in float vBackdrop; -out vec4 oFragColor; - -void main(){ - oFragColor = clamp(abs(texture(uSrc, vTexCoord)+ vBackdrop), 0.0, 1.0); +void main() +{ + oFragColor = clamp(abs(texture(SPIRV_Cross_CombineduSrcuSampler, vTexCoord) + vec4(vBackdrop)), vec4(0.0), vec4(1.0)); } diff --git a/resources/shaders/gl3/tile_clip.vs.glsl b/resources/shaders/gl3/tile_clip.vs.glsl index 6693ec921..9cf2b9b01 100644 --- a/resources/shaders/gl3/tile_clip.vs.glsl +++ b/resources/shaders/gl3/tile_clip.vs.glsl @@ -2,35 +2,19 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -in ivec2 aTileOffset; -in ivec2 aDestTileOrigin; -in ivec2 aSrcTileOrigin; -in int aSrcBackdrop; - +layout(location = 1) in ivec2 aDestTileOrigin; +layout(location = 0) in ivec2 aTileOffset; +layout(location = 2) in ivec2 aSrcTileOrigin; out vec2 vTexCoord; out float vBackdrop; +layout(location = 3) in int aSrcBackdrop; -void main(){ - vec2 destPosition = vec2(aDestTileOrigin + aTileOffset)/ vec2(256.0); - vec2 srcPosition = vec2(aSrcTileOrigin + aTileOffset)/ vec2(256.0); +void main() +{ + vec2 destPosition = vec2(aDestTileOrigin + aTileOffset) / vec2(256.0); + vec2 srcPosition = vec2(aSrcTileOrigin + aTileOffset) / vec2(256.0); vTexCoord = srcPosition; vBackdrop = float(aSrcBackdrop); - gl_Position = vec4(mix(vec2(- 1.0), vec2(1.0), destPosition), 0.0, 1.0); + gl_Position = vec4(mix(vec2(-1.0), vec2(1.0), destPosition), 0.0, 1.0); } diff --git a/resources/shaders/gl3/tile_copy.fs.glsl b/resources/shaders/gl3/tile_copy.fs.glsl index af33abfd2..015b6ec45 100644 --- a/resources/shaders/gl3/tile_copy.fs.glsl +++ b/resources/shaders/gl3/tile_copy.fs.glsl @@ -2,29 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uFramebufferSize[1]; +uniform sampler2D SPIRV_Cross_CombineduSrcuSampler; +layout(location = 0) out vec4 oFragColor; - - - - - - - - -precision highp float; - - - - - -uniform vec2 uFramebufferSize; -uniform sampler2D uSrc; - -out vec4 oFragColor; - -void main(){ - vec2 texCoord = gl_FragCoord . xy / uFramebufferSize; - oFragColor = texture(uSrc, texCoord); +void main() +{ + vec2 texCoord = gl_FragCoord.xy / uFramebufferSize[0].xy; + oFragColor = texture(SPIRV_Cross_CombineduSrcuSampler, texCoord); } diff --git a/resources/shaders/gl3/tile_copy.vs.glsl b/resources/shaders/gl3/tile_copy.vs.glsl index 87925fda3..d20f31e40 100644 --- a/resources/shaders/gl3/tile_copy.vs.glsl +++ b/resources/shaders/gl3/tile_copy.vs.glsl @@ -2,29 +2,13 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uTransform; -uniform vec2 uTileSize; - -in ivec2 aTilePosition; - -void main(){ - vec2 position = vec2(aTilePosition)* uTileSize; - gl_Position = uTransform * vec4(position, 0.0, 1.0); +uniform vec4 uTileSize[1]; +uniform vec4 uTransform[4]; +layout(location = 0) in ivec2 aTilePosition; + +void main() +{ + vec2 position = vec2(aTilePosition) * uTileSize[0].xy; + gl_Position = mat4(uTransform[0], uTransform[1], uTransform[2], uTransform[3]) * vec4(position, 0.0, 1.0); } diff --git a/resources/shaders/gl4/blit.fs.glsl b/resources/shaders/gl4/blit.fs.glsl index b32fc956f..1a9b2d9f1 100644 --- a/resources/shaders/gl4/blit.fs.glsl +++ b/resources/shaders/gl4/blit.fs.glsl @@ -2,30 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +layout(binding = 0) uniform sampler2D SPIRV_Cross_CombineduSrcuSampler; +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 oFragColor; - - - - - - - - -precision highp float; - - - - - -uniform sampler2D uSrc; - -in vec2 vTexCoord; - -out vec4 oFragColor; - -void main(){ - vec4 color = texture(uSrc, vTexCoord); - oFragColor = vec4(color . rgb * color . a, color . a); +void main() +{ + vec4 color = texture(SPIRV_Cross_CombineduSrcuSampler, vTexCoord); + oFragColor = vec4(color.xyz * color.w, color.w); } diff --git a/resources/shaders/gl4/blit.vs.glsl b/resources/shaders/gl4/blit.vs.glsl index 6c9391d50..0a3bf222e 100644 --- a/resources/shaders/gl4/blit.vs.glsl +++ b/resources/shaders/gl4/blit.vs.glsl @@ -2,32 +2,13 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +layout(location = 0) in ivec2 aPosition; +layout(location = 0) out vec2 vTexCoord; - - - - - - - - - -precision highp float; - - - - - -in ivec2 aPosition; - -out vec2 vTexCoord; - -void main(){ +void main() +{ vec2 texCoord = vec2(aPosition); - - - vTexCoord = texCoord; - gl_Position = vec4(mix(vec2(- 1.0), vec2(1.0), vec2(aPosition)), 0.0, 1.0); + gl_Position = vec4(mix(vec2(-1.0), vec2(1.0), vec2(aPosition)), 0.0, 1.0); } diff --git a/resources/shaders/gl4/clear.fs.glsl b/resources/shaders/gl4/clear.fs.glsl index 447e4d838..bfc45445d 100644 --- a/resources/shaders/gl4/clear.fs.glsl +++ b/resources/shaders/gl4/clear.fs.glsl @@ -2,27 +2,11 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uColor[1]; +layout(location = 0) out vec4 oFragColor; - - - - - - - - - -precision highp float; - - - - - -uniform vec4 uColor; - -out vec4 oFragColor; - -void main(){ - oFragColor = vec4(uColor . rgb, 1.0)* uColor . a; +void main() +{ + oFragColor = vec4(uColor[0].xyz, 1.0) * uColor[0].w; } diff --git a/resources/shaders/gl4/clear.vs.glsl b/resources/shaders/gl4/clear.vs.glsl index 2dd02b1ce..76b85239b 100644 --- a/resources/shaders/gl4/clear.vs.glsl +++ b/resources/shaders/gl4/clear.vs.glsl @@ -2,29 +2,13 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform vec4 uRect; -uniform vec2 uFramebufferSize; - -in ivec2 aPosition; - -void main(){ - vec2 position = mix(uRect . xy, uRect . zw, vec2(aPosition))/ uFramebufferSize * 2.0 - 1.0; - gl_Position = vec4(position . x, - position . y, 0.0, 1.0); +uniform vec4 uRect[1]; +uniform vec4 uFramebufferSize[1]; +layout(location = 0) in ivec2 aPosition; + +void main() +{ + vec2 position = ((mix(uRect[0].xy, uRect[0].zw, vec2(aPosition)) / uFramebufferSize[0].xy) * 2.0) - vec2(1.0); + gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/resources/shaders/gl4/debug_solid.fs.glsl b/resources/shaders/gl4/debug_solid.fs.glsl index 447e4d838..bfc45445d 100644 --- a/resources/shaders/gl4/debug_solid.fs.glsl +++ b/resources/shaders/gl4/debug_solid.fs.glsl @@ -2,27 +2,11 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uColor[1]; +layout(location = 0) out vec4 oFragColor; - - - - - - - - - -precision highp float; - - - - - -uniform vec4 uColor; - -out vec4 oFragColor; - -void main(){ - oFragColor = vec4(uColor . rgb, 1.0)* uColor . a; +void main() +{ + oFragColor = vec4(uColor[0].xyz, 1.0) * uColor[0].w; } diff --git a/resources/shaders/gl4/debug_solid.vs.glsl b/resources/shaders/gl4/debug_solid.vs.glsl index de155484a..705fbc5ef 100644 --- a/resources/shaders/gl4/debug_solid.vs.glsl +++ b/resources/shaders/gl4/debug_solid.vs.glsl @@ -2,28 +2,12 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uFramebufferSize[1]; +layout(location = 0) in ivec2 aPosition; - - - - - - - - - -precision highp float; - - - - - -uniform vec2 uFramebufferSize; - -in ivec2 aPosition; - -void main(){ - vec2 position = vec2(aPosition)/ uFramebufferSize * 2.0 - 1.0; - gl_Position = vec4(position . x, - position . y, 0.0, 1.0); +void main() +{ + vec2 position = ((vec2(aPosition) / uFramebufferSize[0].xy) * 2.0) - vec2(1.0); + gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/resources/shaders/gl4/debug_texture.fs.glsl b/resources/shaders/gl4/debug_texture.fs.glsl index c786f3520..c35786c4d 100644 --- a/resources/shaders/gl4/debug_texture.fs.glsl +++ b/resources/shaders/gl4/debug_texture.fs.glsl @@ -2,31 +2,15 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uColor[1]; +layout(binding = 2) uniform sampler2D SPIRV_Cross_CombineduTextureuSampler; +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 oFragColor; - - - - - - - - -precision highp float; - - - - - -uniform sampler2D uTexture; -uniform vec4 uColor; - -in vec2 vTexCoord; - -out vec4 oFragColor; - -void main(){ - float alpha = texture(uTexture, vTexCoord). r * uColor . a; - oFragColor = alpha * vec4(uColor . rgb, 1.0); +void main() +{ + float alpha = texture(SPIRV_Cross_CombineduTextureuSampler, vTexCoord).x * uColor[0].w; + oFragColor = vec4(uColor[0].xyz, 1.0) * alpha; } diff --git a/resources/shaders/gl4/debug_texture.vs.glsl b/resources/shaders/gl4/debug_texture.vs.glsl index e073da211..009773372 100644 --- a/resources/shaders/gl4/debug_texture.vs.glsl +++ b/resources/shaders/gl4/debug_texture.vs.glsl @@ -2,33 +2,16 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform vec2 uFramebufferSize; -uniform vec2 uTextureSize; - -in ivec2 aPosition; -in ivec2 aTexCoord; - -out vec2 vTexCoord; - -void main(){ - vTexCoord = vec2(aTexCoord)/ uTextureSize; - vec2 position = vec2(aPosition)/ uFramebufferSize * 2.0 - 1.0; - gl_Position = vec4(position . x, - position . y, 0.0, 1.0); +uniform vec4 uTextureSize[1]; +uniform vec4 uFramebufferSize[1]; +layout(location = 0) out vec2 vTexCoord; +layout(location = 1) in ivec2 aTexCoord; +layout(location = 0) in ivec2 aPosition; + +void main() +{ + vTexCoord = vec2(aTexCoord) / uTextureSize[0].xy; + vec2 position = ((vec2(aPosition) / uFramebufferSize[0].xy) * 2.0) - vec2(1.0); + gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/resources/shaders/gl4/demo_ground.fs.glsl b/resources/shaders/gl4/demo_ground.fs.glsl index 63c0883ea..2c4c3168e 100644 --- a/resources/shaders/gl4/demo_ground.fs.glsl +++ b/resources/shaders/gl4/demo_ground.fs.glsl @@ -2,31 +2,23 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform vec4 uGroundColor; -uniform vec4 uGridlineColor; - -in vec2 vTexCoord; - -out vec4 oFragColor; - -void main(){ - vec2 texCoordPx = fract(vTexCoord)/ fwidth(vTexCoord); - oFragColor = any(lessThanEqual(texCoordPx, vec2(1.0)))? uGridlineColor : uGroundColor; +uniform vec4 uGridlineColor[1]; +uniform vec4 uGroundColor[1]; +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 oFragColor; + +void main() +{ + vec2 texCoordPx = fract(vTexCoord) / fwidth(vTexCoord); + vec4 _28; + if (any(lessThanEqual(texCoordPx, vec2(1.0)))) + { + _28 = uGridlineColor[0]; + } + else + { + _28 = uGroundColor[0]; + } + oFragColor = _28; } diff --git a/resources/shaders/gl4/demo_ground.vs.glsl b/resources/shaders/gl4/demo_ground.vs.glsl index cb3a47421..ab3fce9c6 100644 --- a/resources/shaders/gl4/demo_ground.vs.glsl +++ b/resources/shaders/gl4/demo_ground.vs.glsl @@ -2,31 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uTransform; -uniform int uGridlineCount; - -in ivec2 aPosition; - -out vec2 vTexCoord; - -void main(){ - vTexCoord = vec2(aPosition * uGridlineCount); - gl_Position = uTransform * vec4(ivec4(aPosition . x, 0, aPosition . y, 1)); +uniform ivec4 uGridlineCount[1]; +uniform vec4 uTransform[4]; +layout(location = 0) out vec2 vTexCoord; +layout(location = 0) in ivec2 aPosition; + +void main() +{ + vTexCoord = vec2(aPosition * ivec2(uGridlineCount[0].x)); + gl_Position = mat4(uTransform[0], uTransform[1], uTransform[2], uTransform[3]) * vec4(ivec4(aPosition.x, 0, aPosition.y, 1)); } diff --git a/resources/shaders/gl4/fill.cs.glsl b/resources/shaders/gl4/fill.cs.glsl index 3a528df59..ebdbcb8cb 100644 --- a/resources/shaders/gl4/fill.cs.glsl +++ b/resources/shaders/gl4/fill.cs.glsl @@ -1,100 +1,65 @@ #version {{version}} // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - - -#extension GL_GOOGLE_include_directive : enable - -precision highp float; - - - - - - - - - - - - - - - - -vec4 computeCoverage(vec2 from, vec2 to, sampler2D areaLUT){ - - vec2 left = from . x < to . x ? from : to, right = from . x < to . x ? to : from; - - - vec2 window = clamp(vec2(from . x, to . x), - 0.5, 0.5); - float offset = mix(window . x, window . y, 0.5)- left . x; - float t = offset /(right . x - left . x); - - - float y = mix(left . y, right . y, t); - float d =(right . y - left . y)/(right . x - left . x); - - - float dX = window . x - window . y; - return texture(areaLUT, vec2(y + 8.0, abs(d * dX))/ 16.0)* dX; +layout(local_size_x = 16, local_size_y = 4, local_size_z = 1) in; + +uniform ivec4 uFirstTileIndex[1]; +layout(binding = 6, std430) restrict readonly buffer bFillTileMap +{ + int iFillTileMap[]; +} _159; + +layout(binding = 4, std430) restrict readonly buffer bFills +{ + uvec2 iFills[]; +} _180; + +layout(binding = 5, std430) restrict readonly buffer bNextFills +{ + int iNextFills[]; +} _264; + +layout(binding = 0) uniform writeonly image2D uDest; +layout(binding = 1) uniform sampler2D SPIRV_Cross_CombineduAreaLUTuSampler; + +vec4 computeCoverage(vec2 from, vec2 to, sampler2D SPIRV_Cross_CombinedareaLUTareaLUTSampler) +{ + bvec2 _34 = bvec2(from.x < to.x); + vec2 left = vec2(_34.x ? from.x : to.x, _34.y ? from.y : to.y); + bvec2 _44 = bvec2(from.x < to.x); + vec2 right = vec2(_44.x ? to.x : from.x, _44.y ? to.y : from.y); + vec2 window = clamp(vec2(from.x, to.x), vec2(-0.5), vec2(0.5)); + float offset = mix(window.x, window.y, 0.5) - left.x; + float t = offset / (right.x - left.x); + float y = mix(left.y, right.y, t); + float d = (right.y - left.y) / (right.x - left.x); + float dX = window.x - window.y; + return textureLod(SPIRV_Cross_CombinedareaLUTareaLUTSampler, vec2(y + 8.0, abs(d * dX)) / vec2(16.0), 0.0) * dX; } - -layout(local_size_x = 16, local_size_y = 4)in; - -uniform writeonly image2D uDest; -uniform sampler2D uAreaLUT; -uniform int uFirstTileIndex; - -layout(std430, binding = 0)buffer bFills { - restrict readonly uvec2 iFills[]; -}; - -layout(std430, binding = 1)buffer bNextFills { - restrict readonly int iNextFills[]; -}; - -layout(std430, binding = 2)buffer bFillTileMap { - restrict readonly int iFillTileMap[]; -}; - -void main(){ - ivec2 tileSubCoord = ivec2(gl_LocalInvocationID . xy)* ivec2(1, 4); - uint tileIndexOffset = gl_WorkGroupID . z; - - uint tileIndex = tileIndexOffset + uint(uFirstTileIndex); - - int fillIndex = iFillTileMap[tileIndex]; - if(fillIndex < 0) +void main() +{ + ivec2 tileSubCoord = ivec2(gl_LocalInvocationID.xy) * ivec2(1, 4); + uint tileIndexOffset = gl_WorkGroupID.z; + uint tileIndex = tileIndexOffset + uint(uFirstTileIndex[0].x); + int fillIndex = _159.iFillTileMap[tileIndex]; + if (fillIndex < 0) + { return; - + } vec4 coverages = vec4(0.0); - do { - uvec2 fill = iFills[fillIndex]; - vec2 from = vec2(fill . y & 0xf,(fill . y >> 4u)& 0xf)+ - vec2(fill . x & 0xff,(fill . x >> 8u)& 0xff)/ 256.0; - vec2 to = vec2((fill . y >> 8u)& 0xf,(fill . y >> 12u)& 0xf)+ - vec2((fill . x >> 16u)& 0xff,(fill . x >> 24u)& 0xff)/ 256.0; - - coverages += computeCoverage(from -(vec2(tileSubCoord)+ vec2(0.5)), - to -(vec2(tileSubCoord)+ vec2(0.5)), - uAreaLUT); - - fillIndex = iNextFills[fillIndex]; - } while(fillIndex >= 0); - - ivec2 tileOrigin = ivec2(tileIndex & 0xff,(tileIndex >> 8u)& 0xff)* ivec2(16, 4); - ivec2 destCoord = tileOrigin + ivec2(gl_LocalInvocationID . xy); + do + { + uvec2 fill = _180.iFills[fillIndex]; + vec2 from = vec2(float(fill.y & 15u), float((fill.y >> 4u) & 15u)) + (vec2(float(fill.x & 255u), float((fill.x >> 8u) & 255u)) / vec2(256.0)); + vec2 to = vec2(float((fill.y >> 8u) & 15u), float((fill.y >> 12u) & 15u)) + (vec2(float((fill.x >> 16u) & 255u), float((fill.x >> 24u) & 255u)) / vec2(256.0)); + vec2 param = from - (vec2(tileSubCoord) + vec2(0.5)); + vec2 param_1 = to - (vec2(tileSubCoord) + vec2(0.5)); + coverages += computeCoverage(param, param_1, SPIRV_Cross_CombineduAreaLUTuSampler); + fillIndex = _264.iNextFills[fillIndex]; + } while (fillIndex >= 0); + ivec2 tileOrigin = ivec2(int(tileIndex & 255u), int((tileIndex >> 8u) & 255u)) * ivec2(16, 4); + ivec2 destCoord = tileOrigin + ivec2(gl_LocalInvocationID.xy); imageStore(uDest, destCoord, coverages); } diff --git a/resources/shaders/gl4/fill.fs.glsl b/resources/shaders/gl4/fill.fs.glsl index e56cbaebb..01c47c165 100644 --- a/resources/shaders/gl4/fill.fs.glsl +++ b/resources/shaders/gl4/fill.fs.glsl @@ -2,62 +2,31 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -#extension GL_GOOGLE_include_directive : enable - -precision highp float; - - - - - - - - - - - - - - - - -vec4 computeCoverage(vec2 from, vec2 to, sampler2D areaLUT){ - - vec2 left = from . x < to . x ? from : to, right = from . x < to . x ? to : from; - - - vec2 window = clamp(vec2(from . x, to . x), - 0.5, 0.5); - float offset = mix(window . x, window . y, 0.5)- left . x; - float t = offset /(right . x - left . x); - - - float y = mix(left . y, right . y, t); - float d =(right . y - left . y)/(right . x - left . x); - - - float dX = window . x - window . y; - return texture(areaLUT, vec2(y + 8.0, abs(d * dX))/ 16.0)* dX; +layout(binding = 2) uniform sampler2D SPIRV_Cross_CombineduAreaLUTuSampler; + +layout(location = 0) out vec4 oFragColor; +layout(location = 0) in vec2 vFrom; +layout(location = 1) in vec2 vTo; + +vec4 computeCoverage(vec2 from, vec2 to, sampler2D SPIRV_Cross_CombinedareaLUTareaLUTSampler) +{ + bvec2 _34 = bvec2(from.x < to.x); + vec2 left = vec2(_34.x ? from.x : to.x, _34.y ? from.y : to.y); + bvec2 _44 = bvec2(from.x < to.x); + vec2 right = vec2(_44.x ? to.x : from.x, _44.y ? to.y : from.y); + vec2 window = clamp(vec2(from.x, to.x), vec2(-0.5), vec2(0.5)); + float offset = mix(window.x, window.y, 0.5) - left.x; + float t = offset / (right.x - left.x); + float y = mix(left.y, right.y, t); + float d = (right.y - left.y) / (right.x - left.x); + float dX = window.x - window.y; + return texture(SPIRV_Cross_CombinedareaLUTareaLUTSampler, vec2(y + 8.0, abs(d * dX)) / vec2(16.0)) * dX; } - -uniform sampler2D uAreaLUT; - -in vec2 vFrom; -in vec2 vTo; - -out vec4 oFragColor; - -void main(){ - oFragColor = computeCoverage(vFrom, vTo, uAreaLUT); +void main() +{ + vec2 param = vFrom; + vec2 param_1 = vTo; + oFragColor = computeCoverage(param, param_1, SPIRV_Cross_CombineduAreaLUTuSampler); } diff --git a/resources/shaders/gl4/fill.vs.glsl b/resources/shaders/gl4/fill.vs.glsl index 58b0b7f02..c1acc414c 100644 --- a/resources/shaders/gl4/fill.vs.glsl +++ b/resources/shaders/gl4/fill.vs.glsl @@ -2,70 +2,53 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform vec2 uFramebufferSize; -uniform vec2 uTileSize; - -in uvec2 aTessCoord; -in uint aFromPx; -in uint aToPx; -in vec2 aFromSubpx; -in vec2 aToSubpx; -in uint aTileIndex; - -out vec2 vFrom; -out vec2 vTo; - -vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth){ - uint tilesPerRow = uint(stencilTextureWidth / uTileSize . x); +uniform vec4 uTileSize[1]; +uniform vec4 uFramebufferSize[1]; +layout(location = 5) in uint aTileIndex; +layout(location = 1) in uint aFromPx; +layout(location = 3) in vec2 aFromSubpx; +layout(location = 2) in uint aToPx; +layout(location = 4) in vec2 aToSubpx; +layout(location = 0) in uvec2 aTessCoord; +layout(location = 0) out vec2 vFrom; +layout(location = 1) out vec2 vTo; + +vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth) +{ + uint tilesPerRow = uint(stencilTextureWidth / uTileSize[0].x); uvec2 tileOffset = uvec2(tileIndex % tilesPerRow, tileIndex / tilesPerRow); - return vec2(tileOffset)* uTileSize * vec2(1.0, 0.25); + return (vec2(tileOffset) * uTileSize[0].xy) * vec2(1.0, 0.25); } -void main(){ - vec2 tileOrigin = computeTileOffset(aTileIndex, uFramebufferSize . x); - - vec2 from = vec2(aFromPx & 15u, aFromPx >> 4u)+ aFromSubpx; - vec2 to = vec2(aToPx & 15u, aToPx >> 4u)+ aToSubpx; - +void main() +{ + uint param = aTileIndex; + float param_1 = uFramebufferSize[0].x; + vec2 tileOrigin = computeTileOffset(param, param_1); + vec2 from = vec2(float(aFromPx & 15u), float(aFromPx >> 4u)) + aFromSubpx; + vec2 to = vec2(float(aToPx & 15u), float(aToPx >> 4u)) + aToSubpx; vec2 position; - if(aTessCoord . x == 0u) - position . x = floor(min(from . x, to . x)); + if (aTessCoord.x == 0u) + { + position.x = floor(min(from.x, to.x)); + } else - position . x = ceil(max(from . x, to . x)); - if(aTessCoord . y == 0u) - position . y = floor(min(from . y, to . y)); + { + position.x = ceil(max(from.x, to.x)); + } + if (aTessCoord.y == 0u) + { + position.y = floor(min(from.y, to.y)); + } else - position . y = uTileSize . y; - position . y = floor(position . y * 0.25); - - - - - - vec2 offset = vec2(0.0, 1.5)- position * vec2(1.0, 4.0); + { + position.y = uTileSize[0].y; + } + position.y = floor(position.y * 0.25); + vec2 offset = vec2(0.0, 1.5) - (position * vec2(1.0, 4.0)); vFrom = from + offset; vTo = to + offset; - - vec2 globalPosition =(tileOrigin + position)/ uFramebufferSize * 2.0 - 1.0; - - - + vec2 globalPosition = (((tileOrigin + position) / uFramebufferSize[0].xy) * 2.0) - vec2(1.0); gl_Position = vec4(globalPosition, 0.0, 1.0); } diff --git a/resources/shaders/gl4/reproject.fs.glsl b/resources/shaders/gl4/reproject.fs.glsl index a2fe1643d..efcd61273 100644 --- a/resources/shaders/gl4/reproject.fs.glsl +++ b/resources/shaders/gl4/reproject.fs.glsl @@ -2,32 +2,16 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uOldTransform[4]; +layout(binding = 2) uniform sampler2D SPIRV_Cross_CombineduTextureuSampler; +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 oFragColor; - - - - - - - - -precision highp float; - - - - - -uniform mat4 uOldTransform; -uniform sampler2D uTexture; - -in vec2 vTexCoord; - -out vec4 oFragColor; - -void main(){ - vec4 normTexCoord = uOldTransform * vec4(vTexCoord, 0.0, 1.0); - vec2 texCoord =((normTexCoord . xy / normTexCoord . w)+ 1.0)* 0.5; - oFragColor = texture(uTexture, texCoord); +void main() +{ + vec4 normTexCoord = mat4(uOldTransform[0], uOldTransform[1], uOldTransform[2], uOldTransform[3]) * vec4(vTexCoord, 0.0, 1.0); + vec2 texCoord = ((normTexCoord.xy / vec2(normTexCoord.w)) + vec2(1.0)) * 0.5; + oFragColor = texture(SPIRV_Cross_CombineduTextureuSampler, texCoord); } diff --git a/resources/shaders/gl4/reproject.vs.glsl b/resources/shaders/gl4/reproject.vs.glsl index 539e30e15..d4d7378a8 100644 --- a/resources/shaders/gl4/reproject.vs.glsl +++ b/resources/shaders/gl4/reproject.vs.glsl @@ -2,36 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uNewTransform[4]; +layout(location = 0) in ivec2 aPosition; +layout(location = 0) out vec2 vTexCoord; - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uNewTransform; - -in ivec2 aPosition; - -out vec2 vTexCoord; - -void main(){ +void main() +{ vec2 position = vec2(aPosition); vTexCoord = position; - - - - - - gl_Position = uNewTransform * vec4(position, 0.0, 1.0); + gl_Position = mat4(uNewTransform[0], uNewTransform[1], uNewTransform[2], uNewTransform[3]) * vec4(position, 0.0, 1.0); } diff --git a/resources/shaders/gl4/stencil.fs.glsl b/resources/shaders/gl4/stencil.fs.glsl index 2174f77ac..c9a19890d 100644 --- a/resources/shaders/gl4/stencil.fs.glsl +++ b/resources/shaders/gl4/stencil.fs.glsl @@ -2,26 +2,10 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +layout(location = 0) out vec4 oFragColor; - - - - - - - - - -precision highp float; - - - - - -out vec4 oFragColor; - -void main(){ - +void main() +{ oFragColor = vec4(1.0, 0.0, 0.0, 1.0); } diff --git a/resources/shaders/gl4/stencil.vs.glsl b/resources/shaders/gl4/stencil.vs.glsl index e42111876..f56fba14e 100644 --- a/resources/shaders/gl4/stencil.vs.glsl +++ b/resources/shaders/gl4/stencil.vs.glsl @@ -2,25 +2,10 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +layout(location = 0) in vec3 aPosition; - - - - - - - - - -precision highp float; - - - - - -in vec3 aPosition; - -void main(){ +void main() +{ gl_Position = vec4(aPosition, 1.0); } diff --git a/resources/shaders/gl4/tile.fs.glsl b/resources/shaders/gl4/tile.fs.glsl index 33815bd91..293cb6da1 100644 --- a/resources/shaders/gl4/tile.fs.glsl +++ b/resources/shaders/gl4/tile.fs.glsl @@ -2,613 +2,570 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -#extension GL_GOOGLE_include_directive : enable - -precision highp float; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uniform sampler2D uColorTexture0; -uniform sampler2D uMaskTexture0; -uniform sampler2D uDestTexture; -uniform sampler2D uGammaLUT; -uniform vec2 uColorTextureSize0; -uniform vec2 uMaskTextureSize0; -uniform vec4 uFilterParams0; -uniform vec4 uFilterParams1; -uniform vec4 uFilterParams2; -uniform vec2 uFramebufferSize; -uniform int uCtrl; - -in vec3 vMaskTexCoord0; -in vec2 vColorTexCoord0; -in vec4 vBaseColor; -in float vTileCtrl; - -out vec4 oFragColor; - - - -vec4 sampleColor(sampler2D colorTexture, vec2 colorTexCoord){ - return texture(colorTexture, colorTexCoord); +uniform vec4 uMaskTextureSize0[1]; +uniform vec4 uColorTextureSize0[1]; +uniform vec4 uFramebufferSize[1]; +uniform vec4 uFilterParams0[1]; +uniform vec4 uFilterParams1[1]; +uniform vec4 uFilterParams2[1]; +uniform ivec4 uCtrl[1]; +layout(binding = 2) uniform sampler2D SPIRV_Cross_CombineduMaskTexture0uSampler; +layout(binding = 1) uniform sampler2D SPIRV_Cross_CombineduColorTexture0uSampler; +layout(binding = 4) uniform sampler2D SPIRV_Cross_CombineduGammaLUTuSampler; +layout(binding = 3) uniform sampler2D SPIRV_Cross_CombineduDestTextureuSampler; + +layout(location = 0) in vec3 vMaskTexCoord0; +layout(location = 2) in vec4 vBaseColor; +layout(location = 1) in vec2 vColorTexCoord0; +layout(location = 0) out vec4 oFragColor; +layout(location = 3) in float vTileCtrl; + +float sampleMask(float maskAlpha, vec2 maskTextureSize, vec3 maskTexCoord, int maskCtrl, sampler2D SPIRV_Cross_CombinedmaskTextureuSampler) +{ + if (maskCtrl == 0) + { + return maskAlpha; + } + ivec2 maskTexCoordI = ivec2(floor(maskTexCoord.xy)); + vec4 texel = texture(SPIRV_Cross_CombinedmaskTextureuSampler, (vec2(maskTexCoordI / ivec2(1, 4)) + vec2(0.5)) / maskTextureSize); + float coverage = texel[maskTexCoordI.y % 4] + maskTexCoord.z; + if ((maskCtrl & 1) != 0) + { + coverage = abs(coverage); + } + else + { + coverage = 1.0 - abs(1.0 - mod(coverage, 2.0)); + } + return min(maskAlpha, coverage); } - - -vec4 combineColor0(vec4 destColor, vec4 srcColor, int op){ - switch(op){ - case 0x1 : - return vec4(srcColor . rgb, srcColor . a * destColor . a); - case 0x2 : - return vec4(destColor . rgb, srcColor . a * destColor . a); +vec4 filterRadialGradient(vec2 colorTexCoord, vec2 colorTextureSize, vec2 fragCoord, vec2 framebufferSize, vec4 filterParams0, vec4 filterParams1, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + vec2 lineFrom = filterParams0.xy; + vec2 lineVector = filterParams0.zw; + vec2 radii = filterParams1.xy; + vec2 uvOrigin = filterParams1.zw; + vec2 dP = colorTexCoord - lineFrom; + vec2 dC = lineVector; + float dR = radii.y - radii.x; + float a = dot(dC, dC) - (dR * dR); + float b = dot(dP, dC) + (radii.x * dR); + float c = dot(dP, dP) - (radii.x * radii.x); + float discrim = (b * b) - (a * c); + vec4 color = vec4(0.0); + if (abs(discrim) >= 9.9999997473787516355514526367188e-06) + { + vec2 ts = vec2((vec2(1.0, -1.0) * sqrt(discrim)) + vec2(b)) / vec2(a); + if (ts.x > ts.y) + { + ts = ts.yx; + } + float _566; + if (ts.x >= 0.0) + { + _566 = ts.x; + } + else + { + _566 = ts.y; + } + float t = _566; + color = texture(SPIRV_Cross_CombinedcolorTextureuSampler, uvOrigin + vec2(clamp(t, 0.0, 1.0), 0.0)); } - return destColor; + return color; } - - -float filterTextSample1Tap(float offset, sampler2D colorTexture, vec2 colorTexCoord){ - return texture(colorTexture, colorTexCoord + vec2(offset, 0.0)). r; +vec4 filterBlur(vec2 colorTexCoord, vec2 colorTextureSize, vec4 filterParams0, vec4 filterParams1, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + vec2 srcOffsetScale = filterParams0.xy / colorTextureSize; + int support = int(filterParams0.z); + vec3 gaussCoeff = filterParams1.xyz; + float gaussSum = gaussCoeff.x; + vec4 color = texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord) * gaussCoeff.x; + vec2 _615 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = vec3(_615.x, _615.y, gaussCoeff.z); + for (int i = 1; i <= support; i += 2) + { + float gaussPartialSum = gaussCoeff.x; + vec2 _635 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = vec3(_635.x, _635.y, gaussCoeff.z); + gaussPartialSum += gaussCoeff.x; + vec2 srcOffset = srcOffsetScale * (float(i) + (gaussCoeff.x / gaussPartialSum)); + color += ((texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord - srcOffset) + texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord + srcOffset)) * gaussPartialSum); + gaussSum += (2.0 * gaussPartialSum); + vec2 _679 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = vec3(_679.x, _679.y, gaussCoeff.z); + } + return color / vec4(gaussSum); } - -void filterTextSample9Tap(out vec4 outAlphaLeft, - out float outAlphaCenter, - out vec4 outAlphaRight, - sampler2D colorTexture, - vec2 colorTexCoord, - vec4 kernel, - float onePixel){ - bool wide = kernel . x > 0.0; - outAlphaLeft = - vec4(wide ? filterTextSample1Tap(- 4.0 * onePixel, colorTexture, colorTexCoord): 0.0, - filterTextSample1Tap(- 3.0 * onePixel, colorTexture, colorTexCoord), - filterTextSample1Tap(- 2.0 * onePixel, colorTexture, colorTexCoord), - filterTextSample1Tap(- 1.0 * onePixel, colorTexture, colorTexCoord)); - outAlphaCenter = filterTextSample1Tap(0.0, colorTexture, colorTexCoord); - outAlphaRight = - vec4(filterTextSample1Tap(1.0 * onePixel, colorTexture, colorTexCoord), - filterTextSample1Tap(2.0 * onePixel, colorTexture, colorTexCoord), - filterTextSample1Tap(3.0 * onePixel, colorTexture, colorTexCoord), - wide ? filterTextSample1Tap(4.0 * onePixel, colorTexture, colorTexCoord): 0.0); +float filterTextSample1Tap(float offset, vec2 colorTexCoord, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + return texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord + vec2(offset, 0.0)).x; } -float filterTextConvolve7Tap(vec4 alpha0, vec3 alpha1, vec4 kernel){ - return dot(alpha0, kernel)+ dot(alpha1, kernel . zyx); +void filterTextSample9Tap(out vec4 outAlphaLeft, out float outAlphaCenter, out vec4 outAlphaRight, vec2 colorTexCoord, vec4 kernel, float onePixel, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + bool wide = kernel.x > 0.0; + float _243; + if (wide) + { + float param = (-4.0) * onePixel; + vec2 param_1 = colorTexCoord; + _243 = filterTextSample1Tap(param, param_1, SPIRV_Cross_CombinedcolorTextureuSampler); + } + else + { + _243 = 0.0; + } + float param_2 = (-3.0) * onePixel; + vec2 param_3 = colorTexCoord; + float param_4 = (-2.0) * onePixel; + vec2 param_5 = colorTexCoord; + float param_6 = (-1.0) * onePixel; + vec2 param_7 = colorTexCoord; + outAlphaLeft = vec4(_243, filterTextSample1Tap(param_2, param_3, SPIRV_Cross_CombinedcolorTextureuSampler), filterTextSample1Tap(param_4, param_5, SPIRV_Cross_CombinedcolorTextureuSampler), filterTextSample1Tap(param_6, param_7, SPIRV_Cross_CombinedcolorTextureuSampler)); + float param_8 = 0.0; + vec2 param_9 = colorTexCoord; + outAlphaCenter = filterTextSample1Tap(param_8, param_9, SPIRV_Cross_CombinedcolorTextureuSampler); + float param_10 = 1.0 * onePixel; + vec2 param_11 = colorTexCoord; + float param_12 = 2.0 * onePixel; + vec2 param_13 = colorTexCoord; + float param_14 = 3.0 * onePixel; + vec2 param_15 = colorTexCoord; + float _303; + if (wide) + { + float param_16 = 4.0 * onePixel; + vec2 param_17 = colorTexCoord; + _303 = filterTextSample1Tap(param_16, param_17, SPIRV_Cross_CombinedcolorTextureuSampler); + } + else + { + _303 = 0.0; + } + outAlphaRight = vec4(filterTextSample1Tap(param_10, param_11, SPIRV_Cross_CombinedcolorTextureuSampler), filterTextSample1Tap(param_12, param_13, SPIRV_Cross_CombinedcolorTextureuSampler), filterTextSample1Tap(param_14, param_15, SPIRV_Cross_CombinedcolorTextureuSampler), _303); } -float filterTextGammaCorrectChannel(float bgColor, float fgColor, sampler2D gammaLUT){ - return texture(gammaLUT, vec2(fgColor, 1.0 - bgColor)). r; +float filterTextConvolve7Tap(vec4 alpha0, vec3 alpha1, vec4 kernel) +{ + return dot(alpha0, kernel) + dot(alpha1, kernel.zyx); } - -vec3 filterTextGammaCorrect(vec3 bgColor, vec3 fgColor, sampler2D gammaLUT){ - return vec3(filterTextGammaCorrectChannel(bgColor . r, fgColor . r, gammaLUT), - filterTextGammaCorrectChannel(bgColor . g, fgColor . g, gammaLUT), - filterTextGammaCorrectChannel(bgColor . b, fgColor . b, gammaLUT)); +float filterTextGammaCorrectChannel(float bgColor, float fgColor, sampler2D SPIRV_Cross_CombinedgammaLUTuSampler) +{ + return texture(SPIRV_Cross_CombinedgammaLUTuSampler, vec2(fgColor, 1.0 - bgColor)).x; } +vec3 filterTextGammaCorrect(vec3 bgColor, vec3 fgColor, sampler2D SPIRV_Cross_CombinedgammaLUTuSampler) +{ + float param = bgColor.x; + float param_1 = fgColor.x; + float param_2 = bgColor.y; + float param_3 = fgColor.y; + float param_4 = bgColor.z; + float param_5 = fgColor.z; + return vec3(filterTextGammaCorrectChannel(param, param_1, SPIRV_Cross_CombinedgammaLUTuSampler), filterTextGammaCorrectChannel(param_2, param_3, SPIRV_Cross_CombinedgammaLUTuSampler), filterTextGammaCorrectChannel(param_4, param_5, SPIRV_Cross_CombinedgammaLUTuSampler)); +} - - - - -vec4 filterText(vec2 colorTexCoord, - sampler2D colorTexture, - sampler2D gammaLUT, - vec2 colorTextureSize, - vec4 filterParams0, - vec4 filterParams1, - vec4 filterParams2){ - +vec4 filterText(vec2 colorTexCoord, vec2 colorTextureSize, vec4 filterParams0, vec4 filterParams1, vec4 filterParams2, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler, sampler2D SPIRV_Cross_CombinedgammaLUTuSampler) +{ vec4 kernel = filterParams0; - vec3 bgColor = filterParams1 . rgb; - vec3 fgColor = filterParams2 . rgb; - bool gammaCorrectionEnabled = filterParams2 . a != 0.0; - - + vec3 bgColor = filterParams1.xyz; + vec3 fgColor = filterParams2.xyz; + bool gammaCorrectionEnabled = filterParams2.w != 0.0; vec3 alpha; - if(kernel . w == 0.0){ - alpha = texture(colorTexture, colorTexCoord). rrr; - } else { - vec4 alphaLeft, alphaRight; - float alphaCenter; - filterTextSample9Tap(alphaLeft, - alphaCenter, - alphaRight, - colorTexture, - colorTexCoord, - kernel, - 1.0 / colorTextureSize . x); - - float r = filterTextConvolve7Tap(alphaLeft, vec3(alphaCenter, alphaRight . xy), kernel); - float g = filterTextConvolve7Tap(vec4(alphaLeft . yzw, alphaCenter), alphaRight . xyz, kernel); - float b = filterTextConvolve7Tap(vec4(alphaLeft . zw, alphaCenter, alphaRight . x), - alphaRight . yzw, - kernel); - + if (kernel.w == 0.0) + { + alpha = texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord).xxx; + } + else + { + vec2 param_3 = colorTexCoord; + vec4 param_4 = kernel; + float param_5 = 1.0 / colorTextureSize.x; + vec4 param; + float param_1; + vec4 param_2; + filterTextSample9Tap(param, param_1, param_2, param_3, param_4, param_5, SPIRV_Cross_CombinedcolorTextureuSampler); + vec4 alphaLeft = param; + float alphaCenter = param_1; + vec4 alphaRight = param_2; + vec4 param_6 = alphaLeft; + vec3 param_7 = vec3(alphaCenter, alphaRight.xy); + vec4 param_8 = kernel; + float r = filterTextConvolve7Tap(param_6, param_7, param_8); + vec4 param_9 = vec4(alphaLeft.yzw, alphaCenter); + vec3 param_10 = alphaRight.xyz; + vec4 param_11 = kernel; + float g = filterTextConvolve7Tap(param_9, param_10, param_11); + vec4 param_12 = vec4(alphaLeft.zw, alphaCenter, alphaRight.x); + vec3 param_13 = alphaRight.yzw; + vec4 param_14 = kernel; + float b = filterTextConvolve7Tap(param_12, param_13, param_14); alpha = vec3(r, g, b); } - - - if(gammaCorrectionEnabled) - alpha = filterTextGammaCorrect(bgColor, alpha, gammaLUT); - - + if (gammaCorrectionEnabled) + { + vec3 param_15 = bgColor; + vec3 param_16 = alpha; + alpha = filterTextGammaCorrect(param_15, param_16, SPIRV_Cross_CombinedgammaLUTuSampler); + } return vec4(mix(bgColor, fgColor, alpha), 1.0); } +vec4 sampleColor(vec2 colorTexCoord, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + return texture(SPIRV_Cross_CombinedcolorTextureuSampler, colorTexCoord); +} +vec4 filterNone(vec2 colorTexCoord, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler) +{ + vec2 param = colorTexCoord; + return sampleColor(param, SPIRV_Cross_CombinedcolorTextureuSampler); +} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -vec4 filterRadialGradient(vec2 colorTexCoord, - sampler2D colorTexture, - vec2 colorTextureSize, - vec2 fragCoord, - vec2 framebufferSize, - vec4 filterParams0, - vec4 filterParams1){ - vec2 lineFrom = filterParams0 . xy, lineVector = filterParams0 . zw; - vec2 radii = filterParams1 . xy, uvOrigin = filterParams1 . zw; - - vec2 dP = colorTexCoord - lineFrom, dC = lineVector; - float dR = radii . y - radii . x; - - float a = dot(dC, dC)- dR * dR; - float b = dot(dP, dC)+ radii . x * dR; - float c = dot(dP, dP)- radii . x * radii . x; - float discrim = b * b - a * c; - - vec4 color = vec4(0.0); - if(abs(discrim)>= 0.00001){ - vec2 ts = vec2(sqrt(discrim)* vec2(1.0, - 1.0)+ vec2(b))/ vec2(a); - if(ts . x > ts . y) - ts = ts . yx; - float t = ts . x >= 0.0 ? ts . x : ts . y; - color = texture(colorTexture, uvOrigin + vec2(clamp(t, 0.0, 1.0), 0.0)); +vec4 filterColor(vec2 colorTexCoord, vec2 colorTextureSize, vec2 fragCoord, vec2 framebufferSize, vec4 filterParams0, vec4 filterParams1, vec4 filterParams2, int colorFilter, sampler2D SPIRV_Cross_CombinedcolorTextureuSampler, sampler2D SPIRV_Cross_CombinedgammaLUTuSampler) +{ + switch (colorFilter) + { + case 1: + { + vec2 param = colorTexCoord; + vec2 param_1 = colorTextureSize; + vec2 param_2 = fragCoord; + vec2 param_3 = framebufferSize; + vec4 param_4 = filterParams0; + vec4 param_5 = filterParams1; + return filterRadialGradient(param, param_1, param_2, param_3, param_4, param_5, SPIRV_Cross_CombinedcolorTextureuSampler); + } + case 3: + { + vec2 param_6 = colorTexCoord; + vec2 param_7 = colorTextureSize; + vec4 param_8 = filterParams0; + vec4 param_9 = filterParams1; + return filterBlur(param_6, param_7, param_8, param_9, SPIRV_Cross_CombinedcolorTextureuSampler); + } + case 2: + { + vec2 param_10 = colorTexCoord; + vec2 param_11 = colorTextureSize; + vec4 param_12 = filterParams0; + vec4 param_13 = filterParams1; + vec4 param_14 = filterParams2; + return filterText(param_10, param_11, param_12, param_13, param_14, SPIRV_Cross_CombinedcolorTextureuSampler, SPIRV_Cross_CombinedgammaLUTuSampler); + } } - - return color; + vec2 param_15 = colorTexCoord; + return filterNone(param_15, SPIRV_Cross_CombinedcolorTextureuSampler); } - - - - - -vec4 filterBlur(vec2 colorTexCoord, - sampler2D colorTexture, - vec2 colorTextureSize, - vec4 filterParams0, - vec4 filterParams1){ - - vec2 srcOffsetScale = filterParams0 . xy / colorTextureSize; - int support = int(filterParams0 . z); - vec3 gaussCoeff = filterParams1 . xyz; - - - float gaussSum = gaussCoeff . x; - vec4 color = texture(colorTexture, colorTexCoord)* gaussCoeff . x; - gaussCoeff . xy *= gaussCoeff . yz; - - - - - - - - - - for(int i = 1;i <= support;i += 2){ - float gaussPartialSum = gaussCoeff . x; - gaussCoeff . xy *= gaussCoeff . yz; - gaussPartialSum += gaussCoeff . x; - - vec2 srcOffset = srcOffsetScale *(float(i)+ gaussCoeff . x / gaussPartialSum); - color +=(texture(colorTexture, colorTexCoord - srcOffset)+ - texture(colorTexture, colorTexCoord + srcOffset))* gaussPartialSum; - - gaussSum += 2.0 * gaussPartialSum; - gaussCoeff . xy *= gaussCoeff . yz; +vec4 combineColor0(vec4 destColor, vec4 srcColor, int op) +{ + switch (op) + { + case 1: + { + return vec4(srcColor.xyz, srcColor.w * destColor.w); + } + case 2: + { + return vec4(destColor.xyz, srcColor.w * destColor.w); + } } - - - return color / gaussSum; + return destColor; } -vec4 filterNone(vec2 colorTexCoord, sampler2D colorTexture){ - return sampleColor(colorTexture, colorTexCoord); +vec3 compositeScreen(vec3 destColor, vec3 srcColor) +{ + return (destColor + srcColor) - (destColor * srcColor); } -vec4 filterColor(vec2 colorTexCoord, - sampler2D colorTexture, - sampler2D gammaLUT, - vec2 colorTextureSize, - vec2 fragCoord, - vec2 framebufferSize, - vec4 filterParams0, - vec4 filterParams1, - vec4 filterParams2, - int colorFilter){ - switch(colorFilter){ - case 0x1 : - return filterRadialGradient(colorTexCoord, - colorTexture, - colorTextureSize, - fragCoord, - framebufferSize, - filterParams0, - filterParams1); - case 0x3 : - return filterBlur(colorTexCoord, - colorTexture, - colorTextureSize, - filterParams0, - filterParams1); - case 0x2 : - return filterText(colorTexCoord, - colorTexture, - gammaLUT, - colorTextureSize, - filterParams0, - filterParams1, - filterParams2); +vec3 compositeSelect(bvec3 cond, vec3 ifTrue, vec3 ifFalse) +{ + float _745; + if (cond.x) + { + _745 = ifTrue.x; + } + else + { + _745 = ifFalse.x; + } + float _756; + if (cond.y) + { + _756 = ifTrue.y; + } + else + { + _756 = ifFalse.y; + } + float _767; + if (cond.z) + { + _767 = ifTrue.z; + } + else + { + _767 = ifFalse.z; } - return filterNone(colorTexCoord, colorTexture); + return vec3(_745, _756, _767); } - - -vec3 compositeSelect(bvec3 cond, vec3 ifTrue, vec3 ifFalse){ - return vec3(cond . x ? ifTrue . x : ifFalse . x, - cond . y ? ifTrue . y : ifFalse . y, - cond . z ? ifTrue . z : ifFalse . z); +vec3 compositeHardLight(vec3 destColor, vec3 srcColor) +{ + vec3 param = destColor; + vec3 param_1 = (vec3(2.0) * srcColor) - vec3(1.0); + bvec3 param_2 = lessThanEqual(srcColor, vec3(0.5)); + vec3 param_3 = (destColor * vec3(2.0)) * srcColor; + vec3 param_4 = compositeScreen(param, param_1); + return compositeSelect(param_2, param_3, param_4); } -float compositeDivide(float num, float denom){ - return denom != 0.0 ? num / denom : 0.0; +vec3 compositeColorDodge(vec3 destColor, vec3 srcColor) +{ + bvec3 destZero = equal(destColor, vec3(0.0)); + bvec3 srcOne = equal(srcColor, vec3(1.0)); + bvec3 param = srcOne; + vec3 param_1 = vec3(1.0); + vec3 param_2 = destColor / (vec3(1.0) - srcColor); + bvec3 param_3 = destZero; + vec3 param_4 = vec3(0.0); + vec3 param_5 = compositeSelect(param, param_1, param_2); + return compositeSelect(param_3, param_4, param_5); } -vec3 compositeColorDodge(vec3 destColor, vec3 srcColor){ - bvec3 destZero = equal(destColor, vec3(0.0)), srcOne = equal(srcColor, vec3(1.0)); - return compositeSelect(destZero, - vec3(0.0), - compositeSelect(srcOne, vec3(1.0), destColor /(vec3(1.0)- srcColor))); +vec3 compositeSoftLight(vec3 destColor, vec3 srcColor) +{ + bvec3 param = lessThanEqual(destColor, vec3(0.25)); + vec3 param_1 = ((((vec3(16.0) * destColor) - vec3(12.0)) * destColor) + vec3(4.0)) * destColor; + vec3 param_2 = sqrt(destColor); + vec3 darkenedDestColor = compositeSelect(param, param_1, param_2); + bvec3 param_3 = lessThanEqual(srcColor, vec3(0.5)); + vec3 param_4 = destColor * (vec3(1.0) - destColor); + vec3 param_5 = darkenedDestColor - destColor; + vec3 factor = compositeSelect(param_3, param_4, param_5); + return destColor + (((srcColor * 2.0) - vec3(1.0)) * factor); } - -vec3 compositeHSLToRGB(vec3 hsl){ - float a = hsl . y * min(hsl . z, 1.0 - hsl . z); - vec3 ks = mod(vec3(0.0, 8.0, 4.0)+ vec3(hsl . x * 1.9098593171027443), 12.0); - return hsl . zzz - clamp(min(ks - vec3(3.0), vec3(9.0)- ks), - 1.0, 1.0)* a; +float compositeDivide(float num, float denom) +{ + float _781; + if (denom != 0.0) + { + _781 = num / denom; + } + else + { + _781 = 0.0; + } + return _781; } - -vec3 compositeRGBToHSL(vec3 rgb){ - float v = max(max(rgb . r, rgb . g), rgb . b), xMin = min(min(rgb . r, rgb . g), rgb . b); - float c = v - xMin, l = mix(xMin, v, 0.5); - vec3 terms = rgb . r == v ? vec3(0.0, rgb . gb): - rgb . g == v ? vec3(2.0, rgb . br): - vec3(4.0, rgb . rg); - float h = 1.0471975511965976 * compositeDivide(terms . x * c + terms . y - terms . z, c); - float s = compositeDivide(c, v); +vec3 compositeRGBToHSL(vec3 rgb) +{ + float v = max(max(rgb.x, rgb.y), rgb.z); + float xMin = min(min(rgb.x, rgb.y), rgb.z); + float c = v - xMin; + float l = mix(xMin, v, 0.5); + vec3 _887; + if (rgb.x == v) + { + _887 = vec3(0.0, rgb.yz); + } + else + { + vec3 _900; + if (rgb.y == v) + { + _900 = vec3(2.0, rgb.zx); + } + else + { + _900 = vec3(4.0, rgb.xy); + } + _887 = _900; + } + vec3 terms = _887; + float param = ((terms.x * c) + terms.y) - terms.z; + float param_1 = c; + float h = 1.0471975803375244140625 * compositeDivide(param, param_1); + float param_2 = c; + float param_3 = v; + float s = compositeDivide(param_2, param_3); return vec3(h, s, l); } -vec3 compositeScreen(vec3 destColor, vec3 srcColor){ - return destColor + srcColor - destColor * srcColor; -} - -vec3 compositeHardLight(vec3 destColor, vec3 srcColor){ - return compositeSelect(lessThanEqual(srcColor, vec3(0.5)), - destColor * vec3(2.0)* srcColor, - compositeScreen(destColor, vec3(2.0)* srcColor - vec3(1.0))); -} - -vec3 compositeSoftLight(vec3 destColor, vec3 srcColor){ - vec3 darkenedDestColor = - compositeSelect(lessThanEqual(destColor, vec3(0.25)), - ((vec3(16.0)* destColor - 12.0)* destColor + 4.0)* destColor, - sqrt(destColor)); - vec3 factor = compositeSelect(lessThanEqual(srcColor, vec3(0.5)), - destColor *(vec3(1.0)- destColor), - darkenedDestColor - destColor); - return destColor +(srcColor * 2.0 - 1.0)* factor; +vec3 compositeHSL(vec3 destColor, vec3 srcColor, int op) +{ + switch (op) + { + case 12: + { + return vec3(srcColor.x, destColor.y, destColor.z); + } + case 13: + { + return vec3(destColor.x, srcColor.y, destColor.z); + } + case 14: + { + return vec3(srcColor.x, srcColor.y, destColor.z); + } + default: + { + return vec3(destColor.x, destColor.y, srcColor.z); + } + } } -vec3 compositeHSL(vec3 destColor, vec3 srcColor, int op){ - switch(op){ - case 0xc : - return vec3(srcColor . x, destColor . y, destColor . z); - case 0xd : - return vec3(destColor . x, srcColor . y, destColor . z); - case 0xe : - return vec3(srcColor . x, srcColor . y, destColor . z); - default : - return vec3(destColor . x, destColor . y, srcColor . z); - } +vec3 compositeHSLToRGB(vec3 hsl) +{ + float a = hsl.y * min(hsl.z, 1.0 - hsl.z); + vec3 ks = mod(vec3(0.0, 8.0, 4.0) + vec3(hsl.x * 1.90985929965972900390625), vec3(12.0)); + return hsl.zzz - (clamp(min(ks - vec3(3.0), vec3(9.0) - ks), vec3(-1.0), vec3(1.0)) * a); } -vec3 compositeRGB(vec3 destColor, vec3 srcColor, int op){ - switch(op){ - case 0x1 : - return destColor * srcColor; - case 0x2 : - return compositeScreen(destColor, srcColor); - case 0x3 : - return compositeHardLight(srcColor, destColor); - case 0x4 : - return min(destColor, srcColor); - case 0x5 : - return max(destColor, srcColor); - case 0x6 : - return compositeColorDodge(destColor, srcColor); - case 0x7 : - return vec3(1.0)- compositeColorDodge(vec3(1.0)- destColor, vec3(1.0)- srcColor); - case 0x8 : - return compositeHardLight(destColor, srcColor); - case 0x9 : - return compositeSoftLight(destColor, srcColor); - case 0xa : - return abs(destColor - srcColor); - case 0xb : - return destColor + srcColor - vec3(2.0)* destColor * srcColor; - case 0xc : - case 0xd : - case 0xe : - case 0xf : - return compositeHSLToRGB(compositeHSL(compositeRGBToHSL(destColor), - compositeRGBToHSL(srcColor), - op)); +vec3 compositeRGB(vec3 destColor, vec3 srcColor, int op) +{ + switch (op) + { + case 1: + { + return destColor * srcColor; + } + case 2: + { + vec3 param = destColor; + vec3 param_1 = srcColor; + return compositeScreen(param, param_1); + } + case 3: + { + vec3 param_2 = srcColor; + vec3 param_3 = destColor; + return compositeHardLight(param_2, param_3); + } + case 4: + { + return min(destColor, srcColor); + } + case 5: + { + return max(destColor, srcColor); + } + case 6: + { + vec3 param_4 = destColor; + vec3 param_5 = srcColor; + return compositeColorDodge(param_4, param_5); + } + case 7: + { + vec3 param_6 = vec3(1.0) - destColor; + vec3 param_7 = vec3(1.0) - srcColor; + return vec3(1.0) - compositeColorDodge(param_6, param_7); + } + case 8: + { + vec3 param_8 = destColor; + vec3 param_9 = srcColor; + return compositeHardLight(param_8, param_9); + } + case 9: + { + vec3 param_10 = destColor; + vec3 param_11 = srcColor; + return compositeSoftLight(param_10, param_11); + } + case 10: + { + return abs(destColor - srcColor); + } + case 11: + { + return (destColor + srcColor) - ((vec3(2.0) * destColor) * srcColor); + } + case 12: + case 13: + case 14: + case 15: + { + vec3 param_12 = destColor; + vec3 param_13 = srcColor; + vec3 param_14 = compositeRGBToHSL(param_12); + vec3 param_15 = compositeRGBToHSL(param_13); + int param_16 = op; + vec3 param_17 = compositeHSL(param_14, param_15, param_16); + return compositeHSLToRGB(param_17); + } } return srcColor; } -vec4 composite(vec4 srcColor, - sampler2D destTexture, - vec2 destTextureSize, - vec2 fragCoord, - int op){ - if(op == 0x0) +vec4 composite(vec4 srcColor, vec2 destTextureSize, vec2 fragCoord, int op, sampler2D SPIRV_Cross_CombineddestTextureuSampler) +{ + if (op == 0) + { return srcColor; - - + } vec2 destTexCoord = fragCoord / destTextureSize; - vec4 destColor = texture(destTexture, destTexCoord); - vec3 blendedRGB = compositeRGB(destColor . rgb, srcColor . rgb, op); - return vec4(srcColor . a *(1.0 - destColor . a)* srcColor . rgb + - srcColor . a * destColor . a * blendedRGB + - (1.0 - srcColor . a)* destColor . rgb, - 1.0); + vec4 destColor = texture(SPIRV_Cross_CombineddestTextureuSampler, destTexCoord); + vec3 param = destColor.xyz; + vec3 param_1 = srcColor.xyz; + int param_2 = op; + vec3 blendedRGB = compositeRGB(param, param_1, param_2); + return vec4(((srcColor.xyz * (srcColor.w * (1.0 - destColor.w))) + (blendedRGB * (srcColor.w * destColor.w))) + (destColor.xyz * (1.0 - srcColor.w)), 1.0); } - - -float sampleMask(float maskAlpha, - sampler2D maskTexture, - vec2 maskTextureSize, - vec3 maskTexCoord, - int maskCtrl){ - if(maskCtrl == 0) - return maskAlpha; - - ivec2 maskTexCoordI = ivec2(floor(maskTexCoord . xy)); - vec4 texel = texture(maskTexture,(vec2(maskTexCoordI / ivec2(1, 4))+ 0.5)/ maskTextureSize); - float coverage = texel[maskTexCoordI . y % 4]+ maskTexCoord . z; - - if((maskCtrl & 0x1)!= 0) - coverage = abs(coverage); - else - coverage = 1.0 - abs(1.0 - mod(coverage, 2.0)); - return min(maskAlpha, coverage); -} - - - -void calculateColor(int tileCtrl, int ctrl){ - - int maskCtrl0 =(tileCtrl >> 0)& 0x3; +void calculateColor(int tileCtrl, int ctrl) +{ + int maskCtrl0 = (tileCtrl >> 0) & 3; float maskAlpha = 1.0; - maskAlpha = sampleMask(maskAlpha, uMaskTexture0, uMaskTextureSize0, vMaskTexCoord0, maskCtrl0); - - + float param = maskAlpha; + vec2 param_1 = uMaskTextureSize0[0].xy; + vec3 param_2 = vMaskTexCoord0; + int param_3 = maskCtrl0; + maskAlpha = sampleMask(param, param_1, param_2, param_3, SPIRV_Cross_CombineduMaskTexture0uSampler); vec4 color = vBaseColor; - int color0Combine =(ctrl >> 6)& - 0x3; - if(color0Combine != 0){ - int color0Filter =(ctrl >> 4)& 0x3; - vec4 color0 = filterColor(vColorTexCoord0, - uColorTexture0, - uGammaLUT, - uColorTextureSize0, - gl_FragCoord . xy, - uFramebufferSize, - uFilterParams0, - uFilterParams1, - uFilterParams2, - color0Filter); - color = combineColor0(color, color0, color0Combine); + int color0Combine = (ctrl >> 6) & 3; + if (color0Combine != 0) + { + int color0Filter = (ctrl >> 4) & 3; + vec2 param_4 = vColorTexCoord0; + vec2 param_5 = uColorTextureSize0[0].xy; + vec2 param_6 = gl_FragCoord.xy; + vec2 param_7 = uFramebufferSize[0].xy; + vec4 param_8 = uFilterParams0[0]; + vec4 param_9 = uFilterParams1[0]; + vec4 param_10 = uFilterParams2[0]; + int param_11 = color0Filter; + vec4 color0 = filterColor(param_4, param_5, param_6, param_7, param_8, param_9, param_10, param_11, SPIRV_Cross_CombineduColorTexture0uSampler, SPIRV_Cross_CombineduGammaLUTuSampler); + vec4 param_12 = color; + vec4 param_13 = color0; + int param_14 = color0Combine; + color = combineColor0(param_12, param_13, param_14); } - - - color . a *= maskAlpha; - - - int compositeOp =(ctrl >> 8)& 0xf; - color = composite(color, uDestTexture, uFramebufferSize, gl_FragCoord . xy, compositeOp); - - - color . rgb *= color . a; + color.w *= maskAlpha; + int compositeOp = (ctrl >> 8) & 15; + vec4 param_15 = color; + vec2 param_16 = uFramebufferSize[0].xy; + vec2 param_17 = gl_FragCoord.xy; + int param_18 = compositeOp; + color = composite(param_15, param_16, param_17, param_18, SPIRV_Cross_CombineduDestTextureuSampler); + vec3 _1389 = color.xyz * color.w; + color = vec4(_1389.x, _1389.y, _1389.z, color.w); oFragColor = color; } - - - - -void main(){ - calculateColor(int(vTileCtrl), uCtrl); +void main() +{ + int param = int(vTileCtrl); + int param_1 = uCtrl[0].x; + calculateColor(param, param_1); } diff --git a/resources/shaders/gl4/tile.vs.glsl b/resources/shaders/gl4/tile.vs.glsl index 6f3819c00..443710a2f 100644 --- a/resources/shaders/gl4/tile.vs.glsl +++ b/resources/shaders/gl4/tile.vs.glsl @@ -2,58 +2,40 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uTransform; -uniform vec2 uTileSize; -uniform sampler2D uTextureMetadata; -uniform ivec2 uTextureMetadataSize; - -in ivec2 aTileOffset; -in ivec2 aTileOrigin; -in uvec2 aMaskTexCoord0; -in ivec2 aMaskBackdrop; -in int aColor; -in int aTileCtrl; - -out vec3 vMaskTexCoord0; -out vec2 vColorTexCoord0; -out vec4 vBaseColor; -out float vTileCtrl; - -void main(){ - vec2 tileOrigin = vec2(aTileOrigin), tileOffset = vec2(aTileOffset); - vec2 position =(tileOrigin + tileOffset)* uTileSize; - - vec2 maskTexCoord0 =(vec2(aMaskTexCoord0)+ tileOffset)* uTileSize; - - vec2 textureMetadataScale = vec2(1.0)/ vec2(uTextureMetadataSize); - vec2 metadataEntryCoord = vec2(aColor % 128 * 4, aColor / 128); - vec2 colorTexMatrix0Coord =(metadataEntryCoord + vec2(0.5, 0.5))* textureMetadataScale; - vec2 colorTexOffsetsCoord =(metadataEntryCoord + vec2(1.5, 0.5))* textureMetadataScale; - vec2 baseColorCoord =(metadataEntryCoord + vec2(2.5, 0.5))* textureMetadataScale; - vec4 colorTexMatrix0 = texture(uTextureMetadata, colorTexMatrix0Coord); - vec4 colorTexOffsets = texture(uTextureMetadata, colorTexOffsetsCoord); - vec4 baseColor = texture(uTextureMetadata, baseColorCoord); - - vColorTexCoord0 = mat2(colorTexMatrix0)* position + colorTexOffsets . xy; - vMaskTexCoord0 = vec3(maskTexCoord0, float(aMaskBackdrop . x)); +uniform vec4 uTileSize[1]; +uniform ivec4 uTextureMetadataSize[1]; +uniform vec4 uTransform[4]; +layout(binding = 2) uniform sampler2D SPIRV_Cross_CombineduTextureMetadatauSampler; + +layout(location = 1) in ivec2 aTileOrigin; +layout(location = 0) in ivec2 aTileOffset; +layout(location = 2) in uvec2 aMaskTexCoord0; +layout(location = 4) in int aColor; +layout(location = 1) out vec2 vColorTexCoord0; +layout(location = 0) out vec3 vMaskTexCoord0; +layout(location = 3) in ivec2 aMaskBackdrop; +layout(location = 2) out vec4 vBaseColor; +layout(location = 3) out float vTileCtrl; +layout(location = 5) in int aTileCtrl; + +void main() +{ + vec2 tileOrigin = vec2(aTileOrigin); + vec2 tileOffset = vec2(aTileOffset); + vec2 position = (tileOrigin + tileOffset) * uTileSize[0].xy; + vec2 maskTexCoord0 = (vec2(aMaskTexCoord0) + tileOffset) * uTileSize[0].xy; + vec2 textureMetadataScale = vec2(1.0) / vec2(uTextureMetadataSize[0].xy); + vec2 metadataEntryCoord = vec2(float((aColor % 128) * 4), float(aColor / 128)); + vec2 colorTexMatrix0Coord = (metadataEntryCoord + vec2(0.5)) * textureMetadataScale; + vec2 colorTexOffsetsCoord = (metadataEntryCoord + vec2(1.5, 0.5)) * textureMetadataScale; + vec2 baseColorCoord = (metadataEntryCoord + vec2(2.5, 0.5)) * textureMetadataScale; + vec4 colorTexMatrix0 = textureLod(SPIRV_Cross_CombineduTextureMetadatauSampler, colorTexMatrix0Coord, 0.0); + vec4 colorTexOffsets = textureLod(SPIRV_Cross_CombineduTextureMetadatauSampler, colorTexOffsetsCoord, 0.0); + vec4 baseColor = textureLod(SPIRV_Cross_CombineduTextureMetadatauSampler, baseColorCoord, 0.0); + vColorTexCoord0 = (mat2(vec2(colorTexMatrix0.xy), vec2(colorTexMatrix0.zw)) * position) + colorTexOffsets.xy; + vMaskTexCoord0 = vec3(maskTexCoord0, float(aMaskBackdrop.x)); vBaseColor = baseColor; vTileCtrl = float(aTileCtrl); - gl_Position = uTransform * vec4(position, 0.0, 1.0); + gl_Position = mat4(uTransform[0], uTransform[1], uTransform[2], uTransform[3]) * vec4(position, 0.0, 1.0); } diff --git a/resources/shaders/gl4/tile_clip.fs.glsl b/resources/shaders/gl4/tile_clip.fs.glsl index 9b8b6cd3f..871231fc0 100644 --- a/resources/shaders/gl4/tile_clip.fs.glsl +++ b/resources/shaders/gl4/tile_clip.fs.glsl @@ -2,30 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +layout(binding = 0) uniform sampler2D SPIRV_Cross_CombineduSrcuSampler; +layout(location = 0) out vec4 oFragColor; +layout(location = 0) in vec2 vTexCoord; +layout(location = 1) in float vBackdrop; - - - - - - - - -precision highp float; - - - - - -uniform sampler2D uSrc; - -in vec2 vTexCoord; -in float vBackdrop; - -out vec4 oFragColor; - -void main(){ - oFragColor = clamp(abs(texture(uSrc, vTexCoord)+ vBackdrop), 0.0, 1.0); +void main() +{ + oFragColor = clamp(abs(texture(SPIRV_Cross_CombineduSrcuSampler, vTexCoord) + vec4(vBackdrop)), vec4(0.0), vec4(1.0)); } diff --git a/resources/shaders/gl4/tile_clip.vs.glsl b/resources/shaders/gl4/tile_clip.vs.glsl index 6693ec921..bf6c55d9e 100644 --- a/resources/shaders/gl4/tile_clip.vs.glsl +++ b/resources/shaders/gl4/tile_clip.vs.glsl @@ -2,35 +2,19 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -in ivec2 aTileOffset; -in ivec2 aDestTileOrigin; -in ivec2 aSrcTileOrigin; -in int aSrcBackdrop; - -out vec2 vTexCoord; -out float vBackdrop; - -void main(){ - vec2 destPosition = vec2(aDestTileOrigin + aTileOffset)/ vec2(256.0); - vec2 srcPosition = vec2(aSrcTileOrigin + aTileOffset)/ vec2(256.0); +layout(location = 1) in ivec2 aDestTileOrigin; +layout(location = 0) in ivec2 aTileOffset; +layout(location = 2) in ivec2 aSrcTileOrigin; +layout(location = 0) out vec2 vTexCoord; +layout(location = 1) out float vBackdrop; +layout(location = 3) in int aSrcBackdrop; + +void main() +{ + vec2 destPosition = vec2(aDestTileOrigin + aTileOffset) / vec2(256.0); + vec2 srcPosition = vec2(aSrcTileOrigin + aTileOffset) / vec2(256.0); vTexCoord = srcPosition; vBackdrop = float(aSrcBackdrop); - gl_Position = vec4(mix(vec2(- 1.0), vec2(1.0), destPosition), 0.0, 1.0); + gl_Position = vec4(mix(vec2(-1.0), vec2(1.0), destPosition), 0.0, 1.0); } diff --git a/resources/shaders/gl4/tile_copy.fs.glsl b/resources/shaders/gl4/tile_copy.fs.glsl index af33abfd2..48abe4391 100644 --- a/resources/shaders/gl4/tile_copy.fs.glsl +++ b/resources/shaders/gl4/tile_copy.fs.glsl @@ -2,29 +2,14 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! +uniform vec4 uFramebufferSize[1]; +layout(binding = 3) uniform sampler2D SPIRV_Cross_CombineduSrcuSampler; +layout(location = 0) out vec4 oFragColor; - - - - - - - - -precision highp float; - - - - - -uniform vec2 uFramebufferSize; -uniform sampler2D uSrc; - -out vec4 oFragColor; - -void main(){ - vec2 texCoord = gl_FragCoord . xy / uFramebufferSize; - oFragColor = texture(uSrc, texCoord); +void main() +{ + vec2 texCoord = gl_FragCoord.xy / uFramebufferSize[0].xy; + oFragColor = texture(SPIRV_Cross_CombineduSrcuSampler, texCoord); } diff --git a/resources/shaders/gl4/tile_copy.vs.glsl b/resources/shaders/gl4/tile_copy.vs.glsl index 87925fda3..d20f31e40 100644 --- a/resources/shaders/gl4/tile_copy.vs.glsl +++ b/resources/shaders/gl4/tile_copy.vs.glsl @@ -2,29 +2,13 @@ // Automatically generated from files in pathfinder/shaders/. Do not edit! - - - - - - - - - - -precision highp float; - - - - - -uniform mat4 uTransform; -uniform vec2 uTileSize; - -in ivec2 aTilePosition; - -void main(){ - vec2 position = vec2(aTilePosition)* uTileSize; - gl_Position = uTransform * vec4(position, 0.0, 1.0); +uniform vec4 uTileSize[1]; +uniform vec4 uTransform[4]; +layout(location = 0) in ivec2 aTilePosition; + +void main() +{ + vec2 position = vec2(aTilePosition) * uTileSize[0].xy; + gl_Position = mat4(uTransform[0], uTransform[1], uTransform[2], uTransform[3]) * vec4(position, 0.0, 1.0); } diff --git a/resources/shaders/metal/blit.fs.metal b/resources/shaders/metal/blit.fs.metal index cb0ab32ae..7ccae4524 100644 --- a/resources/shaders/metal/blit.fs.metal +++ b/resources/shaders/metal/blit.fs.metal @@ -14,10 +14,10 @@ struct main0_in float2 vTexCoord [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], texture2d uSrc [[texture(0)]], sampler uSrcSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uSrc [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; - float4 color = uSrc.sample(uSrcSmplr, in.vTexCoord); + float4 color = uSrc.sample(uSampler, in.vTexCoord); out.oFragColor = float4(color.xyz * color.w, color.w); return out; } diff --git a/resources/shaders/metal/clear.fs.metal b/resources/shaders/metal/clear.fs.metal index d8be9fb68..f4d373c28 100644 --- a/resources/shaders/metal/clear.fs.metal +++ b/resources/shaders/metal/clear.fs.metal @@ -4,15 +4,20 @@ using namespace metal; +struct uColor +{ + float4 color; +}; + struct main0_out { float4 oFragColor [[color(0)]]; }; -fragment main0_out main0(constant float4& uColor [[buffer(0)]]) +fragment main0_out main0(constant uColor& _12 [[buffer(0)]]) { main0_out out = {}; - out.oFragColor = float4(uColor.xyz, 1.0) * uColor.w; + out.oFragColor = float4(_12.color.xyz, 1.0) * _12.color.w; return out; } diff --git a/resources/shaders/metal/clear.vs.metal b/resources/shaders/metal/clear.vs.metal index a61648fbd..7f4126fe0 100644 --- a/resources/shaders/metal/clear.vs.metal +++ b/resources/shaders/metal/clear.vs.metal @@ -4,6 +4,16 @@ using namespace metal; +struct uRect +{ + float4 rect; +}; + +struct uFramebufferSize +{ + float2 framebufferSize; +}; + struct main0_out { float4 gl_Position [[position]]; @@ -14,10 +24,10 @@ struct main0_in int2 aPosition [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant float4& uRect [[buffer(0)]], constant float2& uFramebufferSize [[buffer(1)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant uRect& _13 [[buffer(0)]], constant uFramebufferSize& _31 [[buffer(1)]]) { main0_out out = {}; - float2 position = ((mix(uRect.xy, uRect.zw, float2(in.aPosition)) / uFramebufferSize) * 2.0) - float2(1.0); + float2 position = ((mix(_13.rect.xy, _13.rect.zw, float2(in.aPosition)) / _31.framebufferSize) * 2.0) - float2(1.0); out.gl_Position = float4(position.x, -position.y, 0.0, 1.0); return out; } diff --git a/resources/shaders/metal/debug_solid.fs.metal b/resources/shaders/metal/debug_solid.fs.metal index d8be9fb68..f4d373c28 100644 --- a/resources/shaders/metal/debug_solid.fs.metal +++ b/resources/shaders/metal/debug_solid.fs.metal @@ -4,15 +4,20 @@ using namespace metal; +struct uColor +{ + float4 color; +}; + struct main0_out { float4 oFragColor [[color(0)]]; }; -fragment main0_out main0(constant float4& uColor [[buffer(0)]]) +fragment main0_out main0(constant uColor& _12 [[buffer(0)]]) { main0_out out = {}; - out.oFragColor = float4(uColor.xyz, 1.0) * uColor.w; + out.oFragColor = float4(_12.color.xyz, 1.0) * _12.color.w; return out; } diff --git a/resources/shaders/metal/debug_solid.vs.metal b/resources/shaders/metal/debug_solid.vs.metal index 286c43944..7c3d80868 100644 --- a/resources/shaders/metal/debug_solid.vs.metal +++ b/resources/shaders/metal/debug_solid.vs.metal @@ -4,6 +4,11 @@ using namespace metal; +struct uFramebufferSize +{ + float2 framebufferSize; +}; + struct main0_out { float4 gl_Position [[position]]; @@ -14,10 +19,10 @@ struct main0_in int2 aPosition [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant float2& uFramebufferSize [[buffer(0)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant uFramebufferSize& _18 [[buffer(0)]]) { main0_out out = {}; - float2 position = ((float2(in.aPosition) / uFramebufferSize) * 2.0) - float2(1.0); + float2 position = ((float2(in.aPosition) / _18.framebufferSize) * 2.0) - float2(1.0); out.gl_Position = float4(position.x, -position.y, 0.0, 1.0); return out; } diff --git a/resources/shaders/metal/debug_texture.fs.metal b/resources/shaders/metal/debug_texture.fs.metal index 8888110ae..7d3443a2f 100644 --- a/resources/shaders/metal/debug_texture.fs.metal +++ b/resources/shaders/metal/debug_texture.fs.metal @@ -4,6 +4,11 @@ using namespace metal; +struct uColor +{ + float4 color; +}; + struct main0_out { float4 oFragColor [[color(0)]]; @@ -14,11 +19,11 @@ struct main0_in float2 vTexCoord [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], constant float4& uColor [[buffer(0)]], texture2d uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], constant uColor& _30 [[buffer(0)]], texture2d uTexture [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; - float alpha = uTexture.sample(uTextureSmplr, in.vTexCoord).x * uColor.w; - out.oFragColor = float4(uColor.xyz, 1.0) * alpha; + float alpha = uTexture.sample(uSampler, in.vTexCoord).x * _30.color.w; + out.oFragColor = float4(_30.color.xyz, 1.0) * alpha; return out; } diff --git a/resources/shaders/metal/debug_texture.vs.metal b/resources/shaders/metal/debug_texture.vs.metal index 1f824608d..85e44c4c5 100644 --- a/resources/shaders/metal/debug_texture.vs.metal +++ b/resources/shaders/metal/debug_texture.vs.metal @@ -4,6 +4,16 @@ using namespace metal; +struct uTextureSize +{ + float2 _textureSize; +}; + +struct uFramebufferSize +{ + float2 framebufferSize; +}; + struct main0_out { float2 vTexCoord [[user(locn0)]]; @@ -16,11 +26,11 @@ struct main0_in int2 aTexCoord [[attribute(1)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant float2& uTextureSize [[buffer(0)]], constant float2& uFramebufferSize [[buffer(1)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant uTextureSize& _18 [[buffer(0)]], constant uFramebufferSize& _31 [[buffer(1)]]) { main0_out out = {}; - out.vTexCoord = float2(in.aTexCoord) / uTextureSize; - float2 position = ((float2(in.aPosition) / uFramebufferSize) * 2.0) - float2(1.0); + out.vTexCoord = float2(in.aTexCoord) / _18._textureSize; + float2 position = ((float2(in.aPosition) / _31.framebufferSize) * 2.0) - float2(1.0); out.gl_Position = float4(position.x, -position.y, 0.0, 1.0); return out; } diff --git a/resources/shaders/metal/demo_ground.fs.metal b/resources/shaders/metal/demo_ground.fs.metal index 9b6d05ae0..3cc797044 100644 --- a/resources/shaders/metal/demo_ground.fs.metal +++ b/resources/shaders/metal/demo_ground.fs.metal @@ -4,6 +4,16 @@ using namespace metal; +struct uGridlineColor +{ + float4 gridlineColor; +}; + +struct uGroundColor +{ + float4 groundColor; +}; + struct main0_out { float4 oFragColor [[color(0)]]; @@ -14,11 +24,20 @@ struct main0_in float2 vTexCoord [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], constant float4& uGridlineColor [[buffer(0)]], constant float4& uGroundColor [[buffer(1)]]) +fragment main0_out main0(main0_in in [[stage_in]], constant uGridlineColor& _33 [[buffer(0)]], constant uGroundColor& _42 [[buffer(1)]]) { main0_out out = {}; float2 texCoordPx = fract(in.vTexCoord) / fwidth(in.vTexCoord); - out.oFragColor = select(uGroundColor, uGridlineColor, bool4(any(texCoordPx <= float2(1.0)))); + float4 _28; + if (any(texCoordPx <= float2(1.0))) + { + _28 = _33.gridlineColor; + } + else + { + _28 = _42.groundColor; + } + out.oFragColor = _28; return out; } diff --git a/resources/shaders/metal/demo_ground.vs.metal b/resources/shaders/metal/demo_ground.vs.metal index 2ec42d001..24dc8e6fa 100644 --- a/resources/shaders/metal/demo_ground.vs.metal +++ b/resources/shaders/metal/demo_ground.vs.metal @@ -4,6 +4,16 @@ using namespace metal; +struct uGridlineCount +{ + int gridlineCount; +}; + +struct uTransform +{ + float4x4 transform; +}; + struct main0_out { float2 vTexCoord [[user(locn0)]]; @@ -15,11 +25,11 @@ struct main0_in int2 aPosition [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant int& uGridlineCount [[buffer(0)]], constant float4x4& uTransform [[buffer(1)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant uGridlineCount& _17 [[buffer(0)]], constant uTransform& _35 [[buffer(1)]]) { main0_out out = {}; - out.vTexCoord = float2(in.aPosition * int2(uGridlineCount)); - out.gl_Position = uTransform * float4(int4(in.aPosition.x, 0, in.aPosition.y, 1)); + out.vTexCoord = float2(in.aPosition * int2(_17.gridlineCount)); + out.gl_Position = _35.transform * float4(int4(in.aPosition.x, 0, in.aPosition.y, 1)); return out; } diff --git a/resources/shaders/metal/fill.cs.metal b/resources/shaders/metal/fill.cs.metal index b1ad19ce2..a6e16e550 100644 --- a/resources/shaders/metal/fill.cs.metal +++ b/resources/shaders/metal/fill.cs.metal @@ -6,6 +6,11 @@ using namespace metal; +struct uFirstTileIndex +{ + int firstTileIndex; +}; + struct bFillTileMap { int iFillTileMap[1]; @@ -24,7 +29,7 @@ struct bNextFills constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(16u, 4u, 1u); static inline __attribute__((always_inline)) -float4 computeCoverage(thread const float2& from, thread const float2& to, thread const texture2d areaLUT, thread const sampler areaLUTSmplr) +float4 computeCoverage(thread const float2& from, thread const float2& to, thread const texture2d areaLUT, thread const sampler areaLUTSampler) { float2 left = select(to, from, bool2(from.x < to.x)); float2 right = select(from, to, bool2(from.x < to.x)); @@ -34,15 +39,15 @@ float4 computeCoverage(thread const float2& from, thread const float2& to, threa float y = mix(left.y, right.y, t); float d = (right.y - left.y) / (right.x - left.x); float dX = window.x - window.y; - return areaLUT.sample(areaLUTSmplr, (float2(y + 8.0, abs(d * dX)) / float2(16.0)), level(0.0)) * dX; + return areaLUT.sample(areaLUTSampler, (float2(y + 8.0, abs(d * dX)) / float2(16.0)), level(0.0)) * dX; } -kernel void main0(constant int& uFirstTileIndex [[buffer(0)]], const device bFillTileMap& _150 [[buffer(1)]], const device bFills& _173 [[buffer(2)]], const device bNextFills& _256 [[buffer(3)]], texture2d uAreaLUT [[texture(0)]], texture2d uDest [[texture(1)]], sampler uAreaLUTSmplr [[sampler(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) +kernel void main0(constant uFirstTileIndex& _147 [[buffer(0)]], const device bFillTileMap& _159 [[buffer(1)]], const device bFills& _180 [[buffer(2)]], const device bNextFills& _264 [[buffer(3)]], texture2d uAreaLUT [[texture(0)]], texture2d uDest [[texture(1)]], sampler uSampler [[sampler(0)]], uint3 gl_LocalInvocationID [[thread_position_in_threadgroup]], uint3 gl_WorkGroupID [[threadgroup_position_in_grid]]) { int2 tileSubCoord = int2(gl_LocalInvocationID.xy) * int2(1, 4); uint tileIndexOffset = gl_WorkGroupID.z; - uint tileIndex = tileIndexOffset + uint(uFirstTileIndex); - int fillIndex = _150.iFillTileMap[tileIndex]; + uint tileIndex = tileIndexOffset + uint(_147.firstTileIndex); + int fillIndex = _159.iFillTileMap[tileIndex]; if (fillIndex < 0) { return; @@ -50,13 +55,13 @@ kernel void main0(constant int& uFirstTileIndex [[buffer(0)]], const device bFil float4 coverages = float4(0.0); do { - uint2 fill = _173.iFills[fillIndex]; + uint2 fill = _180.iFills[fillIndex]; float2 from = float2(float(fill.y & 15u), float((fill.y >> 4u) & 15u)) + (float2(float(fill.x & 255u), float((fill.x >> 8u) & 255u)) / float2(256.0)); float2 to = float2(float((fill.y >> 8u) & 15u), float((fill.y >> 12u) & 15u)) + (float2(float((fill.x >> 16u) & 255u), float((fill.x >> 24u) & 255u)) / float2(256.0)); float2 param = from - (float2(tileSubCoord) + float2(0.5)); float2 param_1 = to - (float2(tileSubCoord) + float2(0.5)); - coverages += computeCoverage(param, param_1, uAreaLUT, uAreaLUTSmplr); - fillIndex = _256.iNextFills[fillIndex]; + coverages += computeCoverage(param, param_1, uAreaLUT, uSampler); + fillIndex = _264.iNextFills[fillIndex]; } while (fillIndex >= 0); int2 tileOrigin = int2(int(tileIndex & 255u), int((tileIndex >> 8u) & 255u)) * int2(16, 4); int2 destCoord = tileOrigin + int2(gl_LocalInvocationID.xy); diff --git a/resources/shaders/metal/fill.fs.metal b/resources/shaders/metal/fill.fs.metal index 77892f268..707127376 100644 --- a/resources/shaders/metal/fill.fs.metal +++ b/resources/shaders/metal/fill.fs.metal @@ -18,7 +18,7 @@ struct main0_in }; static inline __attribute__((always_inline)) -float4 computeCoverage(thread const float2& from, thread const float2& to, thread const texture2d areaLUT, thread const sampler areaLUTSmplr) +float4 computeCoverage(thread const float2& from, thread const float2& to, thread const texture2d areaLUT, thread const sampler areaLUTSampler) { float2 left = select(to, from, bool2(from.x < to.x)); float2 right = select(from, to, bool2(from.x < to.x)); @@ -28,15 +28,15 @@ float4 computeCoverage(thread const float2& from, thread const float2& to, threa float y = mix(left.y, right.y, t); float d = (right.y - left.y) / (right.x - left.x); float dX = window.x - window.y; - return areaLUT.sample(areaLUTSmplr, (float2(y + 8.0, abs(d * dX)) / float2(16.0))) * dX; + return areaLUT.sample(areaLUTSampler, (float2(y + 8.0, abs(d * dX)) / float2(16.0))) * dX; } -fragment main0_out main0(main0_in in [[stage_in]], texture2d uAreaLUT [[texture(0)]], sampler uAreaLUTSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uAreaLUT [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; float2 param = in.vFrom; float2 param_1 = in.vTo; - out.oFragColor = computeCoverage(param, param_1, uAreaLUT, uAreaLUTSmplr); + out.oFragColor = computeCoverage(param, param_1, uAreaLUT, uSampler); return out; } diff --git a/resources/shaders/metal/fill.vs.metal b/resources/shaders/metal/fill.vs.metal index a8cf9a86e..b06c58adb 100644 --- a/resources/shaders/metal/fill.vs.metal +++ b/resources/shaders/metal/fill.vs.metal @@ -6,6 +6,16 @@ using namespace metal; +struct uTileSize +{ + float2 tileSize; +}; + +struct uFramebufferSize +{ + float2 framebufferSize; +}; + struct main0_out { float2 vFrom [[user(locn0)]]; @@ -24,19 +34,19 @@ struct main0_in }; static inline __attribute__((always_inline)) -float2 computeTileOffset(thread const uint& tileIndex, thread const float& stencilTextureWidth, thread float2 uTileSize) +float2 computeTileOffset(thread const uint& tileIndex, thread const float& stencilTextureWidth, constant uTileSize& v_20) { - uint tilesPerRow = uint(stencilTextureWidth / uTileSize.x); + uint tilesPerRow = uint(stencilTextureWidth / v_20.tileSize.x); uint2 tileOffset = uint2(tileIndex % tilesPerRow, tileIndex / tilesPerRow); - return (float2(tileOffset) * uTileSize) * float2(1.0, 0.25); + return (float2(tileOffset) * v_20.tileSize) * float2(1.0, 0.25); } -vertex main0_out main0(main0_in in [[stage_in]], constant float2& uTileSize [[buffer(0)]], constant float2& uFramebufferSize [[buffer(1)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant uTileSize& v_20 [[buffer(0)]], constant uFramebufferSize& _57 [[buffer(1)]]) { main0_out out = {}; uint param = in.aTileIndex; - float param_1 = uFramebufferSize.x; - float2 tileOrigin = computeTileOffset(param, param_1, uTileSize); + float param_1 = _57.framebufferSize.x; + float2 tileOrigin = computeTileOffset(param, param_1, v_20); float2 from = float2(float(in.aFromPx & 15u), float(in.aFromPx >> 4u)) + in.aFromSubpx; float2 to = float2(float(in.aToPx & 15u), float(in.aToPx >> 4u)) + in.aToSubpx; float2 position; @@ -54,13 +64,13 @@ vertex main0_out main0(main0_in in [[stage_in]], constant float2& uTileSize [[bu } else { - position.y = uTileSize.y; + position.y = v_20.tileSize.y; } position.y = floor(position.y * 0.25); float2 offset = float2(0.0, 1.5) - (position * float2(1.0, 4.0)); out.vFrom = from + offset; out.vTo = to + offset; - float2 globalPosition = (((tileOrigin + position) / uFramebufferSize) * 2.0) - float2(1.0); + float2 globalPosition = (((tileOrigin + position) / _57.framebufferSize) * 2.0) - float2(1.0); globalPosition.y = -globalPosition.y; out.gl_Position = float4(globalPosition, 0.0, 1.0); return out; diff --git a/resources/shaders/metal/reproject.fs.metal b/resources/shaders/metal/reproject.fs.metal index 61f140468..e39a88ecf 100644 --- a/resources/shaders/metal/reproject.fs.metal +++ b/resources/shaders/metal/reproject.fs.metal @@ -4,6 +4,11 @@ using namespace metal; +struct uOldTransform +{ + float4x4 oldTransform; +}; + struct main0_out { float4 oFragColor [[color(0)]]; @@ -14,12 +19,12 @@ struct main0_in float2 vTexCoord [[user(locn0)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], constant float4x4& uOldTransform [[buffer(0)]], texture2d uTexture [[texture(0)]], sampler uTextureSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], constant uOldTransform& _13 [[buffer(0)]], texture2d uTexture [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; - float4 normTexCoord = uOldTransform * float4(in.vTexCoord, 0.0, 1.0); + float4 normTexCoord = _13.oldTransform * float4(in.vTexCoord, 0.0, 1.0); float2 texCoord = ((normTexCoord.xy / float2(normTexCoord.w)) + float2(1.0)) * 0.5; - out.oFragColor = uTexture.sample(uTextureSmplr, texCoord); + out.oFragColor = uTexture.sample(uSampler, texCoord); return out; } diff --git a/resources/shaders/metal/reproject.vs.metal b/resources/shaders/metal/reproject.vs.metal index da03751f4..a7cf025e0 100644 --- a/resources/shaders/metal/reproject.vs.metal +++ b/resources/shaders/metal/reproject.vs.metal @@ -4,6 +4,11 @@ using namespace metal; +struct uNewTransform +{ + float4x4 newTransform; +}; + struct main0_out { float2 vTexCoord [[user(locn0)]]; @@ -15,13 +20,13 @@ struct main0_in int2 aPosition [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant float4x4& uNewTransform [[buffer(0)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant uNewTransform& _36 [[buffer(0)]]) { main0_out out = {}; float2 position = float2(in.aPosition); out.vTexCoord = position; position.y = 1.0 - position.y; - out.gl_Position = uNewTransform * float4(position, 0.0, 1.0); + out.gl_Position = _36.newTransform * float4(position, 0.0, 1.0); return out; } diff --git a/resources/shaders/metal/tile.fs.metal b/resources/shaders/metal/tile.fs.metal index 1b2c7e9db..e2ac15191 100644 --- a/resources/shaders/metal/tile.fs.metal +++ b/resources/shaders/metal/tile.fs.metal @@ -6,7 +6,40 @@ using namespace metal; -constant float3 _1042 = {}; +struct uMaskTextureSize0 +{ + float2 iMaskTextureSize0; +}; + +struct uColorTextureSize0 +{ + float2 iColorTextureSize0; +}; + +struct uFramebufferSize +{ + float2 iFramebufferSize; +}; + +struct uFilterParams0 +{ + float4 iFilterParams0; +}; + +struct uFilterParams1 +{ + float4 iFilterParams1; +}; + +struct uFilterParams2 +{ + float4 iFilterParams2; +}; + +struct uCtrl +{ + int iCtrl; +}; struct main0_out { @@ -29,14 +62,14 @@ inline Tx mod(Tx x, Ty y) } static inline __attribute__((always_inline)) -float sampleMask(thread const float& maskAlpha, thread const texture2d maskTexture, thread const sampler maskTextureSmplr, thread const float2& maskTextureSize, thread const float3& maskTexCoord, thread const int& maskCtrl) +float sampleMask(thread const float& maskAlpha, thread const texture2d maskTexture, thread const float2& maskTextureSize, thread const float3& maskTexCoord, thread const int& maskCtrl, thread sampler uSampler) { if (maskCtrl == 0) { return maskAlpha; } int2 maskTexCoordI = int2(floor(maskTexCoord.xy)); - float4 texel = maskTexture.sample(maskTextureSmplr, ((float2(maskTexCoordI / int2(1, 4)) + float2(0.5)) / maskTextureSize)); + float4 texel = maskTexture.sample(uSampler, ((float2(maskTexCoordI / int2(1, 4)) + float2(0.5)) / maskTextureSize)); float coverage = texel[maskTexCoordI.y % 4] + maskTexCoord.z; if ((maskCtrl & 1) != 0) { @@ -50,7 +83,7 @@ float sampleMask(thread const float& maskAlpha, thread const texture2d ma } static inline __attribute__((always_inline)) -float4 filterRadialGradient(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const sampler colorTextureSmplr, thread const float2& colorTextureSize, thread const float2& fragCoord, thread const float2& framebufferSize, thread const float4& filterParams0, thread const float4& filterParams1) +float4 filterRadialGradient(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const float2& colorTextureSize, thread const float2& fragCoord, thread const float2& framebufferSize, thread const float4& filterParams0, thread const float4& filterParams1, thread sampler uSampler) { float2 lineFrom = filterParams0.xy; float2 lineVector = filterParams0.zw; @@ -71,66 +104,66 @@ float4 filterRadialGradient(thread const float2& colorTexCoord, thread const tex { ts = ts.yx; } - float _555; + float _566; if (ts.x >= 0.0) { - _555 = ts.x; + _566 = ts.x; } else { - _555 = ts.y; + _566 = ts.y; } - float t = _555; - color = colorTexture.sample(colorTextureSmplr, (uvOrigin + float2(fast::clamp(t, 0.0, 1.0), 0.0))); + float t = _566; + color = colorTexture.sample(uSampler, (uvOrigin + float2(fast::clamp(t, 0.0, 1.0), 0.0))); } return color; } static inline __attribute__((always_inline)) -float4 filterBlur(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const sampler colorTextureSmplr, thread const float2& colorTextureSize, thread const float4& filterParams0, thread const float4& filterParams1) +float4 filterBlur(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const float2& colorTextureSize, thread const float4& filterParams0, thread const float4& filterParams1, thread sampler uSampler) { float2 srcOffsetScale = filterParams0.xy / colorTextureSize; int support = int(filterParams0.z); float3 gaussCoeff = filterParams1.xyz; float gaussSum = gaussCoeff.x; - float4 color = colorTexture.sample(colorTextureSmplr, colorTexCoord) * gaussCoeff.x; - float2 _600 = gaussCoeff.xy * gaussCoeff.yz; - gaussCoeff = float3(_600.x, _600.y, gaussCoeff.z); + float4 color = colorTexture.sample(uSampler, colorTexCoord) * gaussCoeff.x; + float2 _615 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = float3(_615.x, _615.y, gaussCoeff.z); for (int i = 1; i <= support; i += 2) { float gaussPartialSum = gaussCoeff.x; - float2 _620 = gaussCoeff.xy * gaussCoeff.yz; - gaussCoeff = float3(_620.x, _620.y, gaussCoeff.z); + float2 _635 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = float3(_635.x, _635.y, gaussCoeff.z); gaussPartialSum += gaussCoeff.x; float2 srcOffset = srcOffsetScale * (float(i) + (gaussCoeff.x / gaussPartialSum)); - color += ((colorTexture.sample(colorTextureSmplr, (colorTexCoord - srcOffset)) + colorTexture.sample(colorTextureSmplr, (colorTexCoord + srcOffset))) * gaussPartialSum); + color += ((colorTexture.sample(uSampler, (colorTexCoord - srcOffset)) + colorTexture.sample(uSampler, (colorTexCoord + srcOffset))) * gaussPartialSum); gaussSum += (2.0 * gaussPartialSum); - float2 _660 = gaussCoeff.xy * gaussCoeff.yz; - gaussCoeff = float3(_660.x, _660.y, gaussCoeff.z); + float2 _679 = gaussCoeff.xy * gaussCoeff.yz; + gaussCoeff = float3(_679.x, _679.y, gaussCoeff.z); } return color / float4(gaussSum); } static inline __attribute__((always_inline)) -float filterTextSample1Tap(thread const float& offset, thread const texture2d colorTexture, thread const sampler colorTextureSmplr, thread const float2& colorTexCoord) +float filterTextSample1Tap(thread const float& offset, thread const texture2d colorTexture, thread const float2& colorTexCoord, thread sampler uSampler) { - return colorTexture.sample(colorTextureSmplr, (colorTexCoord + float2(offset, 0.0))).x; + return colorTexture.sample(uSampler, (colorTexCoord + float2(offset, 0.0))).x; } static inline __attribute__((always_inline)) -void filterTextSample9Tap(thread float4& outAlphaLeft, thread float& outAlphaCenter, thread float4& outAlphaRight, thread const texture2d colorTexture, thread const sampler colorTextureSmplr, thread const float2& colorTexCoord, thread const float4& kernel0, thread const float& onePixel) +void filterTextSample9Tap(thread float4& outAlphaLeft, thread float& outAlphaCenter, thread float4& outAlphaRight, thread const texture2d colorTexture, thread const float2& colorTexCoord, thread const float4& kernel0, thread const float& onePixel, thread sampler uSampler) { bool wide = kernel0.x > 0.0; - float _236; + float _243; if (wide) { float param = (-4.0) * onePixel; float2 param_1 = colorTexCoord; - _236 = filterTextSample1Tap(param, colorTexture, colorTextureSmplr, param_1); + _243 = filterTextSample1Tap(param, colorTexture, param_1, uSampler); } else { - _236 = 0.0; + _243 = 0.0; } float param_2 = (-3.0) * onePixel; float2 param_3 = colorTexCoord; @@ -138,28 +171,28 @@ void filterTextSample9Tap(thread float4& outAlphaLeft, thread float& outAlphaCen float2 param_5 = colorTexCoord; float param_6 = (-1.0) * onePixel; float2 param_7 = colorTexCoord; - outAlphaLeft = float4(_236, filterTextSample1Tap(param_2, colorTexture, colorTextureSmplr, param_3), filterTextSample1Tap(param_4, colorTexture, colorTextureSmplr, param_5), filterTextSample1Tap(param_6, colorTexture, colorTextureSmplr, param_7)); + outAlphaLeft = float4(_243, filterTextSample1Tap(param_2, colorTexture, param_3, uSampler), filterTextSample1Tap(param_4, colorTexture, param_5, uSampler), filterTextSample1Tap(param_6, colorTexture, param_7, uSampler)); float param_8 = 0.0; float2 param_9 = colorTexCoord; - outAlphaCenter = filterTextSample1Tap(param_8, colorTexture, colorTextureSmplr, param_9); + outAlphaCenter = filterTextSample1Tap(param_8, colorTexture, param_9, uSampler); float param_10 = 1.0 * onePixel; float2 param_11 = colorTexCoord; float param_12 = 2.0 * onePixel; float2 param_13 = colorTexCoord; float param_14 = 3.0 * onePixel; float2 param_15 = colorTexCoord; - float _296; + float _303; if (wide) { float param_16 = 4.0 * onePixel; float2 param_17 = colorTexCoord; - _296 = filterTextSample1Tap(param_16, colorTexture, colorTextureSmplr, param_17); + _303 = filterTextSample1Tap(param_16, colorTexture, param_17, uSampler); } else { - _296 = 0.0; + _303 = 0.0; } - outAlphaRight = float4(filterTextSample1Tap(param_10, colorTexture, colorTextureSmplr, param_11), filterTextSample1Tap(param_12, colorTexture, colorTextureSmplr, param_13), filterTextSample1Tap(param_14, colorTexture, colorTextureSmplr, param_15), _296); + outAlphaRight = float4(filterTextSample1Tap(param_10, colorTexture, param_11, uSampler), filterTextSample1Tap(param_12, colorTexture, param_13, uSampler), filterTextSample1Tap(param_14, colorTexture, param_15, uSampler), _303); } static inline __attribute__((always_inline)) @@ -169,13 +202,13 @@ float filterTextConvolve7Tap(thread const float4& alpha0, thread const float3& a } static inline __attribute__((always_inline)) -float filterTextGammaCorrectChannel(thread const float& bgColor, thread const float& fgColor, thread const texture2d gammaLUT, thread const sampler gammaLUTSmplr) +float filterTextGammaCorrectChannel(thread const float& bgColor, thread const float& fgColor, thread const texture2d gammaLUT, thread sampler uSampler) { - return gammaLUT.sample(gammaLUTSmplr, float2(fgColor, 1.0 - bgColor)).x; + return gammaLUT.sample(uSampler, float2(fgColor, 1.0 - bgColor)).x; } static inline __attribute__((always_inline)) -float3 filterTextGammaCorrect(thread const float3& bgColor, thread const float3& fgColor, thread const texture2d gammaLUT, thread const sampler gammaLUTSmplr) +float3 filterTextGammaCorrect(thread const float3& bgColor, thread const float3& fgColor, thread const texture2d gammaLUT, thread sampler uSampler) { float param = bgColor.x; float param_1 = fgColor.x; @@ -183,11 +216,11 @@ float3 filterTextGammaCorrect(thread const float3& bgColor, thread const float3& float param_3 = fgColor.y; float param_4 = bgColor.z; float param_5 = fgColor.z; - return float3(filterTextGammaCorrectChannel(param, param_1, gammaLUT, gammaLUTSmplr), filterTextGammaCorrectChannel(param_2, param_3, gammaLUT, gammaLUTSmplr), filterTextGammaCorrectChannel(param_4, param_5, gammaLUT, gammaLUTSmplr)); + return float3(filterTextGammaCorrectChannel(param, param_1, gammaLUT, uSampler), filterTextGammaCorrectChannel(param_2, param_3, gammaLUT, uSampler), filterTextGammaCorrectChannel(param_4, param_5, gammaLUT, uSampler)); } static inline __attribute__((always_inline)) -float4 filterText(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const sampler colorTextureSmplr, thread const texture2d gammaLUT, thread const sampler gammaLUTSmplr, thread const float2& colorTextureSize, thread const float4& filterParams0, thread const float4& filterParams1, thread const float4& filterParams2) +float4 filterText(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const texture2d gammaLUT, thread const float2& colorTextureSize, thread const float4& filterParams0, thread const float4& filterParams1, thread const float4& filterParams2, thread sampler uSampler) { float4 kernel0 = filterParams0; float3 bgColor = filterParams1.xyz; @@ -196,7 +229,7 @@ float4 filterText(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const sampler colorTextureSmplr, thread const float2& colorTexCoord) +float4 sampleColor(thread const texture2d colorTexture, thread const float2& colorTexCoord, thread sampler uSampler) { - return colorTexture.sample(colorTextureSmplr, colorTexCoord); + return colorTexture.sample(uSampler, colorTexCoord); } static inline __attribute__((always_inline)) -float4 filterNone(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const sampler colorTextureSmplr) +float4 filterNone(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread sampler uSampler) { float2 param = colorTexCoord; - return sampleColor(colorTexture, colorTextureSmplr, param); + return sampleColor(colorTexture, param, uSampler); } static inline __attribute__((always_inline)) -float4 filterColor(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const sampler colorTextureSmplr, thread const texture2d gammaLUT, thread const sampler gammaLUTSmplr, thread const float2& colorTextureSize, thread const float2& fragCoord, thread const float2& framebufferSize, thread const float4& filterParams0, thread const float4& filterParams1, thread const float4& filterParams2, thread const int& colorFilter) +float4 filterColor(thread const float2& colorTexCoord, thread const texture2d colorTexture, thread const texture2d gammaLUT, thread const float2& colorTextureSize, thread const float2& fragCoord, thread const float2& framebufferSize, thread const float4& filterParams0, thread const float4& filterParams1, thread const float4& filterParams2, thread const int& colorFilter, thread sampler uSampler) { switch (colorFilter) { @@ -259,7 +292,7 @@ float4 filterColor(thread const float2& colorTexCoord, thread const texture2d destTexture, thread const sampler destTextureSmplr, thread const float2& destTextureSize, thread const float2& fragCoord, thread const int& op) +float4 composite(thread const float4& srcColor, thread const texture2d destTexture, thread const float2& destTextureSize, thread const float2& fragCoord, thread const int& op, thread sampler uSampler) { if (op == 0) { return srcColor; } float2 destTexCoord = fragCoord / destTextureSize; - float4 destColor = destTexture.sample(destTextureSmplr, destTexCoord); + float4 destColor = destTexture.sample(uSampler, destTexCoord); float3 param = destColor.xyz; float3 param_1 = srcColor.xyz; int param_2 = op; @@ -555,29 +588,29 @@ float4 composite(thread const float4& srcColor, thread const texture2d de } static inline __attribute__((always_inline)) -void calculateColor(thread const int& tileCtrl, thread const int& ctrl, thread texture2d uMaskTexture0, thread const sampler uMaskTexture0Smplr, thread float2 uMaskTextureSize0, thread float3& vMaskTexCoord0, thread float4& vBaseColor, thread float2& vColorTexCoord0, thread texture2d uColorTexture0, thread const sampler uColorTexture0Smplr, thread texture2d uGammaLUT, thread const sampler uGammaLUTSmplr, thread float2 uColorTextureSize0, thread float4& gl_FragCoord, thread float2 uFramebufferSize, thread float4 uFilterParams0, thread float4 uFilterParams1, thread float4 uFilterParams2, thread texture2d uDestTexture, thread const sampler uDestTextureSmplr, thread float4& oFragColor) +void calculateColor(thread const int& tileCtrl, thread const int& ctrl, thread sampler uSampler, thread texture2d uMaskTexture0, constant uMaskTextureSize0& v_1279, thread float3& vMaskTexCoord0, thread float4& vBaseColor, thread float2& vColorTexCoord0, thread texture2d uColorTexture0, thread texture2d uGammaLUT, constant uColorTextureSize0& v_1317, thread float4& gl_FragCoord, constant uFramebufferSize& v_1321, constant uFilterParams0& v_1324, constant uFilterParams1& v_1327, constant uFilterParams2& v_1330, thread texture2d uDestTexture, thread float4& oFragColor) { int maskCtrl0 = (tileCtrl >> 0) & 3; float maskAlpha = 1.0; float param = maskAlpha; - float2 param_1 = uMaskTextureSize0; + float2 param_1 = v_1279.iMaskTextureSize0; float3 param_2 = vMaskTexCoord0; int param_3 = maskCtrl0; - maskAlpha = sampleMask(param, uMaskTexture0, uMaskTexture0Smplr, param_1, param_2, param_3); + maskAlpha = sampleMask(param, uMaskTexture0, param_1, param_2, param_3, uSampler); float4 color = vBaseColor; int color0Combine = (ctrl >> 6) & 3; if (color0Combine != 0) { int color0Filter = (ctrl >> 4) & 3; float2 param_4 = vColorTexCoord0; - float2 param_5 = uColorTextureSize0; + float2 param_5 = v_1317.iColorTextureSize0; float2 param_6 = gl_FragCoord.xy; - float2 param_7 = uFramebufferSize; - float4 param_8 = uFilterParams0; - float4 param_9 = uFilterParams1; - float4 param_10 = uFilterParams2; + float2 param_7 = v_1321.iFramebufferSize; + float4 param_8 = v_1324.iFilterParams0; + float4 param_9 = v_1327.iFilterParams1; + float4 param_10 = v_1330.iFilterParams2; int param_11 = color0Filter; - float4 color0 = filterColor(param_4, uColorTexture0, uColorTexture0Smplr, uGammaLUT, uGammaLUTSmplr, param_5, param_6, param_7, param_8, param_9, param_10, param_11); + float4 color0 = filterColor(param_4, uColorTexture0, uGammaLUT, param_5, param_6, param_7, param_8, param_9, param_10, param_11, uSampler); float4 param_12 = color; float4 param_13 = color0; int param_14 = color0Combine; @@ -586,21 +619,21 @@ void calculateColor(thread const int& tileCtrl, thread const int& ctrl, thread t color.w *= maskAlpha; int compositeOp = (ctrl >> 8) & 15; float4 param_15 = color; - float2 param_16 = uFramebufferSize; + float2 param_16 = v_1321.iFramebufferSize; float2 param_17 = gl_FragCoord.xy; int param_18 = compositeOp; - color = composite(param_15, uDestTexture, uDestTextureSmplr, param_16, param_17, param_18); - float3 _1347 = color.xyz * color.w; - color = float4(_1347.x, _1347.y, _1347.z, color.w); + color = composite(param_15, uDestTexture, param_16, param_17, param_18, uSampler); + float3 _1389 = color.xyz * color.w; + color = float4(_1389.x, _1389.y, _1389.z, color.w); oFragColor = color; } -fragment main0_out main0(main0_in in [[stage_in]], constant int& uCtrl [[buffer(6)]], constant float2& uMaskTextureSize0 [[buffer(0)]], constant float2& uColorTextureSize0 [[buffer(1)]], constant float2& uFramebufferSize [[buffer(2)]], constant float4& uFilterParams0 [[buffer(3)]], constant float4& uFilterParams1 [[buffer(4)]], constant float4& uFilterParams2 [[buffer(5)]], texture2d uMaskTexture0 [[texture(0)]], texture2d uColorTexture0 [[texture(1)]], texture2d uGammaLUT [[texture(2)]], texture2d uDestTexture [[texture(3)]], sampler uMaskTexture0Smplr [[sampler(0)]], sampler uColorTexture0Smplr [[sampler(1)]], sampler uGammaLUTSmplr [[sampler(2)]], sampler uDestTextureSmplr [[sampler(3)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(main0_in in [[stage_in]], constant uMaskTextureSize0& v_1279 [[buffer(0)]], constant uColorTextureSize0& v_1317 [[buffer(1)]], constant uFramebufferSize& v_1321 [[buffer(2)]], constant uFilterParams0& v_1324 [[buffer(3)]], constant uFilterParams1& v_1327 [[buffer(4)]], constant uFilterParams2& v_1330 [[buffer(5)]], constant uCtrl& _1401 [[buffer(6)]], texture2d uMaskTexture0 [[texture(0)]], texture2d uColorTexture0 [[texture(1)]], texture2d uGammaLUT [[texture(2)]], texture2d uDestTexture [[texture(3)]], sampler uSampler [[sampler(0)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; int param = int(in.vTileCtrl); - int param_1 = uCtrl; - calculateColor(param, param_1, uMaskTexture0, uMaskTexture0Smplr, uMaskTextureSize0, in.vMaskTexCoord0, in.vBaseColor, in.vColorTexCoord0, uColorTexture0, uColorTexture0Smplr, uGammaLUT, uGammaLUTSmplr, uColorTextureSize0, gl_FragCoord, uFramebufferSize, uFilterParams0, uFilterParams1, uFilterParams2, uDestTexture, uDestTextureSmplr, out.oFragColor); + int param_1 = _1401.iCtrl; + calculateColor(param, param_1, uSampler, uMaskTexture0, v_1279, in.vMaskTexCoord0, in.vBaseColor, in.vColorTexCoord0, uColorTexture0, uGammaLUT, v_1317, gl_FragCoord, v_1321, v_1324, v_1327, v_1330, uDestTexture, out.oFragColor); return out; } diff --git a/resources/shaders/metal/tile.vs.metal b/resources/shaders/metal/tile.vs.metal index 6b297b65c..35a40cc57 100644 --- a/resources/shaders/metal/tile.vs.metal +++ b/resources/shaders/metal/tile.vs.metal @@ -4,6 +4,21 @@ using namespace metal; +struct uTileSize +{ + float2 tileSize; +}; + +struct uTextureMetadataSize +{ + int2 textureMetadataSize; +}; + +struct uTransform +{ + float4x4 transform; +}; + struct main0_out { float3 vMaskTexCoord0 [[user(locn0)]]; @@ -23,26 +38,26 @@ struct main0_in int aTileCtrl [[attribute(5)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant int2& uTextureMetadataSize [[buffer(1)]], constant float2& uTileSize [[buffer(0)]], constant float4x4& uTransform [[buffer(2)]], texture2d uTextureMetadata [[texture(0)]], sampler uTextureMetadataSmplr [[sampler(0)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant uTileSize& _26 [[buffer(0)]], constant uTextureMetadataSize& _49 [[buffer(1)]], constant uTransform& _161 [[buffer(2)]], texture2d uTextureMetadata [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; float2 tileOrigin = float2(in.aTileOrigin); float2 tileOffset = float2(in.aTileOffset); - float2 position = (tileOrigin + tileOffset) * uTileSize; - float2 maskTexCoord0 = (float2(in.aMaskTexCoord0) + tileOffset) * uTileSize; - float2 textureMetadataScale = float2(1.0) / float2(uTextureMetadataSize); + float2 position = (tileOrigin + tileOffset) * _26.tileSize; + float2 maskTexCoord0 = (float2(in.aMaskTexCoord0) + tileOffset) * _26.tileSize; + float2 textureMetadataScale = float2(1.0) / float2(_49.textureMetadataSize); float2 metadataEntryCoord = float2(float((in.aColor % 128) * 4), float(in.aColor / 128)); float2 colorTexMatrix0Coord = (metadataEntryCoord + float2(0.5)) * textureMetadataScale; float2 colorTexOffsetsCoord = (metadataEntryCoord + float2(1.5, 0.5)) * textureMetadataScale; float2 baseColorCoord = (metadataEntryCoord + float2(2.5, 0.5)) * textureMetadataScale; - float4 colorTexMatrix0 = uTextureMetadata.sample(uTextureMetadataSmplr, colorTexMatrix0Coord, level(0.0)); - float4 colorTexOffsets = uTextureMetadata.sample(uTextureMetadataSmplr, colorTexOffsetsCoord, level(0.0)); - float4 baseColor = uTextureMetadata.sample(uTextureMetadataSmplr, baseColorCoord, level(0.0)); + float4 colorTexMatrix0 = uTextureMetadata.sample(uSampler, colorTexMatrix0Coord, level(0.0)); + float4 colorTexOffsets = uTextureMetadata.sample(uSampler, colorTexOffsetsCoord, level(0.0)); + float4 baseColor = uTextureMetadata.sample(uSampler, baseColorCoord, level(0.0)); out.vColorTexCoord0 = (float2x2(float2(colorTexMatrix0.xy), float2(colorTexMatrix0.zw)) * position) + colorTexOffsets.xy; out.vMaskTexCoord0 = float3(maskTexCoord0, float(in.aMaskBackdrop.x)); out.vBaseColor = baseColor; out.vTileCtrl = float(in.aTileCtrl); - out.gl_Position = uTransform * float4(position, 0.0, 1.0); + out.gl_Position = _161.transform * float4(position, 0.0, 1.0); return out; } diff --git a/resources/shaders/metal/tile_clip.fs.metal b/resources/shaders/metal/tile_clip.fs.metal index de4bf10a0..03baf4b4d 100644 --- a/resources/shaders/metal/tile_clip.fs.metal +++ b/resources/shaders/metal/tile_clip.fs.metal @@ -15,10 +15,10 @@ struct main0_in float vBackdrop [[user(locn1)]]; }; -fragment main0_out main0(main0_in in [[stage_in]], texture2d uSrc [[texture(0)]], sampler uSrcSmplr [[sampler(0)]]) +fragment main0_out main0(main0_in in [[stage_in]], texture2d uSrc [[texture(0)]], sampler uSampler [[sampler(0)]]) { main0_out out = {}; - out.oFragColor = fast::clamp(abs(uSrc.sample(uSrcSmplr, in.vTexCoord) + float4(in.vBackdrop)), float4(0.0), float4(1.0)); + out.oFragColor = fast::clamp(abs(uSrc.sample(uSampler, in.vTexCoord) + float4(in.vBackdrop)), float4(0.0), float4(1.0)); return out; } diff --git a/resources/shaders/metal/tile_copy.fs.metal b/resources/shaders/metal/tile_copy.fs.metal index 67e61befa..4106ef58b 100644 --- a/resources/shaders/metal/tile_copy.fs.metal +++ b/resources/shaders/metal/tile_copy.fs.metal @@ -4,16 +4,21 @@ using namespace metal; +struct uFramebufferSize +{ + float2 framebufferSize; +}; + struct main0_out { float4 oFragColor [[color(0)]]; }; -fragment main0_out main0(constant float2& uFramebufferSize [[buffer(0)]], texture2d uSrc [[texture(0)]], sampler uSrcSmplr [[sampler(0)]], float4 gl_FragCoord [[position]]) +fragment main0_out main0(constant uFramebufferSize& _17 [[buffer(0)]], texture2d uSrc [[texture(0)]], sampler uSampler [[sampler(0)]], float4 gl_FragCoord [[position]]) { main0_out out = {}; - float2 texCoord = gl_FragCoord.xy / uFramebufferSize; - out.oFragColor = uSrc.sample(uSrcSmplr, texCoord); + float2 texCoord = gl_FragCoord.xy / _17.framebufferSize; + out.oFragColor = uSrc.sample(uSampler, texCoord); return out; } diff --git a/resources/shaders/metal/tile_copy.vs.metal b/resources/shaders/metal/tile_copy.vs.metal index 6ac89c860..baa3b9026 100644 --- a/resources/shaders/metal/tile_copy.vs.metal +++ b/resources/shaders/metal/tile_copy.vs.metal @@ -4,6 +4,16 @@ using namespace metal; +struct uTileSize +{ + float2 tileSize; +}; + +struct uTransform +{ + float4x4 transform; +}; + struct main0_out { float4 gl_Position [[position]]; @@ -14,11 +24,11 @@ struct main0_in int2 aTilePosition [[attribute(0)]]; }; -vertex main0_out main0(main0_in in [[stage_in]], constant float2& uTileSize [[buffer(0)]], constant float4x4& uTransform [[buffer(1)]]) +vertex main0_out main0(main0_in in [[stage_in]], constant uTileSize& _18 [[buffer(0)]], constant uTransform& _34 [[buffer(1)]]) { main0_out out = {}; - float2 position = float2(in.aTilePosition) * uTileSize; - out.gl_Position = uTransform * float4(position, 0.0, 1.0); + float2 position = float2(in.aTilePosition) * _18.tileSize; + out.gl_Position = _34.transform * float4(position, 0.0, 1.0); return out; } diff --git a/resources/shaders/vulkan/blit.fs.spv b/resources/shaders/vulkan/blit.fs.spv new file mode 100644 index 000000000..dca202be5 Binary files /dev/null and b/resources/shaders/vulkan/blit.fs.spv differ diff --git a/resources/shaders/vulkan/blit.vs.spv b/resources/shaders/vulkan/blit.vs.spv new file mode 100644 index 000000000..354b57fbf Binary files /dev/null and b/resources/shaders/vulkan/blit.vs.spv differ diff --git a/resources/shaders/vulkan/clear.fs.spv b/resources/shaders/vulkan/clear.fs.spv new file mode 100644 index 000000000..a03bd936c Binary files /dev/null and b/resources/shaders/vulkan/clear.fs.spv differ diff --git a/resources/shaders/vulkan/clear.vs.spv b/resources/shaders/vulkan/clear.vs.spv new file mode 100644 index 000000000..4a75e1d19 Binary files /dev/null and b/resources/shaders/vulkan/clear.vs.spv differ diff --git a/resources/shaders/vulkan/debug_solid.fs.spv b/resources/shaders/vulkan/debug_solid.fs.spv new file mode 100644 index 000000000..c2c23b843 Binary files /dev/null and b/resources/shaders/vulkan/debug_solid.fs.spv differ diff --git a/resources/shaders/vulkan/debug_solid.vs.spv b/resources/shaders/vulkan/debug_solid.vs.spv new file mode 100644 index 000000000..850396e99 Binary files /dev/null and b/resources/shaders/vulkan/debug_solid.vs.spv differ diff --git a/resources/shaders/vulkan/debug_texture.fs.spv b/resources/shaders/vulkan/debug_texture.fs.spv new file mode 100644 index 000000000..526a0c377 Binary files /dev/null and b/resources/shaders/vulkan/debug_texture.fs.spv differ diff --git a/resources/shaders/vulkan/debug_texture.vs.spv b/resources/shaders/vulkan/debug_texture.vs.spv new file mode 100644 index 000000000..9a5ab3739 Binary files /dev/null and b/resources/shaders/vulkan/debug_texture.vs.spv differ diff --git a/resources/shaders/vulkan/demo_ground.fs.spv b/resources/shaders/vulkan/demo_ground.fs.spv new file mode 100644 index 000000000..eecbff831 Binary files /dev/null and b/resources/shaders/vulkan/demo_ground.fs.spv differ diff --git a/resources/shaders/vulkan/demo_ground.vs.spv b/resources/shaders/vulkan/demo_ground.vs.spv new file mode 100644 index 000000000..998fc9eae Binary files /dev/null and b/resources/shaders/vulkan/demo_ground.vs.spv differ diff --git a/resources/shaders/vulkan/fill.cs.spv b/resources/shaders/vulkan/fill.cs.spv new file mode 100644 index 000000000..3531bf25d Binary files /dev/null and b/resources/shaders/vulkan/fill.cs.spv differ diff --git a/resources/shaders/vulkan/fill.fs.spv b/resources/shaders/vulkan/fill.fs.spv new file mode 100644 index 000000000..f8e75b74a Binary files /dev/null and b/resources/shaders/vulkan/fill.fs.spv differ diff --git a/resources/shaders/vulkan/fill.vs.spv b/resources/shaders/vulkan/fill.vs.spv new file mode 100644 index 000000000..697f11668 Binary files /dev/null and b/resources/shaders/vulkan/fill.vs.spv differ diff --git a/resources/shaders/vulkan/reproject.fs.spv b/resources/shaders/vulkan/reproject.fs.spv new file mode 100644 index 000000000..e40464c80 Binary files /dev/null and b/resources/shaders/vulkan/reproject.fs.spv differ diff --git a/resources/shaders/vulkan/reproject.vs.spv b/resources/shaders/vulkan/reproject.vs.spv new file mode 100644 index 000000000..1104e14b7 Binary files /dev/null and b/resources/shaders/vulkan/reproject.vs.spv differ diff --git a/resources/shaders/vulkan/stencil.fs.spv b/resources/shaders/vulkan/stencil.fs.spv new file mode 100644 index 000000000..63f7fd7d3 Binary files /dev/null and b/resources/shaders/vulkan/stencil.fs.spv differ diff --git a/resources/shaders/vulkan/stencil.vs.spv b/resources/shaders/vulkan/stencil.vs.spv new file mode 100644 index 000000000..6fc53e39d Binary files /dev/null and b/resources/shaders/vulkan/stencil.vs.spv differ diff --git a/resources/shaders/vulkan/tile.fs.spv b/resources/shaders/vulkan/tile.fs.spv new file mode 100644 index 000000000..ec9928be0 Binary files /dev/null and b/resources/shaders/vulkan/tile.fs.spv differ diff --git a/resources/shaders/vulkan/tile.vs.spv b/resources/shaders/vulkan/tile.vs.spv new file mode 100644 index 000000000..9aa290e96 Binary files /dev/null and b/resources/shaders/vulkan/tile.vs.spv differ diff --git a/resources/shaders/vulkan/tile_clip.fs.spv b/resources/shaders/vulkan/tile_clip.fs.spv new file mode 100644 index 000000000..f1169cdb2 Binary files /dev/null and b/resources/shaders/vulkan/tile_clip.fs.spv differ diff --git a/resources/shaders/vulkan/tile_clip.vs.spv b/resources/shaders/vulkan/tile_clip.vs.spv new file mode 100644 index 000000000..e6618d85f Binary files /dev/null and b/resources/shaders/vulkan/tile_clip.vs.spv differ diff --git a/resources/shaders/vulkan/tile_copy.fs.spv b/resources/shaders/vulkan/tile_copy.fs.spv new file mode 100644 index 000000000..f0ca4c00c Binary files /dev/null and b/resources/shaders/vulkan/tile_copy.fs.spv differ diff --git a/resources/shaders/vulkan/tile_copy.vs.spv b/resources/shaders/vulkan/tile_copy.vs.spv new file mode 100644 index 000000000..d48eab723 Binary files /dev/null and b/resources/shaders/vulkan/tile_copy.vs.spv differ diff --git a/shaders/Makefile b/shaders/Makefile index c121d3a13..67aebe922 100644 --- a/shaders/Makefile +++ b/shaders/Makefile @@ -40,18 +40,23 @@ OUT=\ $(SHADERS:%=$(TARGET_DIR)/gl4/%) \ $(SHADERS:%.glsl=$(TARGET_DIR)/metal/%.metal) \ $(SHADERS:%.glsl=build/metal/%.spv) \ - $(COMPUTE_SHADERS:%=$(TARGET_DIR)/gl4/%) \ + $(SHADERS:%.glsl=$(TARGET_DIR)/vulkan/%.spv) \ $(COMPUTE_SHADERS:%.glsl=$(TARGET_DIR)/metal/%.metal) \ $(COMPUTE_SHADERS:%.glsl=build/metal/%.spv) \ + $(COMPUTE_SHADERS:%.glsl=$(TARGET_DIR)/gl4/%.glsl) \ + $(COMPUTE_SHADERS:%.glsl=$(TARGET_DIR)/vulkan/%.spv) \ $(EMPTY) GLSL_3_VERSION=330 GLSL_4_VERSION=430 GLSLANGFLAGS=--auto-map-locations -I. GLSLANGFLAGS_METAL=$(GLSLANGFLAGS) -DPF_ORIGIN_UPPER_LEFT=1 +GLSLANGFLAGS_VULKAN=$(GLSLANGFLAGS) SPIRVCROSS?=spirv-cross -SPIRVCROSSFLAGS=--msl --msl-version 020100 +SPIRVCROSSFLAGS_METAL=--msl --msl-version 020100 +SPIRVCROSSFLAGS_GL3=--version $(GLSL_3_VERSION) --no-420pack-extension --glsl-emit-ubo-as-plain-uniforms --flatten-ubo --combined-samplers-inherit-bindings +SPIRVCROSSFLAGS_GL4=--version $(GLSL_4_VERSION) --glsl-emit-ubo-as-plain-uniforms --flatten-ubo --combined-samplers-inherit-bindings GLSL_VERSION_HEADER="\#version {{version}}" HEADER="// Automatically generated from files in pathfinder/shaders/. Do not edit!" @@ -66,28 +71,28 @@ clean: rm -f $(OUT) build/metal/%.fs.spv: %.fs.glsl $(INCLUDES) - mkdir -p build/metal && glslangValidator $(GLSLANGFLAGS_METAL) -G$(GLSL_VERSION) -S frag -o $@ $< + mkdir -p build/metal && glslangValidator $(GLSLANGFLAGS_METAL) -V -S frag -o $@ $< -$(TARGET_DIR)/gl3/%.fs.glsl: %.fs.glsl $(INCLUDES) - mkdir -p $(TARGET_DIR)/gl3 && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( glslangValidator $(GLSLANGFLAGS) -S frag -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 ) +build/metal/%.vs.spv: %.vs.glsl $(INCLUDES) + mkdir -p build/metal && glslangValidator $(GLSLANGFLAGS_METAL) -V -S vert -o $@ $< -$(TARGET_DIR)/gl4/%.fs.glsl: %.fs.glsl $(INCLUDES) - mkdir -p $(TARGET_DIR)/gl4 && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( glslangValidator $(GLSLANGFLAGS) -S frag -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 ) +build/metal/%.cs.spv: %.cs.glsl $(INCLUDES) + mkdir -p build/metal && glslangValidator $(GLSLANGFLAGS_METAL) -V -S comp -o $@ $< -build/metal/%.vs.spv: %.vs.glsl $(INCLUDES) - mkdir -p build/metal && glslangValidator $(GLSLANGFLAGS_METAL) -G$(GLSL_VERSION) -S vert -o $@ $< +$(TARGET_DIR)/metal/%.metal: build/metal/%.spv + mkdir -p $(TARGET_DIR)/metal && echo $(HEADER) > $@ && ( $(SPIRVCROSS) $(SPIRVCROSSFLAGS_METAL) $< >> $@ ) || ( rm $@ && exit 1 ) -$(TARGET_DIR)/gl3/%.vs.glsl: %.vs.glsl $(INCLUDES) - mkdir -p $(TARGET_DIR)/gl3 && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( glslangValidator $(GLSLANGFLAGS) -S vert -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 ) +$(TARGET_DIR)/vulkan/%.vs.spv: %.vs.glsl $(INCLUDES) + mkdir -p $(TARGET_DIR)/vulkan && glslangValidator $(GLSLANGFLAGS_VULKAN) -V -S vert -o $@ $< -$(TARGET_DIR)/gl4/%.vs.glsl: %.vs.glsl $(INCLUDES) - mkdir -p $(TARGET_DIR)/gl3 && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( glslangValidator $(GLSLANGFLAGS) -S vert -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 ) +$(TARGET_DIR)/vulkan/%.fs.spv: %.fs.glsl $(INCLUDES) + mkdir -p $(TARGET_DIR)/vulkan && glslangValidator $(GLSLANGFLAGS_VULKAN) -V -S frag -o $@ $< -build/metal/%.cs.spv: %.cs.glsl $(INCLUDES) - mkdir -p build/metal && glslangValidator $(GLSLANGFLAGS_METAL) -G$(GLSL_COMPUTE_VERSION) -S comp -o $@ $< +$(TARGET_DIR)/vulkan/%.cs.spv: %.cs.glsl $(INCLUDES) + mkdir -p $(TARGET_DIR)/vulkan && glslangValidator $(GLSLANGFLAGS_VULKAN) -V -S comp -o $@ $< -$(TARGET_DIR)/gl4/%.cs.glsl: %.cs.glsl $(INCLUDES) - mkdir -p $(TARGET_DIR)/gl4 && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( glslangValidator $(GLSLANGFLAGS) -S vert -E $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 ) +$(TARGET_DIR)/gl3/%.glsl: $(TARGET_DIR)/vulkan/%.spv + mkdir -p $(TARGET_DIR)/gl3 && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( $(SPIRVCROSS) $(SPIRVCROSSFLAGS_GL3) $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 ) -$(TARGET_DIR)/metal/%.metal: build/metal/%.spv - mkdir -p $(TARGET_DIR)/metal && echo $(HEADER) > $@ && ( $(SPIRVCROSS) $(SPIRVCROSSFLAGS) $< >> $@ ) || ( rm $@ && exit 1 ) +$(TARGET_DIR)/gl4/%.glsl: $(TARGET_DIR)/vulkan/%.spv + mkdir -p $(TARGET_DIR)/gl4 && echo $(GLSL_VERSION_HEADER) > $@ && echo $(HEADER) >> $@ && ( $(SPIRVCROSS) $(SPIRVCROSSFLAGS_GL4) $< | sed $(GLSL_SED_ARGS) >> $@ ) || ( rm $@ && exit 1 ) \ No newline at end of file diff --git a/shaders/blit.fs.glsl b/shaders/blit.fs.glsl index 8d461ed41..027a3f110 100644 --- a/shaders/blit.fs.glsl +++ b/shaders/blit.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/blit.fs.glsl // @@ -16,13 +16,14 @@ precision highp float; precision highp sampler2D; #endif -uniform sampler2D uSrc; +layout(set=0, binding=0) uniform texture2D uSrc; +layout(set=0, binding=1) uniform sampler uSampler; in vec2 vTexCoord; out vec4 oFragColor; void main() { - vec4 color = texture(uSrc, vTexCoord); + vec4 color = texture(sampler2D(uSrc, uSampler), vTexCoord); oFragColor = vec4(color.rgb * color.a, color.a); } diff --git a/shaders/blit.vs.glsl b/shaders/blit.vs.glsl index ca3b0f7c4..cd83081a1 100644 --- a/shaders/blit.vs.glsl +++ b/shaders/blit.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/blit.vs.glsl // diff --git a/shaders/clear.fs.glsl b/shaders/clear.fs.glsl index 624f66e91..c46ab5dcb 100644 --- a/shaders/clear.fs.glsl +++ b/shaders/clear.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/clear.fs.glsl // @@ -16,10 +16,12 @@ precision highp float; precision highp sampler2D; #endif -uniform vec4 uColor; +layout(set=0, binding=2) uniform uColor { + vec4 color; +}; out vec4 oFragColor; void main() { - oFragColor = vec4(uColor.rgb, 1.0) * uColor.a; + oFragColor = vec4(color.rgb, 1.0) * color.a; } diff --git a/shaders/clear.vs.glsl b/shaders/clear.vs.glsl index 2bf5cc46f..1e169bb32 100644 --- a/shaders/clear.vs.glsl +++ b/shaders/clear.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/clear.vs.glsl // @@ -16,12 +16,16 @@ precision highp float; precision highp sampler2D; #endif -uniform vec4 uRect; -uniform vec2 uFramebufferSize; +layout(set=0, binding=0) uniform uRect { + vec4 rect; +}; +layout(set=0, binding=1) uniform uFramebufferSize { + vec2 framebufferSize; +}; in ivec2 aPosition; void main() { - vec2 position = mix(uRect.xy, uRect.zw, vec2(aPosition)) / uFramebufferSize * 2.0 - 1.0; + vec2 position = mix(rect.xy, rect.zw, vec2(aPosition)) / framebufferSize * 2.0 - 1.0; gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/shaders/debug_solid.fs.glsl b/shaders/debug_solid.fs.glsl index 5ceb65f9f..556449dee 100644 --- a/shaders/debug_solid.fs.glsl +++ b/shaders/debug_solid.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/debug_solid.fs.glsl // @@ -16,10 +16,12 @@ precision highp float; precision highp sampler2D; #endif -uniform vec4 uColor; +layout(set=0, binding=1) uniform uColor { + vec4 color; +}; out vec4 oFragColor; void main() { - oFragColor = vec4(uColor.rgb, 1.0) * uColor.a; + oFragColor = vec4(color.rgb, 1.0) * color.a; } diff --git a/shaders/debug_solid.vs.glsl b/shaders/debug_solid.vs.glsl index b10dde448..3bf49b72a 100644 --- a/shaders/debug_solid.vs.glsl +++ b/shaders/debug_solid.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/debug_solid.vs.glsl // @@ -16,11 +16,13 @@ precision highp float; precision highp sampler2D; #endif -uniform vec2 uFramebufferSize; +layout(set=0, binding=0) uniform uFramebufferSize { + vec2 framebufferSize; +}; in ivec2 aPosition; void main() { - vec2 position = vec2(aPosition) / uFramebufferSize * 2.0 - 1.0; + vec2 position = vec2(aPosition) / framebufferSize * 2.0 - 1.0; gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/shaders/debug_texture.fs.glsl b/shaders/debug_texture.fs.glsl index c01d386a0..bdffc15c0 100644 --- a/shaders/debug_texture.fs.glsl +++ b/shaders/debug_texture.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/debug_texture.fs.glsl // @@ -16,14 +16,17 @@ precision highp float; precision highp sampler2D; #endif -uniform sampler2D uTexture; -uniform vec4 uColor; +layout(set=0, binding=2) uniform texture2D uTexture; +layout(set=0, binding=3) uniform sampler uSampler; +layout(set=0, binding=4) uniform uColor { + vec4 color; +}; in vec2 vTexCoord; out vec4 oFragColor; void main() { - float alpha = texture(uTexture, vTexCoord).r * uColor.a; - oFragColor = alpha * vec4(uColor.rgb, 1.0); + float alpha = texture(sampler2D(uTexture, uSampler), vTexCoord).r * color.a; + oFragColor = alpha * vec4(color.rgb, 1.0); } diff --git a/shaders/debug_texture.vs.glsl b/shaders/debug_texture.vs.glsl index 2f918e294..0b9ac6b9d 100644 --- a/shaders/debug_texture.vs.glsl +++ b/shaders/debug_texture.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/debug_texture.vs.glsl // @@ -16,8 +16,12 @@ precision highp float; precision highp sampler2D; #endif -uniform vec2 uFramebufferSize; -uniform vec2 uTextureSize; +layout(set=0, binding=0) uniform uFramebufferSize { + vec2 framebufferSize; +}; +layout(set=0, binding=1) uniform uTextureSize { + vec2 textureSize; +}; in ivec2 aPosition; in ivec2 aTexCoord; @@ -25,7 +29,7 @@ in ivec2 aTexCoord; out vec2 vTexCoord; void main() { - vTexCoord = vec2(aTexCoord) / uTextureSize; - vec2 position = vec2(aPosition) / uFramebufferSize * 2.0 - 1.0; + vTexCoord = vec2(aTexCoord) / textureSize; + vec2 position = vec2(aPosition) / framebufferSize * 2.0 - 1.0; gl_Position = vec4(position.x, -position.y, 0.0, 1.0); } diff --git a/shaders/demo_ground.fs.glsl b/shaders/demo_ground.fs.glsl index edfbe1a27..86f197722 100644 --- a/shaders/demo_ground.fs.glsl +++ b/shaders/demo_ground.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/resources/shaders/demo_ground.fs.glsl // @@ -16,8 +16,12 @@ precision highp float; precision highp sampler2D; #endif -uniform vec4 uGroundColor; -uniform vec4 uGridlineColor; +layout(set=0, binding=2) uniform uGroundColor { + vec4 groundColor; +}; +layout(set=0, binding=3) uniform uGridlineColor { + vec4 gridlineColor; +}; in vec2 vTexCoord; @@ -25,5 +29,5 @@ out vec4 oFragColor; void main() { vec2 texCoordPx = fract(vTexCoord) / fwidth(vTexCoord); - oFragColor = any(lessThanEqual(texCoordPx, vec2(1.0))) ? uGridlineColor : uGroundColor; + oFragColor = any(lessThanEqual(texCoordPx, vec2(1.0))) ? gridlineColor : groundColor; } diff --git a/shaders/demo_ground.vs.glsl b/shaders/demo_ground.vs.glsl index 723d79dbd..2ee19ee2c 100644 --- a/shaders/demo_ground.vs.glsl +++ b/shaders/demo_ground.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/resources/shaders/demo_ground.vs.glsl // @@ -16,14 +16,18 @@ precision highp float; precision highp sampler2D; #endif -uniform mat4 uTransform; -uniform int uGridlineCount; +layout(set=0, binding=0) uniform uTransform { + mat4 transform; +}; +layout(set=0, binding=1) uniform uGridlineCount { + int gridlineCount; +}; in ivec2 aPosition; out vec2 vTexCoord; void main() { - vTexCoord = vec2(aPosition * uGridlineCount); - gl_Position = uTransform * vec4(ivec4(aPosition.x, 0, aPosition.y, 1)); + vTexCoord = vec2(aPosition * gridlineCount); + gl_Position = transform * vec4(ivec4(aPosition.x, 0, aPosition.y, 1)); } diff --git a/shaders/fill.cs.glsl b/shaders/fill.cs.glsl index 700c2946b..d03de8657 100644 --- a/shaders/fill.cs.glsl +++ b/shaders/fill.cs.glsl @@ -22,19 +22,22 @@ precision highp sampler2D; layout(local_size_x = 16, local_size_y = 4) in; -uniform writeonly image2D uDest; -uniform sampler2D uAreaLUT; -uniform int uFirstTileIndex; +layout (set=0, binding = 0) uniform writeonly image2D uDest; +layout (set=0, binding = 1) uniform texture2D uAreaLUT; +layout (set=0, binding = 2) uniform sampler uSampler; +layout (set=0, binding = 3) uniform uFirstTileIndex { + int firstTileIndex; +}; -layout(std430, binding = 0) buffer bFills { +layout(std430, set=0, binding = 4) buffer bFills { restrict readonly uvec2 iFills[]; }; -layout(std430, binding = 1) buffer bNextFills { +layout(std430, set=0, binding = 5) buffer bNextFills { restrict readonly int iNextFills[]; }; -layout(std430, binding = 2) buffer bFillTileMap { +layout(std430, set=0, binding = 6) buffer bFillTileMap { restrict readonly int iFillTileMap[]; }; @@ -42,7 +45,7 @@ void main() { ivec2 tileSubCoord = ivec2(gl_LocalInvocationID.xy) * ivec2(1, 4); uint tileIndexOffset = gl_WorkGroupID.z; - uint tileIndex = tileIndexOffset + uint(uFirstTileIndex); + uint tileIndex = tileIndexOffset + uint(firstTileIndex); int fillIndex = iFillTileMap[tileIndex]; if (fillIndex < 0) @@ -58,7 +61,7 @@ void main() { coverages += computeCoverage(from - (vec2(tileSubCoord) + vec2(0.5)), to - (vec2(tileSubCoord) + vec2(0.5)), - uAreaLUT); + uAreaLUT, uSampler); fillIndex = iNextFills[fillIndex]; } while (fillIndex >= 0); diff --git a/shaders/fill.fs.glsl b/shaders/fill.fs.glsl index 6ed65f9cc..74428d81a 100644 --- a/shaders/fill.fs.glsl +++ b/shaders/fill.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/fill.fs.glsl // @@ -20,7 +20,8 @@ precision highp sampler2D; #include "fill.inc.glsl" -uniform sampler2D uAreaLUT; +layout(set=0, binding=2) uniform texture2D uAreaLUT; +layout(set=0, binding=3) uniform sampler uSampler; in vec2 vFrom; in vec2 vTo; @@ -28,5 +29,5 @@ in vec2 vTo; out vec4 oFragColor; void main() { - oFragColor = computeCoverage(vFrom, vTo, uAreaLUT); + oFragColor = computeCoverage(vFrom, vTo, uAreaLUT, uSampler); } diff --git a/shaders/fill.inc.glsl b/shaders/fill.inc.glsl index c22125ae8..5f0f68768 100644 --- a/shaders/fill.inc.glsl +++ b/shaders/fill.inc.glsl @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -vec4 computeCoverage(vec2 from, vec2 to, sampler2D areaLUT) { +vec4 computeCoverage(vec2 from, vec2 to, texture2D areaLUT, sampler areaLUTSampler) { // Determine winding, and sort into a consistent order so we only need to find one root below. vec2 left = from.x < to.x ? from : to, right = from.x < to.x ? to : from; @@ -23,5 +23,5 @@ vec4 computeCoverage(vec2 from, vec2 to, sampler2D areaLUT) { // Look up area under that line, and scale horizontally to the window size. float dX = window.x - window.y; - return texture(areaLUT, vec2(y + 8.0, abs(d * dX)) / 16.0) * dX; + return texture(sampler2D(areaLUT, areaLUTSampler), vec2(y + 8.0, abs(d * dX)) / 16.0) * dX; } diff --git a/shaders/fill.vs.glsl b/shaders/fill.vs.glsl index d513b5efd..7e41f4c74 100644 --- a/shaders/fill.vs.glsl +++ b/shaders/fill.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/fill.vs.glsl // @@ -16,8 +16,12 @@ precision highp float; precision highp sampler2D; #endif -uniform vec2 uFramebufferSize; -uniform vec2 uTileSize; +layout(std140, set=0, binding=0) uniform uFramebufferSize { + vec2 framebufferSize; +}; +layout(std140, set=0, binding=1) uniform uTileSize { + vec2 tileSize; +}; in uvec2 aTessCoord; in uint aFromPx; @@ -30,13 +34,13 @@ out vec2 vFrom; out vec2 vTo; vec2 computeTileOffset(uint tileIndex, float stencilTextureWidth) { - uint tilesPerRow = uint(stencilTextureWidth / uTileSize.x); + uint tilesPerRow = uint(stencilTextureWidth / tileSize.x); uvec2 tileOffset = uvec2(tileIndex % tilesPerRow, tileIndex / tilesPerRow); - return vec2(tileOffset) * uTileSize * vec2(1.0, 0.25); + return vec2(tileOffset) * tileSize * vec2(1.0, 0.25); } void main() { - vec2 tileOrigin = computeTileOffset(aTileIndex, uFramebufferSize.x); + vec2 tileOrigin = computeTileOffset(aTileIndex, framebufferSize.x); vec2 from = vec2(aFromPx & 15u, aFromPx >> 4u) + aFromSubpx; vec2 to = vec2(aToPx & 15u, aToPx >> 4u) + aToSubpx; @@ -49,7 +53,7 @@ void main() { if (aTessCoord.y == 0u) position.y = floor(min(from.y, to.y)); else - position.y = uTileSize.y; + position.y = tileSize.y; position.y = floor(position.y * 0.25); // Since each fragment corresponds to 4 pixels on a scanline, the varying interpolation will @@ -60,7 +64,7 @@ void main() { vFrom = from + offset; vTo = to + offset; - vec2 globalPosition = (tileOrigin + position) / uFramebufferSize * 2.0 - 1.0; + vec2 globalPosition = (tileOrigin + position) / framebufferSize * 2.0 - 1.0; #ifdef PF_ORIGIN_UPPER_LEFT globalPosition.y = -globalPosition.y; #endif diff --git a/shaders/reproject.fs.glsl b/shaders/reproject.fs.glsl index 81d3e0eb8..ef604ff20 100644 --- a/shaders/reproject.fs.glsl +++ b/shaders/reproject.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/reproject.fs.glsl // @@ -16,15 +16,18 @@ precision highp float; precision highp sampler2D; #endif -uniform mat4 uOldTransform; -uniform sampler2D uTexture; +layout(set=0, binding=1) uniform uOldTransform { + mat4 oldTransform; +}; +layout(set=0, binding=2) uniform texture2D uTexture; +layout(set=0, binding=3) uniform sampler uSampler; in vec2 vTexCoord; out vec4 oFragColor; void main() { - vec4 normTexCoord = uOldTransform * vec4(vTexCoord, 0.0, 1.0); + vec4 normTexCoord = oldTransform * vec4(vTexCoord, 0.0, 1.0); vec2 texCoord = ((normTexCoord.xy / normTexCoord.w) + 1.0) * 0.5; - oFragColor = texture(uTexture, texCoord); + oFragColor = texture(sampler2D(uTexture, uSampler), texCoord); } diff --git a/shaders/reproject.vs.glsl b/shaders/reproject.vs.glsl index 9c5f7f2ac..a1385be72 100644 --- a/shaders/reproject.vs.glsl +++ b/shaders/reproject.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/reproject.vs.glsl // @@ -16,7 +16,9 @@ precision highp float; precision highp sampler2D; #endif -uniform mat4 uNewTransform; +layout(set=0, binding=0) uniform uNewTransform { + mat4 newTransform; +}; in ivec2 aPosition; @@ -30,5 +32,5 @@ void main() { // FIXME(pcwalton): This is wrong. position.y = 1.0 - position.y; #endif - gl_Position = uNewTransform * vec4(position, 0.0, 1.0); + gl_Position = newTransform * vec4(position, 0.0, 1.0); } diff --git a/shaders/stencil.fs.glsl b/shaders/stencil.fs.glsl index a3ab4d066..5522e683e 100644 --- a/shaders/stencil.fs.glsl +++ b/shaders/stencil.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/stencil.fs.glsl // diff --git a/shaders/stencil.vs.glsl b/shaders/stencil.vs.glsl index 0f66d5304..802635ee8 100644 --- a/shaders/stencil.vs.glsl +++ b/shaders/stencil.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/stencil.vs.glsl // diff --git a/shaders/tile.fs.glsl b/shaders/tile.fs.glsl index 487fcb5cd..3d5a604c5 100644 --- a/shaders/tile.fs.glsl +++ b/shaders/tile.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/tile.fs.glsl // @@ -81,17 +81,33 @@ precision highp sampler2D; #define COMBINER_CTRL_COLOR_COMBINE_SHIFT 6 #define COMBINER_CTRL_COMPOSITE_SHIFT 8 -uniform sampler2D uColorTexture0; -uniform sampler2D uMaskTexture0; -uniform sampler2D uDestTexture; -uniform sampler2D uGammaLUT; -uniform vec2 uColorTextureSize0; -uniform vec2 uMaskTextureSize0; -uniform vec4 uFilterParams0; -uniform vec4 uFilterParams1; -uniform vec4 uFilterParams2; -uniform vec2 uFramebufferSize; -uniform int uCtrl; +layout(set=1, binding=0) uniform sampler uSampler; +layout(set=1, binding=1) uniform texture2D uColorTexture0; +layout(set=1, binding=2) uniform texture2D uMaskTexture0; +layout(set=1, binding=3) uniform texture2D uDestTexture; +layout(set=1, binding=4) uniform texture2D uGammaLUT; + +layout(set=2, binding=0) uniform uColorTextureSize0 { + vec2 iColorTextureSize0; +}; +layout(set=2, binding=1) uniform uMaskTextureSize0 { + vec2 iMaskTextureSize0; +}; +layout(set=2, binding=2) uniform uFilterParams0 { + vec4 iFilterParams0; +}; +layout(set=2, binding=3) uniform uFilterParams1 { + vec4 iFilterParams1; +}; +layout(set=2, binding=4) uniform uFilterParams2 { + vec4 iFilterParams2; +}; +layout(set=2, binding=5) uniform uFramebufferSize { + vec2 iFramebufferSize; +}; +layout(set=2, binding=6) uniform uCtrl { + int iCtrl; +}; in vec3 vMaskTexCoord0; in vec2 vColorTexCoord0; @@ -102,8 +118,8 @@ out vec4 oFragColor; // Color sampling -vec4 sampleColor(sampler2D colorTexture, vec2 colorTexCoord) { - return texture(colorTexture, colorTexCoord); +vec4 sampleColor(texture2D colorTexture, vec2 colorTexCoord) { + return texture(sampler2D(colorTexture, uSampler), colorTexCoord); } // Color combining @@ -120,15 +136,15 @@ vec4 combineColor0(vec4 destColor, vec4 srcColor, int op) { // Text filter -float filterTextSample1Tap(float offset, sampler2D colorTexture, vec2 colorTexCoord) { - return texture(colorTexture, colorTexCoord + vec2(offset, 0.0)).r; +float filterTextSample1Tap(float offset, texture2D colorTexture, vec2 colorTexCoord) { + return texture(sampler2D(colorTexture, uSampler), colorTexCoord + vec2(offset, 0.0)).r; } // Samples 9 taps around the current pixel. void filterTextSample9Tap(out vec4 outAlphaLeft, out float outAlphaCenter, out vec4 outAlphaRight, - sampler2D colorTexture, + texture2D colorTexture, vec2 colorTexCoord, vec4 kernel, float onePixel) { @@ -150,12 +166,12 @@ float filterTextConvolve7Tap(vec4 alpha0, vec3 alpha1, vec4 kernel) { return dot(alpha0, kernel) + dot(alpha1, kernel.zyx); } -float filterTextGammaCorrectChannel(float bgColor, float fgColor, sampler2D gammaLUT) { - return texture(gammaLUT, vec2(fgColor, 1.0 - bgColor)).r; +float filterTextGammaCorrectChannel(float bgColor, float fgColor, texture2D gammaLUT) { + return texture(sampler2D(gammaLUT, uSampler), vec2(fgColor, 1.0 - bgColor)).r; } // `fgColor` is in linear space. -vec3 filterTextGammaCorrect(vec3 bgColor, vec3 fgColor, sampler2D gammaLUT) { +vec3 filterTextGammaCorrect(vec3 bgColor, vec3 fgColor, texture2D gammaLUT) { return vec3(filterTextGammaCorrectChannel(bgColor.r, fgColor.r, gammaLUT), filterTextGammaCorrectChannel(bgColor.g, fgColor.g, gammaLUT), filterTextGammaCorrectChannel(bgColor.b, fgColor.b, gammaLUT)); @@ -167,8 +183,8 @@ vec3 filterTextGammaCorrect(vec3 bgColor, vec3 fgColor, sampler2D gammaLUT) { // filterParams1 | bgColor.r bgColor.g bgColor.b - // filterParams2 | fgColor.r fgColor.g fgColor.b gammaCorrectionEnabled vec4 filterText(vec2 colorTexCoord, - sampler2D colorTexture, - sampler2D gammaLUT, + texture2D colorTexture, + texture2D gammaLUT, vec2 colorTextureSize, vec4 filterParams0, vec4 filterParams1, @@ -182,7 +198,7 @@ vec4 filterText(vec2 colorTexCoord, // Apply defringing if necessary. vec3 alpha; if (kernel.w == 0.0) { - alpha = texture(colorTexture, colorTexCoord).rrr; + alpha = texture(sampler2D(colorTexture, uSampler), colorTexCoord).rrr; } else { vec4 alphaLeft, alphaRight; float alphaCenter; @@ -302,7 +318,7 @@ vec4 filterText(vec2 colorTexCoord, // filterParams1 | radii.x radii.y uvOrigin.x uvOrigin.y // filterParams2 | - - - - vec4 filterRadialGradient(vec2 colorTexCoord, - sampler2D colorTexture, + texture2D colorTexture, vec2 colorTextureSize, vec2 fragCoord, vec2 framebufferSize, @@ -325,7 +341,7 @@ vec4 filterRadialGradient(vec2 colorTexCoord, if (ts.x > ts.y) ts = ts.yx; float t = ts.x >= 0.0 ? ts.x : ts.y; - color = texture(colorTexture, uvOrigin + vec2(clamp(t, 0.0, 1.0), 0.0)); + color = texture(sampler2D(colorTexture, uSampler), uvOrigin + vec2(clamp(t, 0.0, 1.0), 0.0)); } return color; @@ -337,7 +353,7 @@ vec4 filterRadialGradient(vec2 colorTexCoord, // filterParams1 | gaussCoeff.x gaussCoeff.y gaussCoeff.z - // filterParams2 | - - - - vec4 filterBlur(vec2 colorTexCoord, - sampler2D colorTexture, + texture2D colorTexture, vec2 colorTextureSize, vec4 filterParams0, vec4 filterParams1) { @@ -348,7 +364,7 @@ vec4 filterBlur(vec2 colorTexCoord, // Set up our incremental calculation. float gaussSum = gaussCoeff.x; - vec4 color = texture(colorTexture, colorTexCoord) * gaussCoeff.x; + vec4 color = texture(sampler2D(colorTexture, uSampler), colorTexCoord) * gaussCoeff.x; gaussCoeff.xy *= gaussCoeff.yz; // This is a common trick that lets us use the texture filtering hardware to evaluate two @@ -365,8 +381,8 @@ vec4 filterBlur(vec2 colorTexCoord, gaussPartialSum += gaussCoeff.x; vec2 srcOffset = srcOffsetScale * (float(i) + gaussCoeff.x / gaussPartialSum); - color += (texture(colorTexture, colorTexCoord - srcOffset) + - texture(colorTexture, colorTexCoord + srcOffset)) * gaussPartialSum; + color += (texture(sampler2D(colorTexture, uSampler), colorTexCoord - srcOffset) + + texture(sampler2D(colorTexture, uSampler), colorTexCoord + srcOffset)) * gaussPartialSum; gaussSum += 2.0 * gaussPartialSum; gaussCoeff.xy *= gaussCoeff.yz; @@ -376,13 +392,13 @@ vec4 filterBlur(vec2 colorTexCoord, return color / gaussSum; } -vec4 filterNone(vec2 colorTexCoord, sampler2D colorTexture) { +vec4 filterNone(vec2 colorTexCoord, texture2D colorTexture) { return sampleColor(colorTexture, colorTexCoord); } vec4 filterColor(vec2 colorTexCoord, - sampler2D colorTexture, - sampler2D gammaLUT, + texture2D colorTexture, + texture2D gammaLUT, vec2 colorTextureSize, vec2 fragCoord, vec2 framebufferSize, @@ -525,7 +541,7 @@ vec3 compositeRGB(vec3 destColor, vec3 srcColor, int op) { } vec4 composite(vec4 srcColor, - sampler2D destTexture, + texture2D destTexture, vec2 destTextureSize, vec2 fragCoord, int op) { @@ -534,7 +550,7 @@ vec4 composite(vec4 srcColor, // FIXME(pcwalton): What should the output alpha be here? vec2 destTexCoord = fragCoord / destTextureSize; - vec4 destColor = texture(destTexture, destTexCoord); + vec4 destColor = texture(sampler2D(destTexture, uSampler), destTexCoord); vec3 blendedRGB = compositeRGB(destColor.rgb, srcColor.rgb, op); return vec4(srcColor.a * (1.0 - destColor.a) * srcColor.rgb + srcColor.a * destColor.a * blendedRGB + @@ -545,7 +561,7 @@ vec4 composite(vec4 srcColor, // Masks float sampleMask(float maskAlpha, - sampler2D maskTexture, + texture2D maskTexture, vec2 maskTextureSize, vec3 maskTexCoord, int maskCtrl) { @@ -553,7 +569,7 @@ float sampleMask(float maskAlpha, return maskAlpha; ivec2 maskTexCoordI = ivec2(floor(maskTexCoord.xy)); - vec4 texel = texture(maskTexture, (vec2(maskTexCoordI / ivec2(1, 4)) + 0.5) / maskTextureSize); + vec4 texel = texture(sampler2D(maskTexture, uSampler), (vec2(maskTexCoordI / ivec2(1, 4)) + 0.5) / maskTextureSize); float coverage = texel[maskTexCoordI.y % 4] + maskTexCoord.z; if ((maskCtrl & TILE_CTRL_MASK_WINDING) != 0) @@ -569,7 +585,7 @@ void calculateColor(int tileCtrl, int ctrl) { // Sample mask. int maskCtrl0 = (tileCtrl >> TILE_CTRL_MASK_0_SHIFT) & TILE_CTRL_MASK_MASK; float maskAlpha = 1.0; - maskAlpha = sampleMask(maskAlpha, uMaskTexture0, uMaskTextureSize0, vMaskTexCoord0, maskCtrl0); + maskAlpha = sampleMask(maskAlpha, uMaskTexture0, iMaskTextureSize0, vMaskTexCoord0, maskCtrl0); // Sample color. vec4 color = vBaseColor; @@ -580,12 +596,12 @@ void calculateColor(int tileCtrl, int ctrl) { vec4 color0 = filterColor(vColorTexCoord0, uColorTexture0, uGammaLUT, - uColorTextureSize0, + iColorTextureSize0, gl_FragCoord.xy, - uFramebufferSize, - uFilterParams0, - uFilterParams1, - uFilterParams2, + iFramebufferSize, + iFilterParams0, + iFilterParams1, + iFilterParams2, color0Filter); color = combineColor0(color, color0, color0Combine); } @@ -595,7 +611,7 @@ void calculateColor(int tileCtrl, int ctrl) { // Apply composite. int compositeOp = (ctrl >> COMBINER_CTRL_COMPOSITE_SHIFT) & COMBINER_CTRL_COMPOSITE_MASK; - color = composite(color, uDestTexture, uFramebufferSize, gl_FragCoord.xy, compositeOp); + color = composite(color, uDestTexture, iFramebufferSize, gl_FragCoord.xy, compositeOp); // Premultiply alpha. color.rgb *= color.a; @@ -607,5 +623,5 @@ void calculateColor(int tileCtrl, int ctrl) { // TODO(pcwalton): Generate this dynamically. void main() { - calculateColor(int(vTileCtrl), uCtrl); + calculateColor(int(vTileCtrl), iCtrl); } diff --git a/shaders/tile.vs.glsl b/shaders/tile.vs.glsl index 3366e1297..5d817c925 100644 --- a/shaders/tile.vs.glsl +++ b/shaders/tile.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/tile.vs.glsl // @@ -16,10 +16,17 @@ precision highp float; precision highp sampler2D; #endif -uniform mat4 uTransform; -uniform vec2 uTileSize; -uniform sampler2D uTextureMetadata; -uniform ivec2 uTextureMetadataSize; +layout(set=0, binding=0) uniform uTransform { + mat4 transform; +}; +layout(set=0, binding=1) uniform uTileSize { + vec2 tileSize; +}; +layout(set=0, binding=2) uniform texture2D uTextureMetadata; +layout(set=0, binding=3) uniform sampler uSampler; +layout(set=0, binding=4) uniform uTextureMetadataSize { + ivec2 textureMetadataSize; +}; in ivec2 aTileOffset; in ivec2 aTileOrigin; @@ -35,22 +42,22 @@ out float vTileCtrl; void main() { vec2 tileOrigin = vec2(aTileOrigin), tileOffset = vec2(aTileOffset); - vec2 position = (tileOrigin + tileOffset) * uTileSize; + vec2 position = (tileOrigin + tileOffset) * tileSize; - vec2 maskTexCoord0 = (vec2(aMaskTexCoord0) + tileOffset) * uTileSize; + vec2 maskTexCoord0 = (vec2(aMaskTexCoord0) + tileOffset) * tileSize; - vec2 textureMetadataScale = vec2(1.0) / vec2(uTextureMetadataSize); + vec2 textureMetadataScale = vec2(1.0) / vec2(textureMetadataSize); vec2 metadataEntryCoord = vec2(aColor % 128 * 4, aColor / 128); vec2 colorTexMatrix0Coord = (metadataEntryCoord + vec2(0.5, 0.5)) * textureMetadataScale; vec2 colorTexOffsetsCoord = (metadataEntryCoord + vec2(1.5, 0.5)) * textureMetadataScale; vec2 baseColorCoord = (metadataEntryCoord + vec2(2.5, 0.5)) * textureMetadataScale; - vec4 colorTexMatrix0 = texture(uTextureMetadata, colorTexMatrix0Coord); - vec4 colorTexOffsets = texture(uTextureMetadata, colorTexOffsetsCoord); - vec4 baseColor = texture(uTextureMetadata, baseColorCoord); + vec4 colorTexMatrix0 = texture(sampler2D(uTextureMetadata, uSampler), colorTexMatrix0Coord); + vec4 colorTexOffsets = texture(sampler2D(uTextureMetadata, uSampler), colorTexOffsetsCoord); + vec4 baseColor = texture(sampler2D(uTextureMetadata, uSampler), baseColorCoord); vColorTexCoord0 = mat2(colorTexMatrix0) * position + colorTexOffsets.xy; vMaskTexCoord0 = vec3(maskTexCoord0, float(aMaskBackdrop.x)); vBaseColor = baseColor; vTileCtrl = float(aTileCtrl); - gl_Position = uTransform * vec4(position, 0.0, 1.0); + gl_Position = transform * vec4(position, 0.0, 1.0); } diff --git a/shaders/tile_clip.fs.glsl b/shaders/tile_clip.fs.glsl index e6c7b6ada..352548561 100644 --- a/shaders/tile_clip.fs.glsl +++ b/shaders/tile_clip.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/tile_clip.fs.glsl // @@ -16,7 +16,8 @@ precision highp float; precision highp sampler2D; #endif -uniform sampler2D uSrc; +layout(set=0, binding=0) uniform texture2D uSrc; +layout(set=0, binding=1) uniform sampler uSampler; in vec2 vTexCoord; in float vBackdrop; @@ -24,5 +25,5 @@ in float vBackdrop; out vec4 oFragColor; void main() { - oFragColor = clamp(abs(texture(uSrc, vTexCoord) + vBackdrop), 0.0, 1.0); + oFragColor = clamp(abs(texture(sampler2D(uSrc, uSampler), vTexCoord) + vBackdrop), 0.0, 1.0); } diff --git a/shaders/tile_clip.vs.glsl b/shaders/tile_clip.vs.glsl index 47186462c..b0c19a704 100644 --- a/shaders/tile_clip.vs.glsl +++ b/shaders/tile_clip.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/tile_clip.vs.glsl // diff --git a/shaders/tile_copy.fs.glsl b/shaders/tile_copy.fs.glsl index bad183c0b..4494995c1 100644 --- a/shaders/tile_copy.fs.glsl +++ b/shaders/tile_copy.fs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/tile_copy.fs.glsl // @@ -16,12 +16,15 @@ precision highp float; precision highp sampler2D; #endif -uniform vec2 uFramebufferSize; -uniform sampler2D uSrc; +layout(set=0, binding=2) uniform uFramebufferSize { + vec2 framebufferSize; +}; +layout(set=0, binding=3) uniform texture2D uSrc; +layout(set=0, binding=4) uniform sampler uSampler; out vec4 oFragColor; void main() { - vec2 texCoord = gl_FragCoord.xy / uFramebufferSize; - oFragColor = texture(uSrc, texCoord); + vec2 texCoord = gl_FragCoord.xy / framebufferSize; + oFragColor = texture(sampler2D(uSrc, uSampler), texCoord); } diff --git a/shaders/tile_copy.vs.glsl b/shaders/tile_copy.vs.glsl index 6b9971d23..5b0515c32 100644 --- a/shaders/tile_copy.vs.glsl +++ b/shaders/tile_copy.vs.glsl @@ -1,4 +1,4 @@ -#version 330 +#version 450 // pathfinder/shaders/tile_copy.vs.glsl // @@ -16,12 +16,16 @@ precision highp float; precision highp sampler2D; #endif -uniform mat4 uTransform; -uniform vec2 uTileSize; +layout(set=0, binding=0) uniform uTransform { + mat4 transform; +}; +layout(set=0, binding=1) uniform uTileSize { + vec2 tileSize; +}; in ivec2 aTilePosition; void main() { - vec2 position = vec2(aTilePosition) * uTileSize; - gl_Position = uTransform * vec4(position, 0.0, 1.0); + vec2 position = vec2(aTilePosition) * tileSize; + gl_Position = transform * vec4(position, 0.0, 1.0); }