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

This also gets rid of some more typecasts in some cases.
This commit is contained in:
lioncash 2013-01-16 09:42:51 -05:00
parent 7e5d877858
commit 8743166663
16 changed files with 98 additions and 104 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, int width, int height) const = 0;
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 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
int Renderer::s_target_width;
int Renderer::s_target_height;
unsigned int Renderer::s_target_width;
unsigned int Renderer::s_target_height;
// TODO: Add functionality to reinit all the render targets when the window is resized.
int Renderer::s_backbuffer_width;
int Renderer::s_backbuffer_height;
unsigned int Renderer::s_backbuffer_width;
unsigned int Renderer::s_backbuffer_height;
TargetRectangle Renderer::target_rc;
@ -163,7 +163,7 @@ int Renderer::EFBToScaledY(int y)
};
}
void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY)
void Renderer::CalculateTargetScale(unsigned int x, unsigned int y, unsigned int &scaledX, unsigned int &scaledY)
{
if (g_ActiveConfig.iEFBScale == 0 || g_ActiveConfig.iEFBScale == 1)
{
@ -172,15 +172,15 @@ void Renderer::CalculateTargetScale(int x, int y, int &scaledX, int &scaledY)
}
else
{
scaledX = x * (int)efb_scale_numeratorX / (int)efb_scale_denominatorX;
scaledY = y * (int)efb_scale_numeratorY / (int)efb_scale_denominatorY;
scaledX = x * (efb_scale_numeratorX / efb_scale_denominatorX);
scaledY = y * (efb_scale_numeratorY / efb_scale_denominatorY);
}
}
// return true if target size changed
bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, int multiplier)
bool Renderer::CalculateTargetSize(unsigned int framebuffer_width, unsigned int framebuffer_height, unsigned int multiplier)
{
int newEFBWidth, newEFBHeight;
u32 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(int backbuffer_width, int backbuffer_height)
void Renderer::UpdateDrawRectangle(u32 backbuffer_width, u32 backbuffer_height)
{
float FloatGLWidth = (float)backbuffer_width;
float FloatGLHeight = (float)backbuffer_height;
@ -492,7 +492,7 @@ void Renderer::UpdateDrawRectangle(int backbuffer_width, int backbuffer_height)
target_rc.bottom = YOffset + iHeight;
}
void Renderer::SetWindowSize(int width, int height)
void Renderer::SetWindowSize(u32 width, u32 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 int GetTargetWidth() { return s_target_width; }
static int GetTargetHeight() { return s_target_height; }
static u32 GetTargetWidth() { return s_target_width; }
static u32 GetTargetHeight() { return s_target_height; }
// Display resolution
static int GetBackbufferWidth() { return s_backbuffer_width; }
static int GetBackbufferHeight() { return s_backbuffer_height; }
static u32 GetBackbufferWidth() { return s_backbuffer_width; }
static u32 GetBackbufferHeight() { return s_backbuffer_height; }
static void SetWindowSize(int width, int height);
static void SetWindowSize(u32 width, u32 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(int backbuffer_width, int backbuffer_height);
static void UpdateDrawRectangle(u32 backbuffer_width, u32 backbuffer_height);
// Use this to upscale native EFB coordinates to IDEAL internal resolution
@ -132,8 +132,8 @@ public:
protected:
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 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 CheckFifoRecording();
static void RecordVideoMemory();
@ -151,12 +151,12 @@ protected:
bool bLastFrameDumped;
// The framebuffer size
static int s_target_width;
static int s_target_height;
static u32 s_target_width;
static u32 s_target_height;
// TODO: Add functionality to reinit all the render targets when the window is resized.
static int s_backbuffer_width;
static int s_backbuffer_height;
static u32 s_backbuffer_width;
static u32 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, int width, int height) const
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 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, int width, int height) const;
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 height) const;
void DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight);
void CopyEFB(float Gamma);

View File

