LCOV - code coverage report
Current view: top level - source/renderer/backend/dummy - Device.cpp (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 36 55 65.5 %
Date: 2023-01-19 00:18:29 Functions: 11 20 55.0 %

          Line data    Source code
       1             : /* Copyright (C) 2023 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 "Device.h"
      21             : 
      22             : #include "renderer/backend/dummy/Buffer.h"
      23             : #include "renderer/backend/dummy/DeviceCommandContext.h"
      24             : #include "renderer/backend/dummy/Framebuffer.h"
      25             : #include "renderer/backend/dummy/PipelineState.h"
      26             : #include "renderer/backend/dummy/ShaderProgram.h"
      27             : #include "renderer/backend/dummy/Texture.h"
      28             : #include "scriptinterface/JSON.h"
      29             : #include "scriptinterface/Object.h"
      30             : #include "scriptinterface/ScriptInterface.h"
      31             : #include "scriptinterface/ScriptRequest.h"
      32             : 
      33             : namespace Renderer
      34             : {
      35             : 
      36             : namespace Backend
      37             : {
      38             : 
      39             : namespace Dummy
      40             : {
      41             : 
      42           8 : CDevice::CDevice()
      43             : {
      44           8 :     m_Name = "Dummy";
      45           8 :     m_Version = "Unknown";
      46           8 :     m_DriverInformation = "Unknown";
      47           8 :     m_Extensions = {};
      48             : 
      49           8 :     m_Backbuffer = CFramebuffer::Create(this);
      50             : 
      51           8 :     m_Capabilities.S3TC = true;
      52           8 :     m_Capabilities.ARBShaders = false;
      53           8 :     m_Capabilities.ARBShadersShadow = false;
      54           8 :     m_Capabilities.computeShaders = true;
      55           8 :     m_Capabilities.debugLabels = true;
      56           8 :     m_Capabilities.debugScopedLabels = true;
      57           8 :     m_Capabilities.multisampling = true;
      58           8 :     m_Capabilities.anisotropicFiltering = true;
      59           8 :     m_Capabilities.maxSampleCount = 4u;
      60           8 :     m_Capabilities.maxAnisotropy = 16.0f;
      61           8 :     m_Capabilities.maxTextureSize = 8192u;
      62           8 :     m_Capabilities.instancing = true;
      63           8 : }
      64             : 
      65             : CDevice::~CDevice() = default;
      66             : 
      67           0 : void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
      68             : {
      69           0 :     Script::SetProperty(rq, settings, "name", "dummy");
      70           0 : }
      71             : 
      72           6 : std::unique_ptr<IDeviceCommandContext> CDevice::CreateCommandContext()
      73             : {
      74           6 :     return CDeviceCommandContext::Create(this);
      75             : }
      76             : 
      77           0 : std::unique_ptr<IGraphicsPipelineState> CDevice::CreateGraphicsPipelineState(
      78             :     const SGraphicsPipelineStateDesc& pipelineStateDesc)
      79             : {
      80           0 :     return CGraphicsPipelineState::Create(this, pipelineStateDesc);
      81             : }
      82             : 
      83          78 : std::unique_ptr<IVertexInputLayout> CDevice::CreateVertexInputLayout(
      84             :     const PS::span<const SVertexAttributeFormat> UNUSED(attributes))
      85             : {
      86          78 :     return nullptr;
      87             : }
      88             : 
      89          60 : std::unique_ptr<ITexture> CDevice::CreateTexture(
      90             :     const char* UNUSED(name), const CTexture::Type type, const uint32_t usage,
      91             :     const Format format, const uint32_t width, const uint32_t height,
      92             :     const Sampler::Desc& UNUSED(defaultSamplerDesc), const uint32_t MIPLevelCount, const uint32_t UNUSED(sampleCount))
      93             : {
      94          60 :     return CTexture::Create(this, type, usage, format, width, height, MIPLevelCount);
      95             : }
      96             : 
      97          51 : std::unique_ptr<ITexture> CDevice::CreateTexture2D(
      98             :     const char* name, const uint32_t usage,
      99             :     const Format format, const uint32_t width, const uint32_t height,
     100             :     const Sampler::Desc& defaultSamplerDesc, const uint32_t MIPLevelCount, const uint32_t sampleCount)
     101             : {
     102             :     return CreateTexture(name, ITexture::Type::TEXTURE_2D, usage,
     103          51 :         format, width, height, defaultSamplerDesc, MIPLevelCount, sampleCount);
     104             : }
     105             : 
     106           0 : std::unique_ptr<IFramebuffer> CDevice::CreateFramebuffer(
     107             :     const char*, SColorAttachment*, SDepthStencilAttachment*)
     108             : {
     109           0 :     return CFramebuffer::Create(this);
     110             : }
     111             : 
     112           1 : std::unique_ptr<IBuffer> CDevice::CreateBuffer(
     113             :     const char*, const CBuffer::Type type, const uint32_t size, const bool dynamic)
     114             : {
     115           1 :     return CBuffer::Create(this, type, size, dynamic);
     116             : }
     117             : 
     118           0 : std::unique_ptr<IShaderProgram> CDevice::CreateShaderProgram(
     119             :     const CStr&, const CShaderDefines&)
     120             : {
     121           0 :     return CShaderProgram::Create(this);
     122             : }
     123             : 
     124           0 : bool CDevice::AcquireNextBackbuffer()
     125             : {
     126             :     // We have nothing to acquire.
     127           0 :     return true;
     128             : }
     129             : 
     130           0 : IFramebuffer* CDevice::GetCurrentBackbuffer(
     131             :     const AttachmentLoadOp, const AttachmentStoreOp,
     132             :     const AttachmentLoadOp, const AttachmentStoreOp)
     133             : {
     134           0 :     return m_Backbuffer.get();
     135             : }
     136             : 
     137           0 : void CDevice::Present()
     138             : {
     139             :     // We have nothing to present.
     140           0 : }
     141             : 
     142           0 : void CDevice::OnWindowResize(const uint32_t UNUSED(width), const uint32_t UNUSED(height))
     143             : {
     144           0 : }
     145             : 
     146          36 : bool CDevice::IsTextureFormatSupported(const Format UNUSED(format)) const
     147             : {
     148          36 :     return true;
     149             : }
     150             : 
     151           0 : bool CDevice::IsFramebufferFormatSupported(const Format UNUSED(format)) const
     152             : {
     153           0 :     return true;
     154             : }
     155             : 
     156           6 : Format CDevice::GetPreferredDepthStencilFormat(
     157             :     const uint32_t, const bool, const bool) const
     158             : {
     159           6 :     return Format::D24_UNORM_S8_UINT;
     160             : }
     161             : 
     162           6 : std::unique_ptr<IDevice> CreateDevice(SDL_Window* UNUSED(window))
     163             : {
     164           6 :     return std::make_unique<Dummy::CDevice>();
     165             : }
     166             : 
     167             : } // namespace Dummy
     168             : 
     169             : } // namespace Backend
     170             : 
     171           3 : } // namespace Renderer

Generated by: LCOV version 1.13