mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-01 14:58:14 +00:00
GPU: Track draw in shader manager.
With device restore etc. everywhere.
This commit is contained in:
1 parent
2dbdd73e5f
commit
1f594f3fb5
11 files changed
+31
-17
No files matched your search
@@ -19,6 +19,10 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace Draw {
|
||||
class DrawContext;
|
||||
}
|
||||
|
||||
enum ShaderLanguage {
|
||||
GLSL_140,
|
||||
GLSL_300,
|
||||
@@ -116,10 +120,13 @@ enum : uint64_t {
|
||||
|
||||
class ShaderManagerCommon {
|
||||
public:
|
||||
ShaderManagerCommon() {}
|
||||
ShaderManagerCommon(Draw::DrawContext *draw) : draw_(draw) {}
|
||||
virtual ~ShaderManagerCommon() {}
|
||||
|
||||
virtual void DirtyLastShader() = 0;
|
||||
|
||||
protected:
|
||||
Draw::DrawContext *draw_ = nullptr;
|
||||
};
|
||||
|
||||
struct TBuiltInResource;
|
||||
|
||||
@@ -77,7 +77,7 @@ GPU_D3D11::GPU_D3D11(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
|
||||
stockD3D11.Create(device_);
|
||||
|
||||
shaderManagerD3D11_ = new ShaderManagerD3D11(device_, context_, featureLevel);
|
||||
shaderManagerD3D11_ = new ShaderManagerD3D11(draw, device_, context_, featureLevel);
|
||||
framebufferManagerD3D11_ = new FramebufferManagerD3D11(draw);
|
||||
framebufferManager_ = framebufferManagerD3D11_;
|
||||
textureCacheD3D11_ = new TextureCacheD3D11(draw);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "math/lin/matrix4x4.h"
|
||||
#include "math/math_util.h"
|
||||
#include "math/dataconv.h"
|
||||
#include "thin3d/thin3d.h"
|
||||
#include "util/text/utf8.h"
|
||||
#include "Common/Common.h"
|
||||
#include "Core/Config.h"
|
||||
@@ -88,8 +89,8 @@ std::string D3D11VertexShader::GetShaderString(DebugShaderStringType type) const
|
||||
}
|
||||
}
|
||||
|
||||
ShaderManagerD3D11::ShaderManagerD3D11(ID3D11Device *device, ID3D11DeviceContext *context, D3D_FEATURE_LEVEL featureLevel)
|
||||
: device_(device), context_(context), featureLevel_(featureLevel), lastVShader_(nullptr), lastFShader_(nullptr) {
|
||||
ShaderManagerD3D11::ShaderManagerD3D11(Draw::DrawContext *draw, ID3D11Device *device, ID3D11DeviceContext *context, D3D_FEATURE_LEVEL featureLevel)
|
||||
: ShaderManagerCommon(draw), device_(device), context_(context), featureLevel_(featureLevel), lastVShader_(nullptr), lastFShader_(nullptr) {
|
||||
codeBuffer_ = new char[16384];
|
||||
memset(&ub_base, 0, sizeof(ub_base));
|
||||
memset(&ub_lights, 0, sizeof(ub_lights));
|
||||
|
||||
@@ -81,7 +81,7 @@ class D3D11PushBuffer;
|
||||
|
||||
class ShaderManagerD3D11 : public ShaderManagerCommon {
|
||||
public:
|
||||
ShaderManagerD3D11(ID3D11Device *device, ID3D11DeviceContext *context, D3D_FEATURE_LEVEL featureLevel);
|
||||
ShaderManagerD3D11(Draw::DrawContext *draw, ID3D11Device *device, ID3D11DeviceContext *context, D3D_FEATURE_LEVEL featureLevel);
|
||||
~ShaderManagerD3D11();
|
||||
|
||||
void GetShaders(int prim, u32 vertType, D3D11VertexShader **vshader, D3D11FragmentShader **fshader, bool useHWTransform);
|
||||
|
||||
@@ -61,7 +61,7 @@ GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
lastVsync_ = g_Config.bVSync ? 1 : 0;
|
||||
dxstate.SetVSyncInterval(g_Config.bVSync);
|
||||
|
||||
shaderManagerDX9_ = new ShaderManagerDX9(device_);
|
||||
shaderManagerDX9_ = new ShaderManagerDX9(draw, device_);
|
||||
framebufferManagerDX9_ = new FramebufferManagerDX9(draw);
|
||||
framebufferManager_ = framebufferManagerDX9_;
|
||||
textureCacheDX9_ = new TextureCacheDX9(draw);
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "math/lin/matrix4x4.h"
|
||||
#include "math/math_util.h"
|
||||
#include "math/dataconv.h"
|
||||
#include "thin3d/thin3d.h"
|
||||
#include "util/text/utf8.h"
|
||||
|
||||
#include "Common/Common.h"
|
||||
@@ -499,7 +500,8 @@ void ShaderManagerDX9::VSUpdateUniforms(u64 dirtyUniforms) {
|
||||
}
|
||||
}
|
||||
|
||||
ShaderManagerDX9::ShaderManagerDX9(LPDIRECT3DDEVICE9 device) : device_(device), lastVShader_(nullptr), lastPShader_(nullptr) {
|
||||
ShaderManagerDX9::ShaderManagerDX9(Draw::DrawContext *draw, LPDIRECT3DDEVICE9 device)
|
||||
: ShaderManagerCommon(draw), device_(device), lastVShader_(nullptr), lastPShader_(nullptr) {
|
||||
codeBuffer_ = new char[16384];
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ protected:
|
||||
|
||||
class ShaderManagerDX9 : public ShaderManagerCommon {
|
||||
public:
|
||||
ShaderManagerDX9(LPDIRECT3DDEVICE9 device);
|
||||
ShaderManagerDX9(Draw::DrawContext *draw, LPDIRECT3DDEVICE9 device);
|
||||
~ShaderManagerDX9();
|
||||
|
||||
void ClearCache(bool deleteThem); // TODO: deleteThem currently not respected
|
||||
|
||||
@@ -28,11 +28,12 @@
|
||||
#include "base/timeutil.h"
|
||||
#include "gfx/gl_debug_log.h"
|
||||
#include "gfx_es2/gpu_features.h"
|
||||
#include "thin3d/GLRenderManager.h"
|
||||
#include "i18n/i18n.h"
|
||||
#include "math/math_util.h"
|
||||
#include "math/lin/matrix4x4.h"
|
||||
#include "profiler/profiler.h"
|
||||
#include "thin3d/thin3d.h"
|
||||
#include "thin3d/GLRenderManager.h"
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/Config.h"
|
||||
@@ -571,7 +572,7 @@ void LinkedShader::UpdateUniforms(u32 vertType, const ShaderID &vsid) {
|
||||
}
|
||||
|
||||
ShaderManagerGLES::ShaderManagerGLES(Draw::DrawContext *draw)
|
||||
: lastShader_(nullptr), shaderSwitchDirtyUniforms_(0), diskCacheDirty_(false), fsCache_(16), vsCache_(16) {
|
||||
: ShaderManagerCommon(draw), lastShader_(nullptr), shaderSwitchDirtyUniforms_(0), diskCacheDirty_(false), fsCache_(16), vsCache_(16) {
|
||||
render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
codeBuffer_ = new char[16384];
|
||||
lastFSID_.set_invalid();
|
||||
@@ -610,6 +611,7 @@ void ShaderManagerGLES::DeviceLost() {
|
||||
|
||||
void ShaderManagerGLES::DeviceRestore(Draw::DrawContext *draw) {
|
||||
render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
||||
draw_ = draw;
|
||||
}
|
||||
|
||||
void ShaderManagerGLES::DirtyShader() {
|
||||
|
||||
@@ -59,7 +59,7 @@ GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
|
||||
UpdateVsyncInterval(true);
|
||||
CheckGPUFeatures();
|
||||
|
||||
shaderManagerVulkan_ = new ShaderManagerVulkan(vulkan_);
|
||||
shaderManagerVulkan_ = new ShaderManagerVulkan(draw, vulkan_);
|
||||
pipelineManager_ = new PipelineManagerVulkan(vulkan_);
|
||||
framebufferManagerVulkan_ = new FramebufferManagerVulkan(draw, vulkan_);
|
||||
framebufferManager_ = framebufferManagerVulkan_;
|
||||
@@ -535,7 +535,7 @@ void GPU_Vulkan::DeviceRestore() {
|
||||
drawEngine_.DeviceRestore(vulkan_, draw_);
|
||||
pipelineManager_->DeviceRestore(vulkan_);
|
||||
textureCacheVulkan_->DeviceRestore(vulkan_, draw_);
|
||||
shaderManagerVulkan_->DeviceRestore(vulkan_);
|
||||
shaderManagerVulkan_->DeviceRestore(vulkan_, draw_);
|
||||
depalShaderCache_.DeviceRestore(draw_, vulkan_);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "math/math_util.h"
|
||||
#include "math/dataconv.h"
|
||||
#include "profiler/profiler.h"
|
||||
#include "thin3d/thin3d.h"
|
||||
#include "util/text/utf8.h"
|
||||
#include "Common/Vulkan/VulkanContext.h"
|
||||
#include "Common/Vulkan/VulkanMemory.h"
|
||||
@@ -156,8 +157,8 @@ std::string VulkanVertexShader::GetShaderString(DebugShaderStringType type) cons
|
||||
}
|
||||
}
|
||||
|
||||
ShaderManagerVulkan::ShaderManagerVulkan(VulkanContext *vulkan)
|
||||
: vulkan_(vulkan), lastVShader_(nullptr), lastFShader_(nullptr), fsCache_(16), vsCache_(16) {
|
||||
ShaderManagerVulkan::ShaderManagerVulkan(Draw::DrawContext *draw, VulkanContext *vulkan)
|
||||
: ShaderManagerCommon(draw), vulkan_(vulkan), lastVShader_(nullptr), lastFShader_(nullptr), fsCache_(16), vsCache_(16) {
|
||||
codeBuffer_ = new char[16384];
|
||||
uboAlignment_ = vulkan_->GetPhysicalDeviceProperties(vulkan_->GetCurrentPhysicalDevice()).limits.minUniformBufferOffsetAlignment;
|
||||
memset(&ub_base, 0, sizeof(ub_base));
|
||||
@@ -174,8 +175,9 @@ ShaderManagerVulkan::~ShaderManagerVulkan() {
|
||||
delete[] codeBuffer_;
|
||||
}
|
||||
|
||||
void ShaderManagerVulkan::DeviceRestore(VulkanContext *vulkan) {
|
||||
void ShaderManagerVulkan::DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw) {
|
||||
vulkan_ = vulkan;
|
||||
draw_ = draw;
|
||||
uboAlignment_ = vulkan_->GetPhysicalDeviceProperties(vulkan_->GetCurrentPhysicalDevice()).limits.minUniformBufferOffsetAlignment;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,10 +83,10 @@ class VulkanPushBuffer;
|
||||
|
||||
class ShaderManagerVulkan : public ShaderManagerCommon {
|
||||
public:
|
||||
ShaderManagerVulkan(VulkanContext *vulkan);
|
||||
ShaderManagerVulkan(Draw::DrawContext *draw, VulkanContext *vulkan);
|
||||
~ShaderManagerVulkan();
|
||||
|
||||
void DeviceRestore(VulkanContext *vulkan);
|
||||
void DeviceRestore(VulkanContext *vulkan, Draw::DrawContext *draw);
|
||||
|
||||
void GetShaders(int prim, u32 vertType, VulkanVertexShader **vshader, VulkanFragmentShader **fshader, bool useHWTransform);
|
||||
void ClearShaders();
|
||||
|
||||
Reference in new issue
Block a user