apply some speedup to dx11 plugin + some minor stuff

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5721 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2010-06-16 10:12:57 +00:00
parent 980a2680be
commit 4f8a6a1573
13 changed files with 202 additions and 221 deletions

View File

@ -130,7 +130,7 @@ void IndexGenerator::AddStrip(int numVerts)
//if we have less than 3 verts //if we have less than 3 verts
if(numVerts == 1) if(numVerts == 1)
{ {
//dicard // discard
index++; index++;
return; return;
} }
@ -341,9 +341,3 @@ void IndexGenerator::AddPoints(int numVerts)
numP += numVerts; numP += numVerts;
Padds++; Padds++;
} }

View File

@ -294,7 +294,7 @@ HRESULT Create(HWND wnd)
{ {
// try using the first one // try using the first one
hr = factory->EnumAdapters(0, &adapter); hr = factory->EnumAdapters(0, &adapter);
if (FAILED(hr)) MessageBox(wnd, _T("Failed to enumerate adapter"), _T("Dolphin Direct3D 11 plugin"), MB_OK | MB_ICONERROR); if (FAILED(hr)) MessageBox(wnd, _T("Failed to enumerate adapters"), _T("Dolphin Direct3D 11 plugin"), MB_OK | MB_ICONERROR);
} }
// TODO: Make this configurable // TODO: Make this configurable
@ -303,7 +303,7 @@ HRESULT Create(HWND wnd)
{ {
// try using the first one // try using the first one
hr = adapter->EnumOutputs(0, &output); hr = adapter->EnumOutputs(0, &output);
if (FAILED(hr)) MessageBox(wnd, _T("Failed to enumerate output"), _T("Dolphin Direct3D 11 plugin"), MB_OK | MB_ICONERROR); if (FAILED(hr)) MessageBox(wnd, _T("Failed to enumerate outputs"), _T("Dolphin Direct3D 11 plugin"), MB_OK | MB_ICONERROR);
} }
// this will need to be changed once multisampling gets implemented // this will need to be changed once multisampling gets implemented

View File

