diff --git a/Source/Plugins/Plugin_VideoDX9/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoDX9/Src/BPStructs.cpp index 46ce8fdceb..b7a70aa706 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/BPStructs.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/BPStructs.cpp @@ -455,31 +455,21 @@ void BPWritten(int addr, int changes, int newval) VertexShaderManager::SetViewportChanged(); - // clear color - u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB; - if (bpmem.blendmode.colorupdate) - { - D3DRECT drc; - drc.x1 = rc.left; - drc.x2 = rc.right; - drc.y1 = rc.top; - drc.y2 = rc.bottom; - //D3D::dev->Clear(1, &drc, D3DCLEAR_STENCIL|D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,clearColor,1.0f,0); - //if ((clearColor>>24) == 255) - D3D::dev->ColorFill(D3D::GetBackBufferSurface(), &rc, clearColor); - } - else - { - // TODO: - // bpmem.blendmode.alphaupdate - // bpmem.blendmode.colorupdate - // i dunno how to implement a clear on alpha only or color only + // Since clear operations use the source rectangle, we have to do + // regular renders + if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate) + { + D3DCOLOR col = 0; + if (bpmem.blendmode.colorupdate || bpmem.blendmode.alphaupdate) + col = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB; + + D3D::dev->Clear(0, NULL, NULL, col, 0, 0); } // clear z-buffer if (bpmem.zmode.updateenable) { - float clearZ = (float)bpmem.clearZValue / float(0xFFFFFF); + float clearZ = (float)(bpmem.clearZValue & 0xFFFFFF) / float(0xFFFFFF); if (clearZ > 1.0f) clearZ = 1.0f; if (clearZ < 0.0f) clearZ = 0.0f; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp index 51fd7a4d19..6f8b3fceb3 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp @@ -88,7 +88,7 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) for (int i = 0; i < 3; i++) { - if (_vtx_decl.normal_offset[i] >= 0) + if (_vtx_decl.normal_offset[i] > 0) { elems[elem_idx].Offset = _vtx_decl.normal_offset[i]; elems[elem_idx].Type = VarToD3D(_vtx_decl.normal_gl_type); @@ -100,7 +100,7 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) for (int i = 0; i < 2; i++) { - if (_vtx_decl.color_offset[i] >= 0) + if (_vtx_decl.color_offset[i] > 0) { elems[elem_idx].Offset = _vtx_decl.color_offset[i]; elems[elem_idx].Type = VarToD3D(_vtx_decl.color_gl_type); @@ -112,7 +112,7 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) for (int i = 0; i < 8; i++) { - if (_vtx_decl.texcoord_offset[i] >= 0) + if (_vtx_decl.texcoord_offset[i] > 0) { elems[elem_idx].Offset = _vtx_decl.texcoord_offset[i]; elems[elem_idx].Type = VarToD3D(_vtx_decl.texcoord_gl_type[i]);