I have a pixel shader that is writing to both color & depth (SV_TARGET & SV_DEPTH).
If use any value derived from a structured buffer it’s fine with the color, but not with the depth. Any clues? Simplified patch & shader attached.
// load a vaule from SB float myValue = valueDefault; uint vCount, dummy; valueBuffer.GetDimensions(vCount, dummy); if (vCount > 0) myValue = valueBuffer(0); Out.Color = float4(In.TexCd.xy,0,1); Out.Depth = In.PosWVP.z/In.PosWVP.w; //error here, writing to color is fine, but depth is not happy Out.Color += myValue; //ok //Out.Depth += myValue; // not ok return Out;
DepthWrite.zip (3.5 kB)