mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
More DX cleanup
This commit is contained in:
parent
d05ef4a859
commit
a8f69e7d64
@ -74,7 +74,7 @@ static const char * pscode =
|
||||
" return c;\n"
|
||||
"}\n";
|
||||
|
||||
void DXSetViewport(float x, float y, float w, float h, float minZ, float maxZ) {
|
||||
static void DXSetViewport(float x, float y, float w, float h, float minZ, float maxZ) {
|
||||
D3DVIEWPORT9 vp;
|
||||
vp.X = (DWORD)x;
|
||||
vp.Y = (DWORD)y;
|
||||
@ -252,11 +252,13 @@ void DXSetViewport(float x, float y, float w, float h, float minZ, float maxZ) {
|
||||
void FramebufferManagerDX9::DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) {
|
||||
if (useBufferedRendering_ && vfb && vfb->fbo_dx9) {
|
||||
fbo_bind_as_render_target(vfb->fbo_dx9);
|
||||
DXSetViewport(0, 0, vfb->renderWidth, vfb->renderHeight);
|
||||
D3DVIEWPORT9 vp{ 0, 0, vfb->renderWidth, vfb->renderHeight, 0.0f, 1.0f };
|
||||
pD3Ddevice->SetViewport(&vp);
|
||||
} else {
|
||||
float x, y, w, h;
|
||||
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL);
|
||||
DXSetViewport(x, y, w, h);
|
||||
D3DVIEWPORT9 vp{ (DWORD)x, (DWORD)y, (DWORD)w, (DWORD)h, 0.0f, 1.0f };
|
||||
pD3Ddevice->SetViewport(&vp);
|
||||
}
|
||||
MakePixelTexture(srcPixels, srcPixelFormat, srcStride, width, height);
|
||||
DisableState();
|
||||
@ -569,7 +571,7 @@ void DXSetViewport(float x, float y, float w, float h, float minZ, float maxZ) {
|
||||
shaderManager_->DirtyLastShader();
|
||||
pD3Ddevice->SetTexture(0, nullptr);
|
||||
|
||||
DXSetViewport(0, 0, vfb->renderWidth, vfb->renderHeight);
|
||||
DXSetViewport(0, 0, vfb->renderWidth, vfb->renderHeight, 0.0f, 1.0f);
|
||||
|
||||
// This should clear stencil and alpha without changing the other colors.
|
||||
HRESULT hr = pD3Ddevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coord, 5 * sizeof(float));
|
||||
@ -784,7 +786,7 @@ void DXSetViewport(float x, float y, float w, float h, float minZ, float maxZ) {
|
||||
if (useBufferedRendering_) {
|
||||
// In buffered, we no longer clear the backbuffer before we start rendering.
|
||||
ClearBuffer();
|
||||
DXSetViewport(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
DXSetViewport(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
u32 offsetX = 0;
|
||||
@ -894,7 +896,7 @@ void DXSetViewport(float x, float y, float w, float h, float minZ, float maxZ) {
|
||||
g_Config.iBufFilter == SCALE_LINEAR ? FB_BLIT_LINEAR : FB_BLIT_NEAREST);
|
||||
if (!result) {
|
||||
ERROR_LOG_REPORT_ONCE(blit_fail, G3D, "fbo_blit_color failed on display");
|
||||
DXSetViewport(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
||||
DXSetViewport(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight, 0.0f, 1.0f);
|
||||
// These are in the output display coordinates
|
||||
if (g_Config.iBufFilter == SCALE_LINEAR) {
|
||||
dxstate.texMagFilter.set(D3DTEXF_LINEAR);
|
||||
|
@ -221,7 +221,8 @@ bool FramebufferManagerDX9::NotifyStencilUpload(u32 addr, int size, bool skipZer
|
||||
if (dstBuffer->fbo_dx9) {
|
||||
fbo_bind_as_render_target(dstBuffer->fbo_dx9);
|
||||
}
|
||||
DXSetViewport(0, 0, w, h);
|
||||
D3DVIEWPORT9 vp{ 0, 0, w, h, 0.0f, 1.0f };
|
||||
pD3Ddevice->SetViewport(&vp);
|
||||
|
||||
MakePixelTexture(src, dstBuffer->format, dstBuffer->fb_stride, dstBuffer->bufferWidth, dstBuffer->bufferHeight);
|
||||
|
||||
|
@ -741,7 +741,8 @@ public:
|
||||
pD3Ddevice->SetRenderState(D3DRS_SCISSORTESTENABLE, FALSE);
|
||||
pD3Ddevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
|
||||
DXSetViewport(0, 0, renderW_, renderH_);
|
||||
D3DVIEWPORT9 vp{ 0, 0, (DWORD)renderW_, (DWORD)renderH_, 0.0f, 1.0f };
|
||||
pD3Ddevice->SetViewport(&vp);
|
||||
HRESULT hr = pD3Ddevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts_, (3 + 2) * sizeof(float));
|
||||
if (FAILED(hr)) {
|
||||
ERROR_LOG_REPORT(G3D, "Depal render failed: %08x", hr);
|
||||
|
@ -9,7 +9,6 @@ namespace DX9 {
|
||||
|
||||
LPDIRECT3DDEVICE9 pD3Ddevice = nullptr;
|
||||
LPDIRECT3DDEVICE9EX pD3DdeviceEx = nullptr;
|
||||
LPDIRECT3D9 pD3D = nullptr;
|
||||
|
||||
IDirect3DVertexDeclaration9* pFramebufferVertexDecl = nullptr;
|
||||
|
||||
@ -19,9 +18,6 @@ static const D3DVERTEXELEMENT9 VertexElements[] = {
|
||||
D3DDECL_END()
|
||||
};
|
||||
|
||||
LPDIRECT3DVERTEXSHADER9 pFramebufferVertexShader = nullptr; // Vertex Shader
|
||||
LPDIRECT3DPIXELSHADER9 pFramebufferPixelShader = nullptr; // Pixel Shader
|
||||
|
||||
bool CompilePixelShader(const char *code, LPDIRECT3DPIXELSHADER9 *pShader, LPD3DXCONSTANTTABLE *pShaderTable, std::string &errorMessage) {
|
||||
ID3DXBuffer *pShaderCode = nullptr;
|
||||
ID3DXBuffer *pErrorMsg = nullptr;
|
||||
|
@ -18,10 +18,5 @@ bool CompileShaders(std::string &errorMessage);
|
||||
bool CompilePixelShader(const char *code, LPDIRECT3DPIXELSHADER9 *pShader, ID3DXConstantTable **pShaderTable, std::string &errorMessage);
|
||||
bool CompileVertexShader(const char *code, LPDIRECT3DVERTEXSHADER9 *pShader, ID3DXConstantTable **pShaderTable, std::string &errorMessage);
|
||||
void DestroyShaders();
|
||||
void DirectxInit(HWND window);
|
||||
|
||||
void DXSetViewport(float x, float y, float w, float h, float minZ = 0.0f, float maxZ = 1.0f);
|
||||
|
||||
#define D3DBLEND_UNK D3DBLEND_FORCE_DWORD
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
@ -304,6 +304,12 @@ enum InfoField {
|
||||
RENDERER,
|
||||
};
|
||||
|
||||
enum class NativeObject {
|
||||
CONTEXT,
|
||||
DEVICE,
|
||||
DEVICE_EX,
|
||||
};
|
||||
|
||||
// Binary compatible with D3D11 viewport.
|
||||
struct Viewport {
|
||||
float TopLeftX;
|
||||
@ -554,6 +560,8 @@ public:
|
||||
|
||||
virtual std::string GetInfoString(InfoField info) const = 0;
|
||||
|
||||
virtual uintptr_t GetNativeObject(NativeObject obj) const = 0;
|
||||
|
||||
protected:
|
||||
void CreatePresets();
|
||||
|
||||
|
@ -70,6 +70,17 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
uintptr_t GetNativeObject(NativeObject obj) const override {
|
||||
switch (obj) {
|
||||
case NativeObject::DEVICE:
|
||||
return (uintptr_t)device_;
|
||||
case NativeObject::CONTEXT:
|
||||
return (uintptr_t)context_;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void ApplyCurrentState();
|
||||
|
||||
|
@ -580,6 +580,19 @@ public:
|
||||
void DrawUP(const void *vdata, int vertexCount) override;
|
||||
void Clear(int mask, uint32_t colorval, float depthVal, int stencilVal);
|
||||
|
||||
uintptr_t GetNativeObject(NativeObject obj) const override {
|
||||
switch (obj) {
|
||||
case NativeObject::CONTEXT:
|
||||
return (uintptr_t)d3d_;
|
||||
case NativeObject::DEVICE:
|
||||
return (uintptr_t)device_;
|
||||
case NativeObject::DEVICE_EX:
|
||||
return (uintptr_t)deviceEx_;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
std::string GetInfoString(InfoField info) const override {
|
||||
switch (info) {
|
||||
case APIVERSION: return "DirectX 9.0";
|
||||
|
@ -606,6 +606,11 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
uintptr_t GetNativeObject(NativeObject obj) const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<OpenGLSamplerState *> samplerStates_;
|
||||
DeviceCaps caps_;
|
||||
|
||||
|
@ -421,6 +421,10 @@ public:
|
||||
|
||||
std::vector<std::string> GetFeatureList() const override;
|
||||
|
||||
uintptr_t GetNativeObject(NativeObject obj) const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
void ApplyDynamicState();
|
||||
void DirtyDynamicState();
|
||||
|
Loading…
Reference in New Issue
Block a user