mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-08 06:05:55 +00:00
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>
63 lines
1.3 KiB
GLSL
63 lines
1.3 KiB
GLSL
#version 310 es
|
|
precision mediump float;
|
|
|
|
struct tint_symbol_2 {
|
|
vec2 vUV;
|
|
};
|
|
struct tint_symbol_3 {
|
|
vec4 value;
|
|
};
|
|
|
|
uniform highp sampler2D randomTexture_Sampler;
|
|
uniform highp sampler2D depthTexture_Sampler;
|
|
|
|
|
|
vec4 tint_symbol_inner(vec2 vUV) {
|
|
vec3 random = texture(randomTexture_Sampler, vUV).rgb;
|
|
int i = 0;
|
|
while (true) {
|
|
if ((i < 1)) {
|
|
} else {
|
|
break;
|
|
}
|
|
vec3 offset = vec3(random.x);
|
|
bool tint_tmp_2 = (offset.x < 0.0f);
|
|
if (!tint_tmp_2) {
|
|
tint_tmp_2 = (offset.y < 0.0f);
|
|
}
|
|
bool tint_tmp_1 = (tint_tmp_2);
|
|
if (!tint_tmp_1) {
|
|
tint_tmp_1 = (offset.x > 1.0f);
|
|
}
|
|
bool tint_tmp = (tint_tmp_1);
|
|
if (!tint_tmp) {
|
|
tint_tmp = (offset.y > 1.0f);
|
|
}
|
|
if ((tint_tmp)) {
|
|
i = (i + 1);
|
|
continue;
|
|
}
|
|
float sampleDepth = texture(depthTexture_Sampler, offset.xy).r;
|
|
i = (i + 1);
|
|
}
|
|
return vec4(1.0f);
|
|
}
|
|
|
|
tint_symbol_3 tint_symbol(tint_symbol_2 tint_symbol_1) {
|
|
vec4 inner_result = tint_symbol_inner(tint_symbol_1.vUV);
|
|
tint_symbol_3 wrapper_result = tint_symbol_3(vec4(0.0f, 0.0f, 0.0f, 0.0f));
|
|
wrapper_result.value = inner_result;
|
|
return wrapper_result;
|
|
}
|
|
in vec2 vUV;
|
|
out vec4 value;
|
|
void main() {
|
|
tint_symbol_2 inputs;
|
|
inputs.vUV = vUV;
|
|
tint_symbol_3 outputs;
|
|
outputs = tint_symbol(inputs);
|
|
value = outputs.value;
|
|
}
|
|
|
|
|