ConfettiFX / The-Forge

The Forge Cross-Platform Rendering Framework PC Windows, Steamdeck (native), Ray Tracing, macOS / iOS, Android, XBOX, PS4, PS5, Switch, Quest 2
Apache License 2.0
4.65k stars 491 forks source link

Vk/Stencil test reference value not exposed #217

Closed gjaegy closed 2 years ago

gjaegy commented 2 years ago

Hi,

It seems TheForge doesn't expose the stencil test reference value in it's public interface. Is there any reason for that ?

For instance, util_to_depth_desc() (in vulkan.cpp) set both front and back reference to 0... I'm going to add it, however, I thought I would ask first, as stencil test is still a commonly used feature. Have I missed any point ?

Cheers, Gregory Jaegy

manas-kulkarni commented 2 years ago

Shouldn't cmdSetStencilReferenceValue cover this for you?

gjaegy commented 2 years ago

Hi, you are right, this will work. Thanks for that.

It seems the version of TheForge we are using is a bit older and doesn't contain this additon. I've been able to easily patch it here, temporarly, adding a member in the DepthStateDesc structure and passing it down to the VkPipelineDepthStencilStateCreateInfo structure in Vulkan.cpp/util_to_depth_desc().

Actually the static way (i.e. the patch I've done) works well for us, out of curiosity, is there any specific reason to use a dynamic state instead ? I'll use cmdSetStencilReferenceValue() in the future once we decide to update (I guess there is no significant performance penalty, isn't it?).

manas-kulkarni commented 2 years ago

The only reason is different stencil reference values mean more pipelines as stencil reference will be baked into the pipeline state. Using a dynamic state for stencil reference makes it more flexible. We haven't seen any performance problems.

Another reason is DX12, Metal, ... don't have the option to bake stencil reference into the PSO. So we have to settle for this option.

wolfgangfengel commented 2 years ago

Can we close it?

gjaegy commented 2 years ago

Yes we can, thanks!


From: Wolfgang Engel @.> Sent: Tuesday, September 14, 2021 9:25:56 PM To: ConfettiFX/The-Forge @.> Cc: gjaegy @.>; Author @.> Subject: Re: [ConfettiFX/The-Forge] Vk/Stencil test reference value not exposed (#217)

Can we close it?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ConfettiFX/The-Forge/issues/217#issuecomment-919449571, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAG3ZUIJU3FC7UGDLOYIJB3UB6OUJANCNFSM5EAAR7DQ. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.