From c541f3c335f64d1517a4cc2d2e20c2b7ca84baa9 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 30 Nov 2008 14:15:34 +0000 Subject: [PATCH] Aniso filter setting working in GL, some code moving around, spelling fixes git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1341 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_VideoOGL/Plugin_VideoOGL.vcproj | 20 ++ .../Plugins/Plugin_VideoOGL/Src/BPStructs.cpp | 76 +--- .../Plugins/Plugin_VideoOGL/Src/BPStructs.h | 3 - Source/Plugins/Plugin_VideoOGL/Src/Config.cpp | 13 +- Source/Plugins/Plugin_VideoOGL/Src/Config.h | 5 +- .../Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp | 31 +- .../Plugin_VideoOGL/Src/GUI/ConfigDlg.h | 6 +- .../Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp | 6 +- Source/Plugins/Plugin_VideoOGL/Src/Render.cpp | 63 ++++ Source/Plugins/Plugin_VideoOGL/Src/Render.h | 3 + .../Plugin_VideoOGL/Src/TextureConverter.cpp | 8 +- .../Plugin_VideoOGL/Src/TextureMngr.cpp | 4 +- .../Plugin_VideoOGL/Src/VertexLoader.cpp | 39 +- .../Src/VertexLoader_Color.cpp | 231 ++++++++++++ .../Plugin_VideoOGL/Src/VertexLoader_Color.h | 220 +----------- .../Src/VertexLoader_Position.cpp | 241 +++++++++++++ .../Src/VertexLoader_Position.h | 224 +----------- .../Src/VertexLoader_TextCoord.cpp | 337 +++++++++++++++++ .../Src/VertexLoader_TextCoord.h | 340 ++---------------- .../Plugin_VideoOGL/Src/VertexManager.cpp | 8 +- Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp | 12 +- 21 files changed, 1037 insertions(+), 853 deletions(-) create mode 100644 Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Color.cpp create mode 100644 Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Position.cpp create mode 100644 Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_TextCoord.cpp diff --git a/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj b/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj index 75691d39a5..6c468402ba 100644 --- a/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj +++ b/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj @@ -739,11 +739,23 @@ + + + + + @@ -756,10 +768,18 @@ RelativePath=".\Src\VertexLoader_Normal.h" > + + + + diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp index 3a7ad113d3..5e5c39524c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.cpp @@ -268,7 +268,7 @@ void BPWritten(int addr, int changes, int newval) } if (changes & 0x18) - SetColorMask(); + Renderer::SetColorMask(); } break; @@ -342,7 +342,7 @@ void BPWritten(int addr, int changes, int newval) if (changes) { VertexManager::Flush(); ((u32*)&bpmem)[addr] = newval; - SetScissorRect(); + Renderer::SetScissorRect(); } break; @@ -352,7 +352,7 @@ void BPWritten(int addr, int changes, int newval) if (changes) { VertexManager::Flush(); ((u32*)&bpmem)[addr] = newval; - if (!SetScissorRect()) { + if (!Renderer::SetScissorRect()) { if (addr == BPMEM_SCISSORBR ) ERROR_LOG("bad scissor!\n"); } @@ -447,7 +447,7 @@ void BPWritten(int addr, int changes, int newval) PE_copy.Hex = bpmem.triggerEFBCopy; if (PE_copy.copy_to_xfb == 0) { - if(g_Config.bEBFToTextureDisable) { + if(g_Config.bEFBToTextureDisable) { glViewport(rc.left,rc.bottom,rc.right,rc.top); glScissor(rc.left,rc.bottom,rc.right,rc.top); } @@ -521,7 +521,7 @@ void BPWritten(int addr, int changes, int newval) ((bpmem.clearZValue>>8)&0xff)*(1/255.0f), ((bpmem.clearZValue>>16)&0xff)*(1/255.0f), 0); glClear(GL_COLOR_BUFFER_BIT); - SetColorMask(); + Renderer::SetColorMask(); GL_REPORT_ERRORD(); } @@ -531,7 +531,7 @@ void BPWritten(int addr, int changes, int newval) glDrawBuffers(2, s_drawbuffers); } - SetScissorRect(); // reset the scissor rect + Renderer::SetScissorRect(); // reset the scissor rect } } break; @@ -732,70 +732,6 @@ void BPWritten(int addr, int changes, int newval) } } - -void SetColorMask() -{ - if (bpmem.blendmode.alphaupdate && bpmem.blendmode.colorupdate) - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); - else if (bpmem.blendmode.alphaupdate) - glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_TRUE); - else if (bpmem.blendmode.colorupdate) - glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE); -} - - -// ======================================================================================= -// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg() -// case 0x52 > SetScissorRect() -// --------------- -// This function handles the OpenGL glScissor() function -// --------------- -// bpmem.scissorTL.x, y = 342x342 -// bpmem.scissorBR.x, y = 981x821 -// Renderer::GetTargetHeight() = the fixed ini file setting -// --------------- -bool SetScissorRect() -{ - int xoff = bpmem.scissorOffset.x * 2 - 342; - int yoff = bpmem.scissorOffset.y * 2 - 342; - - float rc_left = bpmem.scissorTL.x - xoff - 342; // left = 0 - rc_left *= MValueX; - if (rc_left < 0) rc_left = 0; - - float rc_top = bpmem.scissorTL.y - yoff - 342; // right = 0 - rc_top *= MValueY; - if (rc_top < 0) rc_top = 0; - - float rc_right = bpmem.scissorBR.x - xoff - 342; // right = 640 - rc_right *= MValueX; - if (rc_right > 640 * MValueX) rc_right = 640 * MValueX; - - float rc_bottom = bpmem.scissorBR.y - yoff - 342; // bottom = 480 - rc_bottom *= MValueY; - if (rc_bottom > 480 * MValueY) rc_bottom = 480 * MValueY; - - /*__Log("Scissor: lt=(%d,%d), rb=(%d,%d,%i), off=(%d,%d)\n", - rc_left, rc_top, - rc_right, rc_bottom, Renderer::GetTargetHeight(), - xoff, yoff - );*/ - - if (rc_right >= rc_left && rc_bottom >= rc_top ) - { - glScissor( - (int)rc_left, // x = 0 - Renderer::GetTargetHeight()-(int)(rc_bottom), // y = 0 - (int)(rc_right-rc_left), // y = 0 - (int)(rc_bottom-rc_top) // y = 0 - ); - return true; - } - - return false; -} - - // Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg() void LoadBPReg(u32 value0) { diff --git a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.h b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.h index b56db6bec9..a4e9a8f2fb 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/BPStructs.h @@ -24,7 +24,4 @@ void BPInit(); void LoadBPReg(u32 value0); void BPReload(); -void SetColorMask(); -bool SetScissorRect(); - #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp index 2242424170..81c7ed20e6 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.cpp @@ -75,11 +75,10 @@ void Config::Load() iniFile.Get("Settings", "DisableTexturing", &bDisableTexturing, 0); iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0); - iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0); + iniFile.Get("Enhancements", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x) - - iniFile.Get("Hacks", "EFBToTextureDisable", &bEBFToTextureDisable, 0); - iniFile.Get("Hacks", "EBFToTextureDisableHotKey", &bEBFToTextureDisableHotKey, 0); + iniFile.Get("Hacks", "EFBToTextureDisable", &bEFBToTextureDisable, 0); + iniFile.Get("Hacks", "EFBToTextureDisableHotKey", &bEFBToTextureDisableHotKey, 0); iniFile.Get("Hacks", "ProjectionHax1", &bProjectionHax1, 0); iniFile.Get("Hacks", "ProjectionHax2", &bProjectionHax2, 0); } @@ -112,10 +111,10 @@ void Config::Save() iniFile.Set("Settings", "DisableTexturing", bDisableTexturing); iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering); - iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso); + iniFile.Set("Enhancements", "MaxAnisotropy", iMaxAnisotropy); - iniFile.Set("Hacks", "EFBToTextureDisable", bEBFToTextureDisable); - iniFile.Set("Hacks", "EBFToTextureDisableHotKey", bEBFToTextureDisableHotKey); + iniFile.Set("Hacks", "EFBToTextureDisable", bEFBToTextureDisable); + iniFile.Set("Hacks", "EFBToTextureDisableHotKey", bEFBToTextureDisableHotKey); iniFile.Set("Hacks", "ProjectionHax1", bProjectionHax1); iniFile.Set("Hacks", "ProjectionHax2", bProjectionHax2); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Config.h b/Source/Plugins/Plugin_VideoOGL/Src/Config.h index d5a000b4c6..5e56626c0f 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Config.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Config.h @@ -44,7 +44,7 @@ struct Config // Enhancements int iMultisampleMode; bool bForceFiltering; - bool bForceMaxAniso; + int iMaxAnisotropy; // Information bool bShowFPS; @@ -63,7 +63,8 @@ struct Config bool bDumpTextures; // Hacks - bool bEBFToTextureDisable; bool bEBFToTextureDisableHotKey; + bool bEFBToTextureDisable; + bool bEFBToTextureDisableHotKey; bool bProjectionHax1; bool bProjectionHax2; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp index 84add16651..4f3d7fbeb8 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.cpp @@ -31,8 +31,8 @@ BEGIN_EVENT_TABLE(ConfigDialog,wxDialog) EVT_COMBOBOX(ID_FULLSCREENCB, ConfigDialog::GeneralSettingsChanged) EVT_COMBOBOX(ID_WINDOWRESOLUTIONCB, ConfigDialog::GeneralSettingsChanged) EVT_COMBOBOX(ID_ALIASMODECB, ConfigDialog::GeneralSettingsChanged) + EVT_CHOICE(ID_MAXANISOTROPY, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(ID_FORCEFILTERING, ConfigDialog::GeneralSettingsChanged) - EVT_CHECKBOX(ID_FORCEANISOTROPY, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(ID_STRETCHTOFIT, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(ID_KEEPAR, ConfigDialog::GeneralSettingsChanged) EVT_CHECKBOX(ID_HIDECURSOR, ConfigDialog::GeneralSettingsChanged) @@ -121,14 +121,20 @@ void ConfigDialog::CreateGUIControls() sbEnhancements = new wxStaticBoxSizer(wxVERTICAL, m_PageGeneral, wxT("Enhancements")); m_ForceFiltering = new wxCheckBox(m_PageGeneral, ID_FORCEFILTERING, wxT("Force bi/trilinear filtering (May cause small glitches)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_ForceFiltering->SetValue(g_Config.bForceFiltering); - m_ForceAnisotropy = new wxCheckBox(m_PageGeneral, ID_FORCEANISOTROPY, wxT("Force maximum anisotropy filtering"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - //m_ForceAnisotropy->SetValue(g_Config.bForceMaxAniso); - m_ForceAnisotropy->Enable(false); + wxStaticText *AnisoText = new wxStaticText(m_PageGeneral, ID_WMTEXT, wxT("Anisotropic filter:"), wxDefaultPosition, wxDefaultSize, 0); + m_MaxAnisotropyCB = new wxChoice(m_PageGeneral, ID_MAXANISOTROPY, wxDefaultPosition, wxDefaultSize, arrayStringFor_MaxAnisotropyCB, 0, wxDefaultValidator); + m_MaxAnisotropyCB->Append("1x"); + m_MaxAnisotropyCB->Append("2x"); + m_MaxAnisotropyCB->Append("4x"); + m_MaxAnisotropyCB->Append("8x"); + m_MaxAnisotropyCB->Append("16x"); + m_MaxAnisotropyCB->SetSelection(g_Config.iMaxAnisotropy - 1); + wxStaticText *AAText = new wxStaticText(m_PageGeneral, ID_AATEXT, wxT("Anti-alias mode:"), wxDefaultPosition, wxDefaultSize, 0); wxArrayString arrayStringFor_AliasModeCB; m_AliasModeCB = new wxComboBox(m_PageGeneral, ID_ALIASMODECB, wxEmptyString, wxDefaultPosition, wxDefaultSize, arrayStringFor_AliasModeCB, 0, wxDefaultValidator); wxString tmp; - tmp<SetValue(tmp); // Usage: The wxGBPosition() must have a column and row @@ -148,7 +154,8 @@ void ConfigDialog::CreateGUIControls() sEnhancements = new wxGridBagSizer(0, 0); sEnhancements->Add(m_ForceFiltering, wxGBPosition(0, 0), wxGBSpan(1, 2), wxALL, 5); - sEnhancements->Add(m_ForceAnisotropy, wxGBPosition(1, 0), wxGBSpan(1, 2), wxALL, 5); + sEnhancements->Add(AnisoText, wxGBPosition(1, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); + sEnhancements->Add(m_MaxAnisotropyCB, wxGBPosition(1, 1), wxGBSpan(1, 2), wxALL, 5); sEnhancements->Add(AAText, wxGBPosition(2, 0), wxGBSpan(1, 1), wxALIGN_CENTER_VERTICAL|wxALL, 5); sEnhancements->Add(m_AliasModeCB, wxGBPosition(2, 1), wxGBSpan(1, 2), wxALL, 5); sbEnhancements->Add(sEnhancements); @@ -200,7 +207,7 @@ void ConfigDialog::CreateGUIControls() m_EFBToTextureDisable->SetToolTip(wxT("Do not copy the Embedded Framebuffer (EFB)" " to the\nTexture. This may result in a speed increase.")); m_EFBToTextureDisable->Enable(true); - m_EFBToTextureDisable->SetValue(g_Config.bEBFToTextureDisable); + m_EFBToTextureDisable->SetValue(g_Config.bEFBToTextureDisable); m_EFBToTextureDisableHotKey = new wxCheckBox(m_PageAdvanced, ID_EFBTOTEXTUREDISABLEHOTKEY, wxT("with hotkey E"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_EFBToTextureDisableHotKey->SetToolTip(wxT("Use the E key to turn this option on and off")); @@ -208,7 +215,7 @@ void ConfigDialog::CreateGUIControls() // JPeterson set the hot key to be Win32-specific m_EFBToTextureDisableHotKey->Enable(false); #endif - m_EFBToTextureDisableHotKey->SetValue(g_Config.bEBFToTextureDisableHotKey); + m_EFBToTextureDisableHotKey->SetValue(g_Config.bEFBToTextureDisableHotKey); m_SafeTextureCache = new wxCheckBox(m_PageAdvanced, ID_SAFETEXTURECACHE, wxT("Safe texture cache"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); m_SafeTextureCache->SetToolTip(wxT("This is useful to prevent Metroid Prime from crashing, but can cause problems in other games.")); @@ -330,8 +337,8 @@ void ConfigDialog::GeneralSettingsChanged(wxCommandEvent& event) case ID_FORCEFILTERING: g_Config.bForceFiltering = m_ForceFiltering->IsChecked(); break; - case ID_FORCEANISOTROPY: - g_Config.bForceMaxAniso = m_ForceAnisotropy->IsChecked(); + case ID_MAXANISOTROPY: + g_Config.iMaxAnisotropy = m_MaxAnisotropyCB->GetSelection() + 1; break; case ID_ALIASMODECB: g_Config.iMultisampleMode = atoi(m_AliasModeCB->GetValue().mb_str()); @@ -380,10 +387,10 @@ void ConfigDialog::AdvancedSettingsChanged(wxCommandEvent& event) case ID_TEXTUREPATH: break; case ID_EFBTOTEXTUREDISABLE: - g_Config.bEBFToTextureDisable = m_EFBToTextureDisable->IsChecked(); + g_Config.bEFBToTextureDisable = m_EFBToTextureDisable->IsChecked(); break; case ID_EFBTOTEXTUREDISABLEHOTKEY: - g_Config.bEBFToTextureDisableHotKey = m_EFBToTextureDisableHotKey->IsChecked(); + g_Config.bEFBToTextureDisableHotKey = m_EFBToTextureDisableHotKey->IsChecked(); break; case ID_PROJECTIONHACK1: g_Config.bProjectionHax1 = m_ProjectionHax1->IsChecked(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h index af029e727d..84c6c5f944 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GUI/ConfigDlg.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -80,7 +81,8 @@ class ConfigDialog : public wxDialog wxComboBox *m_WindowResolutionCB; wxCheckBox *m_ForceFiltering; // advanced - wxCheckBox *m_ForceAnisotropy; + wxChoice *m_MaxAnisotropyCB; + wxArrayString arrayStringFor_MaxAnisotropyCB; wxComboBox *m_AliasModeCB; wxCheckBox *m_ShowFPS; wxCheckBox *m_ShaderErrors; @@ -118,7 +120,7 @@ class ConfigDialog : public wxDialog ID_WINDOWRESOLUTIONCB, ID_FORCEFILTERING, - ID_FORCEANISOTROPY, + ID_MAXANISOTROPY, ID_AATEXT, ID_ALIASMODECB, diff --git a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp index b656d5a3f4..61cd5c9f7c 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/OS/Win32.cpp @@ -138,11 +138,11 @@ namespace EmuWindow hypotheticalScene->sendMessage(KEYDOWN...); */ case 'E': // EFB hotkey - if(g_Config.bEBFToTextureDisableHotKey) + if(g_Config.bEFBToTextureDisableHotKey) { - g_Config.bEBFToTextureDisable = !g_Config.bEBFToTextureDisable; + g_Config.bEFBToTextureDisable = !g_Config.bEFBToTextureDisable; Renderer::AddMessage(StringFromFormat("Copy EFB was turned %s", - g_Config.bEBFToTextureDisable ? "off" : "on").c_str(), 5000); + g_Config.bEFBToTextureDisable ? "off" : "on").c_str(), 5000); } break; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index bc437f227f..08303a19f3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -561,6 +561,69 @@ void Renderer::RestoreGLState() SetColorMask(); } +void Renderer::SetColorMask() +{ + if (bpmem.blendmode.alphaupdate && bpmem.blendmode.colorupdate) + glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE); + else if (bpmem.blendmode.alphaupdate) + glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_TRUE); + else if (bpmem.blendmode.colorupdate) + glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_FALSE); +} + + +// ======================================================================================= +// Call browser: OpcodeDecoding.cpp ExecuteDisplayList > Decode() > LoadBPReg() +// case 0x52 > SetScissorRect() +// --------------- +// This function handles the OpenGL glScissor() function +// --------------- +// bpmem.scissorTL.x, y = 342x342 +// bpmem.scissorBR.x, y = 981x821 +// Renderer::GetTargetHeight() = the fixed ini file setting +// --------------- +bool Renderer::SetScissorRect() +{ + int xoff = bpmem.scissorOffset.x * 2 - 342; + int yoff = bpmem.scissorOffset.y * 2 - 342; + + float rc_left = bpmem.scissorTL.x - xoff - 342; // left = 0 + rc_left *= MValueX; + if (rc_left < 0) rc_left = 0; + + float rc_top = bpmem.scissorTL.y - yoff - 342; // right = 0 + rc_top *= MValueY; + if (rc_top < 0) rc_top = 0; + + float rc_right = bpmem.scissorBR.x - xoff - 342; // right = 640 + rc_right *= MValueX; + if (rc_right > 640 * MValueX) rc_right = 640 * MValueX; + + float rc_bottom = bpmem.scissorBR.y - yoff - 342; // bottom = 480 + rc_bottom *= MValueY; + if (rc_bottom > 480 * MValueY) rc_bottom = 480 * MValueY; + + /*__Log("Scissor: lt=(%d,%d), rb=(%d,%d,%i), off=(%d,%d)\n", + rc_left, rc_top, + rc_right, rc_bottom, Renderer::GetTargetHeight(), + xoff, yoff + );*/ + + if (rc_right >= rc_left && rc_bottom >= rc_top ) + { + glScissor( + (int)rc_left, // x = 0 + Renderer::GetTargetHeight()-(int)(rc_bottom), // y = 0 + (int)(rc_right-rc_left), // y = 0 + (int)(rc_bottom-rc_top) // y = 0 + ); + return true; + } + + return false; +} + + bool Renderer::IsUsingATIDrawBuffers() { return s_bATIDrawBuffers; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.h b/Source/Plugins/Plugin_VideoOGL/Src/Render.h index 314606b05e..c5c88eb5f5 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.h @@ -68,6 +68,9 @@ public: static void SetZBufferRender(); // sets rendering of the zbuffer using MRTs static u32 GetZBufferTarget(); + static void SetColorMask(); + static bool SetScissorRect(); + static void SetRenderMode(RenderMode mode); static RenderMode GetRenderMode(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp index 0062c3203a..4826ff3d8b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp @@ -148,10 +148,10 @@ void EncodeToRam(GLuint srcTexture, const TRectangle& sourceRc, glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, s_rgbToYuyvProgram.glprogid); glBegin(GL_QUADS); - glTexCoord2f(sourceRc.left, sourceRc.top); glVertex2f(-1,-1); - glTexCoord2f(sourceRc.left, sourceRc.bottom); glVertex2f(-1,1); - glTexCoord2f(sourceRc.right, sourceRc.bottom); glVertex2f(1,1); - glTexCoord2f(sourceRc.right, sourceRc.top); glVertex2f(1,-1); + glTexCoord2f((float)sourceRc.left, (float)sourceRc.top); glVertex2f(-1,-1); + glTexCoord2f((float)sourceRc.left, (float)sourceRc.bottom); glVertex2f(-1,1); + glTexCoord2f((float)sourceRc.right, (float)sourceRc.bottom); glVertex2f(1,1); + glTexCoord2f((float)sourceRc.right, (float)sourceRc.top); glVertex2f(1,-1); glEnd(); GL_REPORT_ERRORD(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp index b2bee4b544..ecd3c99800 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp @@ -100,9 +100,9 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, c_WrapSettings[newmode.wrap_t]); } - if (g_Config.bForceMaxAniso) + if (g_Config.iMaxAnisotropy >= 1) { - // not used for now, check out GL_EXT_texture_filter_anisotropic + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, 1 << g_Config.iMaxAnisotropy); } } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp index 80ea83121c..7961bf165e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader.cpp @@ -27,25 +27,28 @@ #include "x64Emitter.h" #include "ABI.h" +#include "LookUpTables.h" #include "Statistics.h" #include "VertexManager.h" #include "VertexLoaderManager.h" +#include "VertexShaderManager.h" +#include "VertexManager.h" #include "VertexLoader.h" #include "BPStructs.h" #include "DataReader.h" +#include "VertexLoader_Position.h" +#include "VertexLoader_Normal.h" +#include "VertexLoader_Color.h" +#include "VertexLoader_TextCoord.h" + #define USE_JIT +#define COMPILED_CODE_SIZE 4096*4 + NativeVertexFormat *g_nativeVertexFmt; - //these don't need to be saved -static float posScale; -static int colElements[2]; -static float tcScaleU[8]; -static float tcScaleV[8]; -static int tcIndex; -static int colIndex; #ifndef _WIN32 #undef inline #define inline @@ -57,9 +60,16 @@ static u8 s_curposmtx; static u8 s_curtexmtx[8]; static int s_texmtxwrite = 0; static int s_texmtxread = 0; -static TVtxAttr* pVtxAttr; static int loop_counter; +// Vertex loaders read these. Although the scale ones should be baked into the shader. +int tcIndex; +int colIndex; +TVtxAttr* pVtxAttr; +int colElements[2]; +float posScale; +float tcScale[8]; + using namespace Gen; void LOADERDECL PosMtx_ReadDirect_UByte() @@ -104,13 +114,6 @@ void LOADERDECL TexMtx_Write_Short3() VertexManager::s_pCurBufferPointer += 8; } -#include "VertexLoader_Position.h" -#include "VertexLoader_Normal.h" -#include "VertexLoader_Color.h" -#include "VertexLoader_TextCoord.h" - -#define COMPILED_CODE_SIZE 4096*4 - VertexLoader::VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr) { m_numLoadedVertices = 0; @@ -628,10 +631,8 @@ void VertexLoader::RunVertices(int vtx_attr_group, int primitive, int count) pVtxAttr = &m_VtxAttr; posScale = shiftLookup[m_VtxAttr.PosFrac]; if (m_NativeFmt->m_components & VB_HAS_UVALL) { - for (int i = 0; i < 8; i++) { - tcScaleU[i] = shiftLookup[m_VtxAttr.texCoord[i].Frac]; - tcScaleV[i] = shiftLookup[m_VtxAttr.texCoord[i].Frac]; - } + for (int i = 0; i < 8; i++) + tcScale[i] = shiftLookup[m_VtxAttr.texCoord[i].Frac]; } for (int i = 0; i < 2; i++) colElements[i] = m_VtxAttr.color[i].Elements; diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Color.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Color.cpp new file mode 100644 index 0000000000..13b3c3fbce --- /dev/null +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Color.cpp @@ -0,0 +1,231 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef _VERTEXLOADERCOLOR_H +#define _VERTEXLOADERCOLOR_H + +#include "Globals.h" +#include "LookUpTables.h" +#include "VertexLoader.h" +#include "VertexManager.h" +#include "VertexLoader_Color.h" + +#define RSHIFT 0 +#define GSHIFT 8 +#define BSHIFT 16 +#define ASHIFT 24 + +extern int colIndex; +extern int colElements[2]; + +inline void _SetCol(u32 val) +{ + *(u32*)VertexManager::s_pCurBufferPointer = val; + VertexManager::s_pCurBufferPointer += 4; + colIndex++; +} + +void _SetCol4444(u16 val) +{ + u32 col = lut4to8[(val>>0)&0xF]<>12)&0xF] <>8)&0xF] <>4)&0xF] <>18)&0x3F] << RSHIFT; + col |= lut6to8[(val>>12)&0x3F] << GSHIFT; + col |= lut6to8[(val>>6)&0x3F] << BSHIFT; + col |= lut6to8[(val>>0)&0x3F] << ASHIFT; + _SetCol(col); +} + +void _SetCol565(u16 val) +{ + u32 col = lut5to8[(val>>11)&0x1f] << RSHIFT; + col |= lut6to8[(val>>5 )&0x3f] << GSHIFT; + col |= lut5to8[(val )&0x1f] << BSHIFT; + _SetCol(col | (0xFF<>0)&0xF]<>12)&0xF] <>8)&0xF] <>4)&0xF] <>18)&0x3F] << RSHIFT; - col |= lut6to8[(val>>12)&0x3F] << GSHIFT; - col |= lut6to8[(val>>6)&0x3F] << BSHIFT; - col |= lut6to8[(val>>0)&0x3F] << ASHIFT; - _SetCol(col); -} - -void _SetCol565(u16 val) -{ - u32 col = lut5to8[(val>>11)&0x1f] << RSHIFT; - col |= lut6to8[(val>>5 )&0x3f] << GSHIFT; - col |= lut5to8[(val )&0x1f] << BSHIFT; - _SetCol(col | (0xFF< +MULPS(XMM0, XMM7); +MOVUPS(MOffset(EDI, 0), XMM0); + + */ + +// ============================================================================== +// Direct +// ============================================================================== +void LOADERDECL Pos_ReadDirect_UByte() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU8() * posScale; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)DataReadU8() * posScale; + if (pVtxAttr->PosElements) + ((float*)VertexManager::s_pCurBufferPointer)[2] = (float)DataReadU8() * posScale; + else + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; + LOG_VTX(); + VertexManager::s_pCurBufferPointer += 12; +} + +void LOADERDECL Pos_ReadDirect_Byte() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)DataReadU8() * posScale; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)DataReadU8() * posScale; + if (pVtxAttr->PosElements) + ((float*)VertexManager::s_pCurBufferPointer)[2] = (float)(s8)DataReadU8() * posScale; + else + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0; + LOG_VTX(); + VertexManager::s_pCurBufferPointer += 12; +} + +void LOADERDECL Pos_ReadDirect_UShort() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU16() * posScale; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)DataReadU16() * posScale; + if (pVtxAttr->PosElements) + ((float*)VertexManager::s_pCurBufferPointer)[2] = (float)DataReadU16() * posScale; + else + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; + LOG_VTX(); + VertexManager::s_pCurBufferPointer += 12; +} + +void LOADERDECL Pos_ReadDirect_Short() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)DataReadU16() * posScale; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)DataReadU16() * posScale; + if (pVtxAttr->PosElements) + ((float*)VertexManager::s_pCurBufferPointer)[2] = (float)(s16)DataReadU16() * posScale; + else + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; + LOG_VTX(); + VertexManager::s_pCurBufferPointer += 12; +} + +void LOADERDECL Pos_ReadDirect_Float() +{ + // No need to use floating point here. + ((u32 *)VertexManager::s_pCurBufferPointer)[0] = DataReadU32(); + ((u32 *)VertexManager::s_pCurBufferPointer)[1] = DataReadU32(); + if (pVtxAttr->PosElements) + ((u32 *)VertexManager::s_pCurBufferPointer)[2] = DataReadU32(); + else + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; + LOG_VTX(); + VertexManager::s_pCurBufferPointer += 12; +} + +#define Pos_ReadIndex_Byte(T) { \ + u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \ + ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)Memory_Read_U8(iAddress)) * posScale; \ + ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)Memory_Read_U8(iAddress+1)) * posScale; \ + if (pVtxAttr->PosElements) \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(T)Memory_Read_U8(iAddress+2)) * posScale; \ + else \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ + LOG_VTX(); \ + VertexManager::s_pCurBufferPointer += 12; \ +} + +#define Pos_ReadIndex_Short(T) { \ + u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \ + ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)Memory_Read_U16(iAddress)) * posScale; \ + ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)Memory_Read_U16(iAddress+2)) * posScale; \ + if (pVtxAttr->PosElements) \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(T)Memory_Read_U16(iAddress+4)) * posScale; \ + else \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ + LOG_VTX(); \ + VertexManager::s_pCurBufferPointer += 12; \ +} + +#define Pos_ReadIndex_Float() { \ + u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]); \ + ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); \ + ((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4); \ + if (pVtxAttr->PosElements) \ + ((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8); \ + else \ + ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ + LOG_VTX(); \ + VertexManager::s_pCurBufferPointer += 12; \ +} + +// ============================================================================== +// Index 8 +// ============================================================================== +void LOADERDECL Pos_ReadIndex8_UByte() +{ + u8 Index = DataReadU8(); + Pos_ReadIndex_Byte(u8); +} + +void LOADERDECL Pos_ReadIndex8_Byte() +{ + u8 Index = DataReadU8(); + Pos_ReadIndex_Byte(s8); +} + +void LOADERDECL Pos_ReadIndex8_UShort() +{ + u8 Index = DataReadU8(); + Pos_ReadIndex_Short(u16); +} + +void LOADERDECL Pos_ReadIndex8_Short() +{ + u8 Index = DataReadU8(); + Pos_ReadIndex_Short(s16); +} + +void LOADERDECL Pos_ReadIndex8_Float() +{ + u8 Index = DataReadU8(); + Pos_ReadIndex_Float(); +} + +// ============================================================================== +// Index 16 +// ============================================================================== + +void LOADERDECL Pos_ReadIndex16_UByte(){ + u16 Index = DataReadU16(); + Pos_ReadIndex_Byte(u8); +} + +void LOADERDECL Pos_ReadIndex16_Byte(){ + u16 Index = DataReadU16(); + Pos_ReadIndex_Byte(s8); +} + +void LOADERDECL Pos_ReadIndex16_UShort(){ + u16 Index = DataReadU16(); + Pos_ReadIndex_Short(u16); +} + +void LOADERDECL Pos_ReadIndex16_Short() +{ + u16 Index = DataReadU16(); + Pos_ReadIndex_Short(s16); +} + +void LOADERDECL Pos_ReadIndex16_Float() +{ + u16 Index = DataReadU16(); + Pos_ReadIndex_Float(); +} + +#endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Position.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Position.h index 43991b8eed..31afccb4b3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Position.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_Position.h @@ -18,216 +18,22 @@ #ifndef VERTEXLOADER_POSITION_H #define VERTEXLOADER_POSITION_H -#define LOG_VTX() PRIM_LOG("vtx: %f %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0], ((float*)VertexManager::s_pCurBufferPointer)[1], ((float*)VertexManager::s_pCurBufferPointer)[2]); +void LOADERDECL Pos_ReadDirect_UByte(); +void LOADERDECL Pos_ReadDirect_Byte(); +void LOADERDECL Pos_ReadDirect_UShort(); +void LOADERDECL Pos_ReadDirect_Short(); +void LOADERDECL Pos_ReadDirect_Float(); -// Thoughts on the implementation of a vertex loader compiler. -// s_pCurBufferPointer should definitely be in a register. -// Could load the position scale factor in XMM7, for example. +void LOADERDECL Pos_ReadIndex8_UByte(); +void LOADERDECL Pos_ReadIndex8_Byte(); +void LOADERDECL Pos_ReadIndex8_UShort(); +void LOADERDECL Pos_ReadIndex8_Short(); +void LOADERDECL Pos_ReadIndex8_Float(); -// The pointer inside DataReadU8 in another. -// Let's check out Pos_ReadDirect_UByte(). For Byte, replace MOVZX with MOVSX. - -/* -MOVZX(32, R(EAX), MOffset(ESI, 0)); -MOVZX(32, R(EBX), MOffset(ESI, 1)); -MOVZX(32, R(ECX), MOffset(ESI, 2)); -MOVD(XMM0, R(EAX)); -MOVD(XMM1, R(EBX)); -MOVD(XMM2, R(ECX)); -CVTDQ2PS(XMM0, XMM0); -CVTDQ2PS(XMM1, XMM1); -CVTDQ2PS(XMM2, XMM2); -MULSS(XMM0, XMM7); -MULSS(XMM1, XMM7); -MULSS(XMM2, XMM7); -MOVSS(MOffset(EDI, 0), XMM0); -MOVSS(MOffset(EDI, 4), XMM1); -MOVSS(MOffset(EDI, 8), XMM2); - -Alternatively, lookup table: -MOVZX(32, R(EAX), MOffset(ESI, 0)); -MOVZX(32, R(EBX), MOffset(ESI, 1)); -MOVZX(32, R(ECX), MOffset(ESI, 2)); -MOV(32, R(EAX), MComplex(LUTREG, EAX, 4)); -MOV(32, R(EBX), MComplex(LUTREG, EBX, 4)); -MOV(32, R(ECX), MComplex(LUTREG, ECX, 4)); -MOV(MOffset(EDI, 0), XMM0); -MOV(MOffset(EDI, 4), XMM1); -MOV(MOffset(EDI, 8), XMM2); - -SSE4: -PINSRB(XMM0, MOffset(ESI, 0), 0); -PINSRB(XMM0, MOffset(ESI, 1), 4); -PINSRB(XMM0, MOffset(ESI, 2), 8); -CVTDQ2PS(XMM0, XMM0); - -MULPS(XMM0, XMM7); -MOVUPS(MOffset(EDI, 0), XMM0); - - */ - -// ============================================================================== -// Direct -// ============================================================================== -void LOADERDECL Pos_ReadDirect_UByte() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU8() * posScale; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)DataReadU8() * posScale; - if (pVtxAttr->PosElements) - ((float*)VertexManager::s_pCurBufferPointer)[2] = (float)DataReadU8() * posScale; - else - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; - LOG_VTX(); - VertexManager::s_pCurBufferPointer += 12; -} - -void LOADERDECL Pos_ReadDirect_Byte() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)DataReadU8() * posScale; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)DataReadU8() * posScale; - if (pVtxAttr->PosElements) - ((float*)VertexManager::s_pCurBufferPointer)[2] = (float)(s8)DataReadU8() * posScale; - else - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0; - LOG_VTX(); - VertexManager::s_pCurBufferPointer += 12; -} - -void LOADERDECL Pos_ReadDirect_UShort() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU16() * posScale; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)DataReadU16() * posScale; - if (pVtxAttr->PosElements) - ((float*)VertexManager::s_pCurBufferPointer)[2] = (float)DataReadU16() * posScale; - else - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; - LOG_VTX(); - VertexManager::s_pCurBufferPointer += 12; -} - -void LOADERDECL Pos_ReadDirect_Short() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)DataReadU16() * posScale; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)DataReadU16() * posScale; - if (pVtxAttr->PosElements) - ((float*)VertexManager::s_pCurBufferPointer)[2] = (float)(s16)DataReadU16() * posScale; - else - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; - LOG_VTX(); - VertexManager::s_pCurBufferPointer += 12; -} - -void LOADERDECL Pos_ReadDirect_Float() -{ - // No need to use floating point here. - ((u32 *)VertexManager::s_pCurBufferPointer)[0] = DataReadU32(); - ((u32 *)VertexManager::s_pCurBufferPointer)[1] = DataReadU32(); - if (pVtxAttr->PosElements) - ((u32 *)VertexManager::s_pCurBufferPointer)[2] = DataReadU32(); - else - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; - LOG_VTX(); - VertexManager::s_pCurBufferPointer += 12; -} - -#define Pos_ReadIndex_Byte(T) { \ - u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \ - ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)Memory_Read_U8(iAddress)) * posScale; \ - ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)Memory_Read_U8(iAddress+1)) * posScale; \ - if (pVtxAttr->PosElements) \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(T)Memory_Read_U8(iAddress+2)) * posScale; \ - else \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ - LOG_VTX(); \ - VertexManager::s_pCurBufferPointer += 12; \ -} - -#define Pos_ReadIndex_Short(T) { \ - u32 iAddress = arraybases[ARRAY_POSITION] + ((u32)Index * arraystrides[ARRAY_POSITION]); \ - ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(T)Memory_Read_U16(iAddress)) * posScale; \ - ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(T)Memory_Read_U16(iAddress+2)) * posScale; \ - if (pVtxAttr->PosElements) \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(T)Memory_Read_U16(iAddress+4)) * posScale; \ - else \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ - LOG_VTX(); \ - VertexManager::s_pCurBufferPointer += 12; \ -} - -#define Pos_ReadIndex_Float() { \ - u32 iAddress = arraybases[ARRAY_POSITION] + (Index * arraystrides[ARRAY_POSITION]); \ - ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); \ - ((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4); \ - if (pVtxAttr->PosElements) \ - ((u32*)VertexManager::s_pCurBufferPointer)[2] = Memory_Read_U32(iAddress+8); \ - else \ - ((float*)VertexManager::s_pCurBufferPointer)[2] = 1.0f; \ - LOG_VTX(); \ - VertexManager::s_pCurBufferPointer += 12; \ -} - -// ============================================================================== -// Index 8 -// ============================================================================== -void LOADERDECL Pos_ReadIndex8_UByte() -{ - u8 Index = DataReadU8(); - Pos_ReadIndex_Byte(u8); -} - -void LOADERDECL Pos_ReadIndex8_Byte() -{ - u8 Index = DataReadU8(); - Pos_ReadIndex_Byte(s8); -} - -void LOADERDECL Pos_ReadIndex8_UShort() -{ - u8 Index = DataReadU8(); - Pos_ReadIndex_Short(u16); -} - -void LOADERDECL Pos_ReadIndex8_Short() -{ - u8 Index = DataReadU8(); - Pos_ReadIndex_Short(s16); -} - -void LOADERDECL Pos_ReadIndex8_Float() -{ - u8 Index = DataReadU8(); - Pos_ReadIndex_Float(); -} - -// ============================================================================== -// Index 16 -// ============================================================================== - -void LOADERDECL Pos_ReadIndex16_UByte(){ - u16 Index = DataReadU16(); - Pos_ReadIndex_Byte(u8); -} - -void LOADERDECL Pos_ReadIndex16_Byte(){ - u16 Index = DataReadU16(); - Pos_ReadIndex_Byte(s8); -} - -void LOADERDECL Pos_ReadIndex16_UShort(){ - u16 Index = DataReadU16(); - Pos_ReadIndex_Short(u16); -} - -void LOADERDECL Pos_ReadIndex16_Short() -{ - u16 Index = DataReadU16(); - Pos_ReadIndex_Short(s16); -} - -void LOADERDECL Pos_ReadIndex16_Float() -{ - u16 Index = DataReadU16(); - Pos_ReadIndex_Float(); -} +void LOADERDECL Pos_ReadIndex16_UByte(); +void LOADERDECL Pos_ReadIndex16_Byte(); +void LOADERDECL Pos_ReadIndex16_UShort(); +void LOADERDECL Pos_ReadIndex16_Short(); +void LOADERDECL Pos_ReadIndex16_Float(); #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_TextCoord.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_TextCoord.cpp new file mode 100644 index 0000000000..bc0125bcc6 --- /dev/null +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_TextCoord.cpp @@ -0,0 +1,337 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef VERTEXLOADER_TEXCOORD_H +#define VERTEXLOADER_TEXCOORD_H + +#include "Globals.h" +#include "VertexLoader.h" +#include "VertexManager.h" +#include "VertexLoader_Position.h" + +#define LOG_TEX1() PRIM_LOG("tex: %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0]); +#define LOG_TEX2() PRIM_LOG("tex: %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0], ((float*)VertexManager::s_pCurBufferPointer)[1]); + +extern int tcIndex; +extern float tcScale[8]; + +void LOADERDECL TexCoord_Read_Dummy() +{ + tcIndex++; +} + +void LOADERDECL TexCoord_ReadDirect_UByte1() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU8() * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadDirect_UByte2() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU8() * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)DataReadU8() * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadDirect_Byte1() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)DataReadU8() * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadDirect_Byte2() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)DataReadU8() * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)DataReadU8() * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadDirect_UShort1() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU16() * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadDirect_UShort2() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU16() * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)DataReadU16() * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadDirect_Short1() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)DataReadU16() * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadDirect_Short2() +{ + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)DataReadU16() * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)DataReadU16() * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadDirect_Float1() +{ + ((u32*)VertexManager::s_pCurBufferPointer)[0] = DataReadU32(); + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadDirect_Float2() +{ + ((u32*)VertexManager::s_pCurBufferPointer)[0] = DataReadU32(); + ((u32*)VertexManager::s_pCurBufferPointer)[1] = DataReadU32(); + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +// ================================================================================== +void LOADERDECL TexCoord_ReadIndex8_UByte1() +{ + u8 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex8_UByte2() +{ + u8 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)Memory_Read_U8(iAddress+1) * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadIndex8_Byte1() +{ + u8 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex8_Byte2() +{ + u8 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)Memory_Read_U8(iAddress+1) * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadIndex8_UShort1() +{ + u8 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex8_UShort2() +{ + u8 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u16)Memory_Read_U16(iAddress+2) * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadIndex8_Short1() +{ + u8 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex8_Short2() +{ + u8 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)Memory_Read_U16(iAddress+2) * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadIndex8_Float1() +{ + u16 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex8_Float2() +{ + u16 Index = DataReadU8(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); + ((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4); + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +// ================================================================================== +void LOADERDECL TexCoord_ReadIndex16_UByte1() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex16_UByte2() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)Memory_Read_U8(iAddress+1) * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadIndex16_Byte1() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex16_Byte2() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)Memory_Read_U8(iAddress+1) * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadIndex16_UShort1() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex16_UShort2() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u16)Memory_Read_U16(iAddress+2) * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadIndex16_Short1() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScale[tcIndex]; + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex16_Short2() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScale[tcIndex]; + ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)Memory_Read_U16(iAddress+2) * tcScale[tcIndex]; + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +void LOADERDECL TexCoord_ReadIndex16_Float1() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); + LOG_TEX1(); + VertexManager::s_pCurBufferPointer += 4; + tcIndex++; +} +void LOADERDECL TexCoord_ReadIndex16_Float2() +{ + u16 Index = DataReadU16(); + u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); + + ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); + ((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress + 4); + LOG_TEX2(); + VertexManager::s_pCurBufferPointer += 8; + tcIndex++; +} + +#endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_TextCoord.h b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_TextCoord.h index f6b7aa6b7c..e7572636db 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_TextCoord.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexLoader_TextCoord.h @@ -18,314 +18,36 @@ #ifndef VERTEXLOADER_TEXCOORD_H #define VERTEXLOADER_TEXCOORD_H -#define LOG_TEX1() PRIM_LOG("tex: %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0]); -#define LOG_TEX2() PRIM_LOG("tex: %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[0], ((float*)VertexManager::s_pCurBufferPointer)[1]); - -extern int tcIndex; - -void LOADERDECL TexCoord_Read_Dummy() -{ - tcIndex++; -} - -void LOADERDECL TexCoord_ReadDirect_UByte1() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU8() * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadDirect_UByte2() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU8() * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)DataReadU8() * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadDirect_Byte1() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)DataReadU8() * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadDirect_Byte2() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)DataReadU8() * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)DataReadU8() * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadDirect_UShort1() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU16() * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadDirect_UShort2() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)DataReadU16() * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)DataReadU16() * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadDirect_Short1() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)DataReadU16() * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadDirect_Short2() -{ - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)DataReadU16() * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)DataReadU16() * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadDirect_Float1() -{ - ((u32*)VertexManager::s_pCurBufferPointer)[0] = DataReadU32(); - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadDirect_Float2() -{ - ((u32*)VertexManager::s_pCurBufferPointer)[0] = DataReadU32(); - ((u32*)VertexManager::s_pCurBufferPointer)[1] = DataReadU32(); - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -// ================================================================================== -void LOADERDECL TexCoord_ReadIndex8_UByte1() -{ - u8 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex8_UByte2() -{ - u8 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)Memory_Read_U8(iAddress+1) * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadIndex8_Byte1() -{ - u8 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex8_Byte2() -{ - u8 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)Memory_Read_U8(iAddress+1) * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadIndex8_UShort1() -{ - u8 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex8_UShort2() -{ - u8 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u16)Memory_Read_U16(iAddress+2) * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadIndex8_Short1() -{ - u8 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex8_Short2() -{ - u8 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)Memory_Read_U16(iAddress+2) * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadIndex8_Float1() -{ - u16 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex8_Float2() -{ - u16 Index = DataReadU8(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); - ((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress+4); - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -// ================================================================================== -void LOADERDECL TexCoord_ReadIndex16_UByte1() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex16_UByte2() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u8)Memory_Read_U8(iAddress+1) * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadIndex16_Byte1() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex16_Byte2() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s8)Memory_Read_U8(iAddress) * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s8)Memory_Read_U8(iAddress+1) * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadIndex16_UShort1() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex16_UShort2() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(u16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(u16)Memory_Read_U16(iAddress+2) * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadIndex16_Short1() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]; - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex16_Short2() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((float*)VertexManager::s_pCurBufferPointer)[0] = (float)(s16)Memory_Read_U16(iAddress) * tcScaleU[tcIndex]; - ((float*)VertexManager::s_pCurBufferPointer)[1] = (float)(s16)Memory_Read_U16(iAddress+2) * tcScaleV[tcIndex]; - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} - -void LOADERDECL TexCoord_ReadIndex16_Float1() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); - LOG_TEX1(); - VertexManager::s_pCurBufferPointer += 4; - tcIndex++; -} -void LOADERDECL TexCoord_ReadIndex16_Float2() -{ - u16 Index = DataReadU16(); - u32 iAddress = arraybases[ARRAY_TEXCOORD0+tcIndex] + (Index * arraystrides[ARRAY_TEXCOORD0+tcIndex]); - - ((u32*)VertexManager::s_pCurBufferPointer)[0] = Memory_Read_U32(iAddress); - ((u32*)VertexManager::s_pCurBufferPointer)[1] = Memory_Read_U32(iAddress + 4); - LOG_TEX2(); - VertexManager::s_pCurBufferPointer += 8; - tcIndex++; -} +void LOADERDECL TexCoord_Read_Dummy(); +void LOADERDECL TexCoord_ReadDirect_UByte1(); +void LOADERDECL TexCoord_ReadDirect_UByte2(); +void LOADERDECL TexCoord_ReadDirect_Byte1(); +void LOADERDECL TexCoord_ReadDirect_Byte2(); +void LOADERDECL TexCoord_ReadDirect_UShort1(); +void LOADERDECL TexCoord_ReadDirect_UShort2(); +void LOADERDECL TexCoord_ReadDirect_Short1(); +void LOADERDECL TexCoord_ReadDirect_Short2(); +void LOADERDECL TexCoord_ReadDirect_Float1(); +void LOADERDECL TexCoord_ReadDirect_Float2(); +void LOADERDECL TexCoord_ReadIndex8_UByte1(); +void LOADERDECL TexCoord_ReadIndex8_UByte2(); +void LOADERDECL TexCoord_ReadIndex8_Byte1(); +void LOADERDECL TexCoord_ReadIndex8_Byte2(); +void LOADERDECL TexCoord_ReadIndex8_UShort1(); +void LOADERDECL TexCoord_ReadIndex8_UShort2(); +void LOADERDECL TexCoord_ReadIndex8_Short1(); +void LOADERDECL TexCoord_ReadIndex8_Short2(); +void LOADERDECL TexCoord_ReadIndex8_Float1(); +void LOADERDECL TexCoord_ReadIndex8_Float2(); +void LOADERDECL TexCoord_ReadIndex16_UByte1(); +void LOADERDECL TexCoord_ReadIndex16_UByte2(); +void LOADERDECL TexCoord_ReadIndex16_Byte1(); +void LOADERDECL TexCoord_ReadIndex16_Byte2(); +void LOADERDECL TexCoord_ReadIndex16_UShort1(); +void LOADERDECL TexCoord_ReadIndex16_UShort2(); +void LOADERDECL TexCoord_ReadIndex16_Short1(); +void LOADERDECL TexCoord_ReadIndex16_Short2(); +void LOADERDECL TexCoord_ReadIndex16_Float1(); +void LOADERDECL TexCoord_ReadIndex16_Float2(); #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp index 3d43d6b5ba..c7461cc7b2 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexManager.cpp @@ -227,8 +227,6 @@ void Flush() FRAGMENTSHADER* ps = PixelShaderMngr::GetShader(); VERTEXSHADER* vs = VertexShaderMngr::GetShader(s_prevcomponents); - //if (!ps) PanicAlert("Pixel shader = 0. Argh."); - //if (!vs) PanicAlert("Vertex shader = 0. Argh."); bool bRestoreBuffers = false; if (Renderer::GetZBufferTarget()) { @@ -295,7 +293,7 @@ void Flush() if (bRestoreBuffers) { GLenum s_drawbuffers[2] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT}; glDrawBuffers(2, s_drawbuffers); - SetColorMask(); + Renderer::SetColorMask(); } ResetBuffer(); @@ -374,8 +372,8 @@ void EnableComponents(u32 components) xfregs.colChans[i].color.enablelighting = false; } } - s_prevcomponents = components; - } + s_prevcomponents = components; + } } } // namespace diff --git a/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp b/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp index 3f1011ee3f..923eb4b78f 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/XFB.cpp @@ -82,11 +82,15 @@ void XFB_Draw(u8 *xfb_in_ram, u32 width, u32 height, s32 yOffset) glViewport(nXoff, nYoff, nBackbufferWidth, nBackbufferHeight); GL_REPORT_ERRORD(); + float w = (float)width; + float h = (float)height; + float yOff = (float)yOffset; + glBegin(GL_QUADS); - glTexCoord2f(width, 0 - yOffset); glVertex2f(1,-1); - glTexCoord2f(width, height - yOffset); glVertex2f(1,1); - glTexCoord2f(0, height - yOffset); glVertex2f(-1,1); - glTexCoord2f(0, 0 - yOffset); glVertex2f(-1,-1); + glTexCoord2f(w, 0 - yOff); glVertex2f(1, -1); + glTexCoord2f(w, h - yOff); glVertex2f(1, 1); + glTexCoord2f(0, h - yOff); glVertex2f(-1, 1); + glTexCoord2f(0, 0 - yOff); glVertex2f(-1,-1); glEnd(); TextureMngr::DisableStage(0);