#pragma once #include "GLExtensions.h" #include "RuntimeShaderArtifact.h" #include #include #include #include class RuntimeTextTextureCache { public: RuntimeTextTextureCache() = default; RuntimeTextTextureCache(const RuntimeTextTextureCache&) = delete; RuntimeTextTextureCache& operator=(const RuntimeTextTextureCache&) = delete; ~RuntimeTextTextureCache(); bool Configure(const RuntimeShaderArtifact& artifact, std::string& error); void UpdateArtifactState(const RuntimeShaderArtifact& artifact); void RefreshTextTextures(RuntimeShaderArtifact* artifactState = nullptr); void BindTextTextures(GLuint program); void ShutdownGl(); static void AssignSamplerUniforms(GLuint program, const RuntimeShaderArtifact& artifact); private: struct TextTexture { std::string parameterId; std::string cachedText; std::shared_ptr> cachedPixels; GLuint texture = 0; unsigned width = 0; unsigned height = 0; unsigned liveWidth = 1; unsigned maxLength = 64; }; bool EnsureTextTexture(TextTexture& texture); const RuntimePreparedTextTexture* FindPreparedTexture(const std::string& parameterId) const; static void DestroyTexture(TextTexture& texture); RuntimeShaderArtifact mArtifact; std::vector mTextTextures; };