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

Abierto Apto para principiantes
#9,135 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
cpp
Área
compilers

Línea de trabajo

Empieza con lib/DXIL/DxilShaderFlags.cpp, donde el issue identifica la asignación del flag, y luego busca el código del validador que calcula el mismo flag. Comprueba cómo se actualiza el flag en los opcodes de sample indicados y compáralo con el comportamiento esperado en DXIL.rst. El trabajo está terminado cuando ambas rutas de cálculo del flag conservan el flag si SampleCmpBias o SampleCmpGrad aparece antes de otra instrucción de sample, y la validación acepta la declaración correspondiente.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
C++
Estrellas
3.7k
Forks
918
Merge medio
3 d 12 h
PR fusionados (30 d)
41

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/DirectXShaderCompiler

Todos los issues de microsoft/DirectXShaderCompiler

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.