8000 Add explicit allocation names by exdal · Pull Request #139 · martty/vuk · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add explicit allocation names #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: new-FE-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/vuk/IR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ namespace vuk {
// TODO: crimes
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Winvalid-offsetof"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
auto image_offsets = std::vector<size_t>{ offsetof(ImageAttachment, extent) + offsetof(Extent3D, width),
offsetof(ImageAttachment, extent) + offsetof(Extent3D, height),
offsetof(ImageAttachment, extent) + offsetof(Extent3D, depth),
Expand All @@ -837,6 +839,7 @@ namespace vuk {
offsetof(ImageAttachment, layer_count),
offsetof(ImageAttachment, base_level),
offsetof(ImageAttachment, level_count) };
#pragma GCC diagnostic pop
#pragma clang diagnostic pop
auto image_type = emplace_type(std::shared_ptr<Type>(new Type{ .kind = Type::COMPOSITE_TY,
.size = sizeof(ImageAttachment),
Expand Down
14 changes: 13 additions & 1 deletion include/vuk/runtime/vk/Allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace vuk {

virtual Result<void, AllocateException> allocate_buffers(std::span<Buffer> dst, std::span<const BufferCreateInfo> cis, SourceLocationAtFrame loc) = 0;
virtual void deallocate_buffers(std::span<const Buffer> dst) = 0;
virtual void set_buffer_allocation_name(Buffer& dst, Name name) = 0;

virtual Result<void, AllocateException>
allocate_framebuffers(std::span<VkFramebuffer> dst, std::span<const FramebufferCreateInfo> cis, SourceLocationAtFrame loc) = 0;
Expand All @@ -64,6 +65,7 @@ namespace vuk {
// gpu only
virtual Result<void, AllocateException> allocate_images(std::span<Image> dst, std::span<const ImageCreateInfo> cis, SourceLocationAtFrame loc) = 0;
virtual void deallocate_images(std::span<const Image> dst) = 0;
virtual void set_image_allocation_name(Image& dst, Name name) = 0;

virtual Result<void, AllocateException>
allocate_image_views(std::span<ImageView> dst, std::span<const ImageViewCreateInfo> cis, SourceLocationAtFrame loc) = 0;
Expand Down Expand Up @@ -228,6 +230,11 @@ namespace vuk {
/// @param src Span of buffers to be deallocated
void deallocate(std::span<const Buffer> src);

/// @brief Set name of the underlying VMA allocation
/// @param dst Destination buffer
/// @param name Name of the allocation
void set_allocation_name(Buffer& dst, Name name);

/// @brief Allocate framebuffers from this Allocator
/// @param dst Destination span to place allocated framebuffers into
/// @param cis Per-element construction info
Expand Down Expand Up @@ -266,6 +273,11 @@ namespace vuk {
/// @param src Span of images to be deallocated
void deallocate(std::span<const Image> src);

/// @brief Set name of the underlying VMA allocation
/// @param dst Destination image
/// @param name Name of the allocation
void set_allocation_name(Image& dst, Name name);

/// @brief Allocate image views from this Allocator
/// @param dst Destination span to place allocated image views into
/// @param cis Per-element construction info
Expand Down Expand Up @@ -558,4 +570,4 @@ namespace vuk {
payload = std::move(value);
}
}
} // namespace vuk
} // namespace vuk
17 changes: 11 additions & 6 deletions include/vuk/runtime/vk/DeviceNestedResource.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "vuk/runtime/vk/Allocator.hpp"
#include "vuk/Exception.hpp"
#include "vuk/runtime/vk/Allocator.hpp"
#include "vuk/vuk_fwd.hpp"

namespace vuk {
Expand Down Expand Up @@ -32,6 +32,8 @@ namespace vuk {

void deallocate_buffers(std::span<const Buffer> src) override;

void set_buffer_allocation_name(Buffer& dst, Name name) override final;

Result<void, AllocateException>
allocate_framebuffers(std::span<VkFramebuffer> dst, std::span<const FramebufferCreateInfo> cis, SourceLocationAtFrame loc) override;

Expand All @@ -41,6 +43,8 @@ namespace vuk {

void deallocate_images(std::span<const Image> src) override;

void set_image_allocation_name(Image& dst, Name name) override final;

Result<void, AllocateException>
allocate_image_views(std::span<ImageView> dst, std::span<const ImageViewCreateInfo> cis, SourceLocationAtFrame loc) override;

Expand Down Expand Up @@ -85,17 +89,18 @@ namespace vuk {

void deallocate_swapchains(std::span<const VkSwapchainKHR> src) override;

Result<void, AllocateException>
allocate_graphics_pipelines(std::span<GraphicsPipelineInfo> dst, std::span<const GraphicsPipelineInstanceCreateInfo> cis, SourceLocationAtFrame loc) override;
Result<void, AllocateException> allocate_graphics_pipelines(std::span<GraphicsPipelineInfo> dst,
std::span<const GraphicsPipelineInstanceCreateInfo> cis,
SourceLocationAtFrame loc) override;
void deallocate_graphics_pipelines(std::span<const GraphicsPipelineInfo> src) override;

Result<void, AllocateException>
allocate_compute_pipelines(std::span<ComputePipelineInfo> dst, std::span<const ComputePipelineInstanceCreateInfo> cis, SourceLocationAtFrame loc) override;
void deallocate_compute_pipelines(std::span<const ComputePipelineInfo> src) override;

Result<void, AllocateException> allocate_ray_tracing_pipelines(std::span<RayTracingPipelineInfo> dst,
std::span<const RayTracingPipelineInstanceCreateInfo> cis,
SourceLocationAtFrame loc) override;
std::span<const RayTracingPipelineInstanceCreateInfo> cis,
SourceLocationAtFrame loc) override;
void deallocate_ray_tracing_pipelines(std::span<const RayTracingPipelineInfo> src) override;

Result<void, AllocateException>
Expand All @@ -108,4 +113,4 @@ namespace vuk {

DeviceResource* upstream = nullptr;
};
} // namespace vuk
} // namespace vuk
10 changes: 7 additions & 3 deletions include/vuk/runtime/vk/DeviceVkResource.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "vuk/runtime/vk/Allocator.hpp"
#include "vuk/Config.hpp"
#include "vuk/runtime/vk/Allocator.hpp"

namespace vuk {
/// @brief Device resource that performs direct allocation from the resources from the Vulkan runtime.
Expand Down Expand Up @@ -38,6 +38,8 @@ namespace vuk {

void deallocate_buffers(std::span<const Buffer> src) override;

void set_buffer_allocation_name(Buffer& dst, Name name) override final;

Result<void, AllocateException>
allocate_framebuffers(std::span<VkFramebuffer> dst, std::span<const FramebufferCreateInfo> cis, SourceLocationAtFrame loc) override;

Expand All @@ -47,6 +49,8 @@ namespace vuk {

void deallocate_images(std::span<const Image> src) override;

void set_image_allocation_name(Image& dst, Name name) override final;

Result<void, AllocateException>
allocate_image_views(std::span<ImageView> dst, std::span<const ImageViewCreateInfo> cis, SourceLocationAtFrame loc) override;

Expand Down Expand Up @@ -91,7 +95,7 @@ namespace vuk {

void deallocate_swapchains(std::span<const VkSwapchainKHR> src) override;

Result<void, AllocateException> allocate_graphics_pipelines(std::span<GraphicsPipelineInfo> dst,
Result<void, AllocateException> allocate_graphics_pipelines(std::span<GraphicsPipelineInfo> dst,
std::span<const GraphicsPipelineInstanceCreateInfo> cis,
SourceLocationAtFrame loc) override;
void deallocate_graphics_pipelines(std::span<const GraphicsPipelineInfo> src) override;
Expand Down Expand Up @@ -119,4 +123,4 @@ namespace vuk {
private:
struct DeviceVkResourceImpl* impl;
};
} // namespace vuk
} // namespace vuk
8 changes: 8 additions & 0 deletions src/runtime/vk/Allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ namespace vuk {
device_resource->deallocate_buffers(src);
}

void Allocator::set_allocation_name(Buffer& dst, Name name) {
device_resource->set_buffer_allocation_name(dst, name);
}

Result<void, AllocateException> Allocator::allocate(std::span<VkFramebuffer> dst, std::span<const FramebufferCreateInfo> cis, SourceLocationAtFrame loc) {
return device_resource->allocate_framebuffers(dst, cis, loc);
}
Expand All @@ -109,6 +113,10 @@ namespace vuk {
device_resource->deallocate_images(src);
}

void Allocator::set_allocation_name(Image& dst, Name name) {
device_resource->set_image_allocation_name(dst, name);
}

Result<void, AllocateException> Allocator::allocate(std::span<ImageView> dst, std::span<const ImageViewCreateInfo> cis, SourceLocationAtFrame loc) {
return device_resource->allocate_image_views(dst, cis, loc);
}
Expand Down
18 changes: 17 additions & 1 deletion src/runtime/vk/DeviceVkResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ namespace vuk {
}
}

void DeviceVkResource::set_buffer_allocation_name(Buffer& dst, Name name) {
vmaSetAllocationName(impl->allocator, static_cast<VmaAllocation>(dst.allocation), name.c_str());
}

Result<void, AllocateException> DeviceVkResource::allocate_images(std::span<Image> dst, std::span<const ImageCreateInfo> cis, SourceLocationAtFrame loc) {
assert(dst.size() == cis.size());
for (int64_t i = 0; i < (int64_t)dst.size(); i++) {
Expand Down Expand Up @@ -288,6 +292,10 @@ namespace vuk {
}
}

void DeviceVkResource::set_image_allocation_name(Image& dst, Name name) {
vmaSetAllocationName(impl->allocator, static_cast<VmaAllocation>(dst.allocation), name.c_str());
}

Result<void, AllocateException>
DeviceVkResource::allocate_image_views(std::span<ImageView> dst, std::span<const ImageViewCreateInfo> cis, SourceLocationAtFrame loc) {
assert(dst.size() == cis.size());
Expand Down Expand Up @@ -1102,6 +1110,10 @@ namespace vuk {
upstream->deallocate_buffers(src);
}

void DeviceNestedResource::set_buffer_allocation_name(Buffer& dst, Name name) {
upstream->set_buffer_allocation_name(dst, name);
}

Result<void, AllocateException>
DeviceNestedResource::allocate_framebuffers(std::span<VkFramebuffer> dst, std::span<const FramebufferCreateInfo> cis, SourceLocationAtFrame loc) {
return upstream->allocate_framebuffers(dst, cis, loc);
Expand All @@ -1119,6 +1131,10 @@ namespace vuk {
upstream->deallocate_images(src);
}

void DeviceNestedResource::set_image_allocation_name(Image& dst, Name name) {
upstream->set_image_allocation_name(dst, name);
}

Result<void, AllocateException>
DeviceNestedResource::allocate_image_views(std::span<ImageView> dst, std::span<const ImageViewCreateInfo> cis, SourceLocationAtFrame loc) {
return upstream->allocate_image_views(dst, cis, loc);
Expand Down Expand Up @@ -1232,4 +1248,4 @@ namespace vuk {
void DeviceNestedResource::deallocate_render_passes(std::span<const VkRenderPass> src) {
return upstream->deallocate_render_passes(src);
}
} // namespace vuk
} // namespace vuk
0