dawn-cmake/test/bug/tint/534.wgsl.expected.glsl
Stephen White f9b8b6104d GLSL: implement CombineSamplers transform (string version).
This transform converts all separate texture/sampler references
in a program into combined texture/samplers. This is required for GLSL,
which does not support separate texture/samplers.

As input, the transform requires a map from the unique sampler/texture
pairs previously gathered by the Resolver to strings, which will be
used as the names of the newly-generated combined samplers. Note that
binding points are unused by GLSL, and so are set to (0, 0) with
collision detection disabled.

All function signatures containing textures or samplers are rewritten,
as well as function calls and texture intrinsic calls. For texture
intrinsic calls, a placeholder sampler is used to satisfy the subsequent
Resolver pass (GLSL texture intrinsics do not require a separate sampler,
but WGSL intrinsics do). The placeholder is also used if the shader
contains only texture references (e.g., textureLoad).

Bug: tint:1366

Change-Id: Iff8407d28fdc2a8adac5cb655707a08c8553c389
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/77080
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
2022-01-24 17:17:22 +00:00

74 lines
1.8 KiB
GLSL

#version 310 es
precision mediump float;
struct Uniforms {
uint dstTextureFlipY;
uint isFloat16;
uint isRGB10A2Unorm;
uint channelCount;
};
layout (binding = 2) buffer OutputBuf_1 {
uint result[];
} tint_symbol;
layout (binding = 3) uniform Uniforms_1 {
uint dstTextureFlipY;
uint isFloat16;
uint isRGB10A2Unorm;
uint channelCount;
} uniforms;
uint ConvertToFp16FloatValue(float fp32) {
return 1u;
}
struct tint_symbol_3 {
uvec3 GlobalInvocationID;
};
uniform highp sampler2D src_1;
uniform highp sampler2D dst_1;
void tint_symbol_1_inner(uvec3 GlobalInvocationID) {
ivec2 size = textureSize(src_1, 0);
ivec2 dstTexCoord = ivec2(GlobalInvocationID.xy);
ivec2 srcTexCoord = dstTexCoord;
if ((uniforms.dstTextureFlipY == 1u)) {
srcTexCoord.y = ((size.y - dstTexCoord.y) - 1);
}
vec4 srcColor = texelFetch(src_1, srcTexCoord, 0);
vec4 dstColor = texelFetch(dst_1, dstTexCoord, 0);
bool success = true;
uvec4 srcColorBits = uvec4(0u, 0u, 0u, 0u);
uvec4 dstColorBits = uvec4(dstColor);
{
for(uint i = 0u; (i < uniforms.channelCount); i = (i + 1u)) {
srcColorBits[i] = ConvertToFp16FloatValue(srcColor[i]);
bool tint_tmp = success;
if (tint_tmp) {
tint_tmp = (srcColorBits[i] == dstColorBits[i]);
}
success = (tint_tmp);
}
}
uint outputIndex = ((GlobalInvocationID.y * uint(size.x)) + GlobalInvocationID.x);
if (success) {
tint_symbol.result[outputIndex] = uint(1);
} else {
tint_symbol.result[outputIndex] = uint(0);
}
}
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
void tint_symbol_1(tint_symbol_3 tint_symbol_2) {
tint_symbol_1_inner(tint_symbol_2.GlobalInvocationID);
return;
}
void main() {
tint_symbol_3 inputs;
inputs.GlobalInvocationID = gl_GlobalInvocationID;
tint_symbol_1(inputs);
}