Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler Can Emit Multiple Precision Decorations Causing Optimization to Fail With Internal Error #1438

Open
benn-geomagical opened this issue Jul 23, 2024 · 0 comments

Comments

@benn-geomagical
Copy link

benn-geomagical commented Jul 23, 2024

Vulkan SDK 1.3.290,0
shaderc v2023.8 v2024.1-9-g3ac03b8
spirv-tools v2024.3 v2022.4-513-g0cfe9e72
glslang 11.1.0-1009-gfa9c3deb
Windows 11 / Intel x86_64

Issue first occurred using Vulkan SDK 1.3.283.0

When constants are defined after precision statements that are not highp the compiler will emit multiple precision decorations causing optimization to fail with an internal error.

shaderc: internal error: compilation succeeded but failed to optimize: ID '22' decorated with RelaxedPrecision multiple times is not allowed.
  %float_0 = OpConstant %float 0

This script repros the issue.

#!/usr/bin/env bash

cat << EOF > repro.vert
#version 450

#if !defined(SHOW_CASE)
# define SHOW_CASE 0
#endif

#if SHOW_CASE == 0
  // error case
  precision mediump float;
  precision mediump int;
#elif SHOW_CASE == 1
  // workaround 1
  precision highp float;
  precision highp int;
#endif

const float kfVal = 0;
const float kfValCopy = kfVal;
const uint kuVal = 0;
const uint kuValCopy = kuVal;

#if SHOW_CASE == 2
  // workaround 2
  precision mediump float;
  precision mediump int;
#endif

in vec4 aPos;

void main() {
  gl_Position = aPos;
}
EOF

function compile() {
  glslc \
    --target-env=vulkan1.1 \
    -fauto-map-locations \
    -g -O \
    -o repro.vert.spv \
    -DSHOW_CASE=${1} \
    repro.vert
}

echo -n "Compiles without error..."
compile 1
echo "done."

echo -n "Compiles without error..."
compile 2
echo "done."

echo "Compils with error:"
compile 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant