In my D3D11 project, I have an HLSL pixel shader (Shader Model 5.0) wherein I have a branch where I iterate over a bound multisampled depth texture pixel's sub-samples to find a specific (nearest depth) sample index, which I then use to sample from another bound multisampled texture. These two matched depth + color textures are the output of a previous multisampled render.
However, the output indicates that it is not taking/returning the correct sub-sample. In this case the pixel sub-samples include background (red) pixels and foreground (brown) pixels, and the shader appears to be returning red.
Doing a capture using the Graphics Debugger and inspecting the captured frame, this confirms that the output for that pixel for that draw call is indeed red. However, when I debug the pixel shader, it appears to be executing correctly. The logic and sub-sample selection is working properly, and the value being returned is the correct one (brown). Literally at "return finalColor;", finalColor is the desired brown color.
I can alter the shader to manually set the sampled color to something obvious (bright green) directly after the multi-sample Load, and this is reflected in the output as expected.
So this leads me to believe that there is some subtle issue regarding multi-sampled texture (sub)sampling that I am experiencing, which the Graphics Debugger stepping somehow avoids. To be clear, all of my sample retrievals are via Load, so there is no filtering in play.
While the Graphics Debugger stepping seems to disagree with the actual final output, the runtime output result is consistently incorrect regardless of my shader compilation settings (full release/optimization, versus full debug (no optimization/prefer branches)).
In my debug configuration I have all DX runtime + HLSL warnings as errors, full validation, and the runtime does not make a peep compiling or during execution.
Any ideas on what might be going wrong? Anyone seen anything similar or have general gotchas for multisampled texture loads?