This commit finishes removing the uses of the integer to float vertex buffer fetch mode. Previous commits noted below already started that process. The last usage was geometry attributes. Now integers are converted to floats as part of the existing upload process. The change makes the Vulkan vertex buffer type conversion unused, so it's removed. That's nice because Vulkan vertex buffers go from 1040 to 568 bytes in size and have significantly less overhead on creation. Related: -153abc372e-1e1ac2bb9b-617858e453Pull Request: https://projects.blender.org/blender/blender/pulls/138873
72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
/* SPDX-FileCopyrightText: 2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "GPU_vertex_buffer.hh"
|
|
|
|
#include "vk_buffer.hh"
|
|
#include "vk_data_conversion.hh"
|
|
|
|
namespace blender::gpu {
|
|
|
|
class VKVertexBuffer : public VertBuf {
|
|
VKBuffer buffer_;
|
|
/** When a vertex buffer is used as a UNIFORM_TEXEL_BUFFER the buffer requires a buffer view. */
|
|
VkBufferView vk_buffer_view_ = VK_NULL_HANDLE;
|
|
|
|
bool data_uploaded_ = false;
|
|
|
|
public:
|
|
~VKVertexBuffer();
|
|
|
|
void bind_as_ssbo(uint binding) override;
|
|
void bind_as_texture(uint binding) override;
|
|
void wrap_handle(uint64_t handle) override;
|
|
|
|
void update_sub(uint start, uint len, const void *data) override;
|
|
void read(void *data) const override;
|
|
|
|
VkBuffer vk_handle() const
|
|
{
|
|
BLI_assert(buffer_.is_allocated());
|
|
return buffer_.vk_handle();
|
|
}
|
|
|
|
VkBufferView vk_buffer_view_get() const
|
|
{
|
|
BLI_assert(vk_buffer_view_ != VK_NULL_HANDLE);
|
|
return vk_buffer_view_;
|
|
}
|
|
|
|
void ensure_updated();
|
|
void ensure_buffer_view();
|
|
|
|
protected:
|
|
void acquire_data() override;
|
|
void resize_data() override;
|
|
void release_data() override;
|
|
void upload_data() override;
|
|
|
|
private:
|
|
void allocate();
|
|
|
|
void upload_data_direct(const VKBuffer &host_buffer);
|
|
void upload_data_via_staging_buffer(VKContext &context);
|
|
|
|
/* VKTexture requires access to `buffer_` to convert a vertex buffer to a texture. */
|
|
friend class VKTexture;
|
|
};
|
|
|
|
BLI_INLINE VKVertexBuffer *unwrap(VertBuf *vertex_buffer)
|
|
{
|
|
return static_cast<VKVertexBuffer *>(vertex_buffer);
|
|
}
|
|
|
|
} // namespace blender::gpu
|