Skip to content

microsoft/nir_to_dxil: Avoid emitting SampleCmpLevel prior to SM 6.7 if possible

I started this patch to address the following:

There are no variants of SPIR-V functions like OpImageSampleProjDrefExplicitLod that assume LOD 0. So, when going from SPIR-V to NIR, a nir_texop_txl is emitted in those cases. The problem is that such NIR function naturally maps to SampleCmpLevel, which is not available prior to Shader Model 6.7.

However, I found chances to make it a bit more comprehensive, so the long commit description reads as the following:

This revises the logic to decide which DXIL sampling function to emit. The decision no longer depends on the shader stage.

This patch also avoids emitting SM 6.7's sampleCmpLevel() when targeting a lower SM and the LOD being constant zero (sampleCmpLevelZero() is emitted instead).

UPDATE: Simplified to solely address the SM < 6.7 compatbility issue.

CC @jenatali

Edited by Pedro J. Estébanez

Merge request reports