Move to Common

This commit is contained in:
Henrik Rydgård 2022-08-05 10:52:35 +02:00
parent d3070005a2
commit 37555fd442
10 changed files with 34 additions and 45 deletions

View File

@ -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

View File

@ -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<UniformDef>::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<std::string> DepalShaderCacheGLES::DebugGetShaderIDs(DebugShaderType type) {
std::vector<std::string> DepalShaderCache::DebugGetShaderIDs(DebugShaderType type) {
std::vector<std::string> ids;
for (auto &iter : cache_) {
ids.push_back(StringFromFormat("%08x", iter.first));
@ -240,7 +240,7 @@ std::vector<std::string> 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);

View File

@ -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;

View File

@ -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_;

View File

@ -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"

View File

@ -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_;

View File

@ -338,6 +338,7 @@
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\ext\xbrz\xbrz.h" />
<ClInclude Include="Common\DepalettizeCommon.h" />
<ClInclude Include="Common\Draw2D.h" />
<ClInclude Include="Common\ReinterpretFramebuffer.h" />
<ClInclude Include="Common\DepalettizeShaderCommon.h" />
@ -382,12 +383,6 @@
<ClInclude Include="Directx9\DrawEngineDX9.h" />
<ClInclude Include="ge_constants.h" />
<ClInclude Include="GeDisasm.h" />
<ClInclude Include="GLES\DepalettizeShaderGLES.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="GLES\FragmentTestCacheGLES.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
@ -460,6 +455,7 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\ext\xbrz\xbrz.cpp" />
<ClCompile Include="Common\DepalettizeCommon.cpp" />
<ClCompile Include="Common\Draw2D.cpp" />
<ClCompile Include="Common\ReinterpretFramebuffer.cpp" />
<ClCompile Include="Common\DepalettizeShaderCommon.cpp" />
@ -530,12 +526,6 @@
<ClCompile Include="Directx9\DrawEngineDX9.cpp" />
<ClCompile Include="GeDisasm.cpp" />
<ClCompile Include="GeConstants.cpp" />
<ClCompile Include="GLES\DepalettizeShaderGLES.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="GLES\DepthBufferGLES.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</ExcludedFromBuild>

View File

@ -171,9 +171,6 @@
<ClInclude Include="GLES\StateMappingGLES.h">
<Filter>GLES</Filter>
</ClInclude>
<ClInclude Include="GLES\DepalettizeShaderGLES.h">
<Filter>GLES</Filter>
</ClInclude>
<ClInclude Include="GLES\FramebufferManagerGLES.h">
<Filter>GLES</Filter>
</ClInclude>
@ -267,6 +264,9 @@
<ClInclude Include="Common\Draw2D.h">
<Filter>Common</Filter>
</ClInclude>
<ClInclude Include="Common\DepalettizeCommon.h">
<Filter>Common</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Math3D.cpp">
@ -416,9 +416,6 @@
<ClCompile Include="GLES\StateMappingGLES.cpp">
<Filter>GLES</Filter>
</ClCompile>
<ClCompile Include="GLES\DepalettizeShaderGLES.cpp">
<Filter>GLES</Filter>
</ClCompile>
<ClCompile Include="GLES\FramebufferManagerGLES.cpp">
<Filter>GLES</Filter>
</ClCompile>
@ -524,6 +521,9 @@
<ClCompile Include="Common\Draw2D.cpp">
<Filter>Common</Filter>
</ClCompile>
<ClCompile Include="Common\DepalettizeCommon.cpp">
<Filter>Common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="..\assets\shaders\tex_4xbrz.csh">

View File

@ -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 \

View File

@ -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 \