mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
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:
@ -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);
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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());
|
||||
|
Reference in New Issue
Block a user