@@ -45,7 +45,7 @@ struct BufferBuilder
4545 using DeviceSizeType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::DeviceSize, VkDeviceSize>::type;
4646 using SharingModeType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vk::SharingMode, VkSharingMode>::type;
4747
48- using DeviceType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPDevice, vkb::Device>::type;
48+ using DeviceType = typename std::conditional<bindingType == vkb::BindingType::Cpp, vkb::core::HPPDevice, vkb::Device>::type;
4949
5050 private:
5151 using Parent = vkb::BuilderBase<bindingType, BufferBuilder<bindingType>, BufferCreateInfoType>;
@@ -56,8 +56,6 @@ struct BufferBuilder
5656 Buffer<bindingType> build (DeviceType &device) const ;
5757 BufferPtr<bindingType> build_unique (DeviceType &device) const ;
5858 BufferBuilder &with_flags (BufferCreateFlagsType flags);
59- BufferBuilder &with_implicit_sharing_mode ();
60- BufferBuilder &with_sharing_mode (SharingModeType sharing_mode);
6159 BufferBuilder &with_usage (BufferUsageFlagsType usage);
6260};
6361
@@ -94,23 +92,6 @@ inline BufferBuilder<bindingType> &BufferBuilder<bindingType>::with_flags(Buffer
9492 return *this ;
9593}
9694
97- template <vkb::BindingType bindingType>
98- inline BufferBuilder<bindingType> &BufferBuilder<bindingType>::with_implicit_sharing_mode()
99- {
100- if (this ->create_info .queueFamilyIndexCount != 0 )
101- {
102- this ->create_info .sharingMode = vk::SharingMode::eConcurrent;
103- }
104- return *this ;
105- }
106-
107- template <vkb::BindingType bindingType>
108- inline BufferBuilder<bindingType> &BufferBuilder<bindingType>::with_sharing_mode(SharingModeType sharing_mode)
109- {
110- this ->create_info .sharingMode = sharing_mode;
111- return *this ;
112- }
113-
11495template <vkb::BindingType bindingType>
11596inline BufferBuilder<bindingType> &BufferBuilder<bindingType>::with_usage(BufferUsageFlagsType usage)
11697{
@@ -181,6 +162,9 @@ class Buffer
181162 */
182163 DeviceSizeType get_size () const ;
183164
165+ private:
166+ static Buffer<vkb::BindingType::Cpp> create_staging_buffer_impl (vkb::core::HPPDevice &device, vk::DeviceSize size, const void *data);
167+
184168 private:
185169 vk::DeviceSize size = 0 ;
186170};
@@ -198,17 +182,24 @@ inline Buffer<bindingType> Buffer<bindingType>::create_staging_buffer(DeviceType
198182template <vkb::BindingType bindingType>
199183inline Buffer<bindingType> Buffer<bindingType>::create_staging_buffer(DeviceType &device, DeviceSizeType size, const void *data)
200184{
201- BufferBuilder<bindingType> builder (size);
202- builder.with_vma_flags (VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT);
203185 if constexpr (bindingType == vkb::BindingType::Cpp)
204186 {
205- builder. with_usage (vk::BufferUsageFlagBits::eTransferSrc );
187+ return create_staging_buffer_impl (device, size, data );
206188 }
207189 else
208190 {
209- builder.with_usage (static_cast <VkBufferUsageFlagBits>(vk::BufferUsageFlagBits::eTransferSrc));
191+ BufferCpp buffer = create_staging_buffer_impl (reinterpret_cast <vkb::core::HPPDevice &>(device), static_cast <vk::DeviceSize>(size), data);
192+ return std::move (*reinterpret_cast <BufferC *>(&buffer));
210193 }
211- Buffer result (device, builder);
194+ }
195+
196+ template <vkb::BindingType bindingType>
197+ inline BufferCpp Buffer<bindingType>::create_staging_buffer_impl(vkb::core::HPPDevice &device, vk::DeviceSize size, const void *data)
198+ {
199+ BufferBuilderCpp builder (size);
200+ builder.with_vma_flags (VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT)
201+ .with_usage (vk::BufferUsageFlagBits::eTransferSrc);
202+ BufferCpp result (device, builder);
212203 if (data != nullptr )
213204 {
214205 result.update (data, size);
0 commit comments