microsoft / microsoft/DirectXShaderCompiler

pack-optimized issue with domain shader

Open
#3,362 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

I am having an issue with a domain shader which reorganizes input/output signature in an unexpected way when pack-optimized compiler flag is used. This in turn gives the following error in dx12 debug layer:

D3D12 ERROR: ID3D12Device::CreateGraphicsPipelineState: Domain Shader - Pixel Shader linkage error: Signatures between stages are incompatible. Semantic 'CLIP' of the input stage has a hardware register component mask that is not a subset of the output of the previous stage. [ STATE_CREATION ERROR #662: CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGISTERMASK]

The signature passed through from VS-HS-DS-PS stages is this (it's in a shared header, so it should be the same in all stages):

struct PixelInput
{
	float4 pos : SV_POSITION;
	float  clip : SV_ClipDistance0;
	float4 pre : PREVIOUSPOSITION;
	float3 nor : NORMAL;
};

In the disassembly I can see this when using pack-optimized for domain shader:

; Output signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; PREVIOUSPOSITION         0   xyzw        0     NONE   float   xyzw
; SV_Position              0   xyzw        1      POS   float   xyzw
; SV_ClipDistance          0      w        2  CLIPDST   float      w
; NORMAL                   0   xyz         2     NONE   float   xyz

And when NOT using pack-optimized:

; Output signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Position              0   xyzw        0      POS   float   xyzw
; SV_ClipDistance          0   x           1  CLIPDST   float   x
; PREVIOUSPOSITION         0   xyzw        2     NONE   float   xyzw
; NORMAL                   0   xyz         3     NONE   float   xyz

And the pixel shader input signature when using pack-optimized:

; Input signature:
;
; Name                 Index   Mask Register SysValue  Format   Used
; -------------------- ----- ------ -------- -------- ------- ------
; SV_Position              0   xyzw        0      POS   float   xy
; SV_ClipDistance          0   x           1  CLIPDST   float
; PREVIOUSPOSITION         0   xyzw        2     NONE   float   xy w

The pack-optimized version of domain output and pixel input doesn't match as you see, which is a problem.
I am attaching the dissassemblies and command line args.
disasm.zip

Best regards,
Janos

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

Start by reproducing the domain-shader compilation with the attached command-line arguments and disassemblies, comparing output and pixel-input signatures with and without pack-optimized. Trace the signature-packing path responsible for the register assignment; done means the domain output and pixel input signatures link successfully under DirectX 12.

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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.