Committing some cleanups by avindra:

- fix numerous warnings
- make some variables unsigned
- remove redundant code and header inclusions
- make code more compact in lots of cases

Committing some additional changes by myself:
- additional header cleanups
- cleanup DX11 initialization/shutdown process (hinted at by avindra)
- Remove the cgD3D9 stuff from Externals since it's no longer needed

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5903 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX
2010-07-18 10:11:34 +00:00
parent b0041f00a3
commit da4c3a5f29
17 changed files with 73 additions and 417 deletions

View File

@ -72,7 +72,7 @@ D3DTexture2D* D3DTexture2D::Create(unsigned int width, unsigned int height, D3D1
void D3DTexture2D::AddRef()
{
ref++;
++ref;
}
UINT D3DTexture2D::Release()

View File

@ -18,7 +18,6 @@
#pragma once
#include "D3DBase.h"
#include "TextureDecoder.h"
namespace D3D
{

View File

@ -481,10 +481,13 @@ void InitUtils()
clearvb = CreateQuadVertexBuffer(4*sizeof(ClearVertex), cqcoords);
CHECK(clearvb!=NULL, "Create vertex buffer of drawClearQuad");
SetDebugObjectName((ID3D11DeviceChild*)clearvb, "vertex buffer of drawClearQuad");
font.Init();
}
void ShutdownUtils()
{
font.Shutdown();
SAFE_RELEASE(point_copy_sampler);
SAFE_RELEASE(linear_copy_sampler);
SAFE_RELEASE(stqvb);

View File

@ -21,7 +21,6 @@
#include "VertexShaderGen.h"
#include "PixelShaderGen.h"
#include <stack>
using std::stack;
namespace D3D

View File

@ -229,15 +229,9 @@ static const D3D11_TEXTURE_ADDRESS_MODE d3dClamps[4] =
void SetupDeviceObjects()
{
HRESULT hr;
D3D::font.Init();
VertexLoaderManager::Init();
FBManager.Create();
VertexShaderManager::Dirty();
PixelShaderManager::Dirty();
HRESULT hr;
float colmat[20]= {0.0f};
colmat[0] = colmat[5] = colmat[10] = 1.0f;
D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(20*sizeof(float), D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DEFAULT);
@ -284,7 +278,6 @@ void SetupDeviceObjects()
CHECK(hr==S_OK, "Create blend state for Renderer::ResetAPIState");
D3D::SetDebugObjectName((ID3D11DeviceChild*)resetblendstate, "blend state for Renderer::ResetAPIState");
// TODO: For some reason this overwrites existing resource private data...
ddesc.DepthEnable = FALSE;
ddesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
ddesc.DepthFunc = D3D11_COMPARISON_LESS;
@ -304,15 +297,7 @@ void SetupDeviceObjects()
void TeardownDeviceObjects()
{
D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), NULL);
FBManager.Destroy();
D3D::font.Shutdown();
TextureCache::Invalidate(false);
VertexManager::DestroyDeviceObjects();
VertexLoaderManager::Shutdown();
VertexShaderCache::Clear();
PixelShaderCache::Clear();
SAFE_RELEASE(access_efb_cbuf);
SAFE_RELEASE(cleardepthstates[0]);
SAFE_RELEASE(cleardepthstates[1]);

View File

@ -173,7 +173,6 @@ void VertexShaderCache::Init()
for (k = 0;k < 32;k++) vs_constant_offset_table[C_NORMALMATRICES+k] = 568+4*k;
for (k = 0;k < 64;k++) vs_constant_offset_table[C_POSTTRANSFORMMATRICES+k] = 696+4*k;
for (k = 0;k < 4;k++) vs_constant_offset_table[C_DEPTHPARAMS+k] = 952+4*k;
if (!File::Exists(File::GetUserPath(D_SHADERCACHE_IDX)))
File::CreateDir(File::GetUserPath(D_SHADERCACHE_IDX));
@ -186,8 +185,7 @@ void VertexShaderCache::Init()
void VertexShaderCache::Clear()
{
VSCache::iterator iter = vshaders.begin();
for (; iter != vshaders.end(); ++iter)
for (VSCache::iterator iter = vshaders.begin(); iter != vshaders.end(); ++iter)
iter->second.Destroy();
vshaders.clear();
}

View File

@ -18,15 +18,9 @@
#ifndef _VERTEXSHADERCACHE_H
#define _VERTEXSHADERCACHE_H
#include "D3DBase.h"
#include <map>
#include <string>
#include "D3DBase.h"
#include "VertexShaderGen.h"
#include "d3dcompiler.h"
#include <map>
class VertexShaderCache
{

View File

@ -27,30 +27,32 @@
#include "Thread.h"
#include "LogManager.h"
#include "resource.h"
#include "main.h"
#include "VideoConfig.h"
#include "Fifo.h"
#include "OpcodeDecoding.h"
#include "TextureCache.h"
#include "BPStructs.h"
#include "VertexManager.h"
#include "VertexLoaderManager.h"
#include "VertexShaderManager.h"
#include "PixelShaderManager.h"
#include "VertexShaderCache.h"
#include "PixelShaderCache.h"
#include "CommandProcessor.h"
#include "PixelEngine.h"
#include "OnScreenDisplay.h"
#include "VideoState.h"
#include "XFBConvert.h"
#include "Render.h"
#include "main.h"
#include "resource.h"
#include "DlgSettings.h"
#include "TextureCache.h"
#include "VertexManager.h"
#include "VertexShaderCache.h"
#include "PixelShaderCache.h"
#include "D3DTexture.h"
#include "D3DUtil.h"
#include "W32Util/Misc.h"
#include "EmuWindow.h"
#include "VideoState.h"
#include "XFBConvert.h"
#include "render.h"
#include "FBManager.h"
#if defined(DEBUGFAST)
@ -222,20 +224,24 @@ void Video_Prepare()
s_efbAccessRequested = FALSE;
s_FifoShuttingDown = FALSE;
s_swapRequested = FALSE;
// internal interfaces
Renderer::Init();
TextureCache::Init();
BPInit();
VertexManager::Init();
VertexShaderCache::Init();
PixelShaderCache::Init();
D3D::InitUtils();
// VideoCommon
BPInit();
Fifo_Init();
VertexLoaderManager::Init();
OpcodeDecoder_Init();
VertexShaderCache::Init();
VertexShaderManager::Init();
PixelShaderCache::Init();
PixelShaderManager::Init();
CommandProcessor::Init();
PixelEngine::Init();
D3D::InitUtils();
// tell the host that the window is ready
g_VideoInitialize.pCoreMessage(WM_USER_CREATE);
@ -246,19 +252,24 @@ void Shutdown()
s_efbAccessRequested = FALSE;
s_FifoShuttingDown = FALSE;
s_swapRequested = FALSE;
// VideoCommon
CommandProcessor::Shutdown();
PixelShaderManager::Shutdown();
PixelShaderCache::Shutdown();
VertexShaderManager::Shutdown();
VertexShaderCache::Shutdown();
OpcodeDecoder_Shutdown();
VertexLoaderManager::Shutdown();
Fifo_Shutdown();
// internal interfaces
D3D::ShutdownUtils();
PixelShaderCache::Shutdown();
VertexShaderCache::Shutdown();
VertexManager::Shutdown();
TextureCache::Shutdown();
D3D::ShutdownUtils();
Renderer::Shutdown();
EmuWindow::Close();
s_PluginInitialized = false;
}
@ -308,11 +319,6 @@ void VideoFifo_CheckSwapRequest()
}
}
inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
{
return !((aLower >= bUpper) || (bLower >= aUpper));
}
// Run from the graphics thread (from Fifo.cpp)
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
{