microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] Validation Error: ID decorated with RelaxedPrecision multiple times is not allowed.

Open
#8,609 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage spirv
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
Compiling HLSL which implements relaxed-precision types to SPIR-V may fail with a SPIR-V validation error similar to the following:
ID '[SPIR-V Result ID]' decorated with RelaxedPrecision multiple times is not allowed.

This issue may be caused by optimizations around relaxed-precision arithmetic operations, possibly in tandem with loop unrolling optimizations.

When disabling optimizations and/or relaxed-precision types [Remove] -DFB_SHADERCOMPILER_16BITRELAXEDPRECISION=1, -Od, the issue will not be present.

Steps to Reproduce

  1. Checkout and build DXC at SHA: 99400dc80ffa0eb6aef56fc6e482f5eff40185e4 ('main' branch)
  2. Run the built dxc.exe on the following provided HLSL source file in:
    problemhlsl.zip
    with arguments:
    -T cs_6_0 -E csMipBatchBlur problemhlsl.hlsl -Fo problemshader.spv -HV 2018 -spirv -O3 -DFB_SHADERCOMPILER_16BITRELAXEDPRECISION=1
  3. Observe output for the aforementioned error.
  4. Try with optimizations and/or relaxed-precision disabled [Remove] -DFB_SHADERCOMPILER_16BITRELAXEDPRECISION=1, -Od and observe that the shader will compile to SPIR-V successfully.

Actual Behavior
Running dxc.exe with the above reproduction steps will produce the following error:

fatal error: generated SPIR-V is invalid: ID '9' decorated with RelaxedPrecision multiple times is not allowed.
  %9 = OpFAdd %float %41 %42

note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible

Environment

  • DXC version: dxcompiler.dll: 1.10(5371-99400dc8)(1.10.2605.0) - 1.10.2605.0
  • Host Operating System: Windows 11 24H2 Build 26100.7462
  • Commit SHA: 99400dc80ffa0eb6aef56fc6e482f5eff40185e4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Build DXC at commit 99400dc80ffa0eb6aef56fc6e482f5eff40185e4 and reproduce the failure with problemhlsl.hlsl from the attached archive using the listed dxc.exe flags. Compare optimized and relaxed-precision-disabled runs, then verify the optimized SPIR-V no longer reports duplicate RelaxedPrecision decorations and passes validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.