[Gameplay] Reduce loom cost
[0ad.git] / source / graphics / ShaderProgram.h
blobcb043ace7de83e586e0f41483902c492934121db
1 /* Copyright (C) 2023 Wildfire Games.
2 * This file is part of 0 A.D.
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef INCLUDED_SHADERPROGRAM
19 #define INCLUDED_SHADERPROGRAM
21 #include "graphics/ShaderDefines.h"
22 #include "graphics/ShaderProgramPtr.h"
23 #include "lib/file/vfs/vfs_path.h"
24 #include "ps/CStr.h"
25 #include "renderer/backend/IShaderProgram.h"
27 #include <vector>
29 /**
30 * A wrapper for backend shader program to handle high-level operations like
31 * file reloading and handling errors on reload.
33 class CShaderProgram
35 NONCOPYABLE(CShaderProgram);
37 public:
38 static CShaderProgramPtr Create(
39 Renderer::Backend::IDevice* device, const CStr& name, const CShaderDefines& defines);
41 void Reload();
43 std::vector<VfsPath> GetFileDependencies() const;
45 Renderer::Backend::IShaderProgram* GetBackendShaderProgram() { return m_BackendShaderProgram.get(); }
47 // TODO: add reloadable handles.
49 protected:
50 CShaderProgram(
51 Renderer::Backend::IDevice* device, const CStr& name, const CShaderDefines& defines);
53 Renderer::Backend::IDevice* m_Device = nullptr;
54 CStr m_Name;
55 CShaderDefines m_Defines;
56 std::unique_ptr<Renderer::Backend::IShaderProgram> m_BackendShaderProgram;
59 #endif // INCLUDED_SHADERPROGRAM