Evergine 2026.5.26.921 · .NET 10 · Windows 11 · DX11 head (and WebGPU head where noted).
Desktop application: a 3D viewer for building models.
What happens
We want to sample the stencil plane of a depth-stencil target. We create the texture as typeless and ask for
a stencil-plane view, but the view that reaches the shader has the resource's own format, so the sample returns
zero.
Repro
var desc = new TextureDescription {
Type = TextureType.Texture2D,
Format = PixelFormat.R24G8_Typeless,
Width = w, Height = h, Depth = 1, ArraySize = 1, MipLevels = 1,
Flags = TextureFlags.DepthStencil | TextureFlags.ShaderResource,
Usage = ResourceUsage.Default,
SampleCount = TextureSampleCount.None,
CpuAccess = ResourceCpuAccess.None,
};
var depth = factory.CreateTexture(ref desc, "mask-depth");
// ask for the STENCIL plane
var view = factory.CreateTextureView(depth, PixelFormat.X24_Typeless_G8_UInt, 0, 1, 0, 1, null);
material.SetTextureViewValue(view, "Mask"); // shader: Texture2D<uint2> Mask : register(t0);
Actual vs expected
- Expected: the bound SRV has format
X24_Typeless_G8_UInt, and Mask.Load(...).g returns the stencil byte.
- Actual: a RenderDoc capture of the sampling draw shows the bound SRV with
viewFormat = D24S8. The
requested format was dropped in favour of the resource's own. D24S8 is not a legal SRV format on D3D11 (it
requires R24_UNorm_X8_TYPELESS for depth or X24_TYPELESS_G8_UINT for stencil), so the shader reads zero
everywhere.
Everything either side of this works
Verified in the same capture, so the fault is isolated to the view format:
- the texture creates fine with
DepthStencil | ShaderResource;
CreateTextureView returns a DX11TextureView and SetTextureViewValue binds it (note SetTextureValue
cannot — TextureView does not derive from Texture);
- the
FrameBuffer still renders correctly with the typeless depth attachment;
- the stencil writes are correct: 743 non-zero texels, all value 1, exactly the silhouette we drew;
- the read is correctly ordered after the write;
- the effect exporter accepts
Texture2D<uint2> in the shader.
Questions
- Is sampling a stencil plane supported, and is
pixelFormat meant to be honoured here?
- Does the WebGPU backend support sampling a stencil aspect? (Dawn is stricter about this.)
Evergine 2026.5.26.921 · .NET 10 · Windows 11 · DX11 head (and WebGPU head where noted).
Desktop application: a 3D viewer for building models.
What happens
We want to sample the stencil plane of a depth-stencil target. We create the texture as typeless and ask for
a stencil-plane view, but the view that reaches the shader has the resource's own format, so the sample returns
zero.
Repro
Actual vs expected
X24_Typeless_G8_UInt, andMask.Load(...).greturns the stencil byte.viewFormat = D24S8. Therequested format was dropped in favour of the resource's own.
D24S8is not a legal SRV format on D3D11 (itrequires
R24_UNorm_X8_TYPELESSfor depth orX24_TYPELESS_G8_UINTfor stencil), so the shader reads zeroeverywhere.
Everything either side of this works
Verified in the same capture, so the fault is isolated to the view format:
DepthStencil | ShaderResource;CreateTextureViewreturns aDX11TextureViewandSetTextureViewValuebinds it (noteSetTextureValuecannot —
TextureViewdoes not derive fromTexture);FrameBufferstill renders correctly with the typeless depth attachment;Texture2D<uint2>in the shader.Questions
pixelFormatmeant to be honoured here?