diff --git a/CMakeLists.txt b/CMakeLists.txt index bfa85f981c..899cdb6c0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1442,8 +1442,6 @@ if(NOT MOBILE_DEVICE) endif() set(GPU_GLES - GPU/GLES/DepalettizeShaderGLES.cpp - GPU/GLES/DepalettizeShaderGLES.h GPU/GLES/DepthBufferGLES.cpp GPU/GLES/GPU_GLES.cpp GPU/GLES/GPU_GLES.h @@ -1531,6 +1529,8 @@ set(GPU_SOURCES ${GPU_NEON} GPU/Common/Draw2D.cpp GPU/Common/Draw2D.h + GPU/Common/DepalettizeCommon.cpp + GPU/Common/DepalettizeCommon.h GPU/Common/DepalettizeShaderCommon.cpp GPU/Common/DepalettizeShaderCommon.h GPU/Common/FragmentShaderGenerator.cpp diff --git a/GPU/GLES/DepalettizeShaderGLES.cpp b/GPU/Common/DepalettizeCommon.cpp similarity index 87% rename from GPU/GLES/DepalettizeShaderGLES.cpp rename to GPU/Common/DepalettizeCommon.cpp index 322e5df8dc..5d3f0fbb25 100644 --- a/GPU/GLES/DepalettizeShaderGLES.cpp +++ b/GPU/Common/DepalettizeCommon.cpp @@ -26,7 +26,7 @@ #include "GPU/Common/DrawEngineCommon.h" #include "GPU/Common/TextureCacheCommon.h" #include "GPU/Common/DepalettizeShaderCommon.h" -#include "GPU/GLES/DepalettizeShaderGLES.h" +#include "GPU/Common/DepalettizeCommon.h" static const InputDef vsInputs[2] = { { "vec2", "a_position", Draw::SEM_POSITION, }, @@ -42,21 +42,21 @@ static const SamplerDef samplers[2] = { { "pal" }, }; -DepalShaderCacheGLES::DepalShaderCacheGLES(Draw::DrawContext *draw) : draw_(draw) { } +DepalShaderCache::DepalShaderCache(Draw::DrawContext *draw) : draw_(draw) { } -DepalShaderCacheGLES::~DepalShaderCacheGLES() { +DepalShaderCache::~DepalShaderCache() { DeviceLost(); } -void DepalShaderCacheGLES::DeviceRestore(Draw::DrawContext *draw) { +void DepalShaderCache::DeviceRestore(Draw::DrawContext *draw) { draw_ = draw; } -void DepalShaderCacheGLES::DeviceLost() { +void DepalShaderCache::DeviceLost() { Clear(); } -bool DepalShaderCacheGLES::GenerateVertexShader(char *buffer, const ShaderLanguageDesc &lang) { +bool DepalShaderCache::GenerateVertexShader(char *buffer, const ShaderLanguageDesc &lang) { ShaderWriter writer(buffer, lang, ShaderStage::Vertex, nullptr, 0); writer.BeginVSMain(vsInputs, Slice::empty(), varyings); writer.C(" v_texcoord0 = a_texcoord0;\n"); @@ -65,7 +65,7 @@ bool DepalShaderCacheGLES::GenerateVertexShader(char *buffer, const ShaderLangua return true; } -Draw::Texture *DepalShaderCacheGLES::GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut) { +Draw::Texture *DepalShaderCache::GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut) { u32 clutId = GetClutID(clutFormat, clutHash); auto oldtex = texCache_.find(clutId); @@ -116,7 +116,7 @@ Draw::Texture *DepalShaderCacheGLES::GetClutTexture(GEPaletteFormat clutFormat, return tex->texture; } -void DepalShaderCacheGLES::Clear() { +void DepalShaderCache::Clear() { for (auto shader = cache_.begin(); shader != cache_.end(); ++shader) { shader->second->fragShader->Release(); if (shader->second->pipeline) { @@ -140,7 +140,7 @@ void DepalShaderCacheGLES::Clear() { } } -void DepalShaderCacheGLES::Decimate() { +void DepalShaderCache::Decimate() { for (auto tex = texCache_.begin(); tex != texCache_.end(); ) { if (tex->second->lastFrame + DEPAL_TEXTURE_OLD_AGE < gpuStats.numFlips) { tex->second->texture->Release(); @@ -152,7 +152,7 @@ void DepalShaderCacheGLES::Decimate() { } } -Draw::SamplerState *DepalShaderCacheGLES::GetSampler() { +Draw::SamplerState *DepalShaderCache::GetSampler() { if (!nearestSampler_) { Draw::SamplerStateDesc desc{}; desc.wrapU = Draw::TextureAddressMode::CLAMP_TO_EDGE; @@ -163,7 +163,7 @@ Draw::SamplerState *DepalShaderCacheGLES::GetSampler() { return nearestSampler_; } -DepalShader *DepalShaderCacheGLES::GetDepalettizeShader(uint32_t clutMode, GEBufferFormat pixelFormat) { +DepalShader *DepalShaderCache::GetDepalettizeShader(uint32_t clutMode, GEBufferFormat pixelFormat) { using namespace Draw; u32 id = GenerateShaderID(clutMode, pixelFormat); @@ -232,7 +232,7 @@ DepalShader *DepalShaderCacheGLES::GetDepalettizeShader(uint32_t clutMode, GEBuf return depal->pipeline ? depal : nullptr; } -std::vector DepalShaderCacheGLES::DebugGetShaderIDs(DebugShaderType type) { +std::vector DepalShaderCache::DebugGetShaderIDs(DebugShaderType type) { std::vector ids; for (auto &iter : cache_) { ids.push_back(StringFromFormat("%08x", iter.first)); @@ -240,7 +240,7 @@ std::vector DepalShaderCacheGLES::DebugGetShaderIDs(DebugShaderType return ids; } -std::string DepalShaderCacheGLES::DebugGetShaderString(std::string idstr, DebugShaderType type, DebugShaderStringType stringType) { +std::string DepalShaderCache::DebugGetShaderString(std::string idstr, DebugShaderType type, DebugShaderStringType stringType) { uint32_t id; sscanf(idstr.c_str(), "%08x", &id); auto iter = cache_.find(id); diff --git a/GPU/GLES/DepalettizeShaderGLES.h b/GPU/Common/DepalettizeCommon.h similarity index 93% rename from GPU/GLES/DepalettizeShaderGLES.h rename to GPU/Common/DepalettizeCommon.h index b9d987a608..5306032a66 100644 --- a/GPU/GLES/DepalettizeShaderGLES.h +++ b/GPU/Common/DepalettizeCommon.h @@ -40,10 +40,10 @@ public: }; // Caches both shaders and palette textures. -class DepalShaderCacheGLES : public DepalShaderCacheCommon { +class DepalShaderCache : public DepalShaderCacheCommon { public: - DepalShaderCacheGLES(Draw::DrawContext *draw); - ~DepalShaderCacheGLES(); + DepalShaderCache(Draw::DrawContext *draw); + ~DepalShaderCache(); // This also uploads the palette and binds the correct texture. DepalShader *GetDepalettizeShader(uint32_t clutMode, GEBufferFormat pixelFormat); @@ -63,7 +63,6 @@ public: static bool GenerateVertexShader(char *buffer, const ShaderLanguageDesc &lang); private: - Draw::DrawContext *draw_; Draw::ShaderModule *vertexShader_ = nullptr; Draw::SamplerState *nearestSampler_ = nullptr; diff --git a/GPU/GLES/GPU_GLES.h b/GPU/GLES/GPU_GLES.h index bcd2c4d1c5..e35400e40a 100644 --- a/GPU/GLES/GPU_GLES.h +++ b/GPU/GLES/GPU_GLES.h @@ -23,9 +23,9 @@ #include "Common/File/Path.h" #include "GPU/GPUCommon.h" +#include "GPU/Common/DepalettizeCommon.h" #include "GPU/GLES/FramebufferManagerGLES.h" #include "GPU/GLES/DrawEngineGLES.h" -#include "GPU/GLES/DepalettizeShaderGLES.h" #include "GPU/GLES/FragmentTestCacheGLES.h" class ShaderManagerGLES; @@ -83,7 +83,7 @@ private: FramebufferManagerGLES *framebufferManagerGL_; TextureCacheGLES *textureCacheGL_; - DepalShaderCacheGLES depalShaderCache_; + DepalShaderCache depalShaderCache_; DrawEngineGLES drawEngine_; FragmentTestCacheGLES fragmentTestCache_; ShaderManagerGLES *shaderManagerGL_; diff --git a/GPU/GLES/TextureCacheGLES.cpp b/GPU/GLES/TextureCacheGLES.cpp index 3bb2550b01..f761d24875 100644 --- a/GPU/GLES/TextureCacheGLES.cpp +++ b/GPU/GLES/TextureCacheGLES.cpp @@ -36,7 +36,7 @@ #include "GPU/GLES/TextureCacheGLES.h" #include "GPU/GLES/FramebufferManagerGLES.h" #include "GPU/Common/FragmentShaderGenerator.h" -#include "GPU/GLES/DepalettizeShaderGLES.h" +#include "GPU/Common/DepalettizeCommon.h" #include "GPU/GLES/ShaderManagerGLES.h" #include "GPU/GLES/DrawEngineGLES.h" #include "GPU/Common/TextureDecoder.h" diff --git a/GPU/GLES/TextureCacheGLES.h b/GPU/GLES/TextureCacheGLES.h index 17b1a8ba33..04d3b7f6b6 100644 --- a/GPU/GLES/TextureCacheGLES.h +++ b/GPU/GLES/TextureCacheGLES.h @@ -27,7 +27,7 @@ struct VirtualFramebuffer; class FramebufferManagerGLES; -class DepalShaderCacheGLES; +class DepalShaderCache; class ShaderManagerGLES; class DrawEngineGLES; class GLRTexture; @@ -41,7 +41,7 @@ public: void StartFrame(); void SetFramebufferManager(FramebufferManagerGLES *fbManager); - void SetDepalShaderCache(DepalShaderCacheGLES *dpCache) { + void SetDepalShaderCache(DepalShaderCache *dpCache) { depalShaderCache_ = dpCache; } void SetShaderManager(ShaderManagerGLES *sm) { @@ -85,7 +85,7 @@ private: GLRTexture *lastBoundTexture = nullptr; FramebufferManagerGLES *framebufferManagerGL_; - DepalShaderCacheGLES *depalShaderCache_; + DepalShaderCache *depalShaderCache_; ShaderManagerGLES *shaderManager_; DrawEngineGLES *drawEngine_; diff --git a/GPU/GPU.vcxproj b/GPU/GPU.vcxproj index ca6cd6a03d..96f0fb05a9 100644 --- a/GPU/GPU.vcxproj +++ b/GPU/GPU.vcxproj @@ -338,6 +338,7 @@ + @@ -382,12 +383,6 @@ - - true - true - true - true - true true @@ -460,6 +455,7 @@ + @@ -530,12 +526,6 @@ - - true - true - true - true - true true diff --git a/GPU/GPU.vcxproj.filters b/GPU/GPU.vcxproj.filters index db9157dde0..2f8533378f 100644 --- a/GPU/GPU.vcxproj.filters +++ b/GPU/GPU.vcxproj.filters @@ -171,9 +171,6 @@ GLES - - GLES - GLES @@ -267,6 +264,9 @@ Common + + Common + @@ -416,9 +416,6 @@ GLES - - GLES - GLES @@ -524,6 +521,9 @@ Common + + Common + diff --git a/android/jni/Android.mk b/android/jni/Android.mk index a0c9774d37..9844cb1fc1 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -320,6 +320,7 @@ EXEC_AND_LIB_FILES := \ $(SRC)/GPU/GeConstants.cpp \ $(SRC)/GPU/GeDisasm.cpp \ $(SRC)/GPU/Common/Draw2D.cpp \ + $(SRC)/GPU/Common/DepalettizeCommon.cpp \ $(SRC)/GPU/Common/DepalettizeShaderCommon.cpp \ $(SRC)/GPU/Common/FragmentShaderGenerator.cpp \ $(SRC)/GPU/Common/FramebufferManagerCommon.cpp \ @@ -348,7 +349,6 @@ EXEC_AND_LIB_FILES := \ $(SRC)/GPU/Debugger/Record.cpp \ $(SRC)/GPU/Debugger/Stepping.cpp \ $(SRC)/GPU/GLES/FramebufferManagerGLES.cpp \ - $(SRC)/GPU/GLES/DepalettizeShaderGLES.cpp \ $(SRC)/GPU/GLES/DepthBufferGLES.cpp \ $(SRC)/GPU/GLES/GPU_GLES.cpp.arm \ $(SRC)/GPU/GLES/TextureCacheGLES.cpp.arm \ diff --git a/libretro/Makefile.common b/libretro/Makefile.common index 9143600e09..316d8a7416 100644 --- a/libretro/Makefile.common +++ b/libretro/Makefile.common @@ -327,6 +327,7 @@ SOURCES_CXX += \ $(GPUCOMMONDIR)/ShaderCommon.cpp \ $(GPUCOMMONDIR)/ShaderUniforms.cpp \ $(GPUCOMMONDIR)/GPUDebugInterface.cpp \ + $(GPUCOMMONDIR)/DepalettizeCommon.cpp \ $(GPUCOMMONDIR)/DepalettizeShaderCommon.cpp \ $(GPUCOMMONDIR)/TransformCommon.cpp \ $(GPUCOMMONDIR)/IndexGenerator.cpp \ @@ -361,7 +362,6 @@ SOURCES_CXX += \ $(GPUDIR)/Software/Rasterizer.cpp \ $(GPUDIR)/Software/RasterizerRectangle.cpp \ $(GPUDIR)/Software/RasterizerRegCache.cpp \ - $(GPUDIR)/GLES/DepalettizeShaderGLES.cpp \ $(GPUDIR)/GLES/DepthBufferGLES.cpp \ $(GPUDIR)/GLES/DrawEngineGLES.cpp \ $(GPUDIR)/GLES/GPU_GLES.cpp \