Skip to content
Merged
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
6 changes: 3 additions & 3 deletions framework/builder_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ inline BuilderType &BuilderBase<bindingType, BuilderType, CreateInfoType>::with_
template <vkb::BindingType bindingType, typename BuilderType, typename CreateInfoType>
inline BuilderType &BuilderBase<bindingType, BuilderType, CreateInfoType>::with_implicit_sharing_mode()
{
create_info.sharingMode = (create_info.queueFamilyIndexCount != 0) ? vk::SharingMode::eConcurrent : vk::SharingMode::eExclusive;
create_info.sharingMode = (1 < create_info.queueFamilyIndexCount) ? vk::SharingMode::eConcurrent : vk::SharingMode::eExclusive;
return *static_cast<BuilderType *>(this);
}

Expand Down Expand Up @@ -153,11 +153,11 @@ inline BuilderType &BuilderBase<bindingType, BuilderType, CreateInfoType>::with_
{
if constexpr (bindingType == vkb::BindingType::Cpp)
{
create_info.sharingMode = static_cast<VkSharingMode>(sharing_mode);
create_info.sharingMode = sharing_mode;
}
else
{
create_info.sharingMode = sharing_mode;
create_info.sharingMode = static_cast<vk::SharingMode>(sharing_mode);
}
return *static_cast<BuilderType *>(this);
}
Expand Down
41 changes: 16 additions & 25 deletions framework/core/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct BufferBuilder
using DeviceSizeType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::DeviceSize, VkDeviceSize>::type;
using SharingModeType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::SharingMode, VkSharingMode>::type;

using DeviceType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPDevice, vkb::Device>::type;
using DeviceType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPDevice, vkb::Device>::type;

private:
using Parent = vkb::BuilderBase<bindingType, BufferBuilder<bindingType>, BufferCreateInfoType>;
Expand All @@ -56,8 +56,6 @@ struct BufferBuilder
Buffer<bindingType> build(DeviceType &device) const;
BufferPtr<bindingType> build_unique(DeviceType &device) const;
BufferBuilder &with_flags(BufferCreateFlagsType flags);
BufferBuilder &with_implicit_sharing_mode();
BufferBuilder &with_sharing_mode(SharingModeType sharing_mode);
BufferBuilder &with_usage(BufferUsageFlagsType usage);
};

Expand Down Expand Up @@ -94,23 +92,6 @@ inline BufferBuilder<bindingType> &BufferBuilder<bindingType>::with_flags(Buffer
return *this;
}

template <vkb::BindingType bindingType>
inline BufferBuilder<bindingType> &BufferBuilder<bindingType>::with_implicit_sharing_mode()
{
if (this->create_info.queueFamilyIndexCount != 0)
{
this->create_info.sharingMode = vk::SharingMode::eConcurrent;
}
return *this;
}

template <vkb::BindingType bindingType>
inline BufferBuilder<bindingType> &BufferBuilder<bindingType>::with_sharing_mode(SharingModeType sharing_mode)
{
this->create_info.sharingMode = sharing_mode;
return *this;
}

template <vkb::BindingType bindingType>
inline BufferBuilder<bindingType> &BufferBuilder<bindingType>::with_usage(BufferUsageFlagsType usage)
{
Expand Down Expand Up @@ -181,6 +162,9 @@ class Buffer
*/
DeviceSizeType get_size() const;

private:
static Buffer<vkb::BindingType::Cpp> create_staging_buffer_impl(vkb::core::HPPDevice &device, vk::DeviceSize size, const void *data);

private:
vk::DeviceSize size = 0;
};
Expand All @@ -198,17 +182,24 @@ inline Buffer<bindingType> Buffer<bindingType>::create_staging_buffer(DeviceType
template <vkb::BindingType bindingType>
inline Buffer<bindingType> Buffer<bindingType>::create_staging_buffer(DeviceType &device, DeviceSizeType size, const void *data)
{
BufferBuilder<bindingType> builder(size);
builder.with_vma_flags(VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
if constexpr (bindingType == vkb::BindingType::Cpp)
{
builder.with_usage(vk::BufferUsageFlagBits::eTransferSrc);
return create_staging_buffer_impl(device, size, data);
}
else
{
builder.with_usage(static_cast<VkBufferUsageFlagBits>(vk::BufferUsageFlagBits::eTransferSrc));
BufferCpp buffer = create_staging_buffer_impl(reinterpret_cast<vkb::core::HPPDevice &>(device), static_cast<vk::DeviceSize>(size), data);
return std::move(*reinterpret_cast<BufferC *>(&buffer));
}
Buffer result(device, builder);
}

template <vkb::BindingType bindingType>
inline BufferCpp Buffer<bindingType>::create_staging_buffer_impl(vkb::core::HPPDevice &device, vk::DeviceSize size, const void *data)
{
BufferBuilderCpp builder(size);
builder.with_vma_flags(VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT)
.with_usage(vk::BufferUsageFlagBits::eTransferSrc);
BufferCpp result(device, builder);
if (data != nullptr)
{
result.update(data, size);
Expand Down
9 changes: 0 additions & 9 deletions framework/core/hpp_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ struct HPPImageBuilder : public vkb::BuilderBaseCpp<HPPImageBuilder, vk::ImageCr
return *this;
}

HPPImageBuilder &with_implicit_sharing_mode()
{
if (create_info.queueFamilyIndexCount != 0)
{
create_info.sharingMode = vk::SharingMode::eConcurrent;
}
return *this;
}

HPPImage build(HPPDevice &device) const;
HPPImagePtr build_unique(HPPDevice &device) const;
};
Expand Down
16 changes: 0 additions & 16 deletions framework/core/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,6 @@ struct ImageBuilder : public vkb::BuilderBaseC<ImageBuilder, VkImageCreateInfo>
return *this;
}

ImageBuilder &with_sharing_mode(VkSharingMode sharing_mode)
{
get_create_info().sharingMode = sharing_mode;
return *this;
}

ImageBuilder &with_flags(VkImageCreateFlags flags)
{
get_create_info().flags = flags;
Expand Down Expand Up @@ -112,16 +106,6 @@ struct ImageBuilder : public vkb::BuilderBaseC<ImageBuilder, VkImageCreateInfo>
return *this;
}

ImageBuilder &with_implicit_sharing_mode()
{
VkImageCreateInfo &create_info = get_create_info();
if (create_info.queueFamilyIndexCount != 0)
{
create_info.sharingMode = VK_SHARING_MODE_CONCURRENT;
}
return *this;
}

template <typename ExtensionType>
ImageBuilder &with_extension(ExtensionType &extension)
{
Expand Down