Files
MapLibreParticleLab/include/mbgl/vulkan/dynamic_texture.hpp
2026-06-23 17:39:50 +02:00

45 lines
1.3 KiB
C++

#pragma once
#include <mbgl/gfx/dynamic_texture.hpp>
#include <mbgl/vulkan/texture2d.hpp>
#define DYNAMIC_TEXTURE_VULKAN_MULTITHREADED_UPLOAD 0
namespace mbgl {
namespace vulkan {
class Context;
struct BufferAllocation;
using SharedBufferAllocation = std::shared_ptr<BufferAllocation>;
class DynamicTexture : public gfx::DynamicTexture {
public:
DynamicTexture(Context& context, Size size, gfx::TexturePixelType pixelType);
~DynamicTexture() override;
void uploadImage(const uint8_t* pixelData, gfx::TextureHandle& texHandle) override;
void uploadDeferredImages(gfx::UploadPass&) override;
bool removeTexture(const gfx::TextureHandle& texHandle) override;
#if DYNAMIC_TEXTURE_VULKAN_MULTITHREADED_UPLOAD
using TexturesToBlit =
std::unordered_map<gfx::TextureHandle, std::shared_ptr<vulkan::Texture2D>, gfx::TextureHandle::Hasher>;
#else
using TextureBuffersToUpload =
std::unordered_map<gfx::TextureHandle, SharedBufferAllocation, gfx::TextureHandle::Hasher>;
#endif
private:
vulkan::Context& context;
#if DYNAMIC_TEXTURE_VULKAN_MULTITHREADED_UPLOAD
TexturesToBlit texturesToBlit;
vk::UniqueCommandPool commandPool;
#else
TextureBuffersToUpload textureBuffersToUpload;
#endif
};
} // namespace vulkan
} // namespace mbgl