From f86b9f7900f4c7ad3f9b4365515c2b6428a09df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 25 Dec 2016 21:01:57 +0100 Subject: [PATCH] Guess what? More renaming --- Common/GraphicsContext.h | 4 +-- Core/CoreParameter.h | 4 +-- GPU/Directx9/GPU_DX9.cpp | 2 +- GPU/GPU.cpp | 2 +- GPU/GPU.h | 4 +-- GPU/Software/SoftGpu.cpp | 2 +- GPU/Software/SoftGpu.h | 6 ++--- UI/DevScreens.cpp | 2 +- UI/EmuScreen.cpp | 4 +-- UI/GameInfoCache.cpp | 4 +-- UI/GameInfoCache.h | 6 ++--- UI/GameScreen.cpp | 2 +- UI/NativeApp.cpp | 4 +-- Windows/GPU/D3D11Context.cpp | 2 +- Windows/GPU/D3D11Context.h | 4 +-- Windows/GPU/D3D9Context.cpp | 2 +- Windows/GPU/D3D9Context.h | 4 +-- Windows/GPU/WindowsGLContext.cpp | 2 +- Windows/GPU/WindowsGLContext.h | 4 +-- Windows/GPU/WindowsVulkanContext.cpp | 2 +- Windows/GPU/WindowsVulkanContext.h | 2 +- ext/native/base/PCMain.cpp | 2 +- ext/native/gfx_es2/draw_buffer.cpp | 2 +- ext/native/gfx_es2/draw_buffer.h | 4 +-- ext/native/gfx_es2/draw_text.cpp | 4 +-- ext/native/gfx_es2/draw_text.h | 6 ++--- ext/native/thin3d/thin3d.cpp | 8 +++--- ext/native/thin3d/thin3d.h | 37 ++++++++++++++-------------- ext/native/thin3d/thin3d_d3d11.cpp | 2 +- ext/native/thin3d/thin3d_d3d9.cpp | 34 ++++++++++++++----------- ext/native/thin3d/thin3d_gl.cpp | 34 ++++++++++--------------- ext/native/thin3d/thin3d_vulkan.cpp | 4 +-- ext/native/ui/screen.h | 8 +++--- ext/native/ui/ui_context.cpp | 2 +- ext/native/ui/ui_context.h | 10 ++++---- ext/native/ui/ui_screen.cpp | 2 +- ext/native/ui/ui_screen.h | 2 +- 37 files changed, 113 insertions(+), 116 deletions(-) diff --git a/Common/GraphicsContext.h b/Common/GraphicsContext.h index 365c4faeaa..cd2d85da0c 100644 --- a/Common/GraphicsContext.h +++ b/Common/GraphicsContext.h @@ -25,7 +25,7 @@ public: // Needs casting to the appropriate type, unfortunately. Should find a better solution.. virtual void *GetAPIContext() { return nullptr; } - virtual Draw::Thin3DContext *CreateThin3DContext() = 0; + virtual Draw::DrawContext *CreateThin3DContext() = 0; }; class DummyGraphicsContext : public GraphicsContext { @@ -35,5 +35,5 @@ public: void SwapBuffers() override {} void Resize() override {} - Draw::Thin3DContext *CreateThin3DContext() override { return nullptr; } + Draw::DrawContext *CreateThin3DContext() override { return nullptr; } }; \ No newline at end of file diff --git a/Core/CoreParameter.h b/Core/CoreParameter.h index a5cae73bb7..35406b8fdf 100644 --- a/Core/CoreParameter.h +++ b/Core/CoreParameter.h @@ -35,7 +35,7 @@ class FileLoader; class GraphicsContext; namespace Draw { - class Thin3DContext; + class DrawContext; } // PSP_CoreParameter() @@ -46,7 +46,7 @@ struct CoreParameter { GPUCore gpuCore; GraphicsContext *graphicsContext; // TODO: Find a better place. - Draw::Thin3DContext *thin3d; + Draw::DrawContext *thin3d; bool enableSound; // there aren't multiple sound cores. std::string fileToStart; diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index e51c9c83bb..1c2165abad 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -513,7 +513,7 @@ GPU_DX9::~GPU_DX9() { // Needs to be called on GPU thread, not reporting thread. void GPU_DX9::BuildReportingInfo() { using namespace Draw; - Thin3DContext *thin3d = gfxCtx_->CreateThin3DContext(); + DrawContext *thin3d = gfxCtx_->CreateThin3DContext(); reportingPrimaryInfo_ = thin3d->GetInfoString(InfoField::VENDORSTRING); reportingFullInfo_ = reportingPrimaryInfo_ + " - " + System_GetProperty(SYSPROP_GPUDRIVER_VERSION) + " - " + thin3d->GetInfoString(InfoField::SHADELANGVERSION); diff --git a/GPU/GPU.cpp b/GPU/GPU.cpp index 49555ecac4..e650f841f0 100644 --- a/GPU/GPU.cpp +++ b/GPU/GPU.cpp @@ -46,7 +46,7 @@ static void SetGPU(T *obj) { #undef new #endif -bool GPU_Init(GraphicsContext *ctx, Draw::Thin3DContext *thin3d) { +bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *thin3d) { switch (PSP_CoreParameter().gpuCore) { case GPUCORE_NULL: SetGPU(new NullGPU()); diff --git a/GPU/GPU.h b/GPU/GPU.h index 43dd2a8064..2d9435da46 100644 --- a/GPU/GPU.h +++ b/GPU/GPU.h @@ -99,8 +99,8 @@ extern GPUInterface *gpu; extern GPUDebugInterface *gpuDebug; namespace Draw { - class Thin3DContext; + class DrawContext; } -bool GPU_Init(GraphicsContext *ctx, Draw::Thin3DContext *thin3d); +bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *thin3d); void GPU_Shutdown(); diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 8638cf5049..0e77f1de51 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -51,7 +51,7 @@ static Draw::SamplerState *samplerLinear = nullptr; static Draw::Buffer *vdata = nullptr; static Draw::Buffer *idata = nullptr; -SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::Thin3DContext *_thin3D) +SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *_thin3D) : gfxCtx_(gfxCtx), thin3d(_thin3D) { using namespace Draw; diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index cab15e1687..6afd3698c4 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -46,13 +46,13 @@ typedef struct { class ShaderManager; namespace Draw { - class Thin3DContext; + class DrawContext; class Texture; } class SoftGPU : public GPUCommon { public: - SoftGPU(GraphicsContext *gfxCtx, Draw::Thin3DContext *_thin3D); + SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *_thin3D); ~SoftGPU(); void InitClear() override {} void ExecuteOp(u32 op, u32 diff) override; @@ -108,6 +108,6 @@ private: GraphicsContext *gfxCtx_; Draw::Texture *fbTex; - Draw::Thin3DContext *thin3d; + Draw::DrawContext *thin3d; std::vector fbTexBuffer; }; diff --git a/UI/DevScreens.cpp b/UI/DevScreens.cpp index 555a7509a0..341676107f 100644 --- a/UI/DevScreens.cpp +++ b/UI/DevScreens.cpp @@ -353,7 +353,7 @@ void SystemInfoScreen::CreateViews() { #endif deviceSpecs->Add(new ItemHeader("GPU Information")); - Thin3DContext *thin3d = screenManager()->getThin3DContext(); + DrawContext *thin3d = screenManager()->getThin3DContext(); deviceSpecs->Add(new InfoItem("3D API", thin3d->GetInfoString(InfoField::APINAME))); deviceSpecs->Add(new InfoItem("Vendor", std::string(thin3d->GetInfoString(InfoField::VENDORSTRING)) + " (" + thin3d->GetInfoString(InfoField::VENDOR) + ")")); diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index d8a3abfbb0..8d950d33a2 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -991,7 +991,7 @@ void EmuScreen::render() { bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE; if (!useBufferedRendering) { - Thin3DContext *thin3d = screenManager()->getThin3DContext(); + DrawContext *thin3d = screenManager()->getThin3DContext(); thin3d->Clear(ClearFlag::COLOR | ClearFlag::DEPTH | ClearFlag::STENCIL, 0xFF000000, 0.0f, 0); Viewport viewport; @@ -1032,7 +1032,7 @@ void EmuScreen::render() { fbo_unbind(); if (!osm.IsEmpty() || g_Config.bShowDebugStats || g_Config.iShowFPSCounter || g_Config.bShowTouchControls || g_Config.bShowDeveloperMenu || g_Config.bShowAudioDebug || saveStatePreview_->GetVisibility() != UI::V_GONE || g_Config.bShowFrameProfiler) { - Thin3DContext *thin3d = screenManager()->getThin3DContext(); + DrawContext *thin3d = screenManager()->getThin3DContext(); // This sets up some important states but not the viewport. screenManager()->getUIContext()->Begin(); diff --git a/UI/GameInfoCache.cpp b/UI/GameInfoCache.cpp index b052e1b314..99a175a96e 100644 --- a/UI/GameInfoCache.cpp +++ b/UI/GameInfoCache.cpp @@ -730,7 +730,7 @@ void GameInfoCache::WaitUntilDone(GameInfo *info) { // Runs on the main thread. -GameInfo *GameInfoCache::GetInfo(Draw::Thin3DContext *thin3d, const std::string &gamePath, int wantFlags) { +GameInfo *GameInfoCache::GetInfo(Draw::DrawContext *thin3d, const std::string &gamePath, int wantFlags) { GameInfo *info = 0; auto iter = info_.find(gamePath); @@ -781,7 +781,7 @@ again: return info; } -void GameInfoCache::SetupTexture(GameInfo *info, std::string &textureData, Draw::Thin3DContext *thin3d, Draw::Texture *&tex, double &loadTime) { +void GameInfoCache::SetupTexture(GameInfo *info, std::string &textureData, Draw::DrawContext *thin3d, Draw::Texture *&tex, double &loadTime) { using namespace Draw; if (textureData.size()) { if (!tex) { diff --git a/UI/GameInfoCache.h b/UI/GameInfoCache.h index dd0811c0b3..57d1b3dd75 100644 --- a/UI/GameInfoCache.h +++ b/UI/GameInfoCache.h @@ -26,7 +26,7 @@ #include "Core/Loaders.h" namespace Draw { - class Thin3DContext; + class DrawContext; class Texture; } class PrioritizedWorkQueue; @@ -192,7 +192,7 @@ public: // but filled in later asynchronously in the background. So keep calling this, // redrawing the UI often. Only set flags to GAMEINFO_WANTBG or WANTSND if you really want them // because they're big. bgTextures and sound may be discarded over time as well. - GameInfo *GetInfo(Draw::Thin3DContext *thin3d, const std::string &gamePath, int wantFlags); + GameInfo *GetInfo(Draw::DrawContext *thin3d, const std::string &gamePath, int wantFlags); void FlushBGs(); // Gets rid of all BG textures. Also gets rid of bg sounds. PrioritizedWorkQueue *WorkQueue() { return gameInfoWQ_; } @@ -202,7 +202,7 @@ public: private: void Init(); void Shutdown(); - void SetupTexture(GameInfo *info, std::string &textureData, Draw::Thin3DContext *thin3d, Draw::Texture *&tex, double &loadTime); + void SetupTexture(GameInfo *info, std::string &textureData, Draw::DrawContext *thin3d, Draw::Texture *&tex, double &loadTime); // Maps ISO path to info. std::map info_; diff --git a/UI/GameScreen.cpp b/UI/GameScreen.cpp index 86140dc413..032888a2c7 100644 --- a/UI/GameScreen.cpp +++ b/UI/GameScreen.cpp @@ -185,7 +185,7 @@ void GameScreen::update(InputState &input) { I18NCategory *ga = GetI18NCategory("Game"); - Draw::Thin3DContext *thin3d = screenManager()->getThin3DContext(); + Draw::DrawContext *thin3d = screenManager()->getThin3DContext(); GameInfo *info = g_gameInfoCache->GetInfo(thin3d, gamePath_, GAMEINFO_WANTBG | GAMEINFO_WANTSIZE); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 36e3554f7f..5d7c3d44cf 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -139,7 +139,7 @@ struct PendingMessage { static recursive_mutex pendingMutex; static std::vector pendingMessages; -static Draw::Thin3DContext *thin3d; +static Draw::DrawContext *thin3d; static UIContext *uiContext; static std::vector inputboxValue; @@ -147,7 +147,7 @@ static std::vector inputboxValue; WindowsAudioBackend *winAudioBackend; #endif -Draw::Thin3DContext *GetThin3D() { +Draw::DrawContext *GetThin3D() { return thin3d; } diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index 6a075b81a5..b69cf46de2 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -15,7 +15,7 @@ void D3D11Context::SwapBuffers() { swapChain_->Present(0, 0); } -Draw::Thin3DContext *D3D11Context::CreateThin3DContext() { +Draw::DrawContext *D3D11Context::CreateThin3DContext() { return Draw::T3DCreateD3D11Context(); // device_, context_); } diff --git a/Windows/GPU/D3D11Context.h b/Windows/GPU/D3D11Context.h index d89aee1e4c..e5c00e9f64 100644 --- a/Windows/GPU/D3D11Context.h +++ b/Windows/GPU/D3D11Context.h @@ -23,7 +23,7 @@ #include "Windows/GPU/WindowsGraphicsContext.h" #include -class Thin3DContext; +class DrawContext; class D3D11Context : public WindowsGraphicsContext { public: @@ -37,7 +37,7 @@ public: void Resize() override; - Draw::Thin3DContext *CreateThin3DContext() override; + Draw::DrawContext *CreateThin3DContext() override; private: ID3D11Device *device_; diff --git a/Windows/GPU/D3D9Context.cpp b/Windows/GPU/D3D9Context.cpp index 516ae82f4a..5859c3af51 100644 --- a/Windows/GPU/D3D9Context.cpp +++ b/Windows/GPU/D3D9Context.cpp @@ -27,7 +27,7 @@ void D3D9Context::SwapBuffers() { } } -Draw::Thin3DContext *D3D9Context::CreateThin3DContext() { +Draw::DrawContext *D3D9Context::CreateThin3DContext() { return Draw::T3DCreateDX9Context(d3d, d3dEx, adapterId, device, deviceEx); } diff --git a/Windows/GPU/D3D9Context.h b/Windows/GPU/D3D9Context.h index 6bf4d9ddc2..55c706c325 100644 --- a/Windows/GPU/D3D9Context.h +++ b/Windows/GPU/D3D9Context.h @@ -24,7 +24,7 @@ #include namespace Draw { - class Thin3DContext; + class DrawContext; } class D3D9Context : public WindowsGraphicsContext { @@ -39,7 +39,7 @@ public: void Resize() override; - Draw::Thin3DContext *CreateThin3DContext() override; + Draw::DrawContext *CreateThin3DContext() override; private: bool has9Ex; diff --git a/Windows/GPU/WindowsGLContext.cpp b/Windows/GPU/WindowsGLContext.cpp index 7089e4652a..857a512553 100644 --- a/Windows/GPU/WindowsGLContext.cpp +++ b/Windows/GPU/WindowsGLContext.cpp @@ -400,7 +400,7 @@ void WindowsGLContext::Shutdown() { void WindowsGLContext::Resize() { } -Draw::Thin3DContext *WindowsGLContext::CreateThin3DContext() { +Draw::DrawContext *WindowsGLContext::CreateThin3DContext() { CheckGLExtensions(); return Draw::T3DCreateGLContext(); } diff --git a/Windows/GPU/WindowsGLContext.h b/Windows/GPU/WindowsGLContext.h index a7a8e7e152..10ae527552 100644 --- a/Windows/GPU/WindowsGLContext.h +++ b/Windows/GPU/WindowsGLContext.h @@ -4,7 +4,7 @@ #include "Windows/GPU/WindowsGraphicsContext.h" namespace Draw { - class Thin3DContext; + class DrawContext; } class WindowsGLContext : public WindowsGraphicsContext { @@ -21,7 +21,7 @@ public: void Resize() override; - Draw::Thin3DContext *CreateThin3DContext() override; + Draw::DrawContext *CreateThin3DContext() override; private: HDC hDC; // Private GDI Device Context diff --git a/Windows/GPU/WindowsVulkanContext.cpp b/Windows/GPU/WindowsVulkanContext.cpp index 8ca56d0cb5..6cdfe217dd 100644 --- a/Windows/GPU/WindowsVulkanContext.cpp +++ b/Windows/GPU/WindowsVulkanContext.cpp @@ -206,7 +206,7 @@ void WindowsVulkanContext::Shutdown() { finalize_glslang(); } -Draw::Thin3DContext *WindowsVulkanContext::CreateThin3DContext() { +Draw::DrawContext *WindowsVulkanContext::CreateThin3DContext() { return Draw::T3DCreateVulkanContext(g_Vulkan); } diff --git a/Windows/GPU/WindowsVulkanContext.h b/Windows/GPU/WindowsVulkanContext.h index d49f1654a7..f79aa59757 100644 --- a/Windows/GPU/WindowsVulkanContext.h +++ b/Windows/GPU/WindowsVulkanContext.h @@ -31,6 +31,6 @@ public: void *GetAPIContext(); - Draw::Thin3DContext *CreateThin3DContext() override; + Draw::DrawContext *CreateThin3DContext() override; }; diff --git a/ext/native/base/PCMain.cpp b/ext/native/base/PCMain.cpp index 544e5df562..446c49d461 100644 --- a/ext/native/base/PCMain.cpp +++ b/ext/native/base/PCMain.cpp @@ -48,7 +48,7 @@ SDLJoystick *joystick = NULL; class GLDummyGraphicsContext : public DummyGraphicsContext { public: - Thin3DContext *CreateThin3DContext() override { + DrawContext *CreateThin3DContext() override { CheckGLExtensions(); return T3DCreateGLContext(); } diff --git a/ext/native/gfx_es2/draw_buffer.cpp b/ext/native/gfx_es2/draw_buffer.cpp index 02291865f7..748b9daa20 100644 --- a/ext/native/gfx_es2/draw_buffer.cpp +++ b/ext/native/gfx_es2/draw_buffer.cpp @@ -32,7 +32,7 @@ DrawBuffer::~DrawBuffer() { delete [] verts_; } -void DrawBuffer::Init(Draw::Thin3DContext *t3d) { +void DrawBuffer::Init(Draw::DrawContext *t3d) { using namespace Draw; if (inited_) diff --git a/ext/native/gfx_es2/draw_buffer.h b/ext/native/gfx_es2/draw_buffer.h index 6766fe4142..07b7df9e11 100644 --- a/ext/native/gfx_es2/draw_buffer.h +++ b/ext/native/gfx_es2/draw_buffer.h @@ -67,7 +67,7 @@ public: void End(); // TODO: Enforce these. Now Init is autocalled and shutdown not called. - void Init(Draw::Thin3DContext *t3d); + void Init(Draw::DrawContext *t3d); void Shutdown(); int Count() const { return count_; } @@ -157,7 +157,7 @@ private: Matrix4x4 drawMatrix_; - Draw::Thin3DContext *t3d_; + Draw::DrawContext *t3d_; Draw::Buffer *vbuf_; Draw::Thin3DVertexFormat *vformat_; Draw::ShaderSet *shaderSet_; diff --git a/ext/native/gfx_es2/draw_text.cpp b/ext/native/gfx_es2/draw_text.cpp index 158b4cbc44..e1b0be19e1 100644 --- a/ext/native/gfx_es2/draw_text.cpp +++ b/ext/native/gfx_es2/draw_text.cpp @@ -50,7 +50,7 @@ struct TextDrawerContext { int *pBitmapBits; }; -TextDrawer::TextDrawer(Draw::Thin3DContext *thin3d) : thin3d_(thin3d), ctx_(nullptr) { +TextDrawer::TextDrawer(Draw::DrawContext *thin3d) : thin3d_(thin3d), ctx_(nullptr) { fontScaleX_ = 1.0f; fontScaleY_ = 1.0f; @@ -300,7 +300,7 @@ void TextDrawer::DrawString(DrawBuffer &target, const char *str, float x, float #else -TextDrawer::TextDrawer(Thin3DContext *thin3d) : thin3d_(thin3d), ctx_(NULL) { +TextDrawer::TextDrawer(DrawContext *thin3d) : thin3d_(thin3d), ctx_(NULL) { fontScaleX_ = 1.0f; fontScaleY_ = 1.0f; } diff --git a/ext/native/gfx_es2/draw_text.h b/ext/native/gfx_es2/draw_text.h index fc490bb800..bc7ccb074f 100644 --- a/ext/native/gfx_es2/draw_text.h +++ b/ext/native/gfx_es2/draw_text.h @@ -14,7 +14,7 @@ #include "gfx_es2/draw_buffer.h" namespace Draw { - class Thin3DContext; + class DrawContext; class Texture; } @@ -49,7 +49,7 @@ struct TextDrawerFontContext; class TextDrawer { public: - TextDrawer(Draw::Thin3DContext *thin3d); + TextDrawer(Draw::DrawContext *thin3d); ~TextDrawer(); uint32_t SetFont(const char *fontName, int size, int flags); @@ -65,7 +65,7 @@ public: void OncePerFrame(); private: - Draw::Thin3DContext *thin3d_; + Draw::DrawContext *thin3d_; void WrapString(std::string &out, const char *str, float maxWidth); diff --git a/ext/native/thin3d/thin3d.cpp b/ext/native/thin3d/thin3d.cpp index 8d57dfe312..73073492f9 100644 --- a/ext/native/thin3d/thin3d.cpp +++ b/ext/native/thin3d/thin3d.cpp @@ -147,7 +147,7 @@ static const char * const vulkan_vsTexCol = "}\n"; -void Thin3DContext::CreatePresets() { +void DrawContext::CreatePresets() { vsPresets_[VS_TEXTURE_COLOR_2D] = CreateShader(ShaderStage::VERTEX, glsl_vsTexCol, hlslVsTexCol, vulkan_vsTexCol); vsPresets_[VS_COLOR_2D] = CreateShader(ShaderStage::VERTEX, glsl_vsCol, hlslVsCol, vulkan_vsCol); @@ -158,7 +158,7 @@ void Thin3DContext::CreatePresets() { ssPresets_[SS_COLOR_2D] = CreateShaderSet(vsPresets_[VS_COLOR_2D], fsPresets_[FS_COLOR_2D]); } -Thin3DContext::~Thin3DContext() { +DrawContext::~DrawContext() { for (int i = 0; i < VS_MAX_PRESET; i++) { if (vsPresets_[i]) { vsPresets_[i]->Release(); @@ -292,7 +292,7 @@ bool Texture::LoadFromFile(const std::string &filename, ImageFileType type) { return retval; } -Texture *Thin3DContext::CreateTextureFromFile(const char *filename, ImageFileType type) { +Texture *DrawContext::CreateTextureFromFile(const char *filename, ImageFileType type) { Texture *tex = CreateTexture(); if (!tex->LoadFromFile(filename, type)) { tex->Release(); @@ -302,7 +302,7 @@ Texture *Thin3DContext::CreateTextureFromFile(const char *filename, ImageFileTyp } // TODO: Remove the code duplication between this and LoadFromFileData -Texture *Thin3DContext::CreateTextureFromFileData(const uint8_t *data, int size, ImageFileType type) { +Texture *DrawContext::CreateTextureFromFileData(const uint8_t *data, int size, ImageFileType type) { int width[16], height[16]; int num_levels = 0; int zim_flags = 0; diff --git a/ext/native/thin3d/thin3d.h b/ext/native/thin3d/thin3d.h index 7f70632e8d..71a4f30718 100644 --- a/ext/native/thin3d/thin3d.h +++ b/ext/native/thin3d/thin3d.h @@ -120,6 +120,7 @@ enum class Primitive { TRIANGLE_LIST, TRIANGLE_STRIP, TRIANGLE_FAN, + // Tesselation shader only PATCH_LIST, // These are for geometry shaders only. LINE_LIST_ADJ, @@ -207,10 +208,10 @@ struct Viewport { float MaxDepth; }; -class Thin3DObject { +class RefCountedObject { public: - Thin3DObject() : refcount_(1) {} - virtual ~Thin3DObject() {} + RefCountedObject() : refcount_(1) {} + virtual ~RefCountedObject() {} // TODO: Reconsider this annoying ref counting stuff. virtual void AddRef() { refcount_++; } @@ -231,25 +232,25 @@ private: int refcount_; }; -class BlendState : public Thin3DObject { +class BlendState : public RefCountedObject { public: }; -class SamplerState : public Thin3DObject { +class SamplerState : public RefCountedObject { public: }; -class DepthStencilState : public Thin3DObject { +class DepthStencilState : public RefCountedObject { public: }; -class Buffer : public Thin3DObject { +class Buffer : public RefCountedObject { public: virtual void SetData(const uint8_t *data, size_t size) = 0; virtual void SubData(const uint8_t *data, size_t offset, size_t size) = 0; }; -class Texture : public Thin3DObject { +class Texture : public RefCountedObject { public: bool LoadFromFile(const std::string &filename, ImageFileType type = ImageFileType::DETECT); bool LoadFromFileData(const uint8_t *data, size_t dataSize, ImageFileType type = ImageFileType::DETECT); @@ -281,23 +282,23 @@ struct VertexComponent { uint8_t offset; }; -class Thin3DVertexFormat : public Thin3DObject { +class Thin3DVertexFormat : public RefCountedObject { public: virtual bool RequiresBuffer() = 0; }; -class Shader : public Thin3DObject { +class Shader : public RefCountedObject { public: }; -class ShaderSet : public Thin3DObject { +class ShaderSet : public RefCountedObject { public: // TODO: Make some faster way of doing these. Support uniform buffers (and fake them on GL 2.0?) virtual void SetVector(const char *name, float *value, int n) = 0; virtual void SetMatrix4x4(const char *name, const float value[16]) = 0; }; -class RasterState : public Thin3DObject { +class RasterState : public RefCountedObject { public: }; @@ -357,9 +358,9 @@ struct T3DRasterStateDesc { Facing facing; }; -class Thin3DContext : public Thin3DObject { +class DrawContext : public RefCountedObject { public: - virtual ~Thin3DContext(); + virtual ~DrawContext(); virtual std::vector GetFeatureList() { return std::vector(); } @@ -436,13 +437,13 @@ protected: private: }; -Thin3DContext *T3DCreateGLContext(); +DrawContext *T3DCreateGLContext(); #ifdef _WIN32 -Thin3DContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx); +DrawContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx); #endif -Thin3DContext *T3DCreateVulkanContext(VulkanContext *context); -Thin3DContext *T3DCreateD3D11Context(); +DrawContext *T3DCreateVulkanContext(VulkanContext *context); +DrawContext *T3DCreateD3D11Context(); } // namespace Draw \ No newline at end of file diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index 62b321a6d3..c59ed292f6 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -2,7 +2,7 @@ namespace Draw { -Thin3DContext *T3DCreateD3D11Context() { +DrawContext *T3DCreateD3D11Context() { return nullptr; } diff --git a/ext/native/thin3d/thin3d_d3d9.cpp b/ext/native/thin3d/thin3d_d3d9.cpp index 8a49a5fe7a..ff0f2eb42b 100644 --- a/ext/native/thin3d/thin3d_d3d9.cpp +++ b/ext/native/thin3d/thin3d_d3d9.cpp @@ -68,16 +68,20 @@ static const D3DTEXTUREFILTERTYPE texFilterToD3D9[] = { D3DTEXF_LINEAR, }; -inline D3DPRIMITIVETYPE PrimToD3D9(Primitive prim) { - switch (prim) { - case Primitive::POINT_LIST: return D3DPT_POINTLIST; - case Primitive::LINE_LIST: return D3DPT_LINELIST; - case Primitive::LINE_STRIP: return D3DPT_LINESTRIP; - case Primitive::TRIANGLE_LIST: return D3DPT_TRIANGLELIST; - case Primitive::TRIANGLE_STRIP: return D3DPT_TRIANGLESTRIP; - case Primitive::TRIANGLE_FAN: return D3DPT_TRIANGLEFAN; - } -} +static const D3DPRIMITIVETYPE primToD3D9[] = { + D3DPT_POINTLIST, + D3DPT_LINELIST, + D3DPT_LINESTRIP, + D3DPT_TRIANGLELIST, + D3DPT_TRIANGLESTRIP, + D3DPT_TRIANGLEFAN, + // These aren't available. + D3DPT_POINTLIST, // tess + D3DPT_POINTLIST, // geom ... + D3DPT_POINTLIST, + D3DPT_POINTLIST, + D3DPT_POINTLIST, +}; inline int PrimCountDivisor(Primitive prim) { switch (prim) { @@ -443,7 +447,7 @@ void Thin3DDX9Texture::SetToSampler(LPDIRECT3DDEVICE9 device, int sampler) { } } -class Thin3DDX9Context : public Thin3DContext { +class Thin3DDX9Context : public DrawContext { public: Thin3DDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx); ~Thin3DDX9Context(); @@ -700,7 +704,7 @@ void Thin3DDX9Context::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFo vbuf->BindAsVertexBuf(device_, fmt->GetStride(), offset); ss->Apply(device_); fmt->Apply(device_); - device_->DrawPrimitive(PrimToD3D9(prim), offset, vertexCount / 3); + device_->DrawPrimitive(primToD3D9[(int)prim], offset, vertexCount / 3); } void Thin3DDX9Context::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, Buffer *vdata, Buffer *idata, int vertexCount, int offset) { @@ -713,7 +717,7 @@ void Thin3DDX9Context::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DV fmt->Apply(device_); vbuf->BindAsVertexBuf(device_, fmt->GetStride(), offset); ibuf->BindAsIndexBuf(device_); - device_->DrawIndexedPrimitive(PrimToD3D9(prim), 0, 0, vertexCount, 0, vertexCount / PrimCountDivisor(prim)); + device_->DrawIndexedPrimitive(primToD3D9[(int)prim], 0, 0, vertexCount, 0, vertexCount / PrimCountDivisor(prim)); } void Thin3DDX9Context::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFormat *format, const void *vdata, int vertexCount) { @@ -722,7 +726,7 @@ void Thin3DDX9Context::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertex ss->Apply(device_); fmt->Apply(device_); - device_->DrawPrimitiveUP(PrimToD3D9(prim), vertexCount / 3, vdata, fmt->GetStride()); + device_->DrawPrimitiveUP(primToD3D9[(int)prim], vertexCount / 3, vdata, fmt->GetStride()); } static uint32_t SwapRB(uint32_t c) { @@ -825,7 +829,7 @@ void Thin3DDX9Shader::SetMatrix4x4(LPDIRECT3DDEVICE9 device, const char *name, c } } -Thin3DContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx) { +DrawContext *T3DCreateDX9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, IDirect3DDevice9 *device, IDirect3DDevice9Ex *deviceEx) { int d3dx_ver = LoadD3DX9Dynamic(); if (!d3dx_ver) { ELOG("Failed to load D3DX9!"); diff --git a/ext/native/thin3d/thin3d_gl.cpp b/ext/native/thin3d/thin3d_gl.cpp index 111861fe09..c31b1db152 100644 --- a/ext/native/thin3d/thin3d_gl.cpp +++ b/ext/native/thin3d/thin3d_gl.cpp @@ -83,26 +83,18 @@ static const unsigned short logicOpToGL[] = { }; #endif -inline GLuint PrimToGL(Primitive prim) { - switch (prim) { - case Primitive::POINT_LIST: return GL_POINTS; - case Primitive::LINE_LIST: return GL_LINES; - case Primitive::LINE_LIST_ADJ: return GL_LINES_ADJACENCY; - case Primitive::LINE_STRIP: return GL_LINE_STRIP; - case Primitive::LINE_STRIP_ADJ: return GL_LINE_STRIP_ADJACENCY; - case Primitive::TRIANGLE_LIST: return GL_TRIANGLES; - case Primitive::TRIANGLE_LIST_ADJ: return GL_TRIANGLES_ADJACENCY; - case Primitive::TRIANGLE_STRIP: return GL_TRIANGLE_STRIP; - case Primitive::TRIANGLE_STRIP_ADJ: return GL_TRIANGLES_ADJACENCY; - case Primitive::TRIANGLE_FAN: return GL_TRIANGLE_FAN; - case Primitive::PATCH_LIST: return GL_PATCHES; - default: return GL_POINTS; - } -} static const unsigned short primToGL[] = { GL_POINTS, GL_LINES, + GL_LINE_STRIP, GL_TRIANGLES, + GL_TRIANGLE_STRIP, + GL_TRIANGLE_FAN, + GL_PATCHES, + GL_LINES_ADJACENCY, + GL_LINE_STRIP_ADJACENCY, + GL_TRIANGLES_ADJACENCY, + GL_TRIANGLE_STRIP_ADJACENCY, }; static const char *glsl_fragment_prelude = @@ -387,7 +379,7 @@ private: std::map uniforms_; }; -class Thin3DGLContext : public Thin3DContext { +class Thin3DGLContext : public DrawContext { public: Thin3DGLContext(); virtual ~Thin3DGLContext(); @@ -936,7 +928,7 @@ void Thin3DGLContext::Draw(Primitive prim, ShaderSet *shaderSet, Thin3DVertexFor fmt->Apply(); ss->Apply(); - glDrawArrays(PrimToGL(prim), offset, vertexCount); + glDrawArrays(primToGL[(int)prim], offset, vertexCount); ss->Unapply(); fmt->Unapply(); @@ -954,7 +946,7 @@ void Thin3DGLContext::DrawIndexed(Primitive prim, ShaderSet *shaderSet, Thin3DVe // Note: ibuf binding is stored in the VAO, so call this after binding the fmt. ibuf->Bind(); - glDrawElements(PrimToGL(prim), vertexCount, GL_UNSIGNED_INT, (const void *)(size_t)offset); + glDrawElements(primToGL[(int)prim], vertexCount, GL_UNSIGNED_INT, (const void *)(size_t)offset); ss->Unapply(); fmt->Unapply(); @@ -969,7 +961,7 @@ void Thin3DGLContext::DrawUP(Primitive prim, ShaderSet *shaderSet, Thin3DVertexF glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glDrawArrays(PrimToGL(prim), 0, vertexCount); + glDrawArrays(primToGL[(int)prim], 0, vertexCount); ss->Unapply(); fmt->Unapply(); @@ -998,7 +990,7 @@ void Thin3DGLContext::Clear(int mask, uint32_t colorval, float depthVal, int ste glClear(glMask); } -Thin3DContext *T3DCreateGLContext() { +DrawContext *T3DCreateGLContext() { return new Thin3DGLContext(); } diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 099233e095..9b44011871 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -385,7 +385,7 @@ struct DescriptorSetKey { } }; -class Thin3DVKContext : public Thin3DContext { +class Thin3DVKContext : public DrawContext { public: Thin3DVKContext(VulkanContext *vulkan); virtual ~Thin3DVKContext(); @@ -1182,7 +1182,7 @@ void Thin3DVKContext::Clear(int mask, uint32_t colorval, float depthVal, int ste } } -Thin3DContext *T3DCreateVulkanContext(VulkanContext *vulkan) { +DrawContext *T3DCreateVulkanContext(VulkanContext *vulkan) { return new Thin3DVKContext(vulkan); } diff --git a/ext/native/ui/screen.h b/ext/native/ui/screen.h index 362f35cb00..c9324f6941 100644 --- a/ext/native/ui/screen.h +++ b/ext/native/ui/screen.h @@ -38,7 +38,7 @@ class ScreenManager; class UIContext; namespace Draw { - class Thin3DContext; + class DrawContext; } class Screen { @@ -102,8 +102,8 @@ public: void setUIContext(UIContext *context) { uiContext_ = context; } UIContext *getUIContext() { return uiContext_; } - void setThin3DContext(Draw::Thin3DContext *context) { thin3DContext_ = context; } - Draw::Thin3DContext *getThin3DContext() { return thin3DContext_; } + void setThin3DContext(Draw::DrawContext *context) { thin3DContext_ = context; } + Draw::DrawContext *getThin3DContext() { return thin3DContext_; } void render(); void resized(); @@ -139,7 +139,7 @@ private: Screen *nextScreen_; UIContext *uiContext_; - Draw::Thin3DContext *thin3DContext_; + Draw::DrawContext *thin3DContext_; const Screen *dialogFinished_; DialogResult dialogResult_; diff --git a/ext/native/ui/ui_context.cpp b/ext/native/ui/ui_context.cpp index 970f86dd7d..e20a57cc6c 100644 --- a/ext/native/ui/ui_context.cpp +++ b/ext/native/ui/ui_context.cpp @@ -23,7 +23,7 @@ UIContext::~UIContext() { blendNormal_->Release(); } -void UIContext::Init(Draw::Thin3DContext *thin3d, Draw::ShaderSet *uishader, Draw::ShaderSet *uishadernotex, Draw::Texture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop) { +void UIContext::Init(Draw::DrawContext *thin3d, Draw::ShaderSet *uishader, Draw::ShaderSet *uishadernotex, Draw::Texture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop) { using namespace Draw; thin3d_ = thin3d; blendNormal_ = thin3d_->CreateBlendState({ true, BlendFactor::SRC_ALPHA, BlendFactor::ONE_MINUS_SRC_ALPHA }); diff --git a/ext/native/ui/ui_context.h b/ext/native/ui/ui_context.h index 592be67bd6..9d685be6f2 100644 --- a/ext/native/ui/ui_context.h +++ b/ext/native/ui/ui_context.h @@ -10,7 +10,7 @@ // Everything forward declared so this header is safe everywhere. namespace Draw { - class Thin3DContext; + class DrawContext; class ShaderSet; class DepthStencilState; class Texture; @@ -36,7 +36,7 @@ public: UIContext(); ~UIContext(); - void Init(Draw::Thin3DContext *thin3d, Draw::ShaderSet *uiShaderTex, Draw::ShaderSet *uiShaderNoTex, Draw::Texture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop); + void Init(Draw::DrawContext *thin3d, Draw::ShaderSet *uiShaderTex, Draw::ShaderSet *uiShaderNoTex, Draw::Texture *uitexture, DrawBuffer *uidrawbuffer, DrawBuffer *uidrawbufferTop); void Begin(); void BeginNoTex(); @@ -74,10 +74,10 @@ public: // in dps, like dp_xres and dp_yres void SetBounds(const Bounds &b) { bounds_ = b; } const Bounds &GetBounds() const { return bounds_; } - Draw::Thin3DContext *GetThin3DContext() { return thin3d_; } + Draw::DrawContext *GetThin3DContext() { return thin3d_; } private: - Draw::Thin3DContext *thin3d_; + Draw::DrawContext *thin3d_; Bounds bounds_; float fontScaleX_; @@ -85,7 +85,7 @@ private: UI::FontStyle *fontStyle_; TextDrawer *textDrawer_; - Draw::Thin3DContext *thin3D_; + Draw::DrawContext *thin3D_; Draw::DepthStencilState *depth_; Draw::SamplerState *sampler_; Draw::RasterState *rasterNoCull_; diff --git a/ext/native/ui/ui_screen.cpp b/ext/native/ui/ui_screen.cpp index c612f749b4..caff8dde45 100644 --- a/ext/native/ui/ui_screen.cpp +++ b/ext/native/ui/ui_screen.cpp @@ -59,7 +59,7 @@ void UIScreen::update(InputState &input) { } void UIScreen::preRender() { - Draw::Thin3DContext *thin3d = screenManager()->getThin3DContext(); + Draw::DrawContext *thin3d = screenManager()->getThin3DContext(); if (!thin3d) { return; } diff --git a/ext/native/ui/ui_screen.h b/ext/native/ui/ui_screen.h index e756469a16..4e4acc41bc 100644 --- a/ext/native/ui/ui_screen.h +++ b/ext/native/ui/ui_screen.h @@ -7,7 +7,7 @@ class I18NCategory; namespace Draw { - class Thin3DContext; + class DrawContext; } class UIScreen : public Screen {