1#ifndef ENGINE_CLIENT_BACKEND_SDL_H
2#define ENGINE_CLIENT_BACKEND_SDL_H
15#include <condition_variable>
21#if defined(CONF_PLATFORM_MACOS)
22#include <objc/objc-runtime.h>
32 Class NSAutoreleasePoolClass = (Class)objc_getClass(
"NSAutoreleasePool");
33 m_Pool = class_createInstance(NSAutoreleasePoolClass, 0);
34 SEL selector = sel_registerName(
"init");
35 ((id(*)(id, SEL))objc_msgSend)(m_Pool, selector);
40 SEL selector = sel_registerName(
"drain");
41 ((id(*)(id, SEL))objc_msgSend)(m_Pool, selector);
71 bool IsIdle()
const override;
98 bool GetWarning(std::vector<std::string> &WarningStrings)
override;
162 void Cmd_Init(
const SCommand_Init *pCommand);
235 int Init(
const char *pName,
int *pScreen,
int *pWidth,
int *pHeight,
int *pRefreshRate,
int *pFsaaSamples,
int Flags,
int *pDesktopWidth,
int *pDesktopHeight,
int *pCurrentWidth,
int *pCurrentHeight,
class IStorage *pStorage)
override;
248 void GetVideoModes(
CVideoMode *pModes,
int MaxModes,
int *pNumModes,
int HiDPIScale,
int MaxWindowWidth,
int MaxWindowHeight,
int ScreenId)
override;
260 bool ResizeWindow(
int w,
int h,
int RefreshRate)
override;
302 bool ShowMessageBox(
unsigned Type,
const char *pTitle,
const char *pMsg)
override;
@ GFX_WARNING_TYPE_NONE
Definition: backend_base.h:51
static constexpr size_t gs_GpuInfoStringSize
Definition: backend_sdl.h:201
Definition: graphics_threaded.h:16
@ CMDGROUP_PLATFORM_SDL
Definition: graphics_threaded.h:81
Definition: backend_base.h:82
Definition: backend_sdl.h:103
void Cmd_Signal(const CCommandBuffer::SCommand_Signal *pCommand)
Definition: backend_sdl.cpp:183
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand)
Definition: backend_sdl.cpp:188
Definition: backend_sdl.h:135
@ CMD_INIT
Definition: backend_sdl.h:143
@ CMD_SHUTDOWN
Definition: backend_sdl.h:144
void Cmd_WindowCreateNtf(const CCommandBuffer::SCommand_WindowCreateNtf *pCommand)
Definition: backend_sdl.cpp:227
void Cmd_VSync(const CCommandBuffer::SCommand_VSync *pCommand)
Definition: backend_sdl.cpp:221
SDL_GLContext m_GLContext
Definition: backend_sdl.h:138
bool RunCommand(const CCommandBuffer::SCommand *pBaseCommand)
Definition: backend_sdl.cpp:251
void Cmd_Init(const SCommand_Init *pCommand)
Definition: backend_sdl.cpp:201
CCommandProcessorFragment_SDL()
void Cmd_Swap(const CCommandBuffer::SCommand_Swap *pCommand)
Definition: backend_sdl.cpp:215
void Cmd_WindowDestroyNtf(const CCommandBuffer::SCommand_WindowDestroyNtf *pCommand)
Definition: backend_sdl.cpp:239
SDL_Window * m_pWindow
Definition: backend_sdl.h:137
void Cmd_Shutdown(const SCommand_Shutdown *pCommand)
Definition: backend_sdl.cpp:209
Definition: backend_sdl.h:177
void RunBuffer(CCommandBuffer *pBuffer) override
Definition: backend_sdl.cpp:328
CCommandProcessorFragment_SDL m_SDL
Definition: backend_sdl.h:179
const SGfxErrorContainer & GetError() const override
Definition: backend_sdl.cpp:419
const SGfxWarningContainer & GetWarning() const override
Definition: backend_sdl.cpp:429
CCommandProcessor_SDL_GL(EBackendType BackendType, int GLMajor, int GLMinor, int GLPatch)
Definition: backend_sdl.cpp:364
virtual ~CCommandProcessor_SDL_GL()
Definition: backend_sdl.cpp:414
void HandleError()
Definition: backend_sdl.cpp:272
SGfxWarningContainer m_Warning
Definition: backend_sdl.h:185
void HandleWarning()
Definition: backend_sdl.cpp:306
SGfxErrorContainer m_Error
Definition: backend_sdl.h:184
void ErroneousCleanup() override
Definition: backend_sdl.cpp:424
CCommandProcessorFragment_General m_General
Definition: backend_sdl.h:180
EBackendType m_BackendType
Definition: backend_sdl.h:182
CCommandProcessorFragment_GLBase * m_pGLBackend
Definition: backend_sdl.h:178
Definition: backend_sdl.h:205
const char * GetScreenName(int Screen) const override
Definition: backend_sdl.cpp:886
int WindowActive() override
Definition: backend_sdl.cpp:1563
void SetWindowGrab(bool Grab) override
Definition: backend_sdl.cpp:1573
void WindowDestroyNtf(uint32_t WindowId) override
Definition: backend_sdl.cpp:1633
SDL_GLContext m_GLContext
Definition: backend_sdl.h:207
bool ResizeWindow(int w, int h, int RefreshRate) override
Definition: backend_sdl.cpp:1578
int Init(const char *pName, int *pScreen, int *pWidth, int *pHeight, int *pRefreshRate, int *pFsaaSamples, int Flags, int *pDesktopWidth, int *pDesktopHeight, int *pCurrentWidth, int *pCurrentHeight, class IStorage *pStorage) override
Definition: backend_sdl.cpp:1004
char m_aVendorString[gs_GpuInfoStringSize]
Definition: backend_sdl.h:222
void GetVideoModes(CVideoMode *pModes, int MaxModes, int *pNumModes, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenId) override
Definition: backend_sdl.cpp:905
const char * GetRendererString() override
Definition: backend_sdl.h:295
std::atomic< uint64_t > m_StagingMemoryUsage
Definition: backend_sdl.h:212
const char * GetVendorString() override
Definition: backend_sdl.h:285
bool HasQuadContainerBuffering() override
Definition: backend_sdl.h:273
void GetCurrentVideoMode(CVideoMode &CurMode, int HiDPIScale, int MaxWindowWidth, int MaxWindowHeight, int ScreenId) override
Definition: backend_sdl.cpp:969
bool UpdateDisplayMode(int Index) override
Definition: backend_sdl.cpp:1542
static void ClampDriverVersion(EBackendType BackendType)
Definition: backend_sdl.cpp:723
uint64_t StagingMemoryUsage() const override
Definition: backend_sdl.cpp:1451
ICommandProcessor * m_pProcessor
Definition: backend_sdl.h:208
TGLBackendReadPresentedImageData m_ReadPresentedImageDataFunc
Definition: backend_sdl.h:216
void Maximize() override
Definition: backend_sdl.cpp:1466
bool SetWindowScreen(int Index) override
Definition: backend_sdl.cpp:1520
void SetWindowParams(int FullscreenMode, bool IsBorderless) override
Definition: backend_sdl.cpp:1471
std::atomic< uint64_t > m_StreamMemoryUsage
Definition: backend_sdl.h:211
uint64_t StreamedMemoryUsage() const override
Definition: backend_sdl.cpp:1446
bool HasTextBuffering() override
Definition: backend_sdl.h:272
SDL_Window * m_pWindow
Definition: backend_sdl.h:206
int GetWindowScreen() override
Definition: backend_sdl.cpp:1558
std::atomic< uint64_t > m_BufferMemoryUsage
Definition: backend_sdl.h:210
int GetNumScreens() const override
Definition: backend_sdl.h:245
const TTwGraphicsGpuList & GetGpus() const override
Definition: backend_sdl.cpp:1456
TGLBackendReadPresentedImageData & GetReadPresentedImageDataFuncUnsafe() override
Definition: backend_sdl.cpp:1642
bool Uses2DTextureArrays() override
Definition: backend_sdl.h:274
int m_NumScreens
Definition: backend_sdl.h:218
static bool IsModernAPI(EBackendType BackendType)
Definition: backend_sdl.cpp:795
bool HasTextureArraysSupport() override
Definition: backend_sdl.h:275
uint64_t BufferMemoryUsage() const override
Definition: backend_sdl.cpp:1441
void Minimize() override
Definition: backend_sdl.cpp:1461
const char * GetErrorString() override
Definition: backend_sdl.h:277
bool UseTrianglesAsQuad() override
Definition: backend_sdl.h:269
bool IsConfigModernAPI() override
Definition: backend_sdl.h:268
int Shutdown() override
Definition: backend_sdl.cpp:1401
TTwGraphicsGpuList m_GpuList
Definition: backend_sdl.h:214
char m_aErrorString[256]
Definition: backend_sdl.h:228
std::atomic< uint64_t > m_TextureMemoryUsage
Definition: backend_sdl.h:209
bool HasQuadBuffering() override
Definition: backend_sdl.h:271
bool HasTileBuffering() override
Definition: backend_sdl.h:270
EBackendType m_BackendType
Definition: backend_sdl.h:226
void GetViewportSize(int &w, int &h) override
Definition: backend_sdl.cpp:1616
char m_aRendererString[gs_GpuInfoStringSize]
Definition: backend_sdl.h:224
bool ShowMessageBox(unsigned Type, const char *pTitle, const char *pMsg) override
Definition: backend_sdl.cpp:778
CGraphicsBackend_SDL_GL(TTranslateFunc &&TranslateFunc)
Definition: backend_sdl.cpp:998
const char * GetVersionString() override
Definition: backend_sdl.h:290
void WindowCreateNtf(uint32_t WindowId) override
Definition: backend_sdl.cpp:1637
void NotifyWindow() override
Definition: backend_sdl.cpp:1621
SBackendCapabilites m_Capabilites
Definition: backend_sdl.h:220
static EBackendType DetectBackend()
Definition: backend_sdl.cpp:688
int WindowOpen() override
Definition: backend_sdl.cpp:1568
uint64_t TextureMemoryUsage() const override
Definition: backend_sdl.cpp:1436
bool GetDriverVersion(EGraphicsDriverAgeType DriverAgeType, int &Major, int &Minor, int &Patch, const char *&pName, EBackendType BackendType) override
Definition: backend_sdl.cpp:807
char m_aVersionString[gs_GpuInfoStringSize]
Definition: backend_sdl.h:223
Definition: backend_sdl.h:56
virtual void ErroneousCleanup()=0
virtual const SGfxErrorContainer & GetError() const =0
virtual ~ICommandProcessor()=default
virtual void RunBuffer(CCommandBuffer *pBuffer)=0
virtual const SGfxWarningContainer & GetWarning() const =0
Definition: backend_sdl.h:48
static void ThreadFunc(void *pUser)
Definition: backend_sdl.cpp:48
void StartProcessor(ICommandProcessor *pProcessor)
Definition: backend_sdl.cpp:86
CCommandBuffer * m_pBuffer
Definition: backend_sdl.h:89
bool HasWarning()
Definition: backend_sdl.h:80
bool IsIdle() const override
Definition: backend_sdl.cpp:145
TTranslateFunc m_TranslateFunc
Definition: backend_sdl.h:50
std::condition_variable m_BufferSwapCond
Definition: backend_sdl.h:88
std::atomic_bool m_Shutdown
Definition: backend_sdl.h:90
ICommandProcessor * m_pProcessor
Definition: backend_sdl.h:86
bool m_Started
Definition: backend_sdl.h:91
void RunBufferSingleThreadedUnsafe(CCommandBuffer *pBuffer) override
Definition: backend_sdl.cpp:140
void WaitForIdle() override
Definition: backend_sdl.cpp:150
void ProcessError(const SGfxErrorContainer &Error)
Definition: backend_sdl.cpp:156
void RunBuffer(CCommandBuffer *pBuffer) override
Definition: backend_sdl.cpp:109
bool GetWarning(std::vector< std::string > &WarningStrings) override
Definition: backend_sdl.cpp:170
CGraphicsBackend_Threaded(TTranslateFunc &&TranslateFunc)
Definition: backend_sdl.cpp:77
void * m_pThread
Definition: backend_sdl.h:93
SGfxWarningContainer m_Warning
Definition: backend_sdl.h:51
std::mutex m_BufferSwapMutex
Definition: backend_sdl.h:87
std::atomic_bool m_BufferInProcess
Definition: backend_sdl.h:92
void StopProcessor()
Definition: backend_sdl.cpp:97
Definition: graphics.h:72
Definition: graphics_threaded.h:672
EBackendType
Definition: graphics.h:142
@ BACKEND_TYPE_AUTO
Definition: graphics.h:148
EGraphicsDriverAgeType
Definition: graphics.h:133
std::function< bool(uint32_t &Width, uint32_t &Height, CImageInfo::EImageFormat &Format, std::vector< uint8_t > &vDstData)> TGLBackendReadPresentedImageData
Definition: graphics.h:180
std::function< const char *(const char *, const char *)> TTranslateFunc
Definition: graphics_threaded.h:1273
Definition: graphics_threaded.h:220
Definition: graphics_threaded.h:483
Definition: graphics_threaded.h:489
Definition: graphics_threaded.h:585
Definition: graphics_threaded.h:593
Definition: graphics_threaded.h:185
SCommand(unsigned Cmd)
Definition: graphics_threaded.h:187
Definition: backend_sdl.h:148
SDL_Window * m_pWindow
Definition: backend_sdl.h:151
SDL_GLContext m_GLContext
Definition: backend_sdl.h:152
SCommand_Init()
Definition: backend_sdl.h:149
Definition: backend_sdl.h:156
SCommand_Shutdown()
Definition: backend_sdl.h:157
Definition: backend_sdl.h:112
bool m_2DArrayTexturesAsExtension
Definition: backend_sdl.h:122
int m_ContextPatch
Definition: backend_sdl.h:130
bool m_NPOTTextures
Definition: backend_sdl.h:119
bool m_TextBuffering
Definition: backend_sdl.h:115
int m_ContextMajor
Definition: backend_sdl.h:128
bool m_QuadBuffering
Definition: backend_sdl.h:114
bool m_QuadContainerBuffering
Definition: backend_sdl.h:116
bool m_2DArrayTextures
Definition: backend_sdl.h:121
bool m_TrianglesAsQuads
Definition: backend_sdl.h:126
bool m_3DTextures
Definition: backend_sdl.h:120
bool m_MipMapping
Definition: backend_sdl.h:118
bool m_ShaderSupport
Definition: backend_sdl.h:123
bool m_TileBuffering
Definition: backend_sdl.h:113
int m_ContextMinor
Definition: backend_sdl.h:129
Definition: backend_base.h:60
Definition: backend_base.h:76
EGfxWarningType m_WarningType
Definition: backend_base.h:77
Definition: graphics.h:154