diff --git a/include/tz/gpu/pass.hpp b/include/tz/gpu/pass.hpp index 017bee3569..3a7f4310d4 100644 --- a/include/tz/gpu/pass.hpp +++ b/include/tz/gpu/pass.hpp @@ -106,8 +106,15 @@ namespace tz::gpu std::size_t triangle_count = 0; }; + /** + * @ingroup tz_gpu_pass + * @brief Specifies creation flags for a new compute pass. + * + * See @ref tz::gpu::pass_info for usage. + **/ struct pass_compute_state { + /// Number of workgroups (XYZ) to dispatch every frame. tz::v3u kernel = tz::v3u::zero(); }; @@ -154,6 +161,32 @@ namespace tz::gpu **/ std::expected create_pass(pass_info); + /** + * @ingroup tz_gpu_pass + * @brief Set the triangle count of an existing graphics pass. + * @param pass Graphics pass to target. If you provide a compute pass, nothing interesting happens. + * @param triangle_count New number of triangles to render every frame. + * + * When you created a graphics pass, you set an initial triangle count via @ref pass_graphics_state::triangle_count. This function will override that count, meaning the next time a pass submits GPU work, the new number of triangles will be rendered. + * + * There are no GPU-sync considerations involved when calling this function. + * @warning If you fail to pass a valid @ref pass_handle to this function, the behaviour is undefined. + */ + void pass_set_triangle_count(pass_handle graphics_pass, std::size_t triangle_count); + + /** + * @ingroup tz_gpu_pass + * @brief Set the compute kernel of an existing compute pass. + * @param pass Compute pass to target. If you provide a graphics pass, nothing interesting happens. + * @param kernel New workgroup dimensions to be dispatched every frame. + * + * When you created a compute pass, you set an initial kernel size via @ref pass_compute_state::kernel. This function will override those dimensions, meaning the next time a pass submits GPU work, the new workgroup dimensions will be dispatched. + * + * There are no GPU-sync considerations involved when calling this function. + * @warning If you fail to pass a valid @ref pass_handle to this function, the behaviour is undefined. + */ + void pass_set_kernel(pass_handle compute_pass, tz::v3u kernel); + /** * @ingroup tz_gpu_pass * @brief Manually destroy a pass. diff --git a/src/tz/gpu/rhi_vulkan.cpp b/src/tz/gpu/rhi_vulkan.cpp index 65d827bfb0..f4eddd607b 100644 --- a/src/tz/gpu/rhi_vulkan.cpp +++ b/src/tz/gpu/rhi_vulkan.cpp @@ -1332,6 +1332,16 @@ namespace tz::gpu return ret; } + void pass_set_triangle_count(pass_handle graphics_pass, std::size_t triangle_count) + { + passes[graphics_pass.peek()].info.graphics.triangle_count = triangle_count; + } + + void pass_set_kernel(pass_handle compute_pass, tz::v3u kernel) + { + passes[compute_pass.peek()].info.compute.kernel = kernel; + } + void destroy_pass(pass_handle pass) { auto i = pass.peek();