2023-06-14 09:06:22 +02:00
|
|
|
/* Copyright (C) 2023 Wildfire Games.
|
2023-12-03 01:30:12 +01:00
|
|
|
* This file is part of 0 A.D.
|
2011-03-26 21:17:21 +01:00
|
|
|
*
|
2023-12-03 01:30:12 +01:00
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
2011-03-26 21:17:21 +01:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2023-12-03 01:30:12 +01:00
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
2011-03-26 21:17:21 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2023-12-03 01:30:12 +01:00
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
2011-03-26 21:17:21 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_SHADERPROGRAM
|
|
|
|
#define INCLUDED_SHADERPROGRAM
|
|
|
|
|
2022-03-14 23:16:14 +01:00
|
|
|
#include "graphics/ShaderDefines.h"
|
2014-07-03 03:00:25 +02:00
|
|
|
#include "graphics/ShaderProgramPtr.h"
|
2011-03-26 21:17:21 +01:00
|
|
|
#include "lib/file/vfs/vfs_path.h"
|
2022-03-14 23:16:14 +01:00
|
|
|
#include "ps/CStr.h"
|
|
|
|
#include "renderer/backend/IShaderProgram.h"
|
2011-03-26 21:17:21 +01:00
|
|
|
|
2021-01-12 00:23:30 +01:00
|
|
|
#include <vector>
|
2011-05-04 03:17:09 +02:00
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
/**
|
2022-03-14 23:16:14 +01:00
|
|
|
* A wrapper for backend shader program to handle high-level operations like
|
|
|
|
* file reloading and handling errors on reload.
|
2011-03-26 21:17:21 +01:00
|
|
|
*/
|
|
|
|
class CShaderProgram
|
|
|
|
{
|
|
|
|
NONCOPYABLE(CShaderProgram);
|
|
|
|
|
|
|
|
public:
|
2023-06-14 09:06:22 +02:00
|
|
|
static CShaderProgramPtr Create(
|
|
|
|
Renderer::Backend::IDevice* device, const CStr& name, const CShaderDefines& defines);
|
2011-03-26 21:17:21 +01:00
|
|
|
|
2022-03-14 23:16:14 +01:00
|
|
|
void Reload();
|
2011-03-26 21:17:21 +01:00
|
|
|
|
2022-03-14 23:16:14 +01:00
|
|
|
std::vector<VfsPath> GetFileDependencies() const;
|
2011-03-26 21:17:21 +01:00
|
|
|
|
2022-05-02 22:57:22 +02:00
|
|
|
Renderer::Backend::IShaderProgram* GetBackendShaderProgram() { return m_BackendShaderProgram.get(); }
|
2021-01-12 00:23:30 +01:00
|
|
|
|
2022-04-23 22:11:14 +02:00
|
|
|
// TODO: add reloadable handles.
|
|
|
|
|
2011-03-26 21:17:21 +01:00
|
|
|
protected:
|
2023-06-14 09:06:22 +02:00
|
|
|
CShaderProgram(
|
|
|
|
Renderer::Backend::IDevice* device, const CStr& name, const CShaderDefines& defines);
|
2012-02-09 18:55:25 +01:00
|
|
|
|
2023-06-14 09:06:22 +02:00
|
|
|
Renderer::Backend::IDevice* m_Device = nullptr;
|
2022-03-14 23:16:14 +01:00
|
|
|
CStr m_Name;
|
|
|
|
CShaderDefines m_Defines;
|
2022-05-02 22:57:22 +02:00
|
|
|
std::unique_ptr<Renderer::Backend::IShaderProgram> m_BackendShaderProgram;
|
2011-03-26 21:17:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // INCLUDED_SHADERPROGRAM
|