Nik02, on 26 February 2012 - 05:49 AM, said:
What about a situation in which a PS5.0 shader writes (potentially conditionally) to a read/write resource after the clip instruction?
I haven't tried it, but I assume that the hardware would be forced to execute enough of the shader to successfully write to the UAV. This is because the spec says that discard should just indicate that the pixel should not be output to the render/depth target...if the hardware decides to early-out the shader as the result of a discard this is purely an opimization, and not part of the behavior specified by that instruction in the spec.
There's a similar situation with UAV's and early z/stencil testing. If you use a UAV the hardware has to turn off early z hardware, since the logical pipeline dictates that the z/stencil testing should actually happen
after the pixel shader and thus shouldn't prevent UAV writes from occurring. This is why there's an earlydepthstencil attribute which you can use to force early z/stencil tests to prevent UAV writes.
EDIT: So I tried writing to a RWTexture2D with a pixel shader that uses discard, and it turns out that the discard will prevent UAV write on my 6970. Interestingly enough, if I put the write
before the discard then the write always goes through. I have no idea whether or not this is defined behavior.