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

[SPIR-V] Forward declaring a function inside another function causes a compiler crash #3214

Closed
Dredhog opened this issue Oct 21, 2020 · 0 comments · Fixed by #3310
Closed
Labels
spirv Work related to SPIR-V

Comments

@Dredhog
Copy link

Dredhog commented Oct 21, 2020

Title

Forward declaring a function inside another function causes a compiler crash.

Functional impact

Can't have forward declarations inside functions. Breaks compatibility with the DXIL backend and backward compatibility with FXC which compile the following example fine.

Minimal repro steps

1.1. Compile forward_decl_issue.txt (seen below) with dxc.exe -T ps_6_0 -E PSMain -spirv forward_decl_issue.txt:

float4 PSMain() : SV_Target
{
  float MulBy2(float f);
  return float4(MulBy2(.25), 1, 0, 1);
}

float MulBy2(float f)
{
    return f*2;
}

Expected result

Compilation succeeds.

Actual result

Compiler crashes on an assertion with the following stack: crash_stack.txt

Further technical details

DXC built from commit 530958e

@ehsannas ehsannas added the spirv Work related to SPIR-V label Oct 21, 2020
ehsannas added a commit to ehsannas/DirectXShaderCompiler that referenced this issue Dec 9, 2020
ehsannas added a commit that referenced this issue Dec 10, 2020
* [spirv] Forward declaration of function inside another.

Fixes #3214.

* Add struct to test shader.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spirv Work related to SPIR-V
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants