bgfx icon indicating copy to clipboard operation
bgfx copied to clipboard

stencil write mask

Open quicklyslow opened this issue 5 years ago • 3 comments

I find that the stencil write mask in DX(StencilWriteMask) and OpenGL(glStencilMask not called) are all set to 0xff in bgfx.

Is there any way I can change this stencil write mask?

In fact, I came across a problem because this stencil write mask. I want to implement a clipRect in clipRect UI, at most 8(each a stencil value bit) nested clipRects. The stencil value I set to each clipRect is 2^n(1, 2, 4...128), with the stencil write mask set to the same value, the value in stencil buffer after replace will be(1, 3, 7...255):

stencil value in buffer= (ref(2^n) & stencil write mask) | (stencil value in buffer now) & (~stencil write mask)

Then I will set stencil op to Equal to (1, 3, 7...255) and keep to do stencil test. That will be all right.

But I can't change the stencil write mask through bgfx(maybe I do not find it), so if the inner clipRect is smaller than the outer, there will be no problem with the stencil write mask being 0xff, I can test stencil by set stencil value to 2^n and Ref the same, but if the inner clipRect is bigger than the outer one, then the inner one will not be clip by the outer one.

I'm sorry that I don't know whether I express the problem clearly, and if there is something wrong, please forgive my ignorance about that.

quicklyslow avatar Nov 01 '18 09:11 quicklyslow

Any news on this?

Practically all platforms support stencil write masks. How come BGFX doesn't? :-)

Metal: https://developer.apple.com/documentation/metal/mtlstencildescriptor/1462496-writemask Vulkan: https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VkStencilOpState.html OpenGL: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glStencilMask.xhtml

Andos avatar Jun 11 '21 11:06 Andos

Any news on this?

No news.

Practically all platforms support stencil write masks. How come BGFX doesn't? :-)

It wasn't really requested hard by users.

bkaradzic avatar Jun 11 '21 14:06 bkaradzic

I noticed it is in the opengl codebase but it was commented out any particular reason why this is the case? doesn't seem like it would be too much to support.

pollend avatar Jan 11 '23 02:01 pollend