40 lines
966 B
Objective-C
40 lines
966 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 Renderer;
|
|
|
|
class MetalTextureCache final
|
|
{
|
|
CVMetalTextureCacheRef m_textureCache = nullptr;
|
|
Vulkan::ResourceManager* m_resourceManager = nullptr;
|
|
std::map<void*, MetalBackedTexture> m_mtlToVkTextureMap;
|
|
Renderer* m_renderer;
|
|
IEventHandler* m_eventHandler = nullptr;
|
|
|
|
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; }
|
|
};
|
|
}
|