Line data Source code
1 : /* Copyright (C) 2022 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
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.
8 : *
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.
13 : *
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/>.
16 : */
17 :
18 : #include "precompiled.h"
19 :
20 : #include "ShaderTechnique.h"
21 :
22 : #include "graphics/ShaderProgram.h"
23 : #include "renderer/backend/IDevice.h"
24 :
25 0 : CShaderPass::CShaderPass(
26 : std::unique_ptr<Renderer::Backend::IGraphicsPipelineState> pipelineState,
27 0 : const CShaderProgramPtr& shader)
28 0 : : m_Shader(shader), m_PipelineState(std::move(pipelineState))
29 : {
30 0 : ENSURE(shader);
31 0 : }
32 :
33 60 : CShaderTechnique::CShaderTechnique(
34 : const VfsPath& path, const CShaderDefines& defines,
35 60 : const PipelineStateDescCallback& callback)
36 60 : : m_Path(path), m_Defines(defines), m_PipelineStateDescCallback(callback)
37 : {
38 60 : }
39 :
40 0 : void CShaderTechnique::SetPasses(std::vector<CShaderPass>&& passes)
41 : {
42 0 : m_Passes = std::move(passes);
43 0 : }
44 :
45 0 : int CShaderTechnique::GetNumPasses() const
46 : {
47 0 : return m_Passes.size();
48 : }
49 :
50 0 : Renderer::Backend::IShaderProgram* CShaderTechnique::GetShader(int pass) const
51 : {
52 0 : ENSURE(0 <= pass && pass < (int)m_Passes.size());
53 0 : return m_Passes[pass].GetPipelineState()->GetShaderProgram();
54 : }
55 :
56 : Renderer::Backend::IGraphicsPipelineState*
57 0 : CShaderTechnique::GetGraphicsPipelineState(int pass) const
58 : {
59 0 : ENSURE(0 <= pass && pass < static_cast<int>(m_Passes.size()));
60 0 : return m_Passes[pass].GetPipelineState();
61 : }
62 :
63 0 : bool CShaderTechnique::GetSortByDistance() const
64 : {
65 0 : return m_SortByDistance;
66 : }
67 :
68 0 : void CShaderTechnique::SetSortByDistance(bool enable)
69 : {
70 0 : m_SortByDistance = enable;
71 3 : }
|