Skip to content

Commit

Permalink
Pass in the DrawContext to all backends
Browse files Browse the repository at this point in the history
  • Loading branch information
hrydgard committed Jan 30, 2017
1 parent e7b044c commit 0d1d6f9
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 34 deletions.
4 changes: 2 additions & 2 deletions GPU/Directx9/GPU_DX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
8 changes: 1 addition & 7 deletions GPU/Directx9/GPU_DX9.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -85,10 +85,6 @@ class GPU_DX9 : public GPUCommon {
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);

Expand Down Expand Up @@ -126,8 +122,6 @@ class GPU_DX9 : public GPUCommon {

std::string reportingPrimaryInfo_;
std::string reportingFullInfo_;

GraphicsContext *gfxCtx_;
};

} // namespace DX9
Expand Down
4 changes: 2 additions & 2 deletions GPU/GLES/GPU_GLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
5 changes: 1 addition & 4 deletions GPU/GLES/GPU_GLES.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -129,7 +128,5 @@ class GPU_GLES : public GPUCommon {

std::string reportingPrimaryInfo_;
std::string reportingFullInfo_;

GraphicsContext *gfxCtx_;
std::string shaderCachePath_;
};
10 changes: 5 additions & 5 deletions GPU/GPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions GPU/GPUCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion GPU/GPUCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -261,6 +265,9 @@ class GPUCommon : public GPUThreadEventQueue, public GPUDebugInterface {
DrawEngineCommon *drawEngineCommon_;
ShaderManagerCommon *shaderManager_;

GraphicsContext *gfxCtx_;
Draw::DrawContext *draw_;

typedef std::list<int> DisplayListQueue;

int nextListID;
Expand Down
2 changes: 1 addition & 1 deletion GPU/Null/NullGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions GPU/Software/SoftGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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{};
Expand Down
2 changes: 0 additions & 2 deletions GPU/Software/SoftGpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ class SoftGPU : public GPUCommon {
u32 displayStride_;
GEBufferFormat displayFormat_;

GraphicsContext *gfxCtx_;
Draw::Texture *fbTex;
Draw::DrawContext *draw_;
Draw::Pipeline *texColor;
std::vector<u32> fbTexBuffer;
};
8 changes: 4 additions & 4 deletions GPU/Vulkan/GPU_Vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
3 changes: 1 addition & 2 deletions GPU/Vulkan/GPU_Vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -108,7 +108,6 @@ class GPU_Vulkan : public GPUCommon {
void UpdateCmdInfo();
static CommandInfo cmdInfo_[256];

GraphicsContext *gfxCtx_;
VulkanContext *vulkan_;
FramebufferManagerVulkan *framebufferManagerVulkan_;
TextureCacheVulkan *textureCacheVulkan_;
Expand Down

0 comments on commit 0d1d6f9

Please sign in to comment.