Vulkan: Pipeline pool #120899

Merged
Jeroen Bakker merged 12 commits from Jeroen-Bakker/blender:vulkan/pipeline-pool into main 2024-04-23 12:39:57 +02:00
5 changed files with 12 additions and 75 deletions
Showing only changes of commit 299147e3b9 - Show all commits

View File

@ -140,20 +140,11 @@ void VKBackend::samplers_update()
void VKBackend::compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len)
{
VKContext &context = *VKContext::get();
if (use_render_graph) {
render_graph::VKDispatchCreateInfo &dispatch_info = context.update_and_get_dispatch_info();
dispatch_info.dispatch_node.group_count_x = groups_x_len;
dispatch_info.dispatch_node.group_count_y = groups_y_len;
dispatch_info.dispatch_node.group_count_z = groups_z_len;
context.render_graph.add_node(dispatch_info);
}
else {
render_graph::VKResourceAccessInfo resource_access_info = {};
context.state_manager_get().apply_bindings(context, resource_access_info);
context.bind_compute_pipeline();
VKCommandBuffers &command_buffers = context.command_buffers_get();
command_buffers.dispatch(groups_x_len, groups_y_len, groups_z_len);
}
render_graph::VKResourceAccessInfo resource_access_info = {};
context.state_manager_get().apply_bindings(context, resource_access_info);
context.bind_compute_pipeline();
VKCommandBuffers &command_buffers = context.command_buffers_get();
command_buffers.dispatch(groups_x_len, groups_y_len, groups_z_len);
}
void VKBackend::compute_dispatch_indirect(StorageBuf *indirect_buf)

View File

@ -213,51 +213,6 @@ void VKContext::bind_compute_pipeline()
}
}
void VKContext::update_pipeline_data(render_graph::VKPipelineData &pipeline_data)
{
VKShader &vk_shader = unwrap(*shader);
pipeline_data.vk_pipeline_layout = vk_shader.vk_pipeline_layout_get();
/* Update descriptor set. */
pipeline_data.vk_descriptor_set = VK_NULL_HANDLE;
if (vk_shader.has_descriptor_set()) {
descriptor_set_.update(*this);
pipeline_data.vk_descriptor_set = descriptor_set_get().active_descriptor_set()->vk_handle();
}
/* Update push constants. */
pipeline_data.push_constants_data = nullptr;
pipeline_data.push_constants_size = 0;
const VKPushConstants::Layout &push_constants_layout =
vk_shader.interface_get().push_constants_layout_get();
if (push_constants_layout.storage_type_get() == VKPushConstants::StorageType::PUSH_CONSTANTS) {
pipeline_data.push_constants_size = push_constants_layout.size_in_bytes();
pipeline_data.push_constants_data = vk_shader.pipeline_get().push_constants_get().data();
}
}
void VKContext::update_dispatch_info()
{
dispatch_info_.dispatch_node = {};
dispatch_info_.resources.reset();
state_manager_get().apply_bindings(*this, dispatch_info_.resources);
update_pipeline_data(dispatch_info_.dispatch_node.pipeline_data);
VKShader &vk_shader = unwrap(*shader);
VkPipeline vk_pipeline = vk_shader.ensure_and_get_compute_pipeline();
dispatch_info_.dispatch_node.pipeline_data.vk_pipeline = vk_pipeline;
}
render_graph::VKDispatchNode::CreateInfo &VKContext::update_and_get_dispatch_info()
{
VKShader *shader = unwrap(this->shader);
/* TODO(#120959): Push constants should be moved outside VKPipeline. */
VKPipeline &pipeline = shader->pipeline_get();
pipeline.update_push_constants(*this);
update_dispatch_info();
return dispatch_info_;
}
/** \} */
/* -------------------------------------------------------------------- */

View File

@ -35,8 +35,6 @@ class VKContext : public Context, NonCopyable {
GPUTexture *surface_texture_ = nullptr;
void *ghost_context_;
render_graph::VKDispatchNode::CreateInfo dispatch_info_ = {};
public:
render_graph::VKRenderGraph render_graph;
@ -72,8 +70,6 @@ class VKContext : public Context, NonCopyable {
VKFrameBuffer *active_framebuffer_get() const;
void bind_compute_pipeline();
void update_dispatch_info();
render_graph::VKDispatchNode::CreateInfo &update_and_get_dispatch_info();
void bind_graphics_pipeline(const GPUPrimType prim_type,
const VKVertexAttributeObject &vertex_attribute_object);
@ -107,13 +103,6 @@ class VKContext : public Context, NonCopyable {
private:
void swap_buffers_pre_handler(const GHOST_VulkanSwapChainData &data);
void swap_buffers_post_handler();
/**
* Update the give shader data with the current state of the context.
*
* NOTE: Shader data structure is reused between render graph nodes.
*/
void update_pipeline_data(render_graph::VKPipelineData &pipeline_data);
};
BLI_INLINE bool operator==(const VKContext &a, const VKContext &b)

View File

@ -182,11 +182,6 @@ class VKDescriptorSetTracker : protected VKResourceTracker<VKDescriptorSet> {
VkPipelineLayout vk_pipeline_layout,
VkPipelineBindPoint vk_pipeline_bind_point);
/**
* Update the descriptor set on the device.
*/
void update(VKContext &context);
void debug_print() const;
protected:
@ -194,6 +189,12 @@ class VKDescriptorSetTracker : protected VKResourceTracker<VKDescriptorSet> {
private:
Binding &ensure_location(VKDescriptorSet::Location location);
/**
* Update the descriptor set on the device.
*/
void update(VKContext &context);
};
} // namespace blender::gpu

View File

@ -48,6 +48,7 @@ void VKDevice::deinit()
}
samplers_.free();
destroy_discarded_resources();
pipelines.free_data();
vkDestroyPipelineCache(vk_device_, vk_pipeline_cache_, vk_allocation_callbacks);
descriptor_set_layouts_.deinit();
vmaDestroyAllocator(mem_allocator_);