70 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);
110 [[nodiscard]] VkFormat
stencil_format() const noexcept {
return stencil_image_format; }
113 [[nodiscard]] VkExtent2D
extent() const noexcept {
return stencil_extent; }
116 [[nodiscard]]
bool valid() const noexcept;
120 void create_resources();
123 void create_pipelines();
126 void destroy_pipelines();
129 void destroy_image();
132 [[nodiscard]] VkFormat choose_stencil_format() const;
142 [[nodiscard]] VkPipeline create_pipeline(const std::
string &vertex_shader, const std::
string &fragment_shader, VkPipelineLayout layout,
bool writes_stencil) const;
145 VkExtent2D stencil_extent{};
146 VkFormat render_color_format = VK_FORMAT_UNDEFINED;
147 VkFormat render_depth_format = VK_FORMAT_UNDEFINED;
148 VkFormat stencil_image_format = VK_FORMAT_UNDEFINED;
149 VkPipelineCache cache = VK_NULL_HANDLE;
150 std::string mask_vertex_path{};
151 std::string mask_fragment_path{};
152 std::string content_vertex_path{};
153 std::string content_fragment_path{};
155 VkImage image = VK_NULL_HANDLE;
156 VkDeviceMemory memory = VK_NULL_HANDLE;
157 VkImageView view = VK_NULL_HANDLE;
158 bool image_initialized =
false;
160 VkPipelineLayout mask_layout = VK_NULL_HANDLE;
161 VkPipelineLayout content_layout = VK_NULL_HANDLE;
162 VkPipeline mask_pipeline = VK_NULL_HANDLE;
163 VkPipeline content_pipeline = VK_NULL_HANDLE;
VK_Stencil(VK_Stencil &&)=delete
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(const VK_Stencil &)=delete
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 draw_content(VkCommandBuffer cmd, const PushConstants &push_constants) const
Draw the fullscreen content pass clipped by stencil reference value 1.
VK_Stencil()=default
Construct an empty stencil helper.
void prepare_for_rendering(VkCommandBuffer cmd)
Transition the stencil image for use as a dynamic-rendering stencil attachment.
VK_Stencil & operator=(VK_Stencil &&)=delete
void destroy()
Release all Vulkan resources and reset the helper to an empty state.
VkFormat stencil_format() const noexcept
Return the selected stencil-capable image format.
VK_Stencil & operator=(const VK_Stencil &)=delete
void resize(VkExtent2D extent)
Recreate the stencil image for a new render extent.
void configure_attachment(VkRenderingAttachmentInfo &attachment) const
Fill a VkRenderingAttachmentInfo for VK_Window dynamic rendering.
bool valid() const noexcept
Check whether image resources are ready for rendering.
Minimal Vulkan handles shared across MXVK helpers.
Reusable Vulkan buffer, image, upload, and one-shot command helpers.
Utilities for loading and saving PNG images.
Push-constant payload shared by the mask and content shaders.
float time
Elapsed animation time in seconds.
float phase
User-defined phase value for animated stencil/content shaders.
float aspect
Render target width divided by height.
float scale
User-defined scale value for stencil/content shaders.
Minimal Vulkan handles required by MXVK resource helpers.