Hi,
In our project, we want to get better performance on Xbox360, so for some specific pass, we want to use hi-stencil to do some pre-PS culling. But unfortunately, some bits of the stencil buffer were used for other reasons in other passes. So my idea is as below if restoring stencil value is available,
a. render the geometries with color writing disable, and set the unused stencil bit to my specific value.
b. render the geometries with color writing disable, and zero the unrelated stencil bits with writing mask. On the other hand, use the hi-stencil ref num same as the stencil value, with hi-stencil func notequal. So the pixels which are not on the geometries are set to culled in hi-stencil buffer.
c. render full screen quad with ps and coloring writing on. So just render on the part with hi-stencil not culled.
d. restore stencil buffer to the original value.
Yeah, I've already know that we can restore the depth value using a simple depth-restore ps with color writing disabled. My question is that, can we create a simple ps to retore stencil buffer? Or is there any other solution for my situation?