MonoGame icon indicating copy to clipboard operation
MonoGame copied to clipboard

Cannot create SamplerComparisonState in HLSL

Open LilithSilver opened this issue 7 months ago • 0 comments

This does not work:

SamplerComparisonState MySampler
{
    Filter = COMPARISON_MIN_MAG_LINEAR_MIP_POINT;
    AddressU = Clamp;
    AddressV = Clamp;
    ComparisonFunc = LESS;
};

Nor does this:

SamplerComparisonState MySampler
{
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    MipFilter = POINT;
    AddressU = Clamp;
    AddressV = Clamp;
    ComparisonFunc = LESS;
};

But this does work:

SamplerComparisonState MySampler : register(ps, s0);
var mySampler = new SamplerState()
{
    Filter = TextureFilter.LinearMipPoint,
    FilterMode = TextureFilterMode.Comparison,
    AddressU = TextureAddressMode.Clamp,
    AddressV = TextureAddressMode.Clamp,
    ComparisonFunction = CompareFunction.Less,
};
device.SamplerStates[0] = mySampler;

However, all 3 compile fine. If this behavior is expected, an error should be produced in the HLSL case.

LilithSilver avatar Jun 19 '25 01:06 LilithSilver