SampleCmp with gradient or bias flag is lost when a later sample in the function has none

Aperta Adatta ai principianti
#9,135 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
compilers

Direzione di ricerca

Inizia con lib/DXIL/DxilShaderFlags.cpp, dove l’issue indica l’assegnazione del flag, quindi individua il codice del validator che calcola lo stesso flag. Controlla come viene aggiornato il flag per gli opcode di sample elencati e confronta il risultato con il comportamento previsto in DXIL.rst. Il lavoro è completato quando entrambi i percorsi di calcolo del flag mantengono il flag se SampleCmpBias o SampleCmpGrad compare prima di un’altra istruzione di sample e la validazione accetta la dichiarazione corrispondente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug needs-triage

Description
The SampleCmpGradientOrBias shader flag is not set when SampleCmpBias or SampleCmpGrad is followed in the same function by Sample, SampleBias, SampleGrad, or SampleCmp. It seems the flag depends on the order of the instructions and not on whether SampleCmpBias or SampleCmpGrad itself is used.

Steps to Reproduce

Texture2D<float> depth : register(t0);
SamplerComparisonState less : register(s0);

float4 main(float2 uv : TEXCOORD0) : SV_Target {
	return depth.SampleCmpBias(less, uv, 0.5, 1.0) + depth.SampleCmp(less, uv, 0.25);
}

Compiled with dxc -T ps_6_8 -E main you will find no additional functionality is listed, but with the two calls swapped the listing will contain

; Note: shader requires additional functionality:
;       SampleCmp with gradient or bias

Expected

The flag should be set whenever SampleCmpBias or SampleCmpGrad is used. The documentation in DXIL.rst says the feature should be listed if "Use of the instructions SampleCmpGrad or SampleCmpBias". When the flag is not present the shader is accepted on devices that lack SampleCmpGradientAndBiasSupported.

Cause
It looks like the flag is assigned rather than accumulated in lib/DXIL/DxilShaderFlags.cpp:

case DXIL::OpCode::Sample:
case DXIL::OpCode::SampleBias:
case DXIL::OpCode::SampleCmp:
case DXIL::OpCode::SampleCmpBias:
  ...
  hasSampleCmpGradientOrBias = dxilOp == DXIL::OpCode::SampleCmpBias;

Since SampleGrad and SampleCmpGrad have a case of their own with the same assignment against SampleCmpGrad, whichever of these instructions comes last in the function decides the flag. I suspect this should've been |= rather than =.

The validator also computes the flags the same way so it has the same issue. If you have a a module that declares the flag for the shader above, it too fails validation with "Flags must match usage" error.

Environment

  • DXC 1.9.2609.5
Lingua principale
C++
Stelle
3.7k
Fork
918
Merge medio
3g 12h
PR unite (30g)
41

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/DirectXShaderCompiler

Tutte le issue di microsoft/DirectXShaderCompiler

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.