Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Kristian Arntzen <post@arntzen-software.no>2022-04-29 14:49:02 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2022-05-02 16:11:24 +0300
commit7a6c2da9aab9a15389f2f122e937faddf98887da (patch)
tree39563bd5e275f16e826eb11c4d98f88f0d9266a0 /reference/opt/shaders
parentd28136cc7ae966e4e680d1f9effcc23520f6c862 (diff)
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.
Diffstat (limited to 'reference/opt/shaders')
-rw-r--r--reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk3
-rw-r--r--reference/opt/shaders/comp/bake_gradient.comp10
-rw-r--r--reference/opt/shaders/frag/constant-array.frag6
-rw-r--r--reference/opt/shaders/frag/frexp-modf.frag4
-rw-r--r--reference/opt/shaders/tese/water_tess.tese5
-rw-r--r--reference/opt/shaders/vert/ground.vert3
-rw-r--r--reference/opt/shaders/vert/ocean.vert3
-rw-r--r--reference/opt/shaders/vert/read-from-row-major-array.vert14
-rw-r--r--reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag6
-rw-r--r--reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag.vk6
-rw-r--r--reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag6
-rw-r--r--reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk6
12 files changed, 59 insertions, 13 deletions
diff --git a/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk b/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk
index b53f800a..4af25ec8 100644
--- a/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk
+++ b/reference/opt/shaders/asm/vert/spec-constant-op-composite.asm.vk.vert.vk
@@ -17,7 +17,8 @@ void main()
_65.y = float(_20);
vec4 _68 = _65;
_68.z = float(_25);
- vec4 _54 = _68 + vec4(_32);
+ vec4 _52 = vec4(_32);
+ vec4 _54 = _68 + _52;
vec2 _58 = _54.xy + vec2(_34);
gl_Position = vec4(_58.x, _58.y, _54.z, _54.w);
_4 = _35;
diff --git a/reference/opt/shaders/comp/bake_gradient.comp b/reference/opt/shaders/comp/bake_gradient.comp
index 69634d5d..e053576a 100644
--- a/reference/opt/shaders/comp/bake_gradient.comp
+++ b/reference/opt/shaders/comp/bake_gradient.comp
@@ -16,11 +16,19 @@ void main()
{
vec4 _59 = (vec2(gl_GlobalInvocationID.xy) * _46.uInvSize.xy).xyxy + (_46.uInvSize * 0.5);
vec2 _67 = _59.xy;
+ mediump float _79 = textureLodOffset(uHeight, _67, 0.0, ivec2(-1, 0)).x;
+ float hp_copy_79 = _79;
+ mediump float _87 = textureLodOffset(uHeight, _67, 0.0, ivec2(1, 0)).x;
+ float hp_copy_87 = _87;
+ mediump float _94 = textureLodOffset(uHeight, _67, 0.0, ivec2(0, -1)).x;
+ float hp_copy_94 = _94;
+ mediump float _101 = textureLodOffset(uHeight, _67, 0.0, ivec2(0, 1)).x;
+ float hp_copy_101 = _101;
vec2 _128 = _59.zw;
vec2 _157 = ((textureLodOffset(uDisplacement, _128, 0.0, ivec2(1, 0)).xy - textureLodOffset(uDisplacement, _128, 0.0, ivec2(-1, 0)).xy) * 0.60000002384185791015625) * _46.uScale.z;
vec2 _161 = ((textureLodOffset(uDisplacement, _128, 0.0, ivec2(0, 1)).xy - textureLodOffset(uDisplacement, _128, 0.0, ivec2(0, -1)).xy) * 0.60000002384185791015625) * _46.uScale.z;
ivec2 _172 = ivec2(gl_GlobalInvocationID.xy);
imageStore(iHeightDisplacement, _172, vec4(textureLod(uHeight, _67, 0.0).x, 0.0, 0.0, 0.0));
- imageStore(iGradJacobian, _172, vec4((_46.uScale.xy * 0.5) * vec2(textureLodOffset(uHeight, _67, 0.0, ivec2(1, 0)).x - textureLodOffset(uHeight, _67, 0.0, ivec2(-1, 0)).x, textureLodOffset(uHeight, _67, 0.0, ivec2(0, 1)).x - textureLodOffset(uHeight, _67, 0.0, ivec2(0, -1)).x), ((1.0 + _157.x) * (1.0 + _161.y)) - (_157.y * _161.x), 0.0));
+ imageStore(iGradJacobian, _172, vec4((_46.uScale.xy * 0.5) * vec2(hp_copy_87 - hp_copy_79, hp_copy_101 - hp_copy_94), ((1.0 + _157.x) * (1.0 + _161.y)) - (_157.y * _161.x), 0.0));
}
diff --git a/reference/opt/shaders/frag/constant-array.frag b/reference/opt/shaders/frag/constant-array.frag
index 914888aa..a7a064a1 100644
--- a/reference/opt/shaders/frag/constant-array.frag
+++ b/reference/opt/shaders/frag/constant-array.frag
@@ -17,6 +17,10 @@ layout(location = 0) flat in mediump int index;
void main()
{
- FragColor = ((_37[index] + _55[index][index + 1]) + vec4(30.0)) + vec4(_75[index].a + _75[index].b);
+ highp float _106 = _75[index].a;
+ float mp_copy_106 = _106;
+ highp float _107 = _75[index].b;
+ float mp_copy_107 = _107;
+ FragColor = ((_37[index] + _55[index][index + 1]) + vec4(30.0)) + vec4(mp_copy_106 + mp_copy_107);
}
diff --git a/reference/opt/shaders/frag/frexp-modf.frag b/reference/opt/shaders/frag/frexp-modf.frag
index 25f3360a..134878e0 100644
--- a/reference/opt/shaders/frag/frexp-modf.frag
+++ b/reference/opt/shaders/frag/frexp-modf.frag
@@ -22,12 +22,14 @@ void main()
{
ResType _22;
_22._m0 = frexp(v0 + 1.0, _22._m1);
+ highp float _24 = _22._m0;
+ float mp_copy_24 = _24;
ResType_1 _35;
_35._m0 = frexp(v1, _35._m1);
float r0;
float _41 = modf(v0, r0);
vec2 r1;
vec2 _45 = modf(v1, r1);
- FragColor = ((((_22._m0 + _35._m0.x) + _35._m0.y) + _41) + _45.x) + _45.y;
+ FragColor = ((((mp_copy_24 + _35._m0.x) + _35._m0.y) + _41) + _45.x) + _45.y;
}
diff --git a/reference/opt/shaders/tese/water_tess.tese b/reference/opt/shaders/tese/water_tess.tese
index 6eb0d1aa..2878c75b 100644
--- a/reference/opt/shaders/tese/water_tess.tese
+++ b/reference/opt/shaders/tese/water_tess.tese
@@ -24,11 +24,12 @@ void main()
vec2 _202 = vOutPatchPosBase + (gl_TessCoord.xy * _31.uPatchSize);
vec2 _216 = mix(vPatchLods.yx, vPatchLods.zw, vec2(gl_TessCoord.x));
float _223 = mix(_216.x, _216.y, gl_TessCoord.y);
- mediump float _225 = floor(_223);
+ mediump float mp_copy_223 = _223;
+ mediump float _225 = floor(mp_copy_223);
vec2 _125 = _202 * _31.uInvHeightmapSize;
vec2 _141 = _31.uInvHeightmapSize * exp2(_225);
vGradNormalTex = vec4(_125 + (_31.uInvHeightmapSize * 0.5), _125 * _31.uScale.zw);
- mediump vec3 _256 = mix(textureLod(uHeightmapDisplacement, _125 + (_141 * 0.5), _225).xyz, textureLod(uHeightmapDisplacement, _125 + (_141 * 1.0), _225 + 1.0).xyz, vec3(_223 - _225));
+ mediump vec3 _256 = mix(textureLod(uHeightmapDisplacement, _125 + (_141 * 0.5), _225).xyz, textureLod(uHeightmapDisplacement, _125 + (_141 * 1.0), _225 + 1.0).xyz, vec3(mp_copy_223 - _225));
vec2 _171 = (_202 * _31.uScale.xy) + _256.yz;
vWorld = vec3(_171.x, _256.x, _171.y);
gl_Position = _31.uMVP * vec4(vWorld, 1.0);
diff --git a/reference/opt/shaders/vert/ground.vert b/reference/opt/shaders/vert/ground.vert
index d9383577..23d8b27d 100644
--- a/reference/opt/shaders/vert/ground.vert
+++ b/reference/opt/shaders/vert/ground.vert
@@ -84,7 +84,8 @@ void main()
vec4 _345 = vec4((_310 + uvec2(_384, _385)).xyxy & (~_317).xxyy);
vec2 _173 = ((_53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _156.InvGroundSize_PatchScale.zw) + mix(_345.xy, _345.zw, vec2(_301 - _303))) * _156.InvGroundSize_PatchScale.xy;
mediump float _362 = textureLod(TexLOD, _173, 0.0).x * 7.96875;
- float _364 = floor(_362);
+ float hp_copy_362 = _362;
+ float _364 = floor(hp_copy_362);
vec2 _185 = _156.InvGroundSize_PatchScale.xy * exp2(_364);
vec3 _230 = (vec3(_173.x, mix(textureLod(TexHeightmap, _173 + (_185 * 0.5), _364).x, textureLod(TexHeightmap, _173 + (_185 * 1.0), _364 + 1.0).x, _362 - _364), _173.y) * _156.GroundScale.xyz) + _156.GroundPosition.xyz;
EyeVec = _230 - _236.g_CamPos.xyz;
diff --git a/reference/opt/shaders/vert/ocean.vert b/reference/opt/shaders/vert/ocean.vert
index 9656938c..9fab66bd 100644
--- a/reference/opt/shaders/vert/ocean.vert
+++ b/reference/opt/shaders/vert/ocean.vert
@@ -116,7 +116,8 @@ void main()
vec2 _197 = ((_53.Patches[(gl_InstanceID + SPIRV_Cross_BaseInstance)].Position.xz * _180.InvOceanSize_PatchScale.zw) + mix(_416.xy, _416.zw, vec2(_351 - _353))) * _180.InvOceanSize_PatchScale.xy;
vec2 _204 = _197 * _180.NormalTexCoordScale.zw;
mediump float _433 = textureLod(TexLOD, _197, 0.0).x * 7.96875;
- float _435 = floor(_433);
+ float hp_copy_433 = _433;
+ float _435 = floor(hp_copy_433);
vec2 _220 = (_180.InvOceanSize_PatchScale.xy * exp2(_435)) * _180.NormalTexCoordScale.zw;
vec3 _267 = ((vec3(_197.x, 0.0, _197.y) + mix(textureLod(TexDisplacement, _204 + (_220 * 0.5), _435).yxz, textureLod(TexDisplacement, _204 + (_220 * 1.0), _435 + 1.0).yxz, vec3(_433 - _435))) * _180.OceanScale.xyz) + _180.OceanPosition.xyz;
EyeVec = _267 - _273.g_CamPos.xyz;
diff --git a/reference/opt/shaders/vert/read-from-row-major-array.vert b/reference/opt/shaders/vert/read-from-row-major-array.vert
index 6c68979b..c491b547 100644
--- a/reference/opt/shaders/vert/read-from-row-major-array.vert
+++ b/reference/opt/shaders/vert/read-from-row-major-array.vert
@@ -13,6 +13,18 @@ mat2x3 spvWorkaroundRowMajor(mat2x3 wrap) { return wrap; }
void main()
{
gl_Position = a_position;
- v_vtxResult = ((float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].x - 2.0) < 0.0500000007450580596923828125) * float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].y - 6.0) < 0.0500000007450580596923828125)) * float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].z - (-6.0)) < 0.0500000007450580596923828125)) * ((float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].x) < 0.0500000007450580596923828125) * float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].y - 5.0) < 0.0500000007450580596923828125)) * float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].z - 5.0) < 0.0500000007450580596923828125));
+ float _172 = float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].x - 2.0) < 0.0500000007450580596923828125);
+ mediump float mp_copy_172 = _172;
+ float _180 = float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].y - 6.0) < 0.0500000007450580596923828125);
+ mediump float mp_copy_180 = _180;
+ float _188 = float(abs(spvWorkaroundRowMajor(_104.var[0][0])[0].z - (-6.0)) < 0.0500000007450580596923828125);
+ mediump float mp_copy_188 = _188;
+ float _221 = float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].x) < 0.0500000007450580596923828125);
+ mediump float mp_copy_221 = _221;
+ float _229 = float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].y - 5.0) < 0.0500000007450580596923828125);
+ mediump float mp_copy_229 = _229;
+ float _237 = float(abs(spvWorkaroundRowMajor(_104.var[0][0])[1].z - 5.0) < 0.0500000007450580596923828125);
+ mediump float mp_copy_237 = _237;
+ v_vtxResult = ((mp_copy_172 * mp_copy_180) * mp_copy_188) * ((mp_copy_221 * mp_copy_229) * mp_copy_237);
}
diff --git a/reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag b/reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag
index df2994ef..f77b448c 100644
--- a/reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag
+++ b/reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag
@@ -13,7 +13,11 @@ layout(location = 0) out vec4 FragColor;
void main()
{
- vec2 _95 = (vTex + (vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler[1], 0)))) + (vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler[2], 1)));
+ highp vec2 _76 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler[1], 0));
+ vec2 mp_copy_76 = _76;
+ highp vec2 _86 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler[2], 1));
+ vec2 mp_copy_86 = _86;
+ vec2 _95 = (vTex + mp_copy_76) + mp_copy_86;
FragColor = ((((texture(SPIRV_Cross_CombineduTextureuSampler[2], _95) + texture(SPIRV_Cross_CombineduTextureuSampler[1], _95)) + texture(SPIRV_Cross_CombineduTextureuSampler[1], _95)) + texture(SPIRV_Cross_CombineduTextureArrayuSampler[3], vTex3)) + texture(SPIRV_Cross_CombineduTextureCubeuSampler[1], vTex3)) + texture(SPIRV_Cross_CombineduTexture3DuSampler[2], vTex3);
}
diff --git a/reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag.vk b/reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag.vk
index d275a0f4..7a0c428d 100644
--- a/reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag.vk
+++ b/reference/opt/shaders/vulkan/frag/separate-sampler-texture-array.vk.frag.vk
@@ -14,7 +14,11 @@ layout(location = 0) out vec4 FragColor;
void main()
{
- vec2 _95 = (vTex + (vec2(1.0) / vec2(textureSize(sampler2D(uTexture[1], uSampler), 0)))) + (vec2(1.0) / vec2(textureSize(sampler2D(uTexture[2], uSampler), 1)));
+ highp vec2 _76 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture[1], uSampler), 0));
+ vec2 mp_copy_76 = _76;
+ highp vec2 _86 = vec2(1.0) / vec2(textureSize(sampler2D(uTexture[2], uSampler), 1));
+ vec2 mp_copy_86 = _86;
+ vec2 _95 = (vTex + mp_copy_76) + mp_copy_86;
FragColor = ((((texture(sampler2D(uTexture[2], uSampler), _95) + texture(sampler2D(uTexture[1], uSampler), _95)) + texture(sampler2D(uTexture[1], uSampler), _95)) + texture(sampler2DArray(uTextureArray[3], uSampler), vTex3)) + texture(samplerCube(uTextureCube[1], uSampler), vTex3)) + texture(sampler3D(uTexture3D[2], uSampler), vTex3);
}
diff --git a/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag b/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag
index aad1e436..c664bd55 100644
--- a/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag
+++ b/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag
@@ -13,7 +13,11 @@ layout(location = 0) out vec4 FragColor;
void main()
{
- vec2 _73 = (vTex + (vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 0)))) + (vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 1)));
+ highp vec2 _54 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 0));
+ vec2 mp_copy_54 = _54;
+ highp vec2 _64 = vec2(1.0) / vec2(textureSize(SPIRV_Cross_CombineduTextureuSampler, 1));
+ vec2 mp_copy_64 = _64;
+ vec2 _73 = (vTex + mp_copy_54) + mp_copy_64;
FragColor = (((texture(SPIRV_Cross_CombineduTextureuSampler, _73) + texture(SPIRV_Cross_CombineduTextureuSampler, _73)) + texture(SPIRV_Cross_CombineduTextureArrayuSampler, vTex3)) + texture(SPIRV_Cross_CombineduTextureCubeuSampler, vTex3)) + texture(SPIRV_Cross_CombineduTexture3DuSampler, vTex3);
}
diff --git a/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk b/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk
index b79374ab..9fcd3252 100644
--- a/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk
+++ b/reference/opt/shaders/vulkan/frag/separate-sampler-texture.vk.frag.vk
@@ -14,7 +14,11 @@ layout(location = 0) out vec4 FragColor;
void main()
{
- vec2 _73 = (vTex + (vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 0)))) + (vec2(1.0) / vec2(textureSize(sampler2D(uTexture, uSampler), 1)));
+ 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);
}