72 VkFormat color_format,
73 VkFormat depth_format,
74 VkPipelineCache pipeline_cache,
75 const std::string &mask_vertex_shader,
76 const std::string &mask_fragment_shader,
77 const std::string &content_vertex_shader,
78 const std::string &content_fragment_shader);
118 [[nodiscard]] VkFormat
stencil_format() const noexcept {
return stencil_image_format; }
121 [[nodiscard]] VkExtent2D
extent() const noexcept {
return stencil_extent; }
124 [[nodiscard]]
bool valid() const noexcept;
128 void create_resources();
131 void create_pipelines();
134 void destroy_pipelines();
137 void destroy_image();
140 [[nodiscard]] VkFormat choose_stencil_format() const;
150 [[nodiscard]] VkPipeline create_pipeline(const std::
string &vertex_shader,
151 const std::
string &fragment_shader,
152 VkPipelineLayout layout,
153 bool writes_stencil) const;
156 VkExtent2D stencil_extent{};
157 VkFormat render_color_format = VK_FORMAT_UNDEFINED;
158 VkFormat render_depth_format = VK_FORMAT_UNDEFINED;
159 VkFormat stencil_image_format = VK_FORMAT_UNDEFINED;
160 VkPipelineCache cache = VK_NULL_HANDLE;
161 std::string mask_vertex_path{};
162 std::string mask_fragment_path{};
163 std::string content_vertex_path{};
164 std::string content_fragment_path{};
166 VkImage image = VK_NULL_HANDLE;
167 VkDeviceMemory memory = VK_NULL_HANDLE;
168 VkImageView view = VK_NULL_HANDLE;
169 bool image_initialized =
false;
171 VkPipelineLayout mask_layout = VK_NULL_HANDLE;
172 VkPipelineLayout content_layout = VK_NULL_HANDLE;
173 VkPipeline mask_pipeline = VK_NULL_HANDLE;
174 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.