Line data Source code
1 : /* Copyright (C) 2026 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 : #ifndef INCLUDED_RENDERER_BACKEND_DUMMY_DEVICE 19 : #define INCLUDED_RENDERER_BACKEND_DUMMY_DEVICE 20 : 21 : #include "ps/CStr.h" 22 : #include "renderer/backend/Backend.h" 23 : #include "renderer/backend/IBuffer.h" 24 : #include "renderer/backend/IDevice.h" 25 : #include "renderer/backend/ITexture.h" 26 : 27 : #include <cstdint> 28 : #include <js/TypeDecls.h> 29 : #include <memory> 30 : #include <span> 31 : #include <string> 32 : #include <vector> 33 : 34 : namespace Renderer::Backend { class IFramebuffer; } 35 : 36 : namespace Renderer 37 : { 38 : 39 : namespace Backend 40 : { 41 : 42 : namespace Dummy 43 : { 44 : 45 : class CDevice : public IDevice 46 : { 47 : public: 48 : CDevice(); 49 : ~CDevice() override; 50 : 51 0 : Backend GetBackend() const override { return Backend::DUMMY; } 52 : 53 0 : const std::string& GetName() const override { return m_Name; } 54 0 : const std::string& GetVersion() const override { return m_Version; } 55 0 : const std::string& GetDriverInformation() const override { return m_DriverInformation; } 56 0 : const std::vector<std::string>& GetExtensions() const override { return m_Extensions; } 57 : 58 : void Report(const Script::Request& rq, JS::HandleValue settings) override; 59 : 60 : std::unique_ptr<IDeviceCommandContext> CreateCommandContext() override; 61 : 62 : std::unique_ptr<ISwapChain> CreateSwapChain( 63 : const char* name, SDL_Window* window, 64 : int surfaceDrawableWidth, int surfaceDrawableHeight, 65 : const bool vsync, std::unique_ptr<ISwapChain> oldSwapChain) override; 66 : 67 : void WaitUntilIdle() override; 68 : 69 : std::unique_ptr<IGraphicsPipelineState> CreateGraphicsPipelineState( 70 : const SGraphicsPipelineStateDesc& pipelineStateDesc) override; 71 : 72 : std::unique_ptr<IComputePipelineState> CreateComputePipelineState( 73 : const SComputePipelineStateDesc& pipelineStateDesc) override; 74 : 75 : std::unique_ptr<IVertexInputLayout> CreateVertexInputLayout( 76 : const std::span<const SVertexAttributeFormat> attributes) override; 77 : 78 : std::unique_ptr<ITexture> CreateTexture( 79 : const char* name, const ITexture::Type type, const uint32_t usage, 80 : const Format format, const uint32_t width, const uint32_t height, 81 : const Sampler::Desc& defaultSamplerDesc, const uint32_t MIPLevelCount, const uint32_t sampleCount) override; 82 : 83 : std::unique_ptr<ITexture> CreateTexture2D( 84 : const char* name, const uint32_t usage, 85 : const Format format, const uint32_t width, const uint32_t height, 86 : const Sampler::Desc& defaultSamplerDesc, const uint32_t MIPLevelCount = 1, const uint32_t sampleCount = 1) override; 87 : 88 : std::unique_ptr<IFramebuffer> CreateFramebuffer( 89 : const char* name, SColorAttachment* colorAttachment, 90 : SDepthStencilAttachment* depthStencilAttachment) override; 91 : 92 : std::unique_ptr<IBuffer> CreateBuffer( 93 : const char* name, const IBuffer::Type type, const uint32_t size, const uint32_t usage) override; 94 : 95 : std::unique_ptr<IShaderProgram> CreateShaderProgram( 96 : const CStr& name, const CShaderDefines& defines) override; 97 : 98 : bool IsTextureFormatSupported(const Format format) const override; 99 : 100 : bool IsFramebufferFormatSupported(const Format format) const override; 101 : 102 : Format GetPreferredDepthStencilFormat( 103 : const uint32_t usage, const bool depth, const bool stencil) const override; 104 : 105 : uint32_t AllocateQuery() override; 106 : 107 : void FreeQuery(const uint32_t handle) override; 108 : 109 : bool IsQueryResultAvailable(const uint32_t handle) const override; 110 : 111 : uint64_t GetQueryResult(const uint32_t handle) override; 112 : 113 20 : const Capabilities& GetCapabilities() const override { return m_Capabilities; } 114 : 115 0 : void CollectStatistics(StatisticsVector&) const override {} 116 : 117 : protected: 118 : 119 : std::string m_Name; 120 : std::string m_Version; 121 : std::string m_DriverInformation; 122 : std::vector<std::string> m_Extensions; 123 : 124 : Capabilities m_Capabilities{}; 125 : }; 126 : 127 : } // namespace Dummy 128 : 129 : } // namespace Backend 130 : 131 : } // namespace Renderer 132 : 133 : #endif // INCLUDED_RENDERER_BACKEND_DUMMY_DEVICE