2021-07-23 14:02:09 +00:00
|
|
|
#pragma once
|
|
|
|
#include "core/host_display.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class RegTestHostDisplay final : public HostDisplay
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RegTestHostDisplay();
|
|
|
|
~RegTestHostDisplay();
|
|
|
|
|
|
|
|
RenderAPI GetRenderAPI() const override;
|
2022-12-04 03:22:11 +00:00
|
|
|
void* GetDevice() const override;
|
|
|
|
void* GetContext() const override;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
2022-12-04 03:22:11 +00:00
|
|
|
bool HasDevice() const override;
|
|
|
|
bool HasSurface() const override;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
2022-12-04 03:22:11 +00:00
|
|
|
bool CreateDevice(const WindowInfo& wi) override;
|
|
|
|
bool SetupDevice() override;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
2022-12-04 03:22:11 +00:00
|
|
|
bool MakeCurrent() override;
|
|
|
|
bool DoneCurrent() override;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
2022-12-04 03:22:11 +00:00
|
|
|
bool ChangeWindow(const WindowInfo& wi) override;
|
|
|
|
void ResizeWindow(s32 new_window_width, s32 new_window_height) override;
|
2021-07-23 14:02:09 +00:00
|
|
|
bool SupportsFullscreen() const override;
|
|
|
|
bool IsFullscreen() override;
|
|
|
|
bool SetFullscreen(bool fullscreen, u32 width, u32 height, float refresh_rate) override;
|
2022-12-04 03:22:11 +00:00
|
|
|
void DestroySurface() override;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
|
|
|
bool SetPostProcessingChain(const std::string_view& config) override;
|
|
|
|
|
|
|
|
bool CreateResources() override;
|
|
|
|
void DestroyResources() override;
|
|
|
|
|
|
|
|
AdapterAndModeList GetAdapterAndModeList() override;
|
|
|
|
bool CreateImGuiContext() override;
|
|
|
|
void DestroyImGuiContext() override;
|
|
|
|
bool UpdateImGuiFontTexture() override;
|
|
|
|
|
2022-10-03 06:44:34 +00:00
|
|
|
std::unique_ptr<GPUTexture> CreateTexture(u32 width, u32 height, u32 layers, u32 levels, u32 samples,
|
|
|
|
GPUTexture::Format format, const void* data, u32 data_stride,
|
2021-07-23 14:02:09 +00:00
|
|
|
bool dynamic = false) override;
|
2022-10-11 09:31:19 +00:00
|
|
|
bool BeginTextureUpdate(GPUTexture* texture, u32 width, u32 height, void** out_buffer, u32* out_pitch) override;
|
|
|
|
void EndTextureUpdate(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height) override;
|
|
|
|
bool UpdateTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, u32 data_stride) override;
|
|
|
|
bool DownloadTexture(GPUTexture* texture, u32 x, u32 y, u32 width, u32 height, void* out_data,
|
|
|
|
u32 out_data_stride) override;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
|
|
|
void SetVSync(bool enabled) override;
|
|
|
|
|
2022-10-11 09:31:19 +00:00
|
|
|
bool Render(bool skip_present) override;
|
2021-07-23 14:02:09 +00:00
|
|
|
bool RenderScreenshot(u32 width, u32 height, std::vector<u32>* out_pixels, u32* out_stride,
|
2022-10-03 06:44:34 +00:00
|
|
|
GPUTexture::Format* out_format) override;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
2022-10-03 06:44:34 +00:00
|
|
|
bool SupportsTextureFormat(GPUTexture::Format format) const override;
|
2021-07-23 14:02:09 +00:00
|
|
|
|
2022-10-11 09:31:19 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class RegTestTexture : public GPUTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
RegTestTexture();
|
|
|
|
~RegTestTexture() override;
|
|
|
|
|
|
|
|
ALWAYS_INLINE const std::vector<u32>& GetPixels() const { return m_frame_buffer; }
|
|
|
|
ALWAYS_INLINE u32 GetPitch() const { return m_frame_buffer_pitch; }
|
|
|
|
|
|
|
|
bool IsValid() const override;
|
|
|
|
|
|
|
|
bool Create(u32 width, u32 height, u32 layers, u32 levels, u32 samples, GPUTexture::Format format);
|
|
|
|
|
|
|
|
bool Upload(u32 x, u32 y, u32 width, u32 height, const void* data, u32 data_stride);
|
|
|
|
bool Download(u32 x, u32 y, u32 width, u32 height, void* data, u32 data_stride) const;
|
|
|
|
|
|
|
|
bool BeginUpload(u32 width, u32 height, void** out_buffer, u32* out_pitch);
|
|
|
|
void EndUpload(u32 x, u32 y, u32 width, u32 height);
|
2021-07-23 14:02:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<u32> m_frame_buffer;
|
2022-10-11 09:31:19 +00:00
|
|
|
std::vector<u32> m_staging_buffer;
|
2022-10-03 06:44:34 +00:00
|
|
|
GPUTexture::Format m_frame_buffer_format = GPUTexture::Format::Unknown;
|
2021-07-23 14:02:09 +00:00
|
|
|
u32 m_frame_buffer_pitch = 0;
|
|
|
|
};
|