From 1d37ba47f4a4d93ae758ecb0fcb33d844a64474f Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Wed, 7 Oct 2020 16:00:21 -0500 Subject: [PATCH] GS: Make GSTexture::Type an enum class --- pcsx2/GS/GSLocalMemory.cpp | 2 +- pcsx2/GS/Renderers/Common/GSDevice.cpp | 22 ++++++++--------- pcsx2/GS/Renderers/Common/GSDevice.h | 6 ++--- pcsx2/GS/Renderers/Common/GSTexture.cpp | 2 +- pcsx2/GS/Renderers/Common/GSTexture.h | 25 ++++++++++---------- pcsx2/GS/Renderers/DX11/GSDevice11.cpp | 26 ++++++++++----------- pcsx2/GS/Renderers/DX11/GSDevice11.h | 4 ++-- pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp | 6 ++--- pcsx2/GS/Renderers/DX11/GSTexture11.cpp | 8 +++---- pcsx2/GS/Renderers/Null/GSDeviceNull.cpp | 2 +- pcsx2/GS/Renderers/Null/GSDeviceNull.h | 2 +- pcsx2/GS/Renderers/Null/GSTextureNull.cpp | 2 +- pcsx2/GS/Renderers/Null/GSTextureNull.h | 7 +++--- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp | 25 ++++++++++++-------- pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h | 4 ++-- pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp | 6 ++--- pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp | 22 ++++++++--------- pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h | 6 ++--- pcsx2/GS/Renderers/SW/GSRendererSW.cpp | 2 +- pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp | 2 +- pcsx2/GS/Renderers/SW/GSTextureSW.cpp | 2 +- pcsx2/GS/Renderers/SW/GSTextureSW.h | 2 +- 22 files changed, 96 insertions(+), 89 deletions(-) diff --git a/pcsx2/GS/GSLocalMemory.cpp b/pcsx2/GS/GSLocalMemory.cpp index d15783aed9..01d05b1efb 100644 --- a/pcsx2/GS/GSLocalMemory.cpp +++ b/pcsx2/GS/GSLocalMemory.cpp @@ -1733,7 +1733,7 @@ void GSLocalMemory::SaveBMP(const std::string& fn, u32 bp, u32 bw, u32 psm, int } } - GSTextureSW t(GSTexture::Offscreen, w, h); + GSTextureSW t(GSTexture::Type::Offscreen, w, h); if (t.Update(GSVector4i(0, 0, w, h), bits, pitch)) { diff --git a/pcsx2/GS/Renderers/Common/GSDevice.cpp b/pcsx2/GS/Renderers/Common/GSDevice.cpp index fe4732fbb0..bbe9366b63 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.cpp +++ b/pcsx2/GS/Renderers/Common/GSDevice.cpp @@ -135,7 +135,7 @@ void GSDevice::Present(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, StretchRect(sTex, dTex, dRect, shader, m_linear_present); } -GSTexture* GSDevice::FetchSurface(int type, int w, int h, int format) +GSTexture* GSDevice::FetchSurface(GSTexture::Type type, int w, int h, int format) { const GSVector2i size(w, h); @@ -225,32 +225,32 @@ void GSDevice::PurgePool() GSTexture* GSDevice::CreateSparseRenderTarget(int w, int h, int format) { - return FetchSurface(HasColorSparse() ? GSTexture::SparseRenderTarget : GSTexture::RenderTarget, w, h, format); + return FetchSurface(HasColorSparse() ? GSTexture::Type::SparseRenderTarget : GSTexture::Type::RenderTarget, w, h, format); } GSTexture* GSDevice::CreateSparseDepthStencil(int w, int h, int format) { - return FetchSurface(HasDepthSparse() ? GSTexture::SparseDepthStencil : GSTexture::DepthStencil, w, h, format); + return FetchSurface(HasDepthSparse() ? GSTexture::Type::SparseDepthStencil : GSTexture::Type::DepthStencil, w, h, format); } GSTexture* GSDevice::CreateRenderTarget(int w, int h, int format) { - return FetchSurface(GSTexture::RenderTarget, w, h, format); + return FetchSurface(GSTexture::Type::RenderTarget, w, h, format); } GSTexture* GSDevice::CreateDepthStencil(int w, int h, int format) { - return FetchSurface(GSTexture::DepthStencil, w, h, format); + return FetchSurface(GSTexture::Type::DepthStencil, w, h, format); } GSTexture* GSDevice::CreateTexture(int w, int h, int format) { - return FetchSurface(GSTexture::Texture, w, h, format); + return FetchSurface(GSTexture::Type::Texture, w, h, format); } GSTexture* GSDevice::CreateOffscreen(int w, int h, int format) { - return FetchSurface(GSTexture::Offscreen, w, h, format); + return FetchSurface(GSTexture::Type::Offscreen, w, h, format); } void GSDevice::StretchRect(GSTexture* sTex, GSTexture* dTex, const GSVector4& dRect, ShaderConvert shader, bool linear) @@ -378,7 +378,7 @@ void GSDevice::ShadeBoost() } } -bool GSDevice::ResizeTexture(GSTexture** t, int type, int w, int h) +bool GSDevice::ResizeTexture(GSTexture** t, GSTexture::Type type, int w, int h) { if (t == NULL) { @@ -402,18 +402,18 @@ bool GSDevice::ResizeTexture(GSTexture** t, int type, int w, int h) bool GSDevice::ResizeTexture(GSTexture** t, int w, int h) { - return ResizeTexture(t, GSTexture::Texture, w, h); + return ResizeTexture(t, GSTexture::Type::Texture, w, h); } bool GSDevice::ResizeTarget(GSTexture** t, int w, int h) { - return ResizeTexture(t, GSTexture::RenderTarget, w, h); + return ResizeTexture(t, GSTexture::Type::RenderTarget, w, h); } bool GSDevice::ResizeTarget(GSTexture** t) { GSVector2i s = m_current->GetSize(); - return ResizeTexture(t, GSTexture::RenderTarget, s.x, s.y); + return ResizeTexture(t, GSTexture::Type::RenderTarget, s.x, s.y); } GSAdapter::operator std::string() const diff --git a/pcsx2/GS/Renderers/Common/GSDevice.h b/pcsx2/GS/Renderers/Common/GSDevice.h index b90c337c08..d7a040f25a 100644 --- a/pcsx2/GS/Renderers/Common/GSDevice.h +++ b/pcsx2/GS/Renderers/Common/GSDevice.h @@ -175,8 +175,8 @@ protected: unsigned int m_frame; // for ageing the pool bool m_linear_present; - virtual GSTexture* CreateSurface(int type, int w, int h, int format) = 0; - virtual GSTexture* FetchSurface(int type, int w, int h, int format); + virtual GSTexture* CreateSurface(GSTexture::Type type, int w, int h, int format) = 0; + virtual GSTexture* FetchSurface(GSTexture::Type type, int w, int h, int format); virtual void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) = 0; virtual void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset) = 0; @@ -244,7 +244,7 @@ public: void ExternalFX(); virtual void RenderOsd(GSTexture* dt) {}; - bool ResizeTexture(GSTexture** t, int type, int w, int h); + bool ResizeTexture(GSTexture** t, GSTexture::Type type, int w, int h); bool ResizeTexture(GSTexture** t, int w, int h); bool ResizeTarget(GSTexture** t, int w, int h); bool ResizeTarget(GSTexture** t); diff --git a/pcsx2/GS/Renderers/Common/GSTexture.cpp b/pcsx2/GS/Renderers/Common/GSTexture.cpp index 9280c68987..ea6ae67f1b 100644 --- a/pcsx2/GS/Renderers/Common/GSTexture.cpp +++ b/pcsx2/GS/Renderers/Common/GSTexture.cpp @@ -22,7 +22,7 @@ GSTexture::GSTexture() , m_size(0, 0) , m_committed_size(0, 0) , m_gpu_page_size(0, 0) - , m_type(0) + , m_type(Type::Invalid) , m_format(0) , m_sparse(false) , last_frame_used(0) diff --git a/pcsx2/GS/Renderers/Common/GSTexture.h b/pcsx2/GS/Renderers/Common/GSTexture.h index 4ab83d0b84..22048dcca3 100644 --- a/pcsx2/GS/Renderers/Common/GSTexture.h +++ b/pcsx2/GS/Renderers/Common/GSTexture.h @@ -19,15 +19,6 @@ class GSTexture { -protected: - GSVector2 m_scale; - GSVector2i m_size; - GSVector2i m_committed_size; - GSVector2i m_gpu_page_size; - int m_type; - int m_format; - bool m_sparse; - public: struct GSMap { @@ -35,17 +26,27 @@ public: int pitch; }; - enum + enum class Type { + Invalid = 0, RenderTarget = 1, DepthStencil, Texture, Offscreen, Backbuffer, SparseRenderTarget, - SparseDepthStencil + SparseDepthStencil, }; +protected: + GSVector2 m_scale; + GSVector2i m_size; + GSVector2i m_committed_size; + GSVector2i m_gpu_page_size; + Type m_type; + int m_format; + bool m_sparse; + public: GSTexture(); virtual ~GSTexture() {} @@ -70,7 +71,7 @@ public: int GetHeight() const { return m_size.y; } GSVector2i GetSize() const { return m_size; } - int GetType() const { return m_type; } + Type GetType() const { return m_type; } int GetFormat() const { return m_format; } virtual void CommitPages(const GSVector2i& region, bool commit) {} diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp index 1b03c83268..c7a79fa02d 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.cpp @@ -418,7 +418,7 @@ bool GSDevice11::Create(const WindowInfo& wi) const GSVector2i tex_font = m_osd.get_texture_font_size(); m_font = std::unique_ptr( - CreateSurface(GSTexture::Texture, tex_font.x, tex_font.y, DXGI_FORMAT_R8_UNORM)); + CreateSurface(GSTexture::Type::Texture, tex_font.x, tex_font.y, DXGI_FORMAT_R8_UNORM)); return true; } @@ -562,7 +562,7 @@ void GSDevice11::ClearStencil(GSTexture* t, u8 c) m_ctx->ClearDepthStencilView(*(GSTexture11*)t, D3D11_CLEAR_STENCIL, 0, c); } -GSTexture* GSDevice11::CreateSurface(int type, int w, int h, int format) +GSTexture* GSDevice11::CreateSurface(GSTexture::Type type, int w, int h, int format) { D3D11_TEXTURE2D_DESC desc; @@ -584,17 +584,17 @@ GSTexture* GSDevice11::CreateSurface(int type, int w, int h, int format) switch (type) { - case GSTexture::RenderTarget: + case GSTexture::Type::RenderTarget: desc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE; break; - case GSTexture::DepthStencil: + case GSTexture::Type::DepthStencil: desc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE; break; - case GSTexture::Texture: + case GSTexture::Type::Texture: desc.BindFlags = D3D11_BIND_SHADER_RESOURCE; desc.MipLevels = layers; break; - case GSTexture::Offscreen: + case GSTexture::Type::Offscreen: desc.Usage = D3D11_USAGE_STAGING; desc.CPUAccessFlags |= D3D11_CPU_ACCESS_READ | D3D11_CPU_ACCESS_WRITE; break; @@ -611,10 +611,10 @@ GSTexture* GSDevice11::CreateSurface(int type, int w, int h, int format) switch (type) { - case GSTexture::RenderTarget: + case GSTexture::Type::RenderTarget: ClearRenderTarget(t, 0); break; - case GSTexture::DepthStencil: + case GSTexture::Type::DepthStencil: ClearDepth(t); break; } @@ -627,10 +627,10 @@ GSTexture* GSDevice11::CreateSurface(int type, int w, int h, int format) return t; } -GSTexture* GSDevice11::FetchSurface(int type, int w, int h, int format) +GSTexture* GSDevice11::FetchSurface(GSTexture::Type type, int w, int h, int format) { if (format == 0) - format = (type == GSTexture::DepthStencil || type == GSTexture::SparseDepthStencil) ? DXGI_FORMAT_R32G8X24_TYPELESS : DXGI_FORMAT_R8G8B8A8_UNORM; + format = (type == GSTexture::Type::DepthStencil || type == GSTexture::Type::SparseDepthStencil) ? DXGI_FORMAT_R32G8X24_TYPELESS : DXGI_FORMAT_R8G8B8A8_UNORM; return __super::FetchSurface(type, w, h, format); } @@ -678,7 +678,7 @@ void GSDevice11::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) // DX api isn't happy if we pass a box for depth copy // It complains that depth/multisample must be a full copy // and asks us to use a NULL for the box - const bool depth = (sTex->GetType() == GSTexture::DepthStencil); + const bool depth = (sTex->GetType() == GSTexture::Type::DepthStencil); auto pBox = depth ? nullptr : &box; m_ctx->CopySubresourceRegion(*(GSTexture11*)dTex, 0, 0, 0, 0, *(GSTexture11*)sTex, 0, pBox); @@ -686,7 +686,7 @@ void GSDevice11::CopyRect(GSTexture* sTex, GSTexture* dTex, const GSVector4i& r) void GSDevice11::CloneTexture(GSTexture* src, GSTexture** dest) { - if (!src || !(src->GetType() == GSTexture::DepthStencil || src->GetType() == GSTexture::RenderTarget)) + if (!src || !(src->GetType() == GSTexture::Type::DepthStencil || src->GetType() == GSTexture::Type::RenderTarget)) { ASSERT(0); return; @@ -695,7 +695,7 @@ void GSDevice11::CloneTexture(GSTexture* src, GSTexture** dest) const int w = src->GetWidth(); const int h = src->GetHeight(); - if (src->GetType() == GSTexture::DepthStencil) + if (src->GetType() == GSTexture::Type::DepthStencil) *dest = CreateDepthStencil(w, h, src->GetFormat()); else *dest = CreateRenderTarget(w, h, src->GetFormat()); diff --git a/pcsx2/GS/Renderers/DX11/GSDevice11.h b/pcsx2/GS/Renderers/DX11/GSDevice11.h index 566d9ac600..9a40e111c9 100644 --- a/pcsx2/GS/Renderers/DX11/GSDevice11.h +++ b/pcsx2/GS/Renderers/DX11/GSDevice11.h @@ -396,8 +396,8 @@ private: int m_mipmap; int m_d3d_texsize; - GSTexture* CreateSurface(int type, int w, int h, int format); - GSTexture* FetchSurface(int type, int w, int h, int format); + GSTexture* CreateSurface(GSTexture::Type type, int w, int h, int format) final; + GSTexture* FetchSurface(GSTexture::Type type, int w, int h, int format) final; void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) final; void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0) final; diff --git a/pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp b/pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp index 194791162a..fdfff16c4b 100644 --- a/pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSRendererDX11.cpp @@ -317,7 +317,7 @@ void GSRendererDX11::EmulateChannelShuffle(GSTexture** rt, const GSTextureCache: m_channel_shuffle = false; } } - else if ((tex->m_texture->GetType() == GSTexture::DepthStencil) && !(tex->m_32_bits_fmt)) + else if ((tex->m_texture->GetType() == GSTexture::Type::DepthStencil) && !(tex->m_32_bits_fmt)) { // So far 2 games hit this code path. Urban Chaos and Tales of Abyss // UC: will copy depth to green channel @@ -653,7 +653,7 @@ void GSRendererDX11::EmulateTextureSampler(const GSTextureCache::Source* tex) // Require a float conversion if the texure is a depth otherwise uses Integral scaling if (psm.depth) { - m_ps_sel.depth_fmt = (tex->m_texture->GetType() != GSTexture::DepthStencil) ? 3 : 1; + m_ps_sel.depth_fmt = (tex->m_texture->GetType() != GSTexture::Type::DepthStencil) ? 3 : 1; } // Shuffle is a 16 bits format, so aem is always required @@ -700,7 +700,7 @@ void GSRendererDX11::EmulateTextureSampler(const GSTextureCache::Source* tex) } // Depth format - if (tex->m_texture->GetType() == GSTexture::DepthStencil) + if (tex->m_texture->GetType() == GSTexture::Type::DepthStencil) { // Require a float conversion if the texure is a depth format m_ps_sel.depth_fmt = (psm.bpp == 16) ? 2 : 1; diff --git a/pcsx2/GS/Renderers/DX11/GSTexture11.cpp b/pcsx2/GS/Renderers/DX11/GSTexture11.cpp index 8ceed7df33..380e1fd699 100644 --- a/pcsx2/GS/Renderers/DX11/GSTexture11.cpp +++ b/pcsx2/GS/Renderers/DX11/GSTexture11.cpp @@ -31,13 +31,13 @@ GSTexture11::GSTexture11(wil::com_ptr_nothrow texture) m_size.y = (int)m_desc.Height; if (m_desc.BindFlags & D3D11_BIND_RENDER_TARGET) - m_type = RenderTarget; + m_type = Type::RenderTarget; else if (m_desc.BindFlags & D3D11_BIND_DEPTH_STENCIL) - m_type = DepthStencil; + m_type = Type::DepthStencil; else if (m_desc.BindFlags & D3D11_BIND_SHADER_RESOURCE) - m_type = Texture; + m_type = Type::Texture; else if (m_desc.Usage == D3D11_USAGE_STAGING) - m_type = Offscreen; + m_type = Type::Offscreen; m_format = (int)m_desc.Format; diff --git a/pcsx2/GS/Renderers/Null/GSDeviceNull.cpp b/pcsx2/GS/Renderers/Null/GSDeviceNull.cpp index 96ff48e38f..37d34c9111 100644 --- a/pcsx2/GS/Renderers/Null/GSDeviceNull.cpp +++ b/pcsx2/GS/Renderers/Null/GSDeviceNull.cpp @@ -31,7 +31,7 @@ bool GSDeviceNull::Reset(int w, int h) return GSDevice::Reset(w, h); } -GSTexture* GSDeviceNull::CreateSurface(int type, int w, int h, int format) +GSTexture* GSDeviceNull::CreateSurface(GSTexture::Type type, int w, int h, int format) { return new GSTextureNull(type, w, h, format); } diff --git a/pcsx2/GS/Renderers/Null/GSDeviceNull.h b/pcsx2/GS/Renderers/Null/GSDeviceNull.h index b7cf7c818f..b81e49c4da 100644 --- a/pcsx2/GS/Renderers/Null/GSDeviceNull.h +++ b/pcsx2/GS/Renderers/Null/GSDeviceNull.h @@ -21,7 +21,7 @@ class GSDeviceNull : public GSDevice { private: - GSTexture* CreateSurface(int type, int w, int h, int format); + GSTexture* CreateSurface(GSTexture::Type type, int w, int h, int format); void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) {} void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0) {} diff --git a/pcsx2/GS/Renderers/Null/GSTextureNull.cpp b/pcsx2/GS/Renderers/Null/GSTextureNull.cpp index adaf082c3b..30e84bc956 100644 --- a/pcsx2/GS/Renderers/Null/GSTextureNull.cpp +++ b/pcsx2/GS/Renderers/Null/GSTextureNull.cpp @@ -21,7 +21,7 @@ GSTextureNull::GSTextureNull() memset(&m_desc, 0, sizeof(m_desc)); } -GSTextureNull::GSTextureNull(int type, int w, int h, int format) +GSTextureNull::GSTextureNull(Type type, int w, int h, int format) { m_desc.type = type; m_desc.w = w; diff --git a/pcsx2/GS/Renderers/Null/GSTextureNull.h b/pcsx2/GS/Renderers/Null/GSTextureNull.h index 9c4d4a8f96..d78e8dce41 100644 --- a/pcsx2/GS/Renderers/Null/GSTextureNull.h +++ b/pcsx2/GS/Renderers/Null/GSTextureNull.h @@ -21,14 +21,15 @@ class GSTextureNull : public GSTexture { struct { - int type, w, h, format; + Type type; + int w, h, format; } m_desc; public: GSTextureNull(); - GSTextureNull(int type, int w, int h, int format); + GSTextureNull(Type type, int w, int h, int format); - int GetType() const { return m_desc.type; } + Type GetType() const { return m_desc.type; } int GetFormat() const { return m_desc.format; } bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0) { return true; } diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp index c29e3028b2..89391c31a3 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.cpp @@ -239,7 +239,7 @@ void GSDeviceOGL::GenerateProfilerData() } } -GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, int fmt) +GSTexture* GSDeviceOGL::CreateSurface(GSTexture::Type type, int w, int h, int fmt) { GL_PUSH("Create surface"); @@ -257,23 +257,25 @@ GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, int fmt) switch (type) { - case GSTexture::RenderTarget: + case GSTexture::Type::RenderTarget: ClearRenderTarget(t, 0); break; - case GSTexture::DepthStencil: + case GSTexture::Type::DepthStencil: ClearDepth(t); // No need to clear the stencil now. break; + default: + break; } } return t; } -GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, int format) +GSTexture* GSDeviceOGL::FetchSurface(GSTexture::Type type, int w, int h, int format) { if (format == 0) - format = (type == GSTexture::DepthStencil || type == GSTexture::SparseDepthStencil) ? GL_DEPTH32F_STENCIL8 : GL_RGBA8; + format = (type == GSTexture::Type::DepthStencil || type == GSTexture::Type::SparseDepthStencil) ? GL_DEPTH32F_STENCIL8 : GL_RGBA8; GSTexture* t = GSDevice::FetchSurface(type, w, h, format); @@ -287,19 +289,21 @@ GSTexture* GSDeviceOGL::FetchSurface(int type, int w, int h, int format) const GSVector4 red(1.0f, 0.0f, 0.0f, 1.0f); switch (type) { - case GSTexture::RenderTarget: + case GSTexture::Type::RenderTarget: ClearRenderTarget(t, 0); break; - case GSTexture::DepthStencil: + case GSTexture::Type::DepthStencil: ClearDepth(t); // No need to clear the stencil now. break; - case GSTexture::Texture: + case GSTexture::Type::Texture: if (m_force_texture_clear > 1) static_cast(t)->Clear((void*)&red); else if (m_force_texture_clear) static_cast(t)->Clear(NULL); + break; + default: break; } } @@ -617,7 +621,8 @@ bool GSDeviceOGL::Create(const WindowInfo& wi) const GSVector2i tex_font = m_osd.get_texture_font_size(); m_font = std::unique_ptr( - new GSTextureOGL(GSTextureOGL::Texture, tex_font.x, tex_font.y, GL_R8, m_fbo_read, false)); + new GSTextureOGL(GSTexture::Type::Texture, tex_font.x, tex_font.y, GL_R8, m_fbo_read, false) + ); // **************************************************************** // Finish window setup and backbuffer @@ -680,7 +685,7 @@ bool GSDeviceOGL::Reset(int w, int h) // there isn't any FBO. Only a dummy texture is created to easily detect when the rendering is done // in the backbuffer m_gl_context->ResizeSurface(w, h); - m_backbuffer = new GSTextureOGL(GSTextureOGL::Backbuffer, m_gl_context->GetSurfaceWidth(), + m_backbuffer = new GSTextureOGL(GSTexture::Type::Backbuffer, m_gl_context->GetSurfaceWidth(), m_gl_context->GetSurfaceHeight(), 0, m_fbo_read, false); return true; } diff --git a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h index 73e1c4f628..31d32e24dc 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h +++ b/pcsx2/GS/Renderers/OpenGL/GSDeviceOGL.h @@ -559,8 +559,8 @@ private: std::unique_ptr m_font; - GSTexture* CreateSurface(int type, int w, int h, int format) final; - GSTexture* FetchSurface(int type, int w, int h, int format) final; + GSTexture* CreateSurface(GSTexture::Type type, int w, int h, int format) final; + GSTexture* FetchSurface(GSTexture::Type type, int w, int h, int format) final; void DoMerge(GSTexture* sTex[3], GSVector4* sRect, GSTexture* dTex, GSVector4* dRect, const GSRegPMODE& PMODE, const GSRegEXTBUF& EXTBUF, const GSVector4& c) final; void DoInterlace(GSTexture* sTex, GSTexture* dTex, int shader, bool linear, float yoffset = 0) final; diff --git a/pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp index da6d659616..76c35894cc 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSRendererOGL.cpp @@ -337,7 +337,7 @@ void GSRendererOGL::EmulateChannelShuffle(GSTexture** rt, const GSTextureCache:: m_channel_shuffle = false; } } - else if ((tex->m_texture->GetType() == GSTexture::DepthStencil) && !(tex->m_32_bits_fmt)) + else if ((tex->m_texture->GetType() == GSTexture::Type::DepthStencil) && !(tex->m_32_bits_fmt)) { // So far 2 games hit this code path. Urban Chaos and Tales of Abyss // UC: will copy depth to green channel @@ -746,7 +746,7 @@ void GSRendererOGL::EmulateTextureSampler(const GSTextureCache::Source* tex) // Require a float conversion if the texure is a depth otherwise uses Integral scaling if (psm.depth) { - m_ps_sel.depth_fmt = (tex->m_texture->GetType() != GSTexture::DepthStencil) ? 3 : 1; + m_ps_sel.depth_fmt = (tex->m_texture->GetType() != GSTexture::Type::DepthStencil) ? 3 : 1; m_vs_sel.int_fst = !PRIM->FST; // select float/int coordinate } @@ -799,7 +799,7 @@ void GSRendererOGL::EmulateTextureSampler(const GSTextureCache::Source* tex) } // Depth format - if (tex->m_texture->GetType() == GSTexture::DepthStencil) + if (tex->m_texture->GetType() == GSTexture::Type::DepthStencil) { // Require a float conversion if the texure is a depth format m_ps_sel.depth_fmt = (psm.bpp == 16) ? 2 : 1; diff --git a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp index 79149a19af..358ef6eb08 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp +++ b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.cpp @@ -161,7 +161,7 @@ namespace PboPool } } // namespace PboPool -GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read, bool mipmap) +GSTextureOGL::GSTextureOGL(Type type, int w, int h, int format, GLuint fbo_read, bool mipmap) : m_clean(false), m_generate_mipmap(true), m_local_buffer(nullptr), m_r_x(0), m_r_y(0), m_r_w(0), m_r_h(0), m_layer(0) { // OpenGL didn't like dimensions of size 0 @@ -252,18 +252,18 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read, switch (m_type) { - case GSTexture::Backbuffer: + case Type::Backbuffer: return; // backbuffer isn't a real texture - case GSTexture::Offscreen: + case Type::Offscreen: // Offscreen is only used to read color. So it only requires 4B by pixel m_local_buffer = (u8*)_aligned_malloc(m_size.x * m_size.y * 4, 32); break; - case GSTexture::Texture: + case Type::Texture: // Only 32 bits input texture will be supported for mipmap m_max_layer = mipmap && m_format == GL_RGBA8 ? (int)log2(std::max(w, h)) : 1; break; - case SparseRenderTarget: - case SparseDepthStencil: + case Type::SparseRenderTarget: + case Type::SparseDepthStencil: m_sparse = true; break; default: @@ -378,7 +378,7 @@ void GSTextureOGL::Clear(const void* data, const GSVector4i& area) bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch, int layer) { - ASSERT(m_type != GSTexture::DepthStencil && m_type != GSTexture::Offscreen); + ASSERT(m_type != Type::DepthStencil && m_type != Type::Offscreen); if (layer >= m_max_layer) return true; @@ -460,9 +460,9 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* _r, int layer) u32 row_byte = r.width() << m_int_shift; m.pitch = row_byte; - if (m_type == GSTexture::Offscreen) + if (m_type == Type::Offscreen) { - // The fastest way will be to use a PBO to read the data asynchronously. Unfortunately GS + // The fastest way will be to use a PBO to read the data asynchronously. Unfortunately GSdx // architecture is waiting the data right now. #ifdef GL_EXT_TEX_SUB_IMAGE @@ -489,7 +489,7 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* _r, int layer) return true; } - else if (m_type == GSTexture::Texture || m_type == GSTexture::RenderTarget) + else if (m_type == Type::Texture || m_type == Type::RenderTarget) { GL_PUSH_("Upload Texture %d", m_texture_id); // POP is in Unmap @@ -518,7 +518,7 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* _r, int layer) void GSTextureOGL::Unmap() { - if (m_type == GSTexture::Texture || m_type == GSTexture::RenderTarget) + if (m_type == Type::Texture || m_type == Type::RenderTarget) { PboPool::Unmap(); diff --git a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h index d057a60e5f..02c5f37f39 100644 --- a/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h +++ b/pcsx2/GS/Renderers/OpenGL/GSTextureOGL.h @@ -60,7 +60,7 @@ private: u32 m_mem_usage; public: - explicit GSTextureOGL(int type, int w, int h, int format, GLuint fbo_read, bool mipmap); + explicit GSTextureOGL(Type type, int w, int h, int format, GLuint fbo_read, bool mipmap); virtual ~GSTextureOGL(); bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0) final; @@ -69,8 +69,8 @@ public: void GenerateMipmap() final; bool Save(const std::string& fn) final; - bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); } - bool IsDss() { return (m_type == GSTexture::DepthStencil || m_type == GSTexture::SparseDepthStencil); } + bool IsBackbuffer() { return (m_type == Type::Backbuffer); } + bool IsDss() { return (m_type == Type::DepthStencil || m_type == Type::SparseDepthStencil); } u32 GetID() final { return m_texture_id; } bool HasBeenCleaned() { return m_clean; } diff --git a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp index 4a4ecbc904..acf55e5c3d 100644 --- a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp @@ -1569,7 +1569,7 @@ void GSRendererSW::SharedData::UpdateSource() if (global.clut != NULL) { - GSTextureSW* t = new GSTextureSW(0, 256, 1); + GSTextureSW* t = new GSTextureSW(GSTexture::Type::Invalid, 256, 1); t->Update(GSVector4i(0, 0, 256, 1), global.clut, sizeof(u32) * 256); diff --git a/pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp b/pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp index af12efda50..6cd5954271 100644 --- a/pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSTextureCacheSW.cpp @@ -296,7 +296,7 @@ bool GSTextureCacheSW::Texture::Save(const std::string& fn, bool dds) const int w = 1 << m_TEX0.TW; int h = 1 << m_TEX0.TH; - GSTextureSW t(0, w, h); + GSTextureSW t(GSTexture::Type::Invalid, w, h); GSTexture::GSMap m; diff --git a/pcsx2/GS/Renderers/SW/GSTextureSW.cpp b/pcsx2/GS/Renderers/SW/GSTextureSW.cpp index e2fc62e1f2..9766d4741e 100644 --- a/pcsx2/GS/Renderers/SW/GSTextureSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSTextureSW.cpp @@ -17,7 +17,7 @@ #include "GSTextureSW.h" #include "GS/GSPng.h" -GSTextureSW::GSTextureSW(int type, int width, int height) +GSTextureSW::GSTextureSW(Type type, int width, int height) { m_mapped.clear(std::memory_order_release); m_size = GSVector2i(width, height); diff --git a/pcsx2/GS/Renderers/SW/GSTextureSW.h b/pcsx2/GS/Renderers/SW/GSTextureSW.h index 34be679311..0908103e01 100644 --- a/pcsx2/GS/Renderers/SW/GSTextureSW.h +++ b/pcsx2/GS/Renderers/SW/GSTextureSW.h @@ -26,7 +26,7 @@ class GSTextureSW final : public GSTexture std::atomic_flag m_mapped; public: - GSTextureSW(int type, int width, int height); + GSTextureSW(Type type, int width, int height); virtual ~GSTextureSW(); bool Update(const GSVector4i& r, const void* data, int pitch, int layer = 0);