Revert "Made several variables/parameters unsigned in the DX9, DX11 and OGL plugins. They make more sense like this (given their names)."

Turns out I was wrong in my previous commit. My bad.

This reverts commit 8743166663.
This commit is contained in:
lioncash 2013-01-16 15:46:11 -05:00
parent 8743166663
commit 0ef3bd9c77
16 changed files with 104 additions and 98 deletions

View File

@ -17,7 +17,7 @@ struct XFBSourceBase
// TODO: only DX9 uses the width/height params
virtual void Draw(const MathUtil::Rectangle<float> &sourcerc,
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 height) const = 0;
const MathUtil::Rectangle<float> &drawrc, int width, int height) const = 0;
virtual void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight) = 0;

View File

@ -60,12 +60,12 @@ std::string Renderer::s_sScreenshotName;
volatile bool Renderer::s_bScreenshot;
// The framebuffer size
unsigned int Renderer::s_target_width;
unsigned int Renderer::s_target_height;
int Renderer::s_target_width;
int Renderer::s_target_height;
// TODO: Add functionality to reinit all the render targets when the window is resized.
unsigned int Renderer::s_backbuffer_width;
unsigned int Renderer::s_backbuffer_height;
int Renderer::s_backbuffer_width;
int Renderer::s_backbuffer_height;
TargetRectangle Renderer::target_rc;
@ -163,7 +163,7 @@ int Renderer::EFBToScaledY(int y)
};
}
void Renderer::CalculateTargetScale(unsigned int x, unsigned int y, unsigned int &scaledX, unsigned int &scaledY)
void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY)
{
if (g_ActiveConfig.iEFBScale == 0 || g_ActiveConfig.iEFBScale == 1)
{
@ -172,15 +172,15 @@ void Renderer::CalculateTargetScale(unsigned int x, unsigned int y, unsigned int
}
else
{
scaledX = x * (efb_scale_numeratorX / efb_scale_denominatorX);
scaledY = y * (efb_scale_numeratorY / efb_scale_denominatorY);
scaledX = x * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX;
scaledY = y * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY;
}
}
// return true if target size changed
bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, unsigned int multiplier)
bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier)
{
u32 newEFBWidth, newEFBHeight;
int newEFBWidth, newEFBHeight;
// TODO: Ugly. Clean up
switch (s_LastEFBScale)
@ -374,7 +374,7 @@ void Renderer::DrawDebugText()
// TODO: remove
extern bool g_aspect_wide;
void Renderer::UpdateDrawRectangle(u32 backbuffer_width, u32 backbuffer_height)
void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height)
{
float FloatGLWidth = (float)backbuffer_width;
float FloatGLHeight = (float)backbuffer_height;
@ -492,7 +492,7 @@ void Renderer::UpdateDrawRectangle(u32 backbuffer_width, u32 backbuffer_height)
target_rc.bottom = YOffset + iHeight;
}
void Renderer::SetWindowSize(u32 width, u32 height)
void Renderer::SetWindowSize(int width, int height)
{
if (width < 1)
width = 1;

View File

@ -67,14 +67,14 @@ public:
virtual void RestoreState() = 0;
// Ideal internal resolution - determined by display resolution (automatic scaling) and/or a multiple of the native EFB resolution
static u32 GetTargetWidth() { return s_target_width; }
static u32 GetTargetHeight() { return s_target_height; }
static int GetTargetWidth() { return s_target_width; }
static int GetTargetHeight() { return s_target_height; }
// Display resolution
static u32 GetBackbufferWidth() { return s_backbuffer_width; }
static u32 GetBackbufferHeight() { return s_backbuffer_height; }
static int GetBackbufferWidth() { return s_backbuffer_width; }
static int GetBackbufferHeight() { return s_backbuffer_height; }
static void SetWindowSize(u32 width, u32 height);
static void SetWindowSize(int width, int height);
// EFB coordinate conversion functions
@ -82,7 +82,7 @@ public:
virtual TargetRectangle ConvertEFBRectangle(const EFBRectangle& rc) = 0;
static const TargetRectangle& GetTargetRectangle() { return target_rc; }
static void UpdateDrawRectangle(u32 backbuffer_width, u32 backbuffer_height);
static void UpdateDrawRectangle(int backbuffer_width, int backbuffer_height);
// Use this to upscale native EFB coordinates to IDEAL internal resolution
@ -132,8 +132,8 @@ public:
protected:
static void CalculateTargetScale(unsigned int x, unsigned int y, unsigned int &scaledX, unsigned int &scaledY);
static bool CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, unsigned int multiplier = 1);
static void CalculateTargetScale(int x, int y, int &scaledX, int &scaledY);
static bool CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier = 1);
static void CheckFifoRecording();
static void RecordVideoMemory();
@ -151,12 +151,12 @@ protected:
bool bLastFrameDumped;
// The framebuffer size
static u32 s_target_width;
static u32 s_target_height;
static int s_target_width;
static int s_target_height;
// TODO: Add functionality to reinit all the render targets when the window is resized.
static u32 s_backbuffer_width;
static u32 s_backbuffer_height;
static int s_backbuffer_width;
static int s_backbuffer_height;
static TargetRectangle target_rc;

