Pass in the DrawContext to all backends

This commit is contained in:
Henrik Rydgard 2017-01-30 16:50:35 +01:00
parent e7b044c449
commit 0d1d6f98e4
12 changed files with 31 additions and 34 deletions

View File

@ -393,8 +393,8 @@ static const CommandTableEntry commandTable[] = {
GPU_DX9::CommandInfo GPU_DX9::cmdInfo_[256];
GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx)
: gfxCtx_(gfxCtx) {
GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
: GPUCommon(gfxCtx, draw) {
lastVsync_ = g_Config.bVSync ? 1 : 0;
dxstate.SetVSyncInterval(g_Config.bVSync);

View File

@ -35,7 +35,7 @@ class LinkedShaderDX9;
class GPU_DX9 : public GPUCommon {
public:
GPU_DX9(GraphicsContext *gfxCtx);
GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
~GPU_DX9();
void CheckGPUFeatures();
@ -85,10 +85,6 @@ public:
void Execute_Spline(u32 op, u32 diff);
void Execute_VertexType(u32 op, u32 diff);
void Execute_VertexTypeSkinning(u32 op, u32 diff);
void Execute_TexScaleU(u32 op, u32 diff);
void Execute_TexScaleV(u32 op, u32 diff);
void Execute_TexOffsetU(u32 op, u32 diff);
void Execute_TexOffsetV(u32 op, u32 diff);
void Execute_TexSize0(u32 op, u32 diff);
void Execute_LoadClut(u32 op, u32 diff);
@ -126,8 +122,6 @@ private:
std::string reportingPrimaryInfo_;
std::string reportingFullInfo_;
GraphicsContext *gfxCtx_;
};
} // namespace DX9

View File

@ -393,8 +393,8 @@ static const CommandTableEntry commandTable[] = {
GPU_GLES::CommandInfo GPU_GLES::cmdInfo_[256];
GPU_GLES::GPU_GLES(GraphicsContext *ctx)
: gfxCtx_(ctx) {
GPU_GLES::GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
: GPUCommon(gfxCtx, draw) {
UpdateVsyncInterval(true);
CheckGPUFeatures();

View File

@ -30,11 +30,10 @@
class ShaderManagerGLES;
class LinkedShader;
class GraphicsContext;
class GPU_GLES : public GPUCommon {
public:
GPU_GLES(GraphicsContext *gfxCtx);
GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
~GPU_GLES();
// This gets called on startup and when we get back from settings.
@ -129,7 +128,5 @@ private:
std::string reportingPrimaryInfo_;
std::string reportingFullInfo_;
GraphicsContext *gfxCtx_;
std::string shaderCachePath_;
};

View File

@ -46,20 +46,20 @@ static void SetGPU(T *obj) {
#undef new
#endif
bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *thin3d) {
bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) {
switch (PSP_CoreParameter().gpuCore) {
case GPUCORE_NULL:
SetGPU(new NullGPU());
break;
case GPUCORE_GLES:
SetGPU(new GPU_GLES(ctx));
SetGPU(new GPU_GLES(ctx, draw));
break;
case GPUCORE_SOFTWARE:
SetGPU(new SoftGPU(ctx, thin3d));
SetGPU(new SoftGPU(ctx, draw));
break;
case GPUCORE_DIRECTX9:
#if defined(_WIN32)
SetGPU(new DIRECTX9_GPU(ctx));
SetGPU(new DIRECTX9_GPU(ctx, draw));
#endif
break;
case GPUCORE_DIRECTX11:
@ -70,7 +70,7 @@ bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *thin3d) {
ERROR_LOG(G3D, "Unable to init Vulkan GPU backend, no context");
break;
}
SetGPU(new GPU_Vulkan(ctx));
SetGPU(new GPU_Vulkan(ctx, draw));
#endif
break;
}

View File

@ -30,11 +30,13 @@ void GPUCommon::Flush() {
drawEngineCommon_->DispatchFlush();
}
GPUCommon::GPUCommon() :
GPUCommon::GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw) :
dumpNextFrame_(false),
dumpThisFrame_(false),
framebufferManager_(nullptr),
resized_(false)
resized_(false),
gfxCtx_(gfxCtx),
draw_(draw)
{
// This assert failed on GCC x86 32-bit (but not MSVC 32-bit!) before adding the
// "padding" field at the end. This is important for save state compatibility.

View File

@ -18,6 +18,10 @@ typedef ThreadEventQueue<GPUInterface, GPUEvent, GPUEventType, GPU_EVENT_INVALID
class FramebufferManagerCommon;
class TextureCacheCommon;
class DrawEngineCommon;
class GraphicsContext;
namespace Draw {
class DrawContext;
}
enum DrawType {
DRAW_UNKNOWN,
@ -28,7 +32,7 @@ enum DrawType {
class GPUCommon : public GPUThreadEventQueue, public GPUDebugInterface {
public:
GPUCommon();
GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
virtual ~GPUCommon();
void Reinitialize() override;
@ -261,6 +265,9 @@ protected:
DrawEngineCommon *drawEngineCommon_;
ShaderManagerCommon *shaderManager_;
GraphicsContext *gfxCtx_;
Draw::DrawContext *draw_;
typedef std::list<int> DisplayListQueue;
int nextListID;

View File

@ -25,7 +25,7 @@
#include "Core/HLE/sceKernelInterrupt.h"
#include "Core/HLE/sceGe.h"
NullGPU::NullGPU() { }
NullGPU::NullGPU() : GPUCommon(nullptr, nullptr) { }
NullGPU::~NullGPU() { }
void NullGPU::FastRunLoop(DisplayList &list) {

View File

@ -47,8 +47,8 @@ static Draw::SamplerState *samplerLinear = nullptr;
static Draw::Buffer *vdata = nullptr;
static Draw::Buffer *idata = nullptr;
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *_thin3D)
: gfxCtx_(gfxCtx), draw_(_thin3D)
SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
: GPUCommon(gfxCtx, draw)
{
using namespace Draw;
TextureDesc desc{};

View File

@ -103,9 +103,7 @@ private:
u32 displayStride_;
GEBufferFormat displayFormat_;
GraphicsContext *gfxCtx_;
Draw::Texture *fbTex;
Draw::DrawContext *draw_;
Draw::Pipeline *texColor;
std::vector<u32> fbTexBuffer;
};

View File

@ -388,10 +388,10 @@ static const CommandTableEntry commandTable[] = {
{ GE_CMD_UNKNOWN_FF, 0 },
};
GPU_Vulkan::GPU_Vulkan(GraphicsContext *ctx)
: vulkan_((VulkanContext *)ctx->GetAPIContext()),
drawEngine_(vulkan_),
gfxCtx_(ctx) {
GPU_Vulkan::GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
: GPUCommon(gfxCtx, draw),
vulkan_((VulkanContext *)gfxCtx->GetAPIContext()),
drawEngine_(vulkan_) {
UpdateVsyncInterval(true);
CheckGPUFeatures();

View File

@ -32,7 +32,7 @@ class LinkedShader;
class GPU_Vulkan : public GPUCommon {
public:
GPU_Vulkan(GraphicsContext *ctx);
GPU_Vulkan(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
~GPU_Vulkan();
// This gets called on startup and when we get back from settings.
@ -108,7 +108,6 @@ private:
void UpdateCmdInfo();
static CommandInfo cmdInfo_[256];
GraphicsContext *gfxCtx_;
VulkanContext *vulkan_;
FramebufferManagerVulkan *framebufferManagerVulkan_;
TextureCacheVulkan *textureCacheVulkan_;