Skip to content

Commit

Permalink
Merge pull request #8349 from unknownbrackets/d3d9-minor
Browse files Browse the repository at this point in the history
Fix some Direct3D 9 validation errors
  • Loading branch information
hrydgard committed Jan 1, 2016
2 parents 03d0d83 + 41b00a9 commit 614eff1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion GPU/Directx9/FramebufferDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,9 @@ namespace DX9 {
if (!fbo)
return fbo;
fbo_bind_as_render_target(fbo);
dxstate.viewport.force(0, 0, w, h);
ClearBuffer(true);
dxstate.viewport.restore();
const TempFBO info = {fbo, gpuStats.numFlips};
tempFBOs_[key] = info;
return fbo;
Expand Down Expand Up @@ -793,7 +795,7 @@ namespace DX9 {
const u32 rw = PSP_CoreParameter().pixelWidth;
const u32 rh = PSP_CoreParameter().pixelHeight;
const RECT srcRect = {(LONG)(u0 * vfb->renderWidth), (LONG)(v0 * vfb->renderHeight), (LONG)(u1 * vfb->renderWidth), (LONG)(v1 * vfb->renderHeight)};
const RECT dstRect = {(LONG)(x * rw / w, y * rh / h), (LONG)((x + w) * rw / w, (y + h) * rh / h)};
const RECT dstRect = {(LONG)(x * rw / w), (LONG)(y * rh / h), (LONG)((x + w) * rw / w), (LONG)((y + h) * rh / h)};
HRESULT hr = fbo_blit_color(vfb->fbo_dx9, &srcRect, nullptr, &dstRect, g_Config.iBufFilter == SCALE_LINEAR ? D3DTEXF_LINEAR : D3DTEXF_POINT);
if (FAILED(hr)) {
ERROR_LOG_REPORT_ONCE(blit_fail, G3D, "fbo_blit_color failed on display: %08x", hr);
Expand Down
7 changes: 6 additions & 1 deletion GPU/Directx9/helper/dx_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,12 @@ class DirectXState {
class StateVp {
D3DVIEWPORT9 viewport;
public:
StateVp() { memset(&viewport, 0, sizeof(viewport)); }
StateVp() {
memset(&viewport, 0, sizeof(viewport));
// It's an error if w/h is zero, so let's start with something that can work.
viewport.Width = 1;
viewport.Height = 1;
}
inline void set(int x, int y, int w, int h, float n = 0.f, float f = 1.f) {
D3DVIEWPORT9 newviewport;
newviewport.X = x;
Expand Down

0 comments on commit 614eff1

Please sign in to comment.