Remove the DX9 namespace, for consistency with the other backends

This commit is contained in:
Henrik Rydgård committed 2022-08-16 21:49:16 +02:00
1 parent cdb4124bc1
commit d0cdb360fd
16 files changed
+40 -102

No files matched your search

+2 -6
View File
@@ -2,12 +2,10 @@
#include "Common/GPU/D3D9/D3D9StateCache.h"
namespace DX9 {
DirectXState dxstate;
LPDIRECT3DDEVICE9 pD3Ddevice = nullptr;
LPDIRECT3DDEVICE9EX pD3DdeviceEx = nullptr;
LPDIRECT3DDEVICE9 pD3Ddevice9 = nullptr;
LPDIRECT3DDEVICE9EX pD3DdeviceEx9 = nullptr;
int DirectXState::state_count = 0;
@@ -62,6 +60,4 @@ void DirectXState::Restore() {
texAddressW.restore(); count++;
}
} // namespace DX9
#endif // _MSC_VER
+27 -31
View File
@@ -4,11 +4,9 @@
#include "Common/GPU/D3D9/D3D9ShaderCompiler.h"
namespace DX9 {
// TODO: Get rid of these somehow.
extern LPDIRECT3DDEVICE9 pD3Ddevice;
extern LPDIRECT3DDEVICE9EX pD3DdeviceEx;
extern LPDIRECT3DDEVICE9 pD3Ddevice9;
extern LPDIRECT3DDEVICE9EX pD3DdeviceEx9;
class DirectXState {
private:
@@ -44,7 +42,7 @@ private:
return _value;
}
void restore() {
pD3Ddevice->SetRenderState(cap, _value);
pD3Ddevice9->SetRenderState(cap, _value);
}
};
@@ -69,7 +67,7 @@ private:
p1 = old;
}
void restore() {
pD3Ddevice->SetRenderState(_state1, p1);
pD3Ddevice9->SetRenderState(_state1, p1);
}
};
@@ -94,7 +92,7 @@ private:
p1 = old;
}
void restore() {
pD3Ddevice->SetSamplerState(0, _state1, p1);
pD3Ddevice9->SetSamplerState(0, _state1, p1);
}
};
@@ -123,7 +121,7 @@ private:
p1 = old;
}
void restore() {
pD3Ddevice->SetSamplerState(0, _state1, p1d);
pD3Ddevice9->SetSamplerState(0, _state1, p1d);
}
};
@@ -141,11 +139,11 @@ private:
inline void set(DWORD newp1, DWORD newp2) {
if (p1 != newp1) {
p1 = newp1;
pD3Ddevice->SetRenderState(_state1, p1);
pD3Ddevice9->SetRenderState(_state1, p1);
}
if (p2 != newp2) {
p2 = newp2;
pD3Ddevice->SetRenderState(_state2, p2);
pD3Ddevice9->SetRenderState(_state2, p2);
}
}
void force(DWORD newp1, DWORD newp2) {
@@ -156,8 +154,8 @@ private:
p2 = old2;
}
void restore() {
pD3Ddevice->SetRenderState(_state1, p1);
pD3Ddevice->SetRenderState(_state2, p2);
pD3Ddevice9->SetRenderState(_state1, p1);
pD3Ddevice9->SetRenderState(_state2, p2);
}
};
@@ -177,15 +175,15 @@ private:
inline void set(DWORD newp1, DWORD newp2, DWORD newp3) {
if (p1 != newp1) {
p1 = newp1;
pD3Ddevice->SetRenderState(_state1, p1);
pD3Ddevice9->SetRenderState(_state1, p1);
}
if (p2 != newp2) {
p2 = newp2;
pD3Ddevice->SetRenderState(_state2, p2);
pD3Ddevice9->SetRenderState(_state2, p2);
}
if (p3 != newp3) {
p3 = newp3;
pD3Ddevice->SetRenderState(_state3, p3);
pD3Ddevice9->SetRenderState(_state3, p3);
}
}
void force(DWORD newp1, DWORD newp2, DWORD newp3) {
@@ -198,9 +196,9 @@ private:
p3 = old3;
}
void restore() {
pD3Ddevice->SetRenderState(_state1, p1);
pD3Ddevice->SetRenderState(_state2, p2);
pD3Ddevice->SetRenderState(_state3, p3);
pD3Ddevice9->SetRenderState(_state1, p1);
pD3Ddevice9->SetRenderState(_state2, p2);
pD3Ddevice9->SetRenderState(_state3, p3);
}
};
@@ -222,19 +220,19 @@ private:
inline void set(DWORD newp1, DWORD newp2, DWORD newp3, DWORD newp4) {
if (p1 != newp1) {
p1 = newp1;
pD3Ddevice->SetRenderState(_state1, p1);
pD3Ddevice9->SetRenderState(_state1, p1);
}
if (p2 != newp2) {
p2 = newp2;
pD3Ddevice->SetRenderState(_state2, p2);
pD3Ddevice9->SetRenderState(_state2, p2);
}
if (p3 != newp3) {
p3 = newp3;
pD3Ddevice->SetRenderState(_state3, p3);
pD3Ddevice9->SetRenderState(_state3, p3);
}
if (p4 != newp4) {
p4 = newp4;
pD3Ddevice->SetRenderState(_state4, p4);
pD3Ddevice9->SetRenderState(_state4, p4);
}
}
void force(DWORD newp1, DWORD newp2, DWORD newp3, DWORD newp4) {
@@ -249,10 +247,10 @@ private:
p4 = old4;
}
void restore() {
pD3Ddevice->SetRenderState(_state1, p1);
pD3Ddevice->SetRenderState(_state2, p2);
pD3Ddevice->SetRenderState(_state3, p3);
pD3Ddevice->SetRenderState(_state3, p4);
pD3Ddevice9->SetRenderState(_state1, p1);
pD3Ddevice9->SetRenderState(_state2, p2);
pD3Ddevice9->SetRenderState(_state3, p3);
pD3Ddevice9->SetRenderState(_state3, p4);
}
};
@@ -284,7 +282,7 @@ private:
c = old;
}
inline void restore() {
pD3Ddevice->SetRenderState(D3DRS_BLENDFACTOR, c);
pD3Ddevice9->SetRenderState(D3DRS_BLENDFACTOR, c);
}
};
@@ -318,7 +316,7 @@ private:
}
inline void restore() {
pD3Ddevice->SetViewport(&viewport);
pD3Ddevice9->SetViewport(&viewport);
}
};
@@ -340,7 +338,7 @@ private:
}
inline void restore() {
pD3Ddevice->SetScissorRect(&rect);
pD3Ddevice9->SetScissorRect(&rect);
}
};
@@ -412,5 +410,3 @@ struct GLExtensions {
extern GLExtensions gl_extensions;
void CheckGLExtensions();
};
+1 -11
View File
@@ -152,7 +152,6 @@ public:
D3DCMPFUNC stencilCompareOp;
void Apply(LPDIRECT3DDEVICE9 device, uint8_t stencilRef, uint8_t stencilWriteMask, uint8_t stencilCompareMask) {
using namespace DX9;
dxstate.depthTest.set(depthTestEnabled);
if (depthTestEnabled) {
dxstate.depthWrite.set(depthWriteEnabled);
@@ -174,7 +173,6 @@ public:
DWORD cullMode; // D3DCULL_*
void Apply(LPDIRECT3DDEVICE9 device) {
using namespace DX9;
dxstate.cullMode.set(cullMode);
dxstate.scissorTest.enable();
}
@@ -188,7 +186,6 @@ public:
uint32_t colorMask;
void Apply(LPDIRECT3DDEVICE9 device) {
using namespace DX9;
dxstate.blend.set(enabled);
dxstate.blendFunc.set(srcCol, dstCol, srcAlpha, dstAlpha);
dxstate.blendEquation.set(eqCol, eqAlpha);
@@ -202,7 +199,6 @@ public:
D3DTEXTUREFILTERTYPE magFilt, minFilt, mipFilt;
void Apply(LPDIRECT3DDEVICE9 device, int index) {
using namespace DX9;
dxstate.texAddressU.set(wrapS);
dxstate.texAddressV.set(wrapT);
dxstate.texMagFilter.set(magFilt);
@@ -689,7 +685,7 @@ D3D9Context::D3D9Context(IDirect3D9 *d3d, IDirect3D9Ex *d3dEx, int adapterId, ID
shaderLanguageDesc_.Init(HLSL_D3D9);
DX9::dxstate.Restore();
dxstate.Restore();
}
D3D9Context::~D3D9Context() {
@@ -1037,15 +1033,11 @@ void D3D9Context::Clear(int mask, uint32_t colorval, float depthVal, int stencil
}
void D3D9Context::SetScissorRect(int left, int top, int width, int height) {
using namespace DX9;
dxstate.scissorRect.set(left, top, left + width, top + height);
dxstate.scissorTest.set(true);
}
void D3D9Context::SetViewports(int count, Viewport *viewports) {
using namespace DX9;
int x = (int)viewports[0].TopLeftX;
int y = (int)viewports[0].TopLeftY;
int w = (int)viewports[0].Width;
@@ -1058,7 +1050,6 @@ void D3D9Context::SetBlendFactor(float color[4]) {
uint32_t g = (uint32_t)(color[1] * 255.0f);
uint32_t b = (uint32_t)(color[2] * 255.0f);
uint32_t a = (uint32_t)(color[3] * 255.0f);
using namespace DX9;
dxstate.blendColor.set(color);
}
@@ -1179,7 +1170,6 @@ D3D9Framebuffer::~D3D9Framebuffer() {
}
void D3D9Context::BindFramebufferAsRenderTarget(Framebuffer *fbo, const RenderPassInfo &rp, const char *tag) {
using namespace DX9;
if (fbo) {
D3D9Framebuffer *fb = (D3D9Framebuffer *)fbo;
device_->SetRenderTarget(0, fb->surf);
+4 -8
View File
@@ -42,8 +42,6 @@
#include "GPU/Directx9/ShaderManagerDX9.h"
#include "GPU/Directx9/GPU_DX9.h"
namespace DX9 {
static const D3DPRIMITIVETYPE d3d_prim[8] = {
// Points, which are expanded to triangles.
D3DPT_TRIANGLELIST,
@@ -248,7 +246,7 @@ void DrawEngineDX9::MarkUnreliable(VertexArrayInfoDX9 *vai) {
}
void DrawEngineDX9::ClearTrackedVertexArrays() {
vai_.Iterate([&](uint32_t hash, DX9::VertexArrayInfoDX9 *vai) {
vai_.Iterate([&](uint32_t hash, VertexArrayInfoDX9 *vai) {
delete vai;
});
vai_.Clear();
@@ -264,7 +262,7 @@ void DrawEngineDX9::DecimateTrackedVertexArrays() {
const int threshold = gpuStats.numFlips - VAI_KILL_AGE;
const int unreliableThreshold = gpuStats.numFlips - VAI_UNRELIABLE_KILL_AGE;
int unreliableLeft = VAI_UNRELIABLE_KILL_MAX;
vai_.Iterate([&](uint32_t hash, DX9::VertexArrayInfoDX9 *vai) {
vai_.Iterate([&](uint32_t hash, VertexArrayInfoDX9 *vai) {
bool kill;
if (vai->status == VertexArrayInfoDX9::VAI_UNRELIABLE) {
// We limit killing unreliable so we don't rehash too often.
@@ -524,7 +522,7 @@ rotateVBO:
ApplyDrawState(prim);
ApplyDrawStateLate();
DX9::VSShader *vshader = shaderManager_->ApplyShader(true, useHWTessellation_, lastVType_, decOptions_.expandAllWeightsToFloat);
VSShader *vshader = shaderManager_->ApplyShader(true, useHWTessellation_, lastVType_, decOptions_.expandAllWeightsToFloat);
IDirect3DVertexDeclaration9 *pHardwareVertexDecl = SetupDecFmtForDraw(vshader, dec_->GetDecVtxFmt(), dec_->VertexType());
if (pHardwareVertexDecl) {
@@ -616,7 +614,7 @@ rotateVBO:
ApplyDrawStateLate();
DX9::VSShader *vshader = shaderManager_->ApplyShader(false, false, lastVType_, decOptions_.expandAllWeightsToFloat);
VSShader *vshader = shaderManager_->ApplyShader(false, false, lastVType_, decOptions_.expandAllWeightsToFloat);
if (result.action == SW_DRAW_PRIMITIVES) {
if (result.setStencil) {
@@ -686,5 +684,3 @@ rotateVBO:
void TessellationDataTransferDX9::SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) {
// TODO
}
} // namespace
-4
View File
@@ -30,8 +30,6 @@
struct DecVtxFormat;
struct UVScale;
namespace DX9 {
class VSShader;
class ShaderManagerDX9;
class TextureCacheDX9;
@@ -175,5 +173,3 @@ private:
int lastRenderStepId_ = -1;
};
} // namespace
+1 -3
View File
@@ -45,7 +45,7 @@
#include <emmintrin.h>
#endif
namespace DX9 {
// TODO: De-indent, the day we move all this readback stuff to GPU/Common
FramebufferManagerDX9::FramebufferManagerDX9(Draw::DrawContext *draw)
: FramebufferManagerCommon(draw) {
@@ -396,5 +396,3 @@ namespace DX9 {
return success;
}
} // namespace DX9
-4
View File
@@ -28,8 +28,6 @@
#include "GPU/GPUCommon.h"
#include "GPU/Common/FramebufferManagerCommon.h"
namespace DX9 {
class TextureCacheDX9;
class DrawEngineDX9;
class ShaderManagerDX9;
@@ -67,5 +65,3 @@ private:
std::unordered_map<u64, OffscreenSurface> offscreenSurfaces_;
};
} // namespace
-4
View File
@@ -49,8 +49,6 @@
#include "Core/HLE/sceKernelInterrupt.h"
#include "Core/HLE/sceGe.h"
namespace DX9 {
GPU_DX9::GPU_DX9(GraphicsContext *gfxCtx, Draw::DrawContext *draw)
: GPUCommon(gfxCtx, draw),
drawEngine_(draw) {
@@ -393,5 +391,3 @@ std::string GPU_DX9::DebugGetShaderString(std::string id, DebugShaderType type,
return shaderManagerDX9_->DebugGetShaderString(id, type, stringType);
}
}
} // namespace DX9
-6
View File
@@ -26,8 +26,6 @@
#include "GPU/Common/DepalettizeCommon.h"
#include "GPU/Common/VertexDecoderCommon.h"
namespace DX9 {
class ShaderManagerDX9;
class LinkedShaderDX9;
class TextureCacheDX9;
@@ -80,7 +78,3 @@ private:
DrawEngineDX9 drawEngine_;
ShaderManagerDX9 *shaderManagerDX9_;
};
} // namespace DX9
typedef DX9::GPU_DX9 DIRECTX9_GPU;
-4
View File
@@ -49,8 +49,6 @@
using namespace Lin;
namespace DX9 {
PSShader::PSShader(LPDIRECT3DDEVICE9 device, FShaderID id, const char *code) : id_(id) {
source_ = code;
#ifdef SHADERLOG
@@ -702,5 +700,3 @@ std::string ShaderManagerDX9::DebugGetShaderString(std::string id, DebugShaderTy
return "N/A";
}
}
} // namespace
-4
View File
@@ -27,8 +27,6 @@
#include "GPU/Common/ShaderId.h"
#include "Common/Math/lin/matrix4x4.h"
namespace DX9 {
class PSShader;
class VSShader;
@@ -126,5 +124,3 @@ private:
typedef std::map<VShaderID, VSShader *> VSCache;
VSCache vsCache_;
};
};
-4
View File
@@ -32,8 +32,6 @@
#include "GPU/Directx9/TextureCacheDX9.h"
#include "GPU/Directx9/FramebufferManagerDX9.h"
namespace DX9 {
static const D3DBLEND dxBlendFactorLookup[(size_t)BlendFactor::COUNT] = {
D3DBLEND_ZERO,
D3DBLEND_ONE,
@@ -298,5 +296,3 @@ void DrawEngineDX9::ApplyDrawStateLate() {
// At this point, we know if the vertices are full alpha or not.
// TODO: Set the nearest/linear here (since we correctly know if alpha/color tests are needed)?
}
}
-4
View File
@@ -51,8 +51,6 @@ D3DFORMAT ToD3D9Format(Draw::DataFormat fmt) {
}
}
namespace DX9 {
#define INVALID_TEX (LPDIRECT3DTEXTURE9)(-1)
static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
@@ -443,5 +441,3 @@ bool TextureCacheDX9::GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level)
return success;
}
};
-4
View File
@@ -26,8 +26,6 @@
struct VirtualFramebuffer;
class DepalShaderCache;
namespace DX9 {
class FramebufferManagerDX9;
class ShaderManagerDX9;
@@ -78,5 +76,3 @@ private:
};
D3DFORMAT getClutDestFormat(GEPaletteFormat format);
};
+1 -1
View File
@@ -83,7 +83,7 @@ bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) {
break;
case GPUCORE_DIRECTX9:
#if PPSSPP_API(D3D9)
SetGPU(new DIRECTX9_GPU(ctx, draw));
SetGPU(new GPU_DX9(ctx, draw));
break;
#else
return false;
+4 -4
View File
@@ -160,8 +160,8 @@ bool D3D9Context::Init(HINSTANCE hInst, HWND wnd, std::string *error_message) {
}
device_->BeginScene();
DX9::pD3Ddevice = device_;
DX9::pD3DdeviceEx = deviceEx_;
pD3Ddevice9 = device_;
pD3DdeviceEx9 = deviceEx_;
if (deviceEx_ && IsWin7OrHigher()) {
// TODO: This makes it slower?
@@ -212,8 +212,8 @@ void D3D9Context::Shutdown() {
device_->Release();
d3d_->Release();
UnloadD3DCompiler();
DX9::pD3Ddevice = nullptr;
DX9::pD3DdeviceEx = nullptr;
pD3Ddevice9 = nullptr;
pD3DdeviceEx9 = nullptr;
device_ = nullptr;
hWnd_ = nullptr;
FreeLibrary(hD3D9_);