Owns a stencil attachment and two fullscreen pipelines for stencil-masked rendering. More...
#include <mxvk/include/mxvk/mxvk_stencil.hpp>
Classes | |
| struct | PushConstants |
| Push-constant payload shared by the mask and content shaders. More... | |
Public Member Functions | |
| void | configure_attachment (VkRenderingAttachmentInfo &attachment) const |
| Fill a VkRenderingAttachmentInfo for VK_Window dynamic rendering. | |
| void | destroy () |
| Release all Vulkan resources and reset the helper to an empty state. | |
| void | draw_content (VkCommandBuffer cmd, const PushConstants &push_constants) const |
| Draw the fullscreen content pass clipped by stencil reference value 1. | |
| void | draw_mask (VkCommandBuffer cmd, const PushConstants &push_constants) const |
| Draw the fullscreen stencil-writing mask pass. | |
| VkExtent2D | extent () const noexcept |
| Return the current stencil attachment extent. | |
| void | initialize (const VulkanContext &context, VkExtent2D extent, VkFormat color_format, VkFormat depth_format, VkPipelineCache pipeline_cache, const std::string &mask_vertex_shader, const std::string &mask_fragment_shader, const std::string &content_vertex_shader, const std::string &content_fragment_shader) |
| Create the stencil attachment and fullscreen mask/content pipelines. | |
| VK_Stencil & | operator= (const VK_Stencil &)=delete |
| VK_Stencil & | operator= (VK_Stencil &&)=delete |
| void | prepare_for_rendering (VkCommandBuffer cmd) |
| Transition the stencil image for use as a dynamic-rendering stencil attachment. | |
| void | resize (VkExtent2D extent) |
| Recreate the stencil image for a new render extent. | |
| VkFormat | stencil_format () const noexcept |
| Return the selected stencil-capable image format. | |
| bool | valid () const noexcept |
| Check whether image resources are ready for rendering. | |
| VK_Stencil ()=default | |
| Construct an empty stencil helper. | |
| VK_Stencil (const VK_Stencil &)=delete | |
| VK_Stencil (VK_Stencil &&)=delete | |
| ~VK_Stencil () | |
| Destroy any live Vulkan resources owned by the helper. | |
Owns a stencil attachment and two fullscreen pipelines for stencil-masked rendering.
VK_Stencil is intended for use from VK_Window subclasses. Call initialize() once the window has a valid device and swapchain extent, call prepare_for_rendering() before VK_Window begins dynamic rendering, pass configure_attachment() through VK_Window::onConfigureDepthStencilAttachments(), then call draw_mask() before draw_content() inside VK_Window::onRecordCustomRendering().
Definition at line 26 of file mxvk_stencil.hpp.
|
default |
Construct an empty stencil helper.
| mxvk::VK_Stencil::~VK_Stencil | ( | ) |
Destroy any live Vulkan resources owned by the helper.
Definition at line 10 of file mxvk_stencil.cpp.
|
delete |
|
delete |
| void mxvk::VK_Stencil::configure_attachment | ( | VkRenderingAttachmentInfo & | attachment | ) | const |
Fill a VkRenderingAttachmentInfo for VK_Window dynamic rendering.
| attachment | Attachment info to populate when the helper is valid. |
Definition at line 90 of file mxvk_stencil.cpp.
| void mxvk::VK_Stencil::destroy | ( | ) |
Release all Vulkan resources and reset the helper to an empty state.
Definition at line 38 of file mxvk_stencil.cpp.
| void mxvk::VK_Stencil::draw_content | ( | VkCommandBuffer | cmd, |
| const PushConstants & | push_constants ) const |
Draw the fullscreen content pass clipped by stencil reference value 1.
| cmd | Command buffer recording inside the dynamic-rendering scope. |
| push_constants | Values passed to the content fragment shader. |
Definition at line 110 of file mxvk_stencil.cpp.
| void mxvk::VK_Stencil::draw_mask | ( | VkCommandBuffer | cmd, |
| const PushConstants & | push_constants ) const |
Draw the fullscreen stencil-writing mask pass.
| cmd | Command buffer recording inside the dynamic-rendering scope. |
| push_constants | Values passed to the mask fragment shader. |
Definition at line 101 of file mxvk_stencil.cpp.
|
inlinenodiscardnoexcept |
Return the current stencil attachment extent.
Definition at line 121 of file mxvk_stencil.hpp.
| void mxvk::VK_Stencil::initialize | ( | const VulkanContext & | context, |
| VkExtent2D | extent, | ||
| VkFormat | color_format, | ||
| VkFormat | depth_format, | ||
| VkPipelineCache | pipeline_cache, | ||
| const std::string & | mask_vertex_shader, | ||
| const std::string & | mask_fragment_shader, | ||
| const std::string & | content_vertex_shader, | ||
| const std::string & | content_fragment_shader ) |
Create the stencil attachment and fullscreen mask/content pipelines.
| context | Vulkan device, physical device, queue, and command pool handles. |
| extent | Size of the stencil attachment in pixels. |
| color_format | Color attachment format used by the active dynamic rendering pass. |
| depth_format | Depth attachment format used by the active dynamic rendering pass. |
| pipeline_cache | Optional pipeline cache used when creating graphics pipelines. |
| mask_vertex_shader | SPIR-V vertex shader path for the stencil-writing pass. |
| mask_fragment_shader | SPIR-V fragment shader path for the stencil-writing pass. |
| content_vertex_shader | SPIR-V vertex shader path for the stencil-tested content pass. |
| content_fragment_shader | SPIR-V fragment shader path for the stencil-tested content pass. |
Existing resources are destroyed before the new resources are created.
Definition at line 14 of file mxvk_stencil.cpp.
|
delete |
|
delete |
| void mxvk::VK_Stencil::prepare_for_rendering | ( | VkCommandBuffer | cmd | ) |
Transition the stencil image for use as a dynamic-rendering stencil attachment.
| cmd | Command buffer currently recording outside a rendering scope. |
Definition at line 62 of file mxvk_stencil.cpp.
| void mxvk::VK_Stencil::resize | ( | VkExtent2D | extent | ) |
Recreate the stencil image for a new render extent.
| extent | New attachment size in pixels. |
Pipelines are retained because they depend on formats, not image dimensions.
Definition at line 53 of file mxvk_stencil.cpp.
|
inlinenodiscardnoexcept |
Return the selected stencil-capable image format.
Definition at line 118 of file mxvk_stencil.hpp.
|
nodiscardnoexcept |
Check whether image resources are ready for rendering.
Definition at line 119 of file mxvk_stencil.cpp.