@ -68,8 +68,8 @@ void ReplaceTexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned int
// TODO: Merge the conversions done here to VideoDecoder // TODO: Merge the conversions done here to VideoDecoder
switch (pcfmt) switch (pcfmt)
{ {
case PC_TEX_FMT_IA4_AS_IA8:
case PC_TEX_FMT_IA8: case PC_TEX_FMT_IA8:
case PC_TEX_FMT_IA4_AS_IA8:
for (unsigned int y = 0; y < height; y++) for (unsigned int y = 0; y < height; y++)
{ {
u16* in = (u16*)buffer + y * pitch; u16* in = (u16*)buffer + y * pitch;
@ -78,43 +78,30 @@ void ReplaceTexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned int
{ {
const u8 I = (*in & 0xFF); const u8 I = (*in & 0xFF);
const u8 A = (*in & 0xFF00) >> 8; const u8 A = (*in & 0xFF00) >> 8;
*pBits = (A << 24) | (I << 16) | (I << 8) | I; *(pBits++) = (A << 24) | (I << 16) | (I << 8) | I;
in++; in++;
pBits++;
} }
} }
break; break;
case PC_TEX_FMT_I8: case PC_TEX_FMT_I8:
case PC_TEX_FMT_I4_AS_I8: case PC_TEX_FMT_I4_AS_I8:
for (unsigned int y = 0; y < height; y++)
{ {
const u8 *pIn = buffer; const u8* in = buffer + (y * pitch);
for (int y = 0; y < height; y++) u32* pBits = (u32*)((u8*)outptr + (y * destPitch));
for(unsigned int i = 0; i < width; i++)
{ {
u8* pBits = ((u8*)outptr + (y * destPitch)); const u8 I = *(in++);
for(int i = 0; i < width * 4; i += 4) memset( pBits++, I, 4 );
{
pBits[i] = pIn[i / 4];
pBits[i+1] = pIn[i / 4];
pBits[i+2] = pIn[i / 4];
pBits[i + 3] = pIn[i / 4];
}
pIn += pitch;
} }
} }
break; break;
case PC_TEX_FMT_BGRA32: case PC_TEX_FMT_BGRA32:
for (unsigned int y = 0; y < height; y++) for (unsigned int y = 0; y < height; y++)
{ {
u32* in = (u32*)buffer + y * pitch; u32* in = (u32*)buffer + y * pitch;
u32* pBits = (u32*)((u8*)outptr + y * destPitch); u32* pBits = (u32*)((u8*)outptr + y * destPitch);
for (unsigned int x = 0; x < width; x++) memcpy( pBits, in, destPitch );
{
const u32 col = *in;
*pBits = col;
in++;
pBits++;
}
} }
break; break;
case PC_TEX_FMT_RGB565: case PC_TEX_FMT_RGB565:
@ -125,13 +112,11 @@ void ReplaceTexture2D(ID3D11Texture2D* pTexture, const u8* buffer, unsigned int
for (unsigned int x = 0; x < width; x++) for (unsigned int x = 0; x < width; x++)
{ {
// we can't simply shift here, since e.g. 11111 must map to 11111111 and not 11111000 // we can't simply shift here, since e.g. 11111 must map to 11111111 and not 11111000
const u16 col = *in; const u16 col = *(in++);
*pBits = 0xFF000000 | // alpha *(pBits++) = 0xFF000000 | // alpha
((((col&0xF800) << 5) * 255 / 31) & 0xFF0000) | // red ((((col&0xF800) << 5) * 255 / 31) & 0xFF0000) | // red
((((col& 0x7e0) << 3) * 255 / 63) & 0xFF00) | // green ((((col& 0x7e0) << 3) * 255 / 63) & 0xFF00) | // green
(( (col& 0x1f) * 255 / 31)); // blue (( (col& 0x1f) * 255 / 31)); // blue
pBits++;
in++;
} }
} }
break; break;

View File

@ -329,8 +329,8 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf); int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf);
int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf); int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf);
int Scaledtex_w = (g_ActiveConfig.bCopyEFBScaled)?((int)(Renderer::GetTargetScaleX() * tex_w)):tex_w; int Scaledtex_w = (g_ActiveConfig.bCopyEFBScaled) ? ((int)(Renderer::GetTargetScaleX() * tex_w)) : tex_w;
int Scaledtex_h = (g_ActiveConfig.bCopyEFBScaled)?((int)(Renderer::GetTargetScaleY() * tex_h)):tex_h; int Scaledtex_h = (g_ActiveConfig.bCopyEFBScaled) ? ((int)(Renderer::GetTargetScaleY() * tex_h)) : tex_h;
TexCache::iterator iter; TexCache::iterator iter;
D3DTexture2D* tex = NULL; D3DTexture2D* tex = NULL;
@ -378,7 +378,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
{ {
case 0: // Z4 case 0: // Z4
case 1: // Z8 case 1: // Z8
colmat[0] = colmat[4] = colmat[8] = colmat[12] =1.0f; colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1.0f;
cbufid = 12; cbufid = 12;
break; break;
case 3: // Z16 //? case 3: // Z16 //?

View File

@ -354,6 +354,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
DEBUGGER_PAUSE_LOG_AT(NEXT_NEW_TEXTURE,true,{printf("A new texture (%d x %d) is loaded", width, height);}); DEBUGGER_PAUSE_LOG_AT(NEXT_NEW_TEXTURE,true,{printf("A new texture (%d x %d) is loaded", width, height);});
return &entry; return &entry;
} }
void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect) void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle &source_rect)
{ {
int efb_w = source_rect.GetWidth(); int efb_w = source_rect.GetWidth();
@ -417,7 +418,7 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
{ {
case 0: // Z4 case 0: // Z4
case 1: // Z8 case 1: // Z8
colmat[0] = colmat[4] = colmat[8] = colmat[12] =1.0f; colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1.0f;
break; break;
case 3: // Z16 //? case 3: // Z16 //?
colmat[1] = colmat[5] = colmat[9] = colmat[12] = 1.0f; colmat[1] = colmat[5] = colmat[9] = colmat[12] = 1.0f;

View File

@ -147,6 +147,7 @@ HWND GetWnd()
{ {
return m_hWnd; return m_hWnd;
} }
HWND GetParentWnd() HWND GetParentWnd()
{ {
return m_hParent; return m_hParent;
@ -305,7 +306,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
} }
// This is called from Create() // This is called from Create()
HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const TCHAR *title) HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const TCHAR *title)
{ {

View File

@ -32,7 +32,7 @@ namespace EmuWindow
void Show(); void Show();
void Close(); void Close();
void SetSize(int displayWidth, int displayHeight); void SetSize(int displayWidth, int displayHeight);
void ToggleDisplayMode (int bFullscreen); void ToggleDisplayMode(int bFullscreen);
} }
#endif // _WIN32_H_ #endif // _WIN32_H_

View File

@ -182,17 +182,17 @@ inline void Draw()
{ {
if(IndexGenerator::GetNumTriangles() > 0) if(IndexGenerator::GetNumTriangles() > 0)
{ {
glDrawElements(GL_TRIANGLES, IndexGenerator::GetTriangleindexLen(), GL_UNSIGNED_SHORT,TIBuffer); glDrawElements(GL_TRIANGLES, IndexGenerator::GetTriangleindexLen(), GL_UNSIGNED_SHORT, TIBuffer);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
if(IndexGenerator::GetNumLines() > 0) if(IndexGenerator::GetNumLines() > 0)
{ {
glDrawElements(GL_LINES, IndexGenerator::GetLineindexLen(), GL_UNSIGNED_SHORT,LIBuffer); glDrawElements(GL_LINES, IndexGenerator::GetLineindexLen(), GL_UNSIGNED_SHORT, LIBuffer);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
if(IndexGenerator::GetNumPoints() > 0) if(IndexGenerator::GetNumPoints() > 0)
{ {
glDrawElements(GL_POINTS, IndexGenerator::GetPointindexLen(), GL_UNSIGNED_SHORT,PIBuffer); glDrawElements(GL_POINTS, IndexGenerator::GetPointindexLen(), GL_UNSIGNED_SHORT, PIBuffer);
INCSTAT(stats.thisFrame.numIndexedDrawCalls); INCSTAT(stats.thisFrame.numIndexedDrawCalls);
} }
} }
@ -366,7 +366,6 @@ void Flush()
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
} }
} // namespace } // namespace

View File

@ -129,7 +129,7 @@ void GetDllInfo (PLUGIN_INFO* _PluginInfo)
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
{ {
globals = _pPluginGlobals; globals = _pPluginGlobals;
LogManager::SetInstance((LogManager *)globals->logManager); LogManager::SetInstance((LogManager*)globals->logManager);
} }
// This is used for the functions right below here which use wxwidgets // This is used for the functions right below here which use wxwidgets
@ -211,7 +211,7 @@ void Initialize(void *init)
g_Config.UpdateProjectionHack(); g_Config.UpdateProjectionHack();
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
//Enable support for PNG screenshots. // Enable support for PNG screenshots.
wxImage::AddHandler( new wxPNGHandler ); wxImage::AddHandler( new wxPNGHandler );
#endif #endif
UpdateActiveConfig(); UpdateActiveConfig();
@ -231,10 +231,11 @@ void Initialize(void *init)
_pVideoInitialize->pXWindow = g_VideoInitialize.pXWindow; _pVideoInitialize->pXWindow = g_VideoInitialize.pXWindow;
#endif #endif
OSD::AddMessage("Dolphin OpenGL Video Plugin" ,5000); OSD::AddMessage("Dolphin OpenGL Video Plugin", 5000);
} }
void DoState(unsigned char **ptr, int mode) { void DoState(unsigned char **ptr, int mode)
{
#if defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_X11) && HAVE_X11
OpenGL_MakeCurrent(); OpenGL_MakeCurrent();
#endif #endif
@ -351,7 +352,8 @@ void Video_AddMessage(const char* pstr, u32 milliseconds)
OSD::AddMessage(pstr, milliseconds); OSD::AddMessage(pstr, milliseconds);
} }
void Video_SetRendering(bool bEnabled) { void Video_SetRendering(bool bEnabled)
{
Fifo_SetRendering(bEnabled); Fifo_SetRendering(bEnabled);
} }