@ -691,18 +691,14 @@ void Renderer::UpdateViewport(Matrix44& vpCorrection)
}
// In D3D, the viewport rectangle must fit within the render target.
int X = intendedX;
if (X < 0)
X = 0;
u32 X = intendedX;
u32 Y = intendedY;
u32 Wd = intendedWd;
u32 Ht = intendedHt;
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;
@ -928,20 +924,17 @@ 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);
int X = GetTargetRectangle().left;
int Y = GetTargetRectangle().top;
int Width = GetTargetRectangle().right - GetTargetRectangle().left;
int Height = GetTargetRectangle().bottom - GetTargetRectangle().top;
u32 X = GetTargetRectangle().left;
u32 Y = GetTargetRectangle().top;
u32 Width = GetTargetRectangle().right - GetTargetRectangle().left;
u32 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 int multisample;
static int resolution;
static int xres, yres;
static unsigned int multisample;
static unsigned int resolution;
static unsigned int xres, yres;
static bool auto_depth_stencil = false;
#define VENDOR_NVIDIA 4318
@ -480,24 +480,25 @@ const D3DCAPS9 &GetCaps()
}
// returns true if size was changed
bool FixTextureSize(int& width, int& height)
bool FixTextureSize(u32& width, u32& height)
{
int oldw = width, oldh = height;
u32 oldw = width;
u32 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 = (int)MakePow2((u32)width);
height = (int)MakePow2((u32)height);
width = MakePow2(width);
height = MakePow2(height);
}
if (caps.TextureCaps & D3DPTEXTURECAPS_SQUAREONLY)
{
width = height = max(width, height);
}
width = min(width, (int)caps.MaxTextureWidth);
height = min(height, (int)caps.MaxTextureHeight);
width = min(width, (u32)caps.MaxTextureWidth);
height = min(height, (u32)caps.MaxTextureHeight);
return (width != oldw) || (height != oldh);
}
@ -515,18 +516,22 @@ bool CheckDepthStencilSupport(D3DFORMAT target_format, D3DFORMAT depth_format)
D3DFORMAT GetSupportedDepthTextureFormat()
{
for (int i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
for (size_t 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 (int i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
for (size_t i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
{
if (D3D::CheckDepthStencilSupport(target_format, DepthFormats[i]))
return DepthFormats[i];
}
return D3DFMT_UNKNOWN;
}
@ -567,7 +572,7 @@ void ShowD3DError(HRESULT err)
PanicAlert("Driver Internal Error");
break;
case D3DERR_OUTOFVIDEOMEMORY:
PanicAlert("Out of vid mem");
PanicAlert("Out of video memory");
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(int& width, int& height);
bool FixTextureSize(u32& width, u32& 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];
int xres;
int yres;
unsigned int xres;
unsigned 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,
int SourceWidth,
int SourceHeight,
int DestWidth,
int DestHeight,
u32 SourceWidth,
u32 SourceHeight,
u32 DestWidth,
u32 DestHeight,
IDirect3DPixelShader9 *PShader,
IDirect3DVertexShader9 *Vshader,
float Gamma)
@ -399,11 +399,11 @@ void drawShadedTexQuad(IDirect3DTexture9 *texture,
void drawShadedTexSubQuad(IDirect3DTexture9 *texture,
const MathUtil::Rectangle<float> *rSource,
int SourceWidth,
int SourceHeight,
u32 SourceWidth,
u32 SourceHeight,
const MathUtil::Rectangle<float> *rDest,
int DestWidth,
int DestHeight,
u32 DestWidth,
u32 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,
int SourceWidth,
int SourceHeight,
int DestWidth,
int DestHeight,
u32 SourceWidth,
u32 SourceHeight,
u32 DestWidth,
u32 DestHeight,
IDirect3DPixelShader9 *PShader,
IDirect3DVertexShader9 *Vshader,
float Gamma = 1.0f);
void drawShadedTexSubQuad(IDirect3DTexture9 *texture,
const MathUtil::Rectangle<float> *rSource,
int SourceWidth,
int SourceHeight,
u32 SourceWidth,
u32 SourceHeight,
const MathUtil::Rectangle<float> *rDest,
int DestWidth,
int DestHeight,
u32 DestWidth,
u32 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;
int target_width = Renderer::GetTargetWidth();
int target_height = Renderer::GetTargetHeight();
u32 target_width = Renderer::GetTargetWidth();
u32 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, int width, int height) const
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 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, int width, int height) const;
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 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;
int SupersampleCoeficient = (s_LastAA % 3) + 1;
u32 SupersampleCoefficient = (s_LastAA % 3) + 1;
s_LastEFBScale = g_ActiveConfig.iEFBScale;
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoeficient);
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoefficient);
// Make sure to use valid texture sizes
D3D::FixTextureSize(s_target_width, s_target_height);
@ -305,7 +305,7 @@ Renderer::Renderer()
SetupDeviceObjects();
for (int stage = 0; stage < 8; stage++)
for (u32 stage = 0; stage < 8; stage++)
D3D::SetSamplerState(stage, D3DSAMP_MAXANISOTROPY, 1 << g_ActiveConfig.iMaxAnisotropy);
D3DVIEWPORT9 vp;
@ -468,8 +468,10 @@ 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.
@ -693,16 +695,14 @@ void Renderer::UpdateViewport(Matrix44& vpCorrection)
}
// In D3D, the viewport rectangle must fit within the render target.
int X = intendedX;
if (X < 0)
X = 0;
int Y = intendedY;
if (Y < 0)
Y = 0;
int Wd = intendedWd;
u32 X = intendedX;
u32 Y = intendedY;
u32 Wd = intendedWd;
u32 Ht = intendedHt;
if (X + Wd > GetTargetWidth())
Wd = GetTargetWidth() - X;
int Ht = intendedHt;
if (Y + Ht > GetTargetHeight())
Ht = GetTargetHeight() - Y;
@ -907,18 +907,14 @@ 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);
}
int X = GetTargetRectangle().left;
int Y = GetTargetRectangle().top;
int Width = GetTargetRectangle().right - GetTargetRectangle().left;
int Height = GetTargetRectangle().bottom - GetTargetRectangle().top;
u32 X = GetTargetRectangle().left;
u32 Y = GetTargetRectangle().top;
u32 Width = (GetTargetRectangle().right - GetTargetRectangle().left);
u32 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;
@ -1153,10 +1149,10 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
UpdateDrawRectangle(s_backbuffer_width, s_backbuffer_height);
int SupersampleCoeficient = (s_LastAA % 3) + 1;
u32 SupersampleCoefficient = (s_LastAA % 3) + 1;
s_LastEFBScale = g_ActiveConfig.iEFBScale;
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoeficient);
CalculateTargetSize(s_backbuffer_width, s_backbuffer_height, SupersampleCoefficient);
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, int width, int height) const
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 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, int width, int height) const;
const MathUtil::Rectangle<float> &drawrc, u32 width, u32 height) const;
const GLuint texture;
};

View File

@ -323,8 +323,8 @@ Renderer::Renderer()
return; // TODO: fail
// Decide frambuffer size
s_backbuffer_width = (int)GLInterface->GetBackBufferWidth();
s_backbuffer_height = (int)GLInterface->GetBackBufferHeight();
s_backbuffer_width = GLInterface->GetBackBufferWidth();
s_backbuffer_height = 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 (int i = 1; i < 8; ++i)
for (unsigned int i = 1; i < 8; ++i)
OGL::TextureCache::DisableStage(i);
// Update GLViewPort