View File

@ -193,7 +193,7 @@ void FramebufferManager::GetTargetSize(unsigned int *width, unsigned int *height
}
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
{
D3D::drawShadedTexSubQuad(tex->GetSRV(), &sourcerc,
texWidth, texHeight, &drawrc, PixelShaderCache::GetColorCopyProgram(false),

View File

@ -64,7 +64,7 @@ struct XFBSource : public XFBSourceBase
~XFBSource() { tex->Release(); }
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;
void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
void CopyEFB(float Gamma);

View File

@ -691,14 +691,18 @@ 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;
@ -924,17 +928,20 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// Prepare to copy the XFBs to our backbuffer
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
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;
// TODO: Redundant checks...
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;
D3D11_VIEWPORT vp = CD3D11_VIEWPORT((float)X, (float)Y, (float)Width, (float)Height);
D3D::context->RSSetViewports(1, &vp);
D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), NULL);

View File

@ -49,9 +49,9 @@ LPDIRECT3DSURFACE9 back_buffer_z;
D3DCAPS9 caps;
HWND hWnd;
static unsigned int multisample;
static unsigned int resolution;
static unsigned int xres, yres;
static int multisample;
static int resolution;
static int xres, yres;
static bool auto_depth_stencil = false;
#define VENDOR_NVIDIA 4318
@ -480,25 +480,24 @@ const D3DCAPS9 &GetCaps()
}
// returns true if size was changed
bool FixTextureSize(u32& width, u32& height)
bool FixTextureSize(int& width, int& height)
{
u32 oldw = width;
u32 oldh = height;
int oldw = width, oldh = height;
// conditional nonpow2 support should work fine for us
if ((caps.TextureCaps & D3DPTEXTURECAPS_POW2) && !(caps.TextureCaps & D3DPTEXTURECAPS_NONPOW2CONDITIONAL))
{
// all texture dimensions need to be powers of two
width = MakePow2(width);
height = MakePow2(height);
width = (int)MakePow2((u32)width);
height = (int)MakePow2((u32)height);
}
if (caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY)
{
width = height = max(width, height);
}
width = min(width, (u32)caps.MaxTextureWidth);
height = min(height, (u32)caps.MaxTextureHeight);
width = min(width, (int)caps.MaxTextureWidth);
height = min(height, (int)caps.MaxTextureHeight);
return (width != oldw) || (height != oldh);
}
@ -516,22 +515,18 @@ bool CheckDepthStencilSupport(D3DFORMAT target_format, D3DFORMAT depth_format)
D3DFORMAT GetSupportedDepthTextureFormat()
{
for (size_t i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
{
for (int i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
if (D3D::CheckTextureSupport(D3DUSAGE_DEPTHSTENCIL, DepthFormats[i]))
return DepthFormats[i];
}
return D3DFMT_UNKNOWN;
}
D3DFORMAT GetSupportedDepthSurfaceFormat(D3DFORMAT target_format)
{
for (size_t i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
{
for (int i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
if (D3D::CheckDepthStencilSupport(target_format, DepthFormats[i]))
return DepthFormats[i];
}
return D3DFMT_UNKNOWN;
}
@ -572,7 +567,7 @@ void ShowD3DError(HRESULT err)
PanicAlert("Driver Internal Error");
break;
case D3DERR_OUTOFVIDEOMEMORY:
PanicAlert("Out of video memory");
PanicAlert("Out of vid mem");
break;
default:
// MessageBox(0,_T("Other error or success"),_T("ERROR"),0);

View File

@ -75,7 +75,7 @@ const char *VertexShaderVersionString();
void ShowD3DError(HRESULT err);
// returns true if size was changed
bool FixTextureSize(u32& width, u32& height);
bool FixTextureSize(int& width, int& height);
// returns true if format is supported
bool CheckTextureSupport(DWORD usage, D3DFORMAT tex_format);
@ -115,8 +115,8 @@ void EnableAlphaToCoverage();
struct Resolution
{
char name[32];
unsigned int xres;
unsigned int yres;
int xres;
int yres;
std::set<D3DFORMAT> bitdepths;
std::set<int> refreshes;
};

View File

@ -365,10 +365,10 @@ int CD3DFont::DrawTextScaled(float x, float y, float fXScale, float fYScale, flo
*/
void drawShadedTexQuad(IDirect3DTexture9 *texture,
const RECT *rSource,
u32 SourceWidth,
u32 SourceHeight,
u32 DestWidth,
u32 DestHeight,
int SourceWidth,
int SourceHeight,
int DestWidth,
int DestHeight,
IDirect3DPixelShader9 *PShader,
IDirect3DVertexShader9 *Vshader,
float Gamma)
@ -399,11 +399,11 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture,
void drawShadedTexSubQuad(IDirect3DTexture9 *texture,
const MathUtil::Rectangle<float> *rSource,
u32 SourceWidth,
u32 SourceHeight,
int SourceWidth,
int SourceHeight,
const MathUtil::Rectangle<float> *rDest,
u32 DestWidth,
u32 DestHeight,
int DestWidth,
int DestHeight,
IDirect3DPixelShader9 *PShader,
IDirect3DVertexShader9 *Vshader,
float Gamma)

View File

@ -65,20 +65,20 @@ namespace D3D
void quad2d(float x1, float y1, float x2, float y2, u32 color, float u1=0, float v1=0, float u2=1, float v2=1);
void drawShadedTexQuad(IDirect3DTexture9 *texture,
const RECT *rSource,
u32 SourceWidth,
u32 SourceHeight,
u32 DestWidth,
u32 DestHeight,
int SourceWidth,
int SourceHeight,
int DestWidth,
int DestHeight,
IDirect3DPixelShader9 *PShader,
IDirect3DVertexShader9 *Vshader,
float Gamma = 1.0f);
void drawShadedTexSubQuad(IDirect3DTexture9 *texture,
const MathUtil::Rectangle<float> *rSource,
u32 SourceWidth,
u32 SourceHeight,
int SourceWidth,
int SourceHeight,
const MathUtil::Rectangle<float> *rDest,
u32 DestWidth,
u32 DestHeight,
int DestWidth,
int DestHeight,
IDirect3DPixelShader9 *PShader,
IDirect3DVertexShader9 *Vshader,
float Gamma = 1.0f);

View File

@ -44,8 +44,8 @@ FramebufferManager::Efb FramebufferManager::s_efb;
FramebufferManager::FramebufferManager()
{
bool depth_textures_supported = true;
u32 target_width = Renderer::GetTargetWidth();
u32 target_height = Renderer::GetTargetHeight();
int target_width = Renderer::GetTargetWidth();
int target_height = Renderer::GetTargetHeight();
s_efb.color_surface_Format = D3DFMT_A8R8G8B8;
// EFB color texture - primary render target
@ -161,7 +161,7 @@ void FramebufferManager::GetTargetSize(unsigned int *width, unsigned int *height
}
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
{
D3D::drawShadedTexSubQuad(texture, &sourcerc, texWidth, texHeight, &drawrc, width , height,
PixelShaderCache::GetColorCopyProgram(0), VertexShaderCache::GetSimpleVertexShader(0));

View File

@ -58,7 +58,7 @@ struct XFBSource : public XFBSourceBase
~XFBSource() { texture->Release(); }
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;
void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
void CopyEFB(float Gamma);

View File

@ -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);
@ -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;
@ -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.
@ -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;
@ -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;
@ -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());

View File

@ -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

View File

@ -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;
};

View File

@ -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__
@ -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