microsoft / microsoft/DirectXShaderCompiler

Crash while linking two shaders

Open
#7,486 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug crash shader-linking
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description

First file TestLinkEntry.hlsl

float4 TestPos(in float4 posin);

struct VSInput 
{
    float4 Pos : POSITION0; 
};

struct VSOutput 
{   float4 Pos : SV_POSITION; 
};

[shader("vertex")]
VSOutput vs_main(VSInput input) 
{ 
    VSOutput output;
    float4 newPos =float4(input.Pos.xyz, 1.0f);
    output.Pos = TestPos(newPos); 
    return output;
};
LPCWSTR argsLink[] = { L"-auto-binding-space",L"0" };
LPCWSTR pTargetProfile = L"lib_6_x";

IDxcCompiler->Compile() and IDxcLinker->RegisterLibrary() as first dxclink lib

second file TestFunction.hlsl

struct CameraMat
{
    float4x4 projection;
    float4x4 view;
    float4x4 model;
};

cbuffer UBO
{ 
    CameraMat cameraMat;
};


float4 TestPos(in float4 posin){
    float4 Pos = mul(cameraMat.projection, mul(cameraMat.view, mul(cameraMat.model, posin))); 
    return Pos;
};
LPCWSTR argsLink[] = { L"-auto-binding-space",L"0" };
LPCWSTR pTargetProfile = L"lib_6_x";

IDxcCompiler->Compile() and IDxcLinker->RegisterLibrary() as second dxclink lib

last link two lib:

LPCWSTR libNames[] = { firstlib ,secondlib };
pLinker->Link(L"vs_main", L"vs_6_0", libNames,2, argsLink, _countof(argsLink), &pLinkResult));

then will crash

fistlib.txt
secondlib.txt

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

Begin by reproducing the crash with fistlib.txt and secondlib.txt, following the IDxcCompiler->Compile(), IDxcLinker->RegisterLibrary(), and pLinker->Link() calls shown in the issue. Trace the two-library link path for the vs_main entry point; done means linking these libraries no longer crashes and the result is handled normally.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.