Merge 'remotes/trunk'
[0ad.git] / source / renderer / backend / dummy / Device.h
blob993345a84ca19950ded2a7a68b2eac2334819072
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_RENDERER_BACKEND_DUMMY_DEVICE
19 #define INCLUDED_RENDERER_BACKEND_DUMMY_DEVICE
21 #include "renderer/backend/dummy/DeviceForward.h"
22 #include "renderer/backend/IDevice.h"
24 #include <memory>
25 #include <string>
26 #include <vector>
28 class CShaderDefines;
30 namespace Renderer
33 namespace Backend
36 namespace Dummy
39 class CDeviceCommandContext;
41 class CDevice : public IDevice
43 public:
44 CDevice();
45 ~CDevice() override;
47 Backend GetBackend() const override { return Backend::DUMMY; }
49 const std::string& GetName() const override { return m_Name; }
50 const std::string& GetVersion() const override { return m_Version; }
51 const std::string& GetDriverInformation() const override { return m_DriverInformation; }
52 const std::vector<std::string>& GetExtensions() const override { return m_Extensions; }
54 void Report(const ScriptRequest& rq, JS::HandleValue settings) override;
56 std::unique_ptr<IDeviceCommandContext> CreateCommandContext() override;
58 std::unique_ptr<IGraphicsPipelineState> CreateGraphicsPipelineState(
59 const SGraphicsPipelineStateDesc& pipelineStateDesc) override;
61 std::unique_ptr<IVertexInputLayout> CreateVertexInputLayout(
62 const PS::span<const SVertexAttributeFormat> attributes) override;
64 std::unique_ptr<ITexture> CreateTexture(
65 const char* name, const ITexture::Type type, const uint32_t usage,
66 const Format format, const uint32_t width, const uint32_t height,
67 const Sampler::Desc& defaultSamplerDesc, const uint32_t MIPLevelCount, const uint32_t sampleCount) override;
69 std::unique_ptr<ITexture> CreateTexture2D(
70 const char* name, const uint32_t usage,
71 const Format format, const uint32_t width, const uint32_t height,
72 const Sampler::Desc& defaultSamplerDesc, const uint32_t MIPLevelCount = 1, const uint32_t sampleCount = 1) override;
74 std::unique_ptr<IFramebuffer> CreateFramebuffer(
75 const char* name, SColorAttachment* colorAttachment,
76 SDepthStencilAttachment* depthStencilAttachment) override;
78 std::unique_ptr<IBuffer> CreateBuffer(
79 const char* name, const IBuffer::Type type, const uint32_t size, const bool dynamic) override;
81 std::unique_ptr<IShaderProgram> CreateShaderProgram(
82 const CStr& name, const CShaderDefines& defines) override;
84 bool AcquireNextBackbuffer() override;
86 IFramebuffer* GetCurrentBackbuffer(
87 const AttachmentLoadOp, const AttachmentStoreOp,
88 const AttachmentLoadOp, const AttachmentStoreOp) override;
90 void Present() override;
92 void OnWindowResize(const uint32_t width, const uint32_t height) override;
94 bool IsTextureFormatSupported(const Format format) const override;
96 bool IsFramebufferFormatSupported(const Format format) const override;
98 Format GetPreferredDepthStencilFormat(
99 const uint32_t usage, const bool depth, const bool stencil) const override;
101 const Capabilities& GetCapabilities() const override { return m_Capabilities; }
103 protected:
105 std::string m_Name;
106 std::string m_Version;
107 std::string m_DriverInformation;
108 std::vector<std::string> m_Extensions;
110 std::unique_ptr<IFramebuffer> m_Backbuffer;
112 Capabilities m_Capabilities{};
115 } // namespace Dummy
117 } // namespace Backend
119 } // namespace Renderer
121 #endif // INCLUDED_RENDERER_BACKEND_DUMMY_DEVICE