duckstation

duckstation, but archived from the revision just before upstream changed it to a proprietary software project, this version is the libre one
git clone https://git.neptards.moe/u3shit/duckstation.git
Log | Files | Refs | README | LICENSE

gpu_sw.h (2282B)


      1 // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
      2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
      3 
      4 #pragma once
      5 
      6 #include "gpu.h"
      7 #include "gpu_sw_backend.h"
      8 
      9 #include "util/gpu_device.h"
     10 
     11 #include "common/heap_array.h"
     12 
     13 #include <memory>
     14 
     15 namespace Threading {
     16 class Thread;
     17 }
     18 
     19 class GPUTexture;
     20 
     21 class GPU_SW final : public GPU
     22 {
     23 public:
     24   GPU_SW();
     25   ~GPU_SW() override;
     26 
     27   ALWAYS_INLINE const GPU_SW_Backend& GetBackend() const { return m_backend; }
     28 
     29   const Threading::Thread* GetSWThread() const override;
     30   bool IsHardwareRenderer() const override;
     31 
     32   bool Initialize() override;
     33   bool DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_display) override;
     34   void Reset(bool clear_vram) override;
     35   void UpdateSettings(const Settings& old_settings) override;
     36 
     37 protected:
     38   void ReadVRAM(u32 x, u32 y, u32 width, u32 height) override;
     39   void FillVRAM(u32 x, u32 y, u32 width, u32 height, u32 color) override;
     40   void UpdateVRAM(u32 x, u32 y, u32 width, u32 height, const void* data, bool set_mask, bool check_mask) override;
     41   void CopyVRAM(u32 src_x, u32 src_y, u32 dst_x, u32 dst_y, u32 width, u32 height) override;
     42   void FlushRender() override;
     43   void UpdateCLUT(GPUTexturePaletteReg reg, bool clut_is_8bit) override;
     44 
     45   template<GPUTexture::Format display_format>
     46   bool CopyOut15Bit(u32 src_x, u32 src_y, u32 width, u32 height, u32 line_skip);
     47 
     48   template<GPUTexture::Format display_format>
     49   bool CopyOut24Bit(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 height, u32 line_skip);
     50 
     51   bool CopyOut(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 height, u32 line_skip, bool is_24bit);
     52 
     53   void UpdateDisplay() override;
     54 
     55   void DispatchRenderCommand() override;
     56 
     57   void FillBackendCommandParameters(GPUBackendCommand* cmd) const;
     58   void FillDrawCommand(GPUBackendDrawCommand* cmd, GPURenderCommand rc) const;
     59 
     60   GPUTexture* GetDisplayTexture(u32 width, u32 height, GPUTexture::Format format);
     61 
     62   FixedHeapArray<u8, GPU_MAX_DISPLAY_WIDTH * GPU_MAX_DISPLAY_HEIGHT * sizeof(u32)> m_upload_buffer;
     63   GPUTexture::Format m_16bit_display_format = GPUTexture::Format::RGB565;
     64   GPUTexture::Format m_24bit_display_format = GPUTexture::Format::RGBA8;
     65   std::unique_ptr<GPUTexture> m_upload_texture;
     66 
     67   GPU_SW_Backend m_backend;
     68 };