[SPIR-V] lit computes specular as n_dot_h * m and fails for half

Aperta
#9,123 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à
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
compilers

Direzione di ricerca

Start by reproducing with dxc -T cs_6_5 -E main -spirv repro.hlsl using the shader in the issue, and compare the OpFMul output with the DXIL path. The lit lowering for SPIR-V needs to emit a Pow (GLSL.std.450) for the specular term, and the half overload must produce operands whose types match the result type. Done means the SPIR-V validates and lit(0.5, 0.25, 2) yields (1, 0.5, 0.0625, 1).

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

Descrizione

spirv

lit is wrong when targeting SPIR-V:

  1. The specular term is computed as n_dot_h * m instead of pow(n_dot_h, m). DXIL is correct.
  2. The half overload fails to compile.
Repro

dxc -T cs_6_5 -E main -spirv repro.hlsl

RWStructuredBuffer<float4> Out : register(u0);
StructuredBuffer<float> In : register(t1);

[numthreads(1,1,1)]
void main() {
  Out[0] = lit(In[0], In[1], In[2]);
}

Output contains OpFMul %float %n_dot_h %m instead of a Pow. For example, lit(0.5, 0.25, 2) returns (1, 0.5, 0.5, 1) instead of (1, 0.5, 0.0625, 1).

Replacing float with half and adding -enable-16bit-types fails with:

fatal error: generated SPIR-V is invalid: GLSL.std.450 FMax: expected types of all operands to be equal to Result Type
  %34 = OpExtInst %float %1 FMax %float_0 %29

With constant half arguments (lit((half)0.25, (half)0.5, (half)3.0)), it fails with Internal compiler error: LLVM Assert.

Found by llvm/offload-test-suite#1724.

Lingua principale
C++
Stelle
3.7k
Fork
926
Merge medio
3g 22h
PR unite (30g)
45

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.