38 changes: 21 additions & 17 deletions Source/Plugins/Plugin_VideoDX9/Src/Render.cpp
Expand Up @@ -288,10 +288,10 @@ Renderer::Renderer()
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);

s_LastAA = g_ActiveConfig.iMultisampleMode;
u32 SupersampleCoefficient = (s_LastAA % 3) + 1;
int SupersampleCoeficient = (s_LastAA % 3) + 1;

s_LastEFBScale = g_ActiveConfig.iEFBScale;
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoefficient);
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoeficient);

// Make sure to use valid texture sizes
D3D::FixTextureSize(s_target_width, s_target_height);
Expand All @@ -305,7 +305,7 @@ Renderer::Renderer()

SetupDeviceObjects();

for (u32 stage = 0; stage < 8; stage++)
for (int stage = 0; stage < 8; stage++)
D3D::SetSamplerState(stage, D3DSAMP_MAXANISOTROPY, 1 << g_ActiveConfig.iMaxAnisotropy);

D3DVIEWPORT9 vp;
Expand Down Expand Up @@ -468,10 +468,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data)

// if depth textures aren't supported by the hardware, just return
if (type == PEEK_Z)
{
if (FramebufferManager::GetEFBDepthTexture() == NULL)
return 0;
}

// We're using three surfaces here:
// - pEFBSurf: EFB Surface. Source surface when peeking, destination surface when poking.
Expand Down Expand Up @@ -695,14 +693,16 @@ void Renderer::UpdateViewport(Matrix44& vpCorrection)
}

// In D3D, the viewport rectangle must fit within the render target.
u32 X = intendedX;
u32 Y = intendedY;
u32 Wd = intendedWd;
u32 Ht = intendedHt;

int X = intendedX;
if (X < 0)
X = 0;
int Y = intendedY;
if (Y < 0)
Y = 0;
int Wd = intendedWd;
if (X + Wd > GetTargetWidth())
Wd = GetTargetWidth() - X;

int Ht = intendedHt;
if (Y + Ht > GetTargetHeight())
Ht = GetTargetHeight() - Y;

Expand Down Expand Up @@ -907,14 +907,18 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
}

u32 X = GetTargetRectangle().left;
u32 Y = GetTargetRectangle().top;
u32 Width = (GetTargetRectangle().right - GetTargetRectangle().left);
u32 Height = (GetTargetRectangle().bottom - GetTargetRectangle().top);
int X = GetTargetRectangle().left;
int Y = GetTargetRectangle().top;
int Width = GetTargetRectangle().right - GetTargetRectangle().left;
int Height = GetTargetRectangle().bottom - GetTargetRectangle().top;

// Sanity check
if (X < 0) X = 0;
if (Y < 0) Y = 0;
if (X > s_backbuffer_width) X = s_backbuffer_width;
if (Y > s_backbuffer_height) Y = s_backbuffer_height;
if (Width < 0) Width = 0;
if (Height < 0) Height = 0;
if (Width > (s_backbuffer_width - X)) Width = s_backbuffer_width - X;
if (Height > (s_backbuffer_height - Y)) Height = s_backbuffer_height - Y;

Expand Down Expand Up @@ -1149,10 +1153,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons

UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);

u32 SupersampleCoefficient = (s_LastAA % 3) + 1;
int SupersampleCoeficient = (s_LastAA % 3) + 1;

s_LastEFBScale = g_ActiveConfig.iEFBScale;
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoefficient);
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoeficient);

D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
Expand Down
2 changes: 1 addition & 1 deletion Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp
Expand Up @@ -299,7 +299,7 @@ GLuint FramebufferManager::ResolveAndGetDepthTarget(const EFBRectangle &source_r
}

void XFBSource::Draw(const MathUtil::Rectangle<float> &sourcerc,
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 height) const
const MathUtil::Rectangle<float> &drawrc, int width, int height) const
{
// Texture map xfbSource->texture onto the main buffer

Expand Down
2 changes: 1 addition & 1 deletion Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.h
Expand Up @@ -63,7 +63,7 @@ struct XFBSource : public XFBSourceBase
void CopyEFB(float Gamma);
void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
void Draw(const MathUtil::Rectangle<float> &sourcerc,
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 height) const;
const MathUtil::Rectangle<float> &drawrc, int width, int height) const;

const GLuint texture;
};
Expand Down
6 changes: 3 additions & 3 deletions Source/Plugins/Plugin_VideoOGL/Src/Render.cpp
Expand Up @@ -323,8 +323,8 @@ Renderer::Renderer()
return; // TODO: fail

// Decide frambuffer size
s_backbuffer_width = GLInterface->GetBackBufferWidth();
s_backbuffer_height = GLInterface->GetBackBufferHeight();
s_backbuffer_width = (int)GLInterface->GetBackBufferWidth();
s_backbuffer_height = (int)GLInterface->GetBackBufferHeight();

// Handle VSync on/off
#ifdef __APPLE__
Expand Down Expand Up @@ -1047,7 +1047,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// Textured triangles are necessary because of post-processing shaders

// Disable all other stages
for (unsigned int i = 1; i < 8; ++i)
for (int i = 1; i < 8; ++i)
OGL::TextureCache::DisableStage(i);

// Update GLViewPort
Expand Down