SPIRV-Cross/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk
Hans-Kristian Arntzen 7a6c2da9aa GLSL: Handle more proper semantics for RelaxedPrecision.
GLSL and RelaxedPrecision are quite different in what they affect.
RelaxedPrecision affects operations, while this is merely implied in
GLSL based on inputs.

This leads to situations where we have to promote mediump inputs to
highp, and the simplest approach is to force highp temporaries for
inputs which are consumed in a highp context. For completeness, we also
demote RelaxedPrecision inputs to mediump variables.

PHI is handled by copying the PHI into a temporary.

We have to be very careful with hoisted temporaries, since the child
temporary will not be analyzed up-front. We inherit the hoisted-ness
state and emit the hoisted child temporary as necessary. When faking the
temporaries with OpCopyObject, we make sure to block any variable
hoisting.

Hoisting children of PHI variables is fine, since PHIs are not hoisted with
the same framework as other temporaries.
2022-05-02 15:11:24 +02:00

25 lines
1.1 KiB
Plaintext

#version 310 es
precision mediump float;
precision highp int;
layout(set = 0, binding = 1) uniform mediump texture2D uTexture;
layout(set = 0, binding = 0) uniform mediump sampler uSampler;
layout(set = 0, binding = 4) uniform mediump texture2DArray uTextureArray;
layout(set = 0, binding = 3) uniform mediump textureCube uTextureCube;
layout(set = 0, binding = 2) uniform mediump texture3D uTexture3D;
layout(location = 0) in vec2 vTex;
layout(location = 1) in vec3 vTex3;
layout(location = 0) out vec4 FragColor;
void main()
{
highp vec2 _54 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 0));
vec2 mp_copy_54 = _54;
highp vec2 _64 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 1));
vec2 mp_copy_64 = _64;
vec2 _73 = (vTex + mp_copy_54) + mp_copy_64;
FragColor = (((texture(sampler2D(uTexture, uSampler), _73) + texture(sampler2D(uTexture, uSampler), _73)) + texture(sampler2DArray(uTextureArray, uSampler), vTex3)) + texture(samplerCube(uTextureCube, uSampler), vTex3)) + texture(sampler3D(uTexture3D, uSampler), vTex3);
}