Make the D3D backend cmd processing work more similar to the GL backend

This commit is contained in:
Henrik Rydgard 2014-09-13 12:11:34 +02:00
parent 7a1be69ec0
commit 9b587bb144
8 changed files with 534 additions and 302 deletions

File diff suppressed because it is too large Load diff

View file

@ -39,7 +39,6 @@ public:
~DIRECTX9_GPU();
virtual void InitClear();
virtual void PreExecuteOp(u32 op, u32 diff);
void ExecuteOpInternal(u32 op, u32 diff);
virtual void ExecuteOp(u32 op, u32 diff);
virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format);
@ -79,11 +78,36 @@ public:
bool GetCurrentTexture(GPUDebugBuffer &buffer, int level);
bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices);
typedef void (DIRECTX9_GPU::*CmdFunc)(u32 op, u32 diff);
struct CommandInfo {
u8 flags;
DIRECTX9_GPU::CmdFunc func;
};
void Execute_Generic(u32 op, u32 diff);
void Execute_Vaddr(u32 op, u32 diff);
void Execute_Iaddr(u32 op, u32 diff);
void Execute_VertexType(u32 op, u32 diff);
void Execute_VertexTypeSkinning(u32 op, u32 diff);
void Execute_WorldMtxNum(u32 op, u32 diff);
void Execute_WorldMtxData(u32 op, u32 diff);
void Execute_ViewMtxNum(u32 op, u32 diff);
void Execute_ViewMtxData(u32 op, u32 diff);
void Execute_ProjMtxNum(u32 op, u32 diff);
void Execute_ProjMtxData(u32 op, u32 diff);
void Execute_TgenMtxNum(u32 op, u32 diff);
void Execute_TgenMtxData(u32 op, u32 diff);
void Execute_BoneMtxNum(u32 op, u32 diff);
void Execute_BoneMtxData(u32 op, u32 diff);
protected:
virtual void FastRunLoop(DisplayList &list);
virtual void ProcessEvent(GPUEvent ev);
virtual void FastLoadBoneMatrix(u32 target);
private:
void UpdateCmdInfo();
void Flush() {
transformDraw_.Flush();
}
@ -101,7 +125,7 @@ private:
TransformDrawEngineDX9 transformDraw_;
ShaderManagerDX9 *shaderManager_;
u8 *commandFlags_;
static CommandInfo cmdInfo_[256];
bool resized_;
int lastVsync_;
@ -110,6 +134,6 @@ private:
std::string reportingFullInfo_;
};
};
} // namespace DX9
typedef DX9::DIRECTX9_GPU DIRECTX9_GPU;

View file

@ -40,7 +40,8 @@ enum {
DIRTY_FOGCOEF = (1 << 3),
DIRTY_TEXENV = (1 << 4),
DIRTY_ALPHACOLORREF = (1 << 5),
DIRTY_COLORREF = (1 << 6),
DIRTY_STENCILREPLACEVALUE = (1 << 6),
DIRTY_ALPHACOLORMASK = (1 << 7),
DIRTY_LIGHT0 = (1 << 8),
DIRTY_LIGHT1 = (1 << 9),
@ -54,6 +55,7 @@ enum {
DIRTY_MATAMBIENTALPHA = (1 << 16),
DIRTY_MATERIAL = (1 << 17), // let's set all 4 together (emissive ambient diffuse specular). We hide specular coef in specular.a
DIRTY_UVSCALEOFFSET = (1 << 18), // this will be dirtied ALL THE TIME... maybe we'll need to do "last value with this shader compares"
DIRTY_TEXCLAMP = (1 << 19),
DIRTY_WORLDMATRIX = (1 << 21),
DIRTY_VIEWMATRIX = (1 << 22), // Maybe we'll fold this into projmatrix eventually
@ -108,8 +110,7 @@ protected:
bool useHWTransform_;
};
class ShaderManagerDX9
{
class ShaderManagerDX9 {
public:
ShaderManagerDX9();
~ShaderManagerDX9();

View file

@ -876,6 +876,19 @@ void TransformDrawEngineDX9::SubmitPrim(void *verts, void *inds, GEPrimitiveType
}
numDrawCalls++;
vertexCountInDrawCalls += vertexCount;
if (g_Config.bSoftwareSkinning && (vertType & GE_VTYPE_WEIGHT_MASK)) {
// TODO
// DecodeVertsStep();
// decodeCounter_++;
}
if (prim == GE_PRIM_RECTANGLES && (gstate.getTextureAddress(0) & 0x3FFFFFFF) == (gstate.getFrameBufAddress() & 0x3FFFFFFF)) {
if (!g_Config.bDisableSlowFramebufEffects) {
gstate_c.textureChanged |= TEXCHANGE_PARAMSONLY;
Flush();
}
}
}
void TransformDrawEngineDX9::DecodeVerts() {

View file

@ -205,8 +205,8 @@ private:
FramebufferManagerDX9 *framebufferManager_;
VertexDecoderJitCache *decJitCache_;
enum { MAX_DEFERRED_DRAW_CALLS = 128 };
DeferredDrawCall drawCalls[MAX_DEFERRED_DRAW_CALLS];
int numDrawCalls;
int vertexCountInDrawCalls;

View file

@ -425,7 +425,7 @@ GLES_GPU::GLES_GPU()
cmdInfo_[cmd].flags |= commandTable[i].flags;
cmdInfo_[cmd].func = commandTable[i].func;
if (!cmdInfo_[cmd].func) {
cmdInfo_[cmd].func = &GLES_GPU::ExecuteOpInternal;
cmdInfo_[cmd].func = &GLES_GPU::Execute_Generic;
}
}
// Find commands missing from the table.
@ -800,8 +800,6 @@ void GLES_GPU::Execute_Prim(u32 op, u32 diff) {
return;
}
// TODO: Split this so that we can collect sequences of primitives, can greatly speed things up
// on platforms where draw calls are expensive like mobile and D3D
void *verts = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
void *inds = 0;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
@ -1367,7 +1365,7 @@ void GLES_GPU::Execute_BlockTransferStart(u32 op, u32 diff) {
gstate_c.textureChanged = TEXCHANGE_UPDATED;
}
void GLES_GPU::ExecuteOpInternal(u32 op, u32 diff) {
void GLES_GPU::Execute_Generic(u32 op, u32 diff) {
u32 cmd = op >> 24;
u32 data = op & 0xFFFFFF;
@ -2168,6 +2166,7 @@ void GLES_GPU::DoState(PointerWrap &p) {
gstate_c.textureChanged = TEXCHANGE_UPDATED;
framebufferManager_.DestroyAllFBOs();
shaderManager_->ClearCache(true);
}
}

View file

@ -39,7 +39,7 @@ public:
virtual void InitClear();
virtual void Reinitialize();
virtual void PreExecuteOp(u32 op, u32 diff);
void ExecuteOpInternal(u32 op, u32 diff);
void Execute_Generic(u32 op, u32 diff);
virtual void ExecuteOp(u32 op, u32 diff);
virtual void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format);

View file

@ -107,9 +107,7 @@ public:
int u_lightambient[4]; // attenuation
};
// Will reach 32 bits soon :P
enum
{
enum {
DIRTY_PROJMATRIX = (1 << 0),
DIRTY_PROJTHROUGHMATRIX = (1 << 1),
DIRTY_FOGCOLOR = (1 << 2),