core: Fix dynamic texture resource management (#4337)
This commit is contained in:
@@ -14,6 +14,7 @@ namespace gfx {
|
||||
|
||||
class Context;
|
||||
class Texture2D;
|
||||
class UploadPass;
|
||||
using Texture2DPtr = std::shared_ptr<Texture2D>;
|
||||
|
||||
class TextureHandle {
|
||||
@@ -60,7 +61,7 @@ public:
|
||||
std::optional<TextureHandle> addImage(const uint8_t* pixelData, const Size& imageSize, int32_t uniqueId = -1);
|
||||
|
||||
virtual void uploadImage(const uint8_t* pixelData, TextureHandle& texHandle);
|
||||
virtual void uploadDeferredImages() {};
|
||||
virtual void uploadDeferredImages(UploadPass&) {};
|
||||
virtual bool removeTexture(const TextureHandle& texHandle);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
const ImageVersionMap& versionMap);
|
||||
|
||||
void removeTextures(const std::vector<TextureHandle>& textureHandles, const DynamicTexturePtr& dynamicTexture);
|
||||
void removeUnusedDynamicTextures();
|
||||
|
||||
private:
|
||||
Context& context;
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
DynamicTexture(Context& context, Size size, gfx::TexturePixelType pixelType);
|
||||
|
||||
void uploadImage(const uint8_t* pixelData, gfx::TextureHandle& texHandle) override;
|
||||
void uploadDeferredImages() override;
|
||||
void uploadDeferredImages(gfx::UploadPass&) override;
|
||||
bool removeTexture(const gfx::TextureHandle& texHandle) override;
|
||||
|
||||
using ImagesToUpload =
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace vulkan {
|
||||
|
||||
class Context;
|
||||
struct BufferAllocation;
|
||||
using UniqueBufferAllocation = std::unique_ptr<BufferAllocation>;
|
||||
using SharedBufferAllocation = std::shared_ptr<BufferAllocation>;
|
||||
|
||||
class DynamicTexture : public gfx::DynamicTexture {
|
||||
public:
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
~DynamicTexture() override;
|
||||
|
||||
void uploadImage(const uint8_t* pixelData, gfx::TextureHandle& texHandle) override;
|
||||
void uploadDeferredImages() override;
|
||||
void uploadDeferredImages(gfx::UploadPass&) override;
|
||||
bool removeTexture(const gfx::TextureHandle& texHandle) override;
|
||||
|
||||
#if DYNAMIC_TEXTURE_VULKAN_MULTITHREADED_UPLOAD
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
std::unordered_map<gfx::TextureHandle, std::shared_ptr<vulkan::Texture2D>, gfx::TextureHandle::Hasher>;
|
||||
#else
|
||||
using TextureBuffersToUpload =
|
||||
std::unordered_map<gfx::TextureHandle, UniqueBufferAllocation, gfx::TextureHandle::Hasher>;
|
||||
std::unordered_map<gfx::TextureHandle, SharedBufferAllocation, gfx::TextureHandle::Hasher>;
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
||||
@@ -38,6 +38,9 @@ public:
|
||||
gfx::Context& getContext() override;
|
||||
const gfx::Context& getContext() const override;
|
||||
|
||||
CommandEncoder& getCommandEncoder() { return commandEncoder; }
|
||||
const CommandEncoder& getCommandEncoder() const { return commandEncoder; }
|
||||
|
||||
std::unique_ptr<gfx::VertexBufferResource> createVertexBufferResource(const void* data,
|
||||
std::size_t size,
|
||||
gfx::BufferUsageType,
|
||||
|
||||
@@ -12,7 +12,7 @@ public:
|
||||
DynamicTexture(Context& context, Size size, gfx::TexturePixelType pixelType);
|
||||
|
||||
void uploadImage(const uint8_t* pixelData, gfx::TextureHandle& texHandle) override;
|
||||
void uploadDeferredImages() override;
|
||||
void uploadDeferredImages(gfx::UploadPass&) override;
|
||||
bool removeTexture(const gfx::TextureHandle& texHandle) override;
|
||||
|
||||
using ImagesToUpload =
|
||||
|
||||
Reference in New Issue
Block a user