Files
OpenVulkano/openVulkanoCpp/Vulkan/Metal/MetalTextureCache.h
2024-07-09 13:43:09 +02:00

36 lines
875 B
Objective-C

/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "MetalBackedTexture.h"
#import <CoreVideo/CVPixelBuffer.h>
#import <CoreVideo/CVMetalTextureCache.h>
namespace OpenVulkano::Vulkan
{
class MetalTextureCache
{
CVMetalTextureCacheRef m_textureCache = nullptr;
Vulkan::ResourceManager* m_resourceManager = nullptr;
std::map<void*, MetalBackedTexture> m_mtlToVkTextureMap;
public:
~MetalTextureCache() { if (m_resourceManager) Close(); }
void Init(IRenderer* renderer);
void Close();
Scene::Texture* Get(CVPixelBufferRef pixelBuffer, MTLPixelFormat pixelFormat);
void ReturnTexture(Scene::Texture* texture);
operator bool() const { return m_resourceManager; }
};
}