Lots of code and warning cleanup. OGL/D3D: Moved to a shared config class in VideoCommon. This lets VideoCommon code read the config without ugly hacks. Fixed various config race conditions by keeping a copy (g_ActiveConfig) of the g_Config struct which is updated once per frame.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4256 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-09-13 08:21:35 +00:00
parent 52ea8a0fd1
commit 700f2ff694
44 changed files with 613 additions and 856 deletions

View File

@ -104,25 +104,24 @@ bool ConsoleListener::IsOpen()
void ConsoleListener::BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst)
{
#ifdef _WIN32
bool SB, SW;
BOOL SB, SW;
if (BufferFirst)
{
// Change screen buffer size
COORD Co = {BufferWidth, BufferHeight};
SB = (bool)SetConsoleScreenBufferSize(hConsole, Co);
SB = SetConsoleScreenBufferSize(hConsole, Co);
// Change the screen buffer window size
SMALL_RECT coo = {0,0,ScreenWidth, ScreenHeight}; // top, left, right, bottom
SW = (bool)SetConsoleWindowInfo(hConsole, TRUE, &coo);
SW = SetConsoleWindowInfo(hConsole, TRUE, &coo);
}
else
{
// Change the screen buffer window size
SMALL_RECT coo = {0,0, ScreenWidth, ScreenHeight}; // top, left, right, bottom
SW = (bool)SetConsoleWindowInfo(hConsole, TRUE, &coo);
SW = SetConsoleWindowInfo(hConsole, TRUE, &coo);
// Change screen buffer size
COORD Co = {BufferWidth, BufferHeight};
SB = (bool)SetConsoleScreenBufferSize(hConsole, Co);
SB = SetConsoleScreenBufferSize(hConsole, Co);
}
#endif
}
@ -158,7 +157,7 @@ COORD ConsoleListener::GetCoordinates(int BytesRead, int BufferWidth)
{
COORD Ret = {0, 0};
// Full rows
int Step = floor((float)BytesRead / (float)BufferWidth);
int Step = (int)floor((float)BytesRead / (float)BufferWidth);
Ret.Y += Step;
// Partial row
Ret.X = BytesRead - (BufferWidth * Step);
@ -195,7 +194,7 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
const int MAX_BYTES = 1024 * 16;
int ReadBufferSize = MAX_BYTES - 32;
DWORD cAttrRead = ReadBufferSize;
int BytesRead = 0;
DWORD BytesRead = 0;
int i = 0;
int LastAttrRead = 0;
while (BytesRead < BufferSize)
@ -215,10 +214,10 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
LastAttrRead = cAttrRead;
}
// Letter space
int LWidth = (int)floor((float)Width / 8.0) - 1.0;
int LHeight = (int)floor((float)Height / 12.0) - 1.0;
int LWidth = (int)(floor((float)Width / 8.0f) - 1.0f);
int LHeight = (int)(floor((float)Height / 12.0f) - 1.0f);
int LBufWidth = LWidth + 1;
int LBufHeight = floor((float)BufferSize / (float)LBufWidth);
int LBufHeight = (int)floor((float)BufferSize / (float)LBufWidth);
// Change screen buffer size
LetterSpace(LBufWidth, LBufHeight);

View File

@ -150,7 +150,7 @@ std::string MemUsage()
if (NULL == hProcess) return "MemUsage Error";
if (GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc)))
Ret = StringFromFormat("%s K", ThS(pmc.WorkingSetSize / 1024, true, 7).c_str());
Ret = StringFromFormat("%s K", ThS((int)(pmc.WorkingSetSize / 1024), true, 7).c_str());
CloseHandle(hProcess);
return Ret;

View File

@ -15,30 +15,37 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Globals.h"
#include <cmath>
#include "Common.h"
#include "IniFile.h"
#include "Config.h"
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
#include "VideoCommon.h"
Config g_Config;
Config g_ActiveConfig;
void UpdateActiveConfig()
{
g_ActiveConfig = g_Config;
}
Config::Config()
{
bRunning = false;
}
void Config::Load()
void Config::Load(const char *ini_file)
{
std::string temp;
IniFile iniFile;
iniFile.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
iniFile.Load(ini_file);
// get resolution
iniFile.Get("Hardware", "WindowedRes", &temp, "640x480");
strncpy(iInternalRes, temp.c_str(), 16);
strncpy(cInternalRes, temp.c_str(), 16);
iniFile.Get("Hardware", "FullscreenRes", &temp, "640x480");
strncpy(iFSResolution, temp.c_str(), 16);
strncpy(cFSResolution, temp.c_str(), 16);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); // Hardware
iniFile.Get("Hardware", "VSync", &bVSync, 0); // Hardware
@ -84,6 +91,13 @@ void Config::Load()
iniFile.Get("Hacks", "EFBToTextureEnable", &bCopyEFBToRAM, 0);
iniFile.Get("Hacks", "ProjectionHack", &iPhackvalue, 0);
iniFile.Get("Hardware", "Adapter", &iAdapter, 0);
if (iAdapter == -1)
iAdapter = 0;
iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0);
iniFile.Get("Hardware", "VSync", &bVsync, 0);
iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0);
// Load common settings
iniFile.Load(CONFIG_FILE);
bool bTmp;
@ -91,9 +105,8 @@ void Config::Load()
SetEnableAlert(bTmp);
}
void Config::GameIniLoad()
void Config::GameIniLoad(IniFile *iniFile)
{
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
if (! iniFile)
return;
@ -128,12 +141,12 @@ void Config::GameIniLoad()
iniFile->Get("Video", "ProjectionHack", &iPhackvalue, 0);
}
void Config::Save()
void Config::Save(const char *ini_file)
{
IniFile iniFile;
iniFile.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
iniFile.Set("Hardware", "WindowedRes", iInternalRes);
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Load(ini_file);
iniFile.Set("Hardware", "WindowedRes", cInternalRes);
iniFile.Set("Hardware", "FullscreenRes", cFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "VSync", bVSync);
iniFile.Set("Hardware", "RenderToMainframe", RenderToMainframe);
@ -178,5 +191,75 @@ void Config::Save()
iniFile.Set("Hacks", "EFBToTextureEnable", bCopyEFBToRAM);
iniFile.Set("Hacks", "ProjectionHack", iPhackvalue);
iniFile.Save(FULL_CONFIG_DIR "gfx_opengl.ini");
iniFile.Set("Hardware", "Adapter", iAdapter);
iniFile.Set("Hardware", "WindowedRes", iWindowedRes);
iniFile.Set("Hardware", "VSync", bVsync);
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Save(ini_file);
}
// TODO: Figure out a better place for this function.
void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc)
{
float FloatGLWidth = (float)backbuffer_width;
float FloatGLHeight = (float)backbuffer_height;
float FloatXOffset = 0;
float FloatYOffset = 0;
// The rendering window size
const float WinWidth = FloatGLWidth;
const float WinHeight = FloatGLHeight;
// Handle aspect ratio.
if (g_ActiveConfig.bKeepAR43 || g_ActiveConfig.bKeepAR169)
{
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
float Ratio = (WinWidth / WinHeight) / (g_Config.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
// Check if height or width is the limiting factor. If ratio > 1 the picture is to wide and have to limit the width.
if (Ratio > 1)
{
// Scale down and center in the X direction.
FloatGLWidth /= Ratio;
FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f;
}
// The window is too high, we have to limit the height
else
{
// Scale down and center in the Y direction.
FloatGLHeight *= Ratio;
FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f;
}
}
// -----------------------------------------------------------------------
// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
// Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
// ------------------
if ((g_ActiveConfig.bKeepAR43 || g_ActiveConfig.bKeepAR169) && g_ActiveConfig.bCrop)
{
float Ratio = g_Config.bKeepAR43 ? ((4.0f / 3.0f) / (5.0f / 4.0f)) : (((16.0f / 9.0f) / (16.0f / 10.0f)));
// The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
float IncreasedWidth = (Ratio - 1.0f) * FloatGLWidth;
float IncreasedHeight = (Ratio - 1.0f) * FloatGLHeight;
// The new width and height
FloatGLWidth = FloatGLWidth * Ratio;
FloatGLHeight = FloatGLHeight * Ratio;
// Adjust the X and Y offset
FloatXOffset = FloatXOffset - (IncreasedWidth * 0.5f);
FloatYOffset = FloatYOffset - (IncreasedHeight * 0.5f);
//NOTICE_LOG(OSREPORT, "Crop Ratio:%1.2f IncreasedHeight:%3.0f YOffset:%3.0f", Ratio, IncreasedHeight, FloatYOffset);
//NOTICE_LOG(OSREPORT, "Crop FloatGLWidth:%1.2f FloatGLHeight:%3.0f", (float)FloatGLWidth, (float)FloatGLHeight);
//NOTICE_LOG(OSREPORT, "");
}
// round(float) = floor(float + 0.5)
int XOffset = (int)(FloatXOffset + 0.5f);
int YOffset = (int)(FloatYOffset + 0.5f);
rc->left = XOffset;
rc->top = flip ? (int)(YOffset + ceil(FloatGLHeight)) : YOffset;
rc->right = XOffset + (int)ceil(FloatGLWidth);
rc->bottom = flip ? YOffset : (int)(YOffset + ceil(FloatGLHeight));
}

View File

@ -15,10 +15,18 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
// IMPORTANT: UI etc should modify g_Config. Graphics code should read g_ActiveConfig.
// The reason for this is to get rid of race conditions etc when the configuration
// changes in the middle of a frame. This is done by copying g_Config to g_ActiveConfig
// at the start of every frame. Noone should ever change members of g_ActiveConfig
// directly.
#ifndef _PLUGIN_VIDEOOGL_CONFIG_H_
#define _PLUGIN_VIDEOOGL_CONFIG_H_
#include "Common.h"
#include "VideoCommon.h"
#include <string>
@ -40,13 +48,15 @@ enum MultisampleMode {
MULTISAMPLE_CSAA_16XQ,
};
class IniFile;
// NEVER inherit from this class.
struct Config
{
Config();
void Load();
void GameIniLoad();
void Save();
void Load(const char *ini_file);
void GameIniLoad(IniFile *iniFile);
void Save(const char *ini_file);
void UpdateProjectionHack();
// General
@ -56,8 +66,8 @@ struct Config
bool bVSync;
// Resolution control
char iFSResolution[16];
char iInternalRes[16];
char cFSResolution[16];
char cInternalRes[16];
bool bNativeResolution, b2xResolution, bRunning; // Should possibly be augmented with 2x, 4x native.
bool bWidescreenHack;
@ -111,10 +121,23 @@ struct Config
int iCompileDLsLevel;
bool bShowShaderErrors;
private:
DISALLOW_COPY_AND_ASSIGN(Config);
// D3D only config, mostly to be merged into the above
int iAdapter;
int iWindowedRes;
int iFSResolution;
bool bVsync;
// Runtime detection config
bool bOldCard;
};
extern Config g_Config;
extern Config g_ActiveConfig;
// Called every frame.
void UpdateActiveConfig();
void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc);
#endif // _PLUGIN_VIDEOOGL_CONFIG_H_

View File

@ -23,6 +23,7 @@
void SetPSConstant4f(int const_number, float f1, float f2, float f3, float f4);
void SetPSConstant4fv(int const_number, const float *f);
void SetMultiPSConstant4fv(int const_number, int count, const float *f);
// The non-API dependent parts.
class PixelShaderManager

View File

@ -3,6 +3,7 @@
Import('env')
files = [
'Config.cpp',
'GlobalControl.cpp',
'BPMemory.cpp',
'CPMemory.cpp',

View File

@ -43,7 +43,7 @@ void Statistics::SwapDL()
Xchg(stats.thisFrame.numBPLoadsInDL, stats.thisFrame.numBPLoads);
}
void Statistics::ToString(char *ptr)
char *Statistics::ToString(char *ptr)
{
char *p = ptr;
p+=sprintf(p,"textures created: %i\n",stats.numTexturesCreated);
@ -72,10 +72,11 @@ void Statistics::ToString(char *ptr)
VertexLoaderManager::AppendListToString(&text1);
// TODO: Check for buffer overflow
p+=sprintf(p,"%s",text1.c_str());
return p;
}
// Is this really needed?
void Statistics::ToStringProj(char *ptr) {
char *Statistics::ToStringProj(char *ptr) {
char *p = ptr;
p+=sprintf(p,"Projection #: X for Raw 6=0 (X for Raw 6!=0)\n\n");
p+=sprintf(p,"Projection 0: %f (%f) Raw 0: %f\n", stats.gproj_0, stats.g2proj_0, stats.proj_0);
@ -94,4 +95,5 @@ void Statistics::ToStringProj(char *ptr) {
p+=sprintf(p,"Projection 13: %f (%f)\n", stats.gproj_13, stats.g2proj_13);
p+=sprintf(p,"Projection 14: %f (%f)\n", stats.gproj_14, stats.g2proj_14);
p+=sprintf(p,"Projection 15: %f (%f)\n", stats.gproj_15, stats.g2proj_15);
return p;
}

View File

@ -78,8 +78,8 @@ struct Statistics
// Yeah, this is unsafe, but we really don't wanna faff around allocating
// buffers here.
static void ToString(char *ptr);
static void ToStringProj(char *ptr);
static char *ToString(char *ptr);
static char *ToStringProj(char *ptr);
};
extern Statistics stats;

View File

@ -121,7 +121,15 @@ struct EFBRectangle : public MathUtil::Rectangle<int>
// depend on the resolution settings. Use Renderer::ConvertEFBRectangle to
// convert an EFBRectangle to a TargetRectangle.
struct TargetRectangle : public MathUtil::Rectangle<int>
{};
{
#ifdef _WIN32
// Only used by D3D plugin.
const RECT *AsRECT() {
// The types are binary compatible so this works.
return (const RECT *)this;
}
#endif
};
#ifdef _WIN32
#define PRIM_LOG(...) {DEBUG_LOG(VIDEO, __VA_ARGS__)}

View File

@ -689,6 +689,14 @@
>
</File>
</Filter>
<File
RelativePath=".\Src\Config.cpp"
>
</File>
<File
RelativePath=".\Src\Config.h"
>
</File>
<File
RelativePath=".\Src\GlobalControl.cpp"
>

View File

@ -1291,14 +1291,6 @@
>
</File>
</Filter>
<File
RelativePath=".\Src\Config.cpp"
>
</File>
<File
RelativePath=".\Src\Config.h"
>
</File>
<File
RelativePath=".\Src\Globals.h"
>

View File

@ -207,9 +207,9 @@ void SetColorMask(const BPCmd &bp)
void CopyEFB(const BPCmd &bp, const EFBRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 &copyfmt, const int &scaleByHalf)
{
if (!g_Config.bEFBCopyDisable)
if (!g_ActiveConfig.bEFBCopyDisable)
{
//if (g_Config.bCopyEFBToRAM)
//if (g_ActiveConfig.bCopyEFBToRAM)
// To RAM, not implemented yet
//TextureConverter::EncodeToRam(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
//else // To D3D Texture
@ -286,12 +286,12 @@ u8 *GetPointer(const u32 &address)
void SetSamplerState(const BPCmd &bp)
{
FourTexUnits &tex = bpmem.tex[(bp.address & 0xE0) == 0xA0];
const FourTexUnits &tex = bpmem.tex[(bp.address & 0xE0) == 0xA0];
int stage = (bp.address & 3);//(addr>>4)&2;
TexMode0 &tm0 = tex.texMode0[stage];
const TexMode0 &tm0 = tex.texMode0[stage];
D3DTEXTUREFILTERTYPE min, mag, mip;
if (g_Config.bForceFiltering)
if (g_ActiveConfig.bForceFiltering)
{
min = mag = mip = D3DTEXF_LINEAR;
}
@ -304,7 +304,7 @@ void SetSamplerState(const BPCmd &bp)
if ((bp.address & 0xE0) == 0xA0)
stage += 4;
if (g_Config.bForceMaxAniso)
if (g_ActiveConfig.iMaxAnisotropy > 1)
{
mag = D3DTEXF_ANISOTROPIC;
min = D3DTEXF_ANISOTROPIC;
@ -314,7 +314,7 @@ void SetSamplerState(const BPCmd &bp)
dev->SetSamplerState(stage, D3DSAMP_MAGFILTER, mag);
dev->SetSamplerState(stage, D3DSAMP_MIPFILTER, mip);
dev->SetSamplerState(stage, D3DSAMP_MAXANISOTROPY, 16);
dev->SetSamplerState(stage, D3DSAMP_MAXANISOTROPY, g_ActiveConfig.iMaxAnisotropy);
dev->SetSamplerState(stage, D3DSAMP_ADDRESSU, d3dClamps[tm0.wrap_s]);
dev->SetSamplerState(stage, D3DSAMP_ADDRESSV, d3dClamps[tm0.wrap_t]);
//wip
@ -323,8 +323,10 @@ void SetSamplerState(const BPCmd &bp)
//sprintf(temp,"lod %f",tm0.lod_bias/4.0f);
//g_VideoInitialize.pLog(temp);
}
void SetInterlacingMode(const BPCmd &bp)
{
// TODO
}
};

View File

@ -1,123 +0,0 @@
// Copyright (C) 2003 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/
#include "Config.h"
#include "IniFile.h"
#include "globals.h"
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
Config g_Config;
Config::Config()
{
}
void Config::Load()
{
IniFile iniFile;
iniFile.Load(FULL_CONFIG_DIR "gfx_dx9.ini");
iniFile.Get("Hardware", "Adapter", &iAdapter, 0);
iniFile.Get("Hardware", "WindowedRes", &iWindowedRes, 0);
iniFile.Get("Hardware", "FullscreenRes", &iFSResolution, 0);
iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0);
iniFile.Get("Hardware", "RenderInMainframe", &renderToMainframe, false);
iniFile.Get("Hardware", "VSync", &bVsync, 0);
if (iAdapter == -1)
iAdapter = 0;
iniFile.Get("Settings", "OverlayStats", &bOverlayStats, false);
iniFile.Get("Settings", "OverlayProjection", &bOverlayProjStats, false);
iniFile.Get("Settings", "Postprocess", &iPostprocessEffect, 0);
iniFile.Get("Settings", "DumpTextures", &bDumpTextures, 0);
iniFile.Get("Settings", "DumpFrames", &bDumpFrames, 0);
iniFile.Get("Settings", "ShowShaderErrors", &bShowShaderErrors, 0);
iniFile.Get("Settings", "Multisample", &iMultisampleMode, 0);
iniFile.Get("Settings", "TexDumpPath", &texDumpPath, 0);
iniFile.Get("Settings", "TexFmtOverlayEnable", &bTexFmtOverlayEnable, 0);
iniFile.Get("Settings", "TexFmtOverlayCenter", &bTexFmtOverlayCenter, 0);
iniFile.Get("Enhancements", "ForceFiltering", &bForceFiltering, 0);
iniFile.Get("Enhancements", "ForceMaxAniso", &bForceMaxAniso, 0);
}
void Config::Save()
{
IniFile iniFile;
iniFile.Load(FULL_CONFIG_DIR "gfx_dx9.ini");
iniFile.Set("Hardware", "Adapter", iAdapter);
iniFile.Set("Hardware", "WindowedRes", iWindowedRes);
iniFile.Set("Hardware", "FullscreenRes", iFSResolution);
iniFile.Set("Hardware", "Fullscreen", bFullscreen);
iniFile.Set("Hardware", "VSync", bVsync);
iniFile.Set("Hardware", "RenderInMainframe", renderToMainframe);
iniFile.Set("Settings", "OverlayStats", bOverlayStats);
iniFile.Set("Settings", "OverlayProjection", bOverlayProjStats);
iniFile.Set("Settings", "Postprocess", iPostprocessEffect);
iniFile.Set("Settings", "DumpTextures", bDumpTextures);
iniFile.Set("Settings", "DumpFrames", bDumpFrames);
iniFile.Set("Settings", "ShowShaderErrors", bShowShaderErrors);
iniFile.Set("Settings", "Multisample", iMultisampleMode);
iniFile.Set("Settings", "TexDumpPath", texDumpPath);
iniFile.Set("Settings", "TexFmtOverlayEnable", bTexFmtOverlayEnable);
iniFile.Set("Settings", "TexFmtOverlayCenter", bTexFmtOverlayCenter);
iniFile.Set("Enhancements", "ForceFiltering", bForceFiltering);
iniFile.Set("Enhancements", "ForceMaxAniso", bForceMaxAniso);
iniFile.Save(FULL_CONFIG_DIR "gfx_dx9.ini");
}
void Config::GameIniLoad()
{
// This function is copied from OGL plugin, slightly modified.
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
if (! iniFile)
return;
if (iniFile->Exists("Video", "ForceFiltering"))
iniFile->Get("Video", "ForceFiltering", &bForceFiltering, 0);
//if (iniFile->Exists("Video", "MaxAnisotropy"))
// iniFile->Get("Video", "MaxAnisotropy", &iMaxAnisotropy, 3); // NOTE - this is x in (1 << x)
if (iniFile->Exists("Video", "EFBCopyDisable"))
iniFile->Get("Video", "EFBCopyDisable", &bEFBCopyDisable, 0);
//if (iniFile->Exists("Video", "EFBCopyDisableHotKey"))
// iniFile->Get("Video", "EFBCopyDisableHotKey", &bEFBCopyDisableHotKey, 0);
if (iniFile->Exists("Video", "EFBToRAMEnable"))
iniFile->Get("Video", "EFBToRAMEnable", &bCopyEFBToRAM, 0);
if (iniFile->Exists("Video", "SafeTextureCache"))
iniFile->Get("Video", "SafeTextureCache", &bSafeTextureCache, bSafeTextureCache);
//if (iniFile->Exists("Video", "MSAA"))
// iniFile->Get("Video", "MSAA", &iMultisampleMode, 0);
if (iniFile->Exists("Video", "DstAlphaPass"))
iniFile->Get("Video", "DstAlphaPass", &bDstAlphaPass, bDstAlphaPass);
if (iniFile->Exists("Video", "UseXFB"))
iniFile->Get("Video", "UseXFB", &bUseXFB, 0);
if (iniFile->Exists("Video", "ProjectionHack"))
iniFile->Get("Video", "ProjectionHack", &iPhackvalue, 0);
}

View File

@ -1,77 +0,0 @@
// Copyright (C) 2003 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 _GLOBALS_H
#define _GLOBALS_H
#include <string>
struct Config
{
Config();
void Load();
void Save();
void GameIniLoad();
int iAdapter;
int iFSResolution;
int iMultisampleMode;
int iPostprocessEffect;
bool renderToMainframe;
bool bFullscreen;
bool bVsync;
bool bWireFrame;
bool bOverlayStats;
bool bOverlayProjStats;
bool bDumpTextures;
bool bDumpFrames;
bool bOldCard;
bool bShowShaderErrors;
//enhancements
bool bForceFiltering;
bool bForceMaxAniso;
bool bPreUpscale;
int iPreUpscaleFilter;
bool bTruform;
int iTruformLevel;
int iWindowedRes;
char psProfile[16];
char vsProfile[16];
bool bTexFmtOverlayEnable;
bool bTexFmtOverlayCenter;
// from game INI file, import from OGL plugin
bool bSafeTextureCache;
bool bEFBCopyDisable;
bool bCopyEFBToRAM;
bool bDstAlphaPass;
bool bUseXFB;
int iPhackvalue;
std::string texDumpPath;
};
extern Config g_Config;
#endif

View File

@ -19,81 +19,74 @@
#include "Render.h"
#include "XFStructs.h"
namespace D3D
{
bool fullScreen = false;
bool nextFullScreen = false;
LPDIRECT3D9 D3D = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 dev = NULL; // Our rendering device
LPDIRECT3DSURFACE9 backBuffer;
D3DCAPS9 caps;
int multisample;
int resolution;
const int MaxTextureStages = 9;
const int MaxRenderStates = 210;
const DWORD MaxTextureTypes = 33;
const DWORD MaxSamplerSize = 13;
const DWORD MaxSamplerTypes = 15;
static DWORD m_RenderStates[MaxRenderStates+46];
static DWORD m_TextureStageStates[MaxTextureStages][MaxTextureTypes];
static DWORD m_SamplerStates[MaxSamplerSize][MaxSamplerTypes];
LPDIRECT3DBASETEXTURE9 m_Textures[16];
LPDIRECT3D9 D3D = NULL; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 dev = NULL; // Our rendering device
LPDIRECT3DSURFACE9 backBuffer;
D3DCAPS9 caps;
HWND hWnd;
static bool fullScreen = false;
static bool nextFullScreen = false;
static int multisample;
static int resolution;
static int xres, yres;
#define VENDOR_NVIDIA 4318
#define VENDOR_ATI 4098
RECT client;
HWND hWnd;
int xres, yres;
int cur_adapter;
Shader Ps;
Shader Vs;
static bool bFrameInProgress = false;
bool bFrameInProgress = false;
#define MAX_ADAPTERS 4
static Adapter adapters[MAX_ADAPTERS];
static int numAdapters;
static int cur_adapter;
//enum shit
Adapter adapters[4];
int numAdapters;
// Value caches for state filtering
const int MaxTextureStages = 9;
const int MaxRenderStates = 210;
const DWORD MaxTextureTypes = 33;
const DWORD MaxSamplerSize = 13;
const DWORD MaxSamplerTypes = 15;
static DWORD m_RenderStates[MaxRenderStates+46];
static DWORD m_TextureStageStates[MaxTextureStages][MaxTextureTypes];
static DWORD m_SamplerStates[MaxSamplerSize][MaxSamplerTypes];
LPDIRECT3DBASETEXTURE9 m_Textures[16];
void Enumerate();
void Enumerate();
int GetNumAdapters()
{
return numAdapters;
}
int GetNumAdapters() { return numAdapters; }
const Adapter &GetAdapter(int i) { return adapters[i]; }
const Adapter &GetCurAdapter() { return adapters[cur_adapter]; }
const Adapter &GetAdapter(int i)
{
return adapters[i];
}
HRESULT Init()
{
// Create the D3D object, which is needed to create the D3DDevice.
D3D = Direct3DCreate9(D3D_SDK_VERSION);
if (!D3D)
return E_FAIL;
Enumerate();
return S_OK;
}
const Adapter &GetCurAdapter()
{
return adapters[cur_adapter];
}
void Shutdown()
{
D3D->Release();
D3D = 0;
}
HRESULT Init()
{
// Create the D3D object, which is needed to create the D3DDevice.
if( NULL == ( D3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
return E_FAIL;
void EnableAlphaToCoverage()
{
// Each vendor has their own specific little hack.
if (GetCurAdapter().ident.VendorId == VENDOR_ATI)
D3D::SetRenderState(D3DRS_POINTSIZE, (D3DFORMAT)MAKEFOURCC('A', '2', 'M', '1'));
else
D3D::SetRenderState(D3DRS_ADAPTIVETESS_Y, (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C'));
}
Enumerate();
return S_OK;
}
void EnableAlphaToCoverage()
{
if (GetCurAdapter().ident.VendorId == VENDOR_ATI)
D3D::SetRenderState(D3DRS_POINTSIZE, (D3DFORMAT)MAKEFOURCC('A', '2', 'M', '1'));
else
D3D::SetRenderState(D3DRS_ADAPTIVETESS_Y, (D3DFORMAT)MAKEFOURCC('A', 'T', 'O', 'C'));
}
void InitPP(int adapter, int resolution, int aa_mode, D3DPRESENT_PARAMETERS *pp)
void InitPP(int adapter, int f, int aa_mode, D3DPRESENT_PARAMETERS *pp)
{
int FSResX = adapters[adapter].resolutions[resolution].xres;
int FSResY = adapters[adapter].resolutions[resolution].yres;
@ -119,6 +112,7 @@ namespace D3D
}
else
{
RECT client;
GetClientRect(hWnd, &client);
xres = pp->BackBufferWidth = client.right - client.left;
yres = pp->BackBufferHeight = client.bottom - client.top;
@ -131,12 +125,10 @@ namespace D3D
void Enumerate()
{
numAdapters = D3D::D3D->GetAdapterCount();
for (int i=0; i<numAdapters; i++)
for (int i = 0; i < std::min(MAX_ADAPTERS, numAdapters); i++)
{
Adapter &a = adapters[i];
D3D::D3D->GetAdapterIdentifier(i, 0, &a.ident);
bool isNvidia = a.ident.VendorId == VENDOR_NVIDIA;
// Add multisample modes
@ -184,14 +176,11 @@ namespace D3D
}
}
}
if (a.aa_levels.size() == 1)
{
strcpy(a.aa_levels[0].name, "(Not supported on this device)");
}
int numModes = D3D::D3D->GetAdapterModeCount(i, D3DFMT_X8R8G8B8);
for (int m = 0; m < numModes; m++)
{
D3DDISPLAYMODE mode;
@ -234,26 +223,26 @@ namespace D3D
D3DPRESENT_PARAMETERS d3dpp;
InitPP(adapter, resolution, aa_mode, &d3dpp);
if( FAILED( D3D->CreateDevice(
if (FAILED(D3D->CreateDevice(
adapter,
D3DDEVTYPE_HAL,
wnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&d3dpp, &dev ) ) )
&d3dpp, &dev)))
{
MessageBoxA(wnd,
"Sorry, but it looks like your 3D accelerator is too old,\n"
"or doesn't support features that Dolphin requires.\n"
"Falling back to software vertex processing.\n",
"Dolphin Direct3D plugin", MB_OK | MB_ICONERROR);
if( FAILED( D3D->CreateDevice(
if (FAILED(D3D->CreateDevice(
adapter,
D3DDEVTYPE_HAL,
wnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED,
// |D3DCREATE_MULTITHREADED /* | D3DCREATE_PUREDEVICE*/,
//D3DCREATE_SOFTWARE_VERTEXPROCESSING ,
&d3dpp, &dev ) ) )
&d3dpp, &dev)))
{
MessageBoxA(wnd,
"Software VP failed too. Upgrade your graphics card.",
@ -264,75 +253,53 @@ namespace D3D
dev->GetDeviceCaps(&caps);
dev->GetRenderTarget(0, &backBuffer);
Ps.Major = (D3D::caps.PixelShaderVersion >> 8) & 0xFF;
Ps.Minor = (D3D::caps.PixelShaderVersion) & 0xFF;
Vs.Major = (D3D::caps.VertexShaderVersion >>8) & 0xFF;
Vs.Minor = (D3D::caps.VertexShaderVersion) & 0xFF;
if (caps.NumSimultaneousRTs < 2)
{
MessageBoxA(0, "Warning - your graphics card does not support multiple render targets.", 0, 0);
}
// Device state would normally be set here
return S_OK;
}
ShaderVersion GetShaderVersion()
{
if (Ps.Major < 2)
{
return PSNONE;
}
//good enough estimate - we really only
//care about zero shader vs ps20
return (ShaderVersion)Ps.Major;
}
void Close()
{
dev->Release();
dev = 0;
}
void Shutdown()
{
D3D->Release();
D3D = 0;
}
const D3DCAPS9 &GetCaps()
{
return caps;
}
const D3DCAPS9 &GetCaps()
{
return caps;
}
const char *VertexShaderVersionString()
{
static const char *versions[5] = {"ERROR", "vs_1_4", "vs_2_0", "vs_3_0", "vs_4_0"};
int version = ((D3D::caps.VertexShaderVersion >> 8) & 0xFF);
return versions[std::min(4, version)];
}
LPDIRECT3DSURFACE9 GetBackBufferSurface()
{
return backBuffer;
}
const char *PixelShaderVersionString()
{
static const char *versions[5] = {"ERROR", "ps_1_4", "ps_2_0", "ps_3_0", "ps_4_0"};
int version = ((D3D::caps.PixelShaderVersion >> 8) & 0xFF);
return versions[std::min(4, version)];
}
void ShowD3DError(HRESULT err)
LPDIRECT3DSURFACE9 GetBackBufferSurface()
{
return backBuffer;
}
void ShowD3DError(HRESULT err)
{
switch (err)
{
switch (err)
{
case D3DERR_DEVICELOST:
MessageBoxA(0, "Device Lost", "D3D ERROR", 0);
break;
case D3DERR_INVALIDCALL:
MessageBoxA(0, "Invalid Call", "D3D ERROR", 0);
break;
case D3DERR_DRIVERINTERNALERROR:
MessageBoxA(0, "Driver Internal Error", "D3D ERROR", 0);
break;
case D3DERR_OUTOFVIDEOMEMORY:
MessageBoxA(0, "Out of vid mem", "D3D ERROR", 0);
break;
default:
// MessageBoxA(0,"Other error or success","ERROR",0);
break;
}
case D3DERR_DEVICELOST: PanicAlert("Device Lost"); break;
case D3DERR_INVALIDCALL: PanicAlert("Invalid Call"); break;
case D3DERR_DRIVERINTERNALERROR: PanicAlert("Driver Internal Error"); break;
case D3DERR_OUTOFVIDEOMEMORY: PanicAlert("Out of vid mem"); break;
default:
// MessageBoxA(0,"Other error or success","ERROR",0);
break;
}
}
void Reset()
{
@ -350,7 +317,7 @@ namespace D3D
return fullScreen;
}
int GetDisplayWidth()
int GetDisplayWidth()
{
return xres;
}
@ -369,11 +336,10 @@ namespace D3D
{
if (bFrameInProgress)
{
PanicAlert("BeginFrame WTF");
return false;
}
bFrameInProgress = true;
if (dev)
{
if (clear)
@ -388,14 +354,16 @@ namespace D3D
void EndFrame()
{
if (!bFrameInProgress)
{
PanicAlert("EndFrame WTF");
return;
}
bFrameInProgress = false;
if (dev)
{
dev->EndScene();
dev->Present( NULL, NULL, NULL, NULL );
dev->Present(NULL, NULL, NULL, NULL);
}
if (fullScreen != nextFullScreen)

View File

@ -18,87 +18,75 @@
#ifndef _D3DBASE_H
#define _D3DBASE_H
#include <d3d9.h>
#include <vector>
#include <set>
#ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
#endif
#include <d3d9.h>
#include "Common.h"
namespace D3D
{
enum ShaderVersion
{
PSNONE = 0,
PS20 = 2,
PS30 = 3,
PS40 = 4,
};
HRESULT Init();
HRESULT Create(int adapter, HWND wnd, bool fullscreen, int resolution, int aa_mode);
void Close();
void Shutdown();
HRESULT Init();
HRESULT Create(int adapter, HWND wnd, bool fullscreen, int resolution, int aa_mode);
void Close();
void Shutdown();
void Reset();
bool BeginFrame(bool clear=true, u32 color=0, float z=1.0f);
void EndFrame();
void SwitchFullscreen(bool fullscreen);
bool IsFullscreen();
int GetDisplayWidth();
int GetDisplayHeight();
ShaderVersion GetShaderVersion();
LPDIRECT3DSURFACE9 GetBackBufferSurface();
const D3DCAPS9 &GetCaps();
void ShowD3DError(HRESULT err);
void EnableAlphaToCoverage();
// Direct access to the device.
extern IDirect3DDevice9 *dev;
extern IDirect3DDevice9 *dev;
void Reset();
bool BeginFrame(bool clear, u32 color, float z);
void EndFrame();
void SwitchFullscreen(bool fullscreen);
bool IsFullscreen();
int GetDisplayWidth();
int GetDisplayHeight();
LPDIRECT3DSURFACE9 GetBackBufferSurface();
const D3DCAPS9 &GetCaps();
const char *PixelShaderVersionString();
const char *VertexShaderVersionString();
void ShowD3DError(HRESULT err);
// The following are "filtered" versions of the corresponding D3Ddev-> functions.
void SetTexture(DWORD Stage, IDirect3DBaseTexture9 *pTexture);
void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
void SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
// The following are "filtered" versions of the corresponding D3Ddev-> functions.
void SetTexture(DWORD Stage, IDirect3DBaseTexture9 *pTexture);
void SetRenderState(D3DRENDERSTATETYPE State, DWORD Value);
void SetTextureStageState(DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value);
void SetSamplerState(DWORD Sampler, D3DSAMPLERSTATETYPE Type, DWORD Value);
struct Resolution
{
char name[32];
int xres;
int yres;
std::set<D3DFORMAT> bitdepths;
std::set<int> refreshes;
};
// Utility functions for vendor specific hacks. So far, just the one.
void EnableAlphaToCoverage();
struct AALevel
{
AALevel(const char *n, D3DMULTISAMPLE_TYPE m, int q) {strcpy(name, n); ms_setting=m; qual_setting=q;}
char name[32];
D3DMULTISAMPLE_TYPE ms_setting;
int qual_setting;
};
struct Resolution
{
char name[32];
int xres;
int yres;
std::set<D3DFORMAT> bitdepths;
std::set<int> refreshes;
};
struct Adapter
{
D3DADAPTER_IDENTIFIER9 ident;
std::vector<Resolution> resolutions;
std::vector<AALevel> aa_levels;
bool supports_alpha_to_coverage;
};
struct AALevel
{
AALevel(const char *n, D3DMULTISAMPLE_TYPE m, int q) {strcpy(name, n); ms_setting=m; qual_setting=q;}
char name[32];
D3DMULTISAMPLE_TYPE ms_setting;
int qual_setting;
};
struct Shader
{
int Minor;
int Major;
};
const Adapter &GetAdapter(int i);
const Adapter &GetCurAdapter();
int GetNumAdapters();
}
struct Adapter
{
D3DADAPTER_IDENTIFIER9 ident;
std::vector<Resolution> resolutions;
std::vector<AALevel> aa_levels;
bool supports_alpha_to_coverage;
};
const Adapter &GetAdapter(int i);
const Adapter &GetCurAdapter();
int GetNumAdapters();
} // namespace
#endif

View File

@ -23,9 +23,6 @@
namespace D3D
{
extern Shader Ps;
extern Shader Vs;
LPDIRECT3DVERTEXSHADER9 CompileVertexShader(const char *code, int len)
{
@ -33,15 +30,12 @@ LPDIRECT3DVERTEXSHADER9 CompileVertexShader(const char *code, int len)
LPD3DXBUFFER shaderBuffer = 0;
LPD3DXBUFFER errorBuffer = 0;
LPDIRECT3DVERTEXSHADER9 vShader = 0;
HRESULT hr;
static char *versions[5] = {"ERROR", "vs_1_4", "vs_2_0", "vs_3_0", "vs_4_0"};
hr = D3DXCompileShader(code, len, 0, 0, "main", versions[Vs.Major], 0, &shaderBuffer, &errorBuffer, 0);
HRESULT hr = D3DXCompileShader(code, len, 0, 0, "main", D3D::VertexShaderVersionString(),
0, &shaderBuffer, &errorBuffer, 0);
if (FAILED(hr))
{
//compilation error
if(g_Config.bShowShaderErrors) {
if (g_ActiveConfig.bShowShaderErrors) {
std::string hello = (char*)errorBuffer->GetBufferPointer();
hello += "\n\n";
hello += code;
@ -55,9 +49,9 @@ LPDIRECT3DVERTEXSHADER9 CompileVertexShader(const char *code, int len)
HRESULT hr = E_FAIL;
if (shaderBuffer)
hr = D3D::dev->CreateVertexShader((DWORD *)shaderBuffer->GetBufferPointer(), &vShader);
if ((FAILED(hr) || vShader == 0) && g_Config.bShowShaderErrors)
if ((FAILED(hr) || vShader == 0) && g_ActiveConfig.bShowShaderErrors)
{
MessageBoxA(0, code, (char*)errorBuffer->GetBufferPointer(),MB_ICONERROR);
MessageBoxA(0, code, (char*)errorBuffer->GetBufferPointer(), MB_ICONERROR);
}
}
@ -66,7 +60,6 @@ LPDIRECT3DVERTEXSHADER9 CompileVertexShader(const char *code, int len)
shaderBuffer->Release();
if (errorBuffer)
errorBuffer->Release();
return vShader;
}
@ -75,17 +68,16 @@ LPDIRECT3DPIXELSHADER9 CompilePixelShader(const char *code, int len)
LPD3DXBUFFER shaderBuffer = 0;
LPD3DXBUFFER errorBuffer = 0;
LPDIRECT3DPIXELSHADER9 pShader = 0;
static char *versions[5] = {"ERROR", "ps_1_4", "ps_2_0", "ps_3_0", "ps_4_0"};
HRESULT hr;
// For some reasons, i had this kind of errors : "Shader uses texture addressing operations
// Someone:
// For some reason, I had this kind of errors : "Shader uses texture addressing operations
// in a dependency chain that is too complex for the target shader model (ps_2_0) to handle."
hr = D3DXCompileShader(code, len, 0, 0, "main", versions[Ps.Major],
0, &shaderBuffer, &errorBuffer, 0);
HRESULT hr = D3DXCompileShader(code, len, 0, 0, "main", D3D::PixelShaderVersionString(),
0, &shaderBuffer, &errorBuffer, 0);
if (FAILED(hr))
{
if(g_Config.bShowShaderErrors) {
if (g_ActiveConfig.bShowShaderErrors) {
std::string hello = (char*)errorBuffer->GetBufferPointer();
hello += "\n\n";
hello += code;
@ -97,7 +89,7 @@ LPDIRECT3DPIXELSHADER9 CompilePixelShader(const char *code, int len)
{
//create it
HRESULT hr = D3D::dev->CreatePixelShader((DWORD *)shaderBuffer->GetBufferPointer(), &pShader);
if ((FAILED(hr) || pShader == 0) && g_Config.bShowShaderErrors)
if ((FAILED(hr) || pShader == 0) && g_ActiveConfig.bShowShaderErrors)
{
MessageBoxA(0, "damn", "error creating pixelshader", MB_ICONERROR);
}
@ -108,7 +100,6 @@ LPDIRECT3DPIXELSHADER9 CompilePixelShader(const char *code, int len)
shaderBuffer->Release();
if (errorBuffer)
errorBuffer->Release();
return pShader;
}

View File

@ -161,21 +161,22 @@ namespace D3D
int CD3DFont::Shutdown()
{
SAFE_RELEASE(m_pVB);
SAFE_RELEASE(m_pTexture);
m_pVB->Release();
m_pVB = NULL;
m_pTexture->Release();
m_pTexture = NULL;
return S_OK;
}
const int RS[6][2] =
{
{ D3DRS_ALPHABLENDENABLE, TRUE },
{ D3DRS_SRCBLEND, D3DBLEND_SRCALPHA },
{ D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA },
{ D3DRS_CULLMODE, D3DCULL_NONE },
{ D3DRS_ZENABLE, FALSE },
{ D3DRS_FOGENABLE, FALSE },
{D3DRS_ALPHABLENDENABLE, TRUE},
{D3DRS_SRCBLEND, D3DBLEND_SRCALPHA},
{D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA},
{D3DRS_CULLMODE, D3DCULL_NONE},
{D3DRS_ZENABLE, FALSE},
{D3DRS_FOGENABLE, FALSE},
};
const int TS[6][2] =
{
@ -250,8 +251,8 @@ namespace D3D
float vpWidth = 1;
float vpHeight = 1;
float sx = x*vpWidth-0.5f;
float sy = y*vpHeight-0.5f;
float sx = x*vpWidth-0.5f;
float sy = y*vpHeight-0.5f;
float fStartX = sx;
@ -267,12 +268,12 @@ namespace D3D
float mx=0;
float maxx=0;
while(*strText)
while (*strText)
{
char c = *strText++;
if (c == ('\n'))
mx=0;
mx = 0;
if (c < (' '))
continue;

View File

@ -19,7 +19,7 @@
#include "IniFile.h"
#include "Debugger.h"
#include "../Config.h"
#include "Config.h"
#include "../Globals.h"
#include "../D3DBase.h"

View File

@ -44,7 +44,7 @@ struct TabDirect3D : public W32Util::Tab
{
WCHAR tempwstr[2000];
for (int i=0; i<D3D::GetNumAdapters(); i++)
for (int i = 0; i < D3D::GetNumAdapters(); i++)
{
const D3D::Adapter &adapter = D3D::GetAdapter(i);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, adapter.ident.Description, -1, tempwstr, 2000);
@ -52,8 +52,7 @@ struct TabDirect3D : public W32Util::Tab
}
const D3D::Adapter &adapter = D3D::GetAdapter(g_Config.iAdapter);
ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_ADAPTER),g_Config.iAdapter);
ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_ADAPTER), g_Config.iAdapter);
for (int i = 0; i < (int)adapter.aa_levels.size(); i++)
{
@ -86,7 +85,7 @@ struct TabDirect3D : public W32Util::Tab
CheckDlgButton(hDlg, IDC_FULLSCREENENABLE, g_Config.bFullscreen ? TRUE : FALSE);
CheckDlgButton(hDlg, IDC_VSYNC, g_Config.bVsync ? TRUE : FALSE);
CheckDlgButton(hDlg, IDC_RENDER_TO_MAINWINDOW, g_Config.renderToMainframe ? TRUE : FALSE);
CheckDlgButton(hDlg, IDC_RENDER_TO_MAINWINDOW, g_Config.RenderToMainframe ? TRUE : FALSE);
}
void Command(HWND hDlg,WPARAM wParam)
@ -108,8 +107,8 @@ struct TabDirect3D : public W32Util::Tab
g_Config.iFSResolution = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_RESOLUTION));
g_Config.bFullscreen = Button_GetCheck(GetDlgItem(hDlg, IDC_FULLSCREENENABLE)) ? true : false;
g_Config.bVsync = Button_GetCheck(GetDlgItem(hDlg, IDC_VSYNC)) ? true : false;
g_Config.renderToMainframe = Button_GetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW)) ? true : false;
g_Config.Save();
g_Config.RenderToMainframe = Button_GetCheck(GetDlgItem(hDlg, IDC_RENDER_TO_MAINWINDOW)) ? true : false;
g_Config.Save(FULL_CONFIG_DIR "gfx_dx9.ini");
}
};
@ -171,6 +170,7 @@ struct TabAdvanced : public W32Util::Tab
//char temp[MAX_PATH];
//GetWindowText(GetDlgItem(hDlg,IDC_TEXDUMPPATH), temp, MAX_PATH); <-- Old method
//g_Config.texDumpPath = temp;
g_Config.Save(FULL_CONFIG_DIR "gfx_dx9.ini");
}
};
@ -179,7 +179,7 @@ struct TabEnhancements : public W32Util::Tab
void Init(HWND hDlg)
{
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEFILTERING),g_Config.bForceFiltering);
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEANISOTROPY),g_Config.bForceMaxAniso);
Button_SetCheck(GetDlgItem(hDlg,IDC_FORCEANISOTROPY),g_Config.iMaxAnisotropy > 1);
/*
Temporarily disabled the old postprocessing code since it wasn't working anyway.
New postprocessing code will come sooner or later, sharing shaders and framework with
@ -212,9 +212,9 @@ struct TabEnhancements : public W32Util::Tab
}
void Apply(HWND hDlg)
{
g_Config.bForceMaxAniso = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY)) ? true : false;
g_Config.bForceFiltering = Button_GetCheck(GetDlgItem(hDlg,IDC_FORCEFILTERING)) ? true : false;
g_Config.iPostprocessEffect = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_POSTPROCESSEFFECT));
g_Config.iMaxAnisotropy = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEANISOTROPY)) ? 8 : 1;
g_Config.bForceFiltering = Button_GetCheck(GetDlgItem(hDlg, IDC_FORCEFILTERING)) ? true : false;
g_Config.Save(FULL_CONFIG_DIR "gfx_dx9.ini");
}
};
@ -224,11 +224,11 @@ void DlgSettings_Show(HINSTANCE hInstance, HWND _hParent)
bool tfoe = g_Config.bTexFmtOverlayEnable;
bool tfoc = g_Config.bTexFmtOverlayCenter;
g_Config.Load();
g_Config.Load(FULL_CONFIG_DIR "gfx_dx9.ini");
W32Util::PropSheet sheet;
sheet.Add(new TabDirect3D,(LPCTSTR)IDD_SETTINGS,_T("Direct3D"));
sheet.Add(new TabEnhancements,(LPCTSTR)IDD_ENHANCEMENTS,_T("Enhancements"));
sheet.Add(new TabAdvanced,(LPCTSTR)IDD_ADVANCED,_T("Advanced"));
sheet.Add(new TabDirect3D, (LPCTSTR)IDD_SETTINGS,_T("Direct3D"));
sheet.Add(new TabEnhancements, (LPCTSTR)IDD_ENHANCEMENTS,_T("Enhancements"));
sheet.Add(new TabAdvanced, (LPCTSTR)IDD_ADVANCED,_T("Advanced"));
#ifdef DEBUGFAST
sheet.Show(hInstance,_hParent,_T("DX9 Graphics Plugin (DEBUGFAST)"));
@ -240,8 +240,6 @@ void DlgSettings_Show(HINSTANCE hInstance, HWND _hParent)
#endif
#endif
g_Config.Save();
if(( tfoe != g_Config.bTexFmtOverlayEnable) ||
((g_Config.bTexFmtOverlayEnable) && ( tfoc != g_Config.bTexFmtOverlayCenter)))
{

View File

@ -27,20 +27,22 @@ HWND GetParentWnd()
LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
{
HDC hdc;
PAINTSTRUCT ps;
switch( iMsg )
{
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}
return 0;
case WM_KEYDOWN:
switch( LOWORD( wParam ))
{
case VK_ESCAPE: // Pressing Esc switch FullScreen/Windowed
if (g_Config.bFullscreen)
if (g_ActiveConfig.bFullscreen)
{
DestroyWindow(hWnd);
PostQuitMessage(0);
@ -127,6 +129,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam )
case WM_SIZE:
// Reset the D3D Device here
// Also make damn sure that this is not called from inside rendering a frame :P
// Renderer::ReinitView();
break;
case WM_SYSCOMMAND:
@ -218,7 +221,6 @@ void Close()
UnregisterClass(m_szClassName, m_hInstance);
}
void SetSize(int width, int height)
{
RECT rc = {0, 0, width, height};
@ -233,4 +235,5 @@ void SetSize(int width, int height)
rc.bottom = rc.top + h;
::MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
}
}

View File

@ -136,7 +136,7 @@ bool PixelShaderCache::SetShader(bool dstAlpha)
return true;
}
if (g_Config.bShowShaderErrors)
if (g_ActiveConfig.bShowShaderErrors)
{
PanicAlert("Failed to compile Pixel Shader:\n\n%s", code);
}

View File

@ -42,34 +42,43 @@
#include "debugger/debugger.h"
static float m_targetWidth;
static float m_targetHeight;
static int s_targetWidth;
static int s_targetHeight;
static int s_backbuffer_width;
static int s_backbuffer_height;
static float xScale;
static float yScale;
static int m_recordWidth;
static int m_recordHeight;
static int s_recordWidth;
static int s_recordHeight;
static bool m_LastFrameDumped;
static bool m_AVIDumping;
static bool s_LastFrameDumped;
static bool s_AVIDumping;
#define NUMWNDRES 6
extern int g_Res[NUMWNDRES][2];
bool Renderer::Init()
{
EmuWindow::SetSize(g_Res[g_Config.iWindowedRes][0], g_Res[g_Config.iWindowedRes][1]);
UpdateActiveConfig();
EmuWindow::SetSize(g_Res[g_ActiveConfig.iWindowedRes][0], g_Res[g_ActiveConfig.iWindowedRes][1]);
D3D::Create(g_Config.iAdapter, EmuWindow::GetWnd(), g_Config.bFullscreen, g_Config.iFSResolution, g_Config.iMultisampleMode);
D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(), g_ActiveConfig.bFullscreen,
g_ActiveConfig.iFSResolution, g_ActiveConfig.iMultisampleMode);
m_targetWidth = (float)D3D::GetDisplayWidth();
m_targetHeight = (float)D3D::GetDisplayHeight();
s_targetWidth = D3D::GetDisplayWidth();
s_targetHeight = D3D::GetDisplayHeight();
xScale = m_targetWidth / (float)EFB_WIDTH;
yScale = m_targetHeight / (float)EFB_HEIGHT;
s_backbuffer_width = s_targetWidth;
s_backbuffer_height = s_targetHeight;
m_LastFrameDumped = false;
m_AVIDumping = false;
xScale = (float)s_targetWidth / (float)EFB_WIDTH;
yScale = (float)s_targetHeight / (float)EFB_HEIGHT;
s_LastFrameDumped = false;
s_AVIDumping = false;
// We're not using fixed function, except for some 2D.
// Let's just set the matrices to identity to be sure.
@ -82,7 +91,7 @@ bool Renderer::Init()
for (int i = 0; i < 8; i++)
D3D::dev->SetSamplerState(i, D3DSAMP_MAXANISOTROPY, 16);
D3D::BeginFrame(true, 0);
D3D::BeginFrame(true, 0, 1.0f);
VertexManager::BeginFrame();
return true;
}
@ -93,7 +102,7 @@ void Renderer::Shutdown()
D3D::EndFrame();
D3D::Close();
if (m_AVIDumping)
if (s_AVIDumping)
{
AVIDump::Stop();
}
@ -126,10 +135,10 @@ void dumpMatrix(D3DXMATRIX &mtx)
TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
{
TargetRectangle result;
result.left = (rc.left * m_targetWidth) / EFB_WIDTH;
result.top = (rc.top * m_targetHeight) / EFB_HEIGHT;
result.right = (rc.right * m_targetWidth) / EFB_WIDTH;
result.bottom = (rc.bottom * m_targetHeight) / EFB_HEIGHT;
result.left = (rc.left * s_targetWidth) / EFB_WIDTH;
result.top = (rc.top * s_targetHeight) / EFB_HEIGHT;
result.right = (rc.right * s_targetWidth) / EFB_WIDTH;
result.bottom = (rc.bottom * s_targetHeight) / EFB_HEIGHT;
return result;
}
@ -165,63 +174,63 @@ void Renderer::SwapBuffers()
}
// Frame dumping routine
if (g_Config.bDumpFrames) {
if (g_ActiveConfig.bDumpFrames) {
D3DDISPLAYMODE DisplayMode;
if (SUCCEEDED(D3D::dev->GetDisplayMode(0, &DisplayMode))) {
LPDIRECT3DSURFACE9 surf;
if (SUCCEEDED(D3D::dev->CreateOffscreenPlainSurface(DisplayMode.Width, DisplayMode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &surf, NULL))) {
if (!m_LastFrameDumped) {
if (!s_LastFrameDumped) {
RECT windowRect;
GetWindowRect(EmuWindow::GetWnd(), &windowRect);
m_recordWidth = windowRect.right - windowRect.left;
m_recordHeight = windowRect.bottom - windowRect.top;
m_AVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), m_recordWidth, m_recordHeight);
if (!m_AVIDumping) {
GetClientRect(EmuWindow::GetWnd(), &windowRect);
s_recordWidth = windowRect.right - windowRect.left;
s_recordHeight = windowRect.bottom - windowRect.top;
s_AVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
if (!s_AVIDumping) {
PanicAlert("Error dumping frames to AVI.");
} else {
char msg [255];
sprintf(msg, "Dumping Frames to \"%s/framedump0.avi\" (%dx%d RGB24)", FULL_FRAMES_DIR, m_recordWidth, m_recordHeight);
sprintf(msg, "Dumping Frames to \"%s/framedump0.avi\" (%dx%d RGB24)", FULL_FRAMES_DIR, s_recordWidth, s_recordHeight);
OSD::AddMessage(msg, 2000);
}
}
if (m_AVIDumping) {
if (s_AVIDumping) {
if (SUCCEEDED(D3D::dev->GetFrontBufferData(0, surf))) {
RECT windowRect;
GetWindowRect(EmuWindow::GetWnd(), &windowRect);
D3DLOCKED_RECT rect;
if (SUCCEEDED(surf->LockRect(&rect, &windowRect, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY))) {
char *data = (char *)malloc(3 * m_recordWidth * m_recordHeight);
formatBufferDump((const char *)rect.pBits, data, m_recordWidth, m_recordHeight, rect.Pitch);
char *data = (char *)malloc(3 * s_recordWidth * s_recordHeight);
formatBufferDump((const char *)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch);
AVIDump::AddFrame(data);
free(data);
surf->UnlockRect();
}
}
}
m_LastFrameDumped = true;
s_LastFrameDumped = true;
surf->Release();
}
}
}
else
{
if(m_LastFrameDumped && m_AVIDumping) {
if(s_LastFrameDumped && s_AVIDumping) {
AVIDump::Stop();
m_AVIDumping = false;
s_AVIDumping = false;
}
m_LastFrameDumped = false;
s_LastFrameDumped = false;
}
char st[8192];
// Finish up the current frame, print some stats
if (g_Config.bOverlayStats)
if (g_ActiveConfig.bOverlayStats)
{
Statistics::ToString(st);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
}
if (g_Config.bOverlayProjStats)
if (g_ActiveConfig.bOverlayProjStats)
{
Statistics::ToStringProj(st);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
@ -253,27 +262,44 @@ void Renderer::SwapBuffers()
VertexShaderCache::Cleanup();
TextureCache::Cleanup();
// Make any new configuration settings active.
UpdateActiveConfig();
/*
TODO: Resize backbuffer if window size has changed. This code crashes, debug it.
RECT rcWindow;
GetClientRect(EmuWindow::GetWnd(), &rcWindow);
if (rcWindow.right - rcWindow.left != s_backbuffer_width ||
rcWindow.bottom - rcWindow.top != s_backbuffer_height)
{
D3D::Reset();
s_backbuffer_width = D3D::GetDisplayWidth();
s_backbuffer_height = D3D::GetDisplayHeight();
}
*/
//Begin new frame
//Set default viewport and scissor, for the clear to work correctly
stats.ResetFrame();
D3DVIEWPORT9 vp;
vp.X = 0;
vp.Y = 0;
vp.Width = (DWORD)m_targetWidth;
vp.Height = (DWORD)m_targetHeight;
vp.Width = (DWORD)s_targetWidth;
vp.Height = (DWORD)s_targetHeight;
vp.MinZ = 0;
vp.MaxZ = 1.0f;
D3D::dev->SetViewport(&vp);
RECT rc;
rc.left = 0;
rc.top = 0;
rc.right = (LONG)m_targetWidth;
rc.bottom = (LONG)m_targetHeight;
rc.right = (LONG)s_targetWidth;
rc.bottom = (LONG)s_targetHeight;
D3D::dev->SetScissorRect(&rc);
D3D::dev->SetRenderState(D3DRS_SCISSORTESTENABLE, false);
// We probably shouldn't clear here.
D3D::dev->Clear(0, 0, D3DCLEAR_TARGET, 0x00000000, 0, 0);
// D3D::dev->Clear(0, 0, D3DCLEAR_TARGET, 0x00000000, 0, 0);
u32 clearColor = (bpmem.clearcolorAR << 16) | bpmem.clearcolorGB;
D3D::BeginFrame(false, clearColor, 1.0f);
@ -284,7 +310,7 @@ void Renderer::SwapBuffers()
VertexManager::BeginFrame();
if (g_Config.bOldCard)
if (g_ActiveConfig.bOldCard)
D3D::font.SetRenderStates(); //compatibility with low end cards
}
@ -302,26 +328,26 @@ bool Renderer::SetScissorRect()
rc.top = (int)(rc.top * yScale);
rc.right = (int)(rc.right * xScale);
rc.bottom = (int)(rc.bottom * yScale);
if (rc.right >= rc.left && rc.bottom >= rc.top) {
if (rc.right >= rc.left && rc.bottom >= rc.top)
{
D3D::dev->SetScissorRect(&rc);
return true;
}
else
{
WARN_LOG(VIDEO, "SCISSOR ERROR");
WARN_LOG(VIDEO, "Bad scissor rectangle: %i %i %i %i", rc.left, rc.top, rc.right, rc.bottom);
return false;
}
}
void Renderer::SetColorMask()
{
DWORD write = 0;
DWORD color_mask = 0;
if (bpmem.blendmode.alphaupdate)
write = D3DCOLORWRITEENABLE_ALPHA;
color_mask = D3DCOLORWRITEENABLE_ALPHA;
if (bpmem.blendmode.colorupdate)
write |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, write);
color_mask |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask);
}
u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
@ -338,7 +364,6 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
// TODO (FIX) : currently, AA path is broken/offset and doesn't return the correct pixel
switch (type)
{
case PEEK_Z:
{
// if (s_MSAASamples > 1)
@ -395,7 +420,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
// TODO: Implement. One way is to draw a tiny pixel-sized rectangle at
// the exact location. Note: EFB pokes are susceptible to Z-buffering
// and perhaps blending.
//WARN_LOG(VIDEOINTERFACE, "This is probably some kind of software rendering");
// WARN_LOG(VIDEOINTERFACE, "This is probably some kind of software rendering");
break;
}
@ -403,16 +428,14 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
return 0;
}
// mtx.m[0][3] = pMatrix[1]; // -0.5f/m_targetWidth; <-- fix d3d pixel center?
// mtx.m[1][3] = pMatrix[3]; // +0.5f/m_targetHeight; <-- fix d3d pixel center?
// mtx.m[0][3] = pMatrix[1]; // -0.5f/s_targetWidth; <-- fix d3d pixel center?
// mtx.m[1][3] = pMatrix[3]; // +0.5f/s_targetHeight; <-- fix d3d pixel center?
// Called from VertexShaderManager
void UpdateViewport()
{
int scissorXOff = bpmem.scissorOffset.x * 2;
int scissorYOff = bpmem.scissorOffset.y * 2;
// -------------------------------------
float MValueX = Renderer::GetTargetScaleX();
float MValueY = Renderer::GetTargetScaleY();

View File

@ -48,7 +48,8 @@ void TextureCache::TCacheEntry::Destroy(bool shutdown)
if (texture)
texture->Release();
texture = 0;
if (!isRenderTarget && !shutdown) {
if (!isRenderTarget && !shutdown)
{
u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr + hashoffset*4);
if (ptr && *ptr == hash)
*ptr = oldpixel;
@ -58,7 +59,7 @@ void TextureCache::TCacheEntry::Destroy(bool shutdown)
void TextureCache::Init()
{
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
TexDecoder_SetTexFmtOverlayOptions(g_Config.bTexFmtOverlayEnable, g_Config.bTexFmtOverlayCenter);
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
}
void TextureCache::Invalidate(bool shutdown)
@ -71,16 +72,14 @@ void TextureCache::Invalidate(bool shutdown)
void TextureCache::Shutdown()
{
Invalidate(true);
FreeMemoryPages(temp, TEMP_SIZE);
temp = NULL;
}
void TextureCache::Cleanup()
{
TexCache::iterator iter=textures.begin();
while(iter != textures.end())
TexCache::iterator iter = textures.begin();
while (iter != textures.end())
{
if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second.frameCount)
{
@ -138,14 +137,14 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
u32 tex_hash = 0;
u32 texID = address;
if (g_Config.bDumpTextures || g_Config.bSafeTextureCache)
if (g_ActiveConfig.bDumpTextures || g_ActiveConfig.bSafeTextureCache)
{
tex_hash = hash_value;
if ((format == GX_TF_C4) || (format == GX_TF_C8) || (format == GX_TF_C14X2))
{
u32 tlutHash = TexDecoder_GetTlutHash(&texMem[tlutaddr], (format == GX_TF_C4) ? 32 : 128);
tex_hash ^= tlutHash;
if (g_Config.bSafeTextureCache)
if (g_ActiveConfig.bSafeTextureCache)
texID ^= tlutHash;
}
}
@ -154,7 +153,6 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
if (iter != textures.end())
{
TCacheEntry &entry = iter->second;
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash)))
{
entry.frameCount = frameCount;
@ -163,7 +161,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
return &entry;
}
lastTexture[stage] = entry.texture;
D3D::SetTexture( stage, entry.texture );
D3D::SetTexture(stage, entry.texture);
return &entry;
}
else
@ -232,7 +230,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
entry.fmt = format;
entry.mode = bpmem.tex[stage > 3].texMode0[stage & 3];
if (g_Config.bDumpTextures)
if (g_ActiveConfig.bDumpTextures)
{ // dump texture to file
char szTemp[MAX_PATH];
@ -262,7 +260,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width,
SETSTAT(stats.numTexturesAlive, (int)textures.size());
//Set the texture!
D3D::SetTexture( stage, entry.texture );
D3D::SetTexture(stage, entry.texture);
lastTexture[stage] = entry.texture;

View File

@ -33,7 +33,7 @@
VertexShaderCache::VSCache VertexShaderCache::vshaders;
const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry;
static float lastVSconstants[C_FOGPARAMS+8][4];
static float GC_ALIGNED16(lastVSconstants[C_FOGPARAMS+8][4]);
void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4)
{
@ -162,7 +162,7 @@ bool VertexShaderCache::SetShader(u32 components)
return true;
}
if (g_Config.bShowShaderErrors)
if (g_ActiveConfig.bShowShaderErrors)
{
PanicAlert("Failed to compile Vertex Shader:\n\n%s", code);
}

View File

@ -25,7 +25,6 @@
#include "LogManager.h"
#include "GlobalControl.h"
#if defined(HAVE_WX) && HAVE_WX
#include "Debugger/Debugger.h"
GFXDebuggerDX9 *m_DebuggerFrame = NULL;
@ -54,6 +53,9 @@ GFXDebuggerDX9 *m_DebuggerFrame = NULL;
#include "VideoState.h"
#include "XFBConvert.h"
// Having to include this is TERRIBLY ugly. FIXME x100
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
#include "Utils.h"
HINSTANCE g_hInstance = NULL;
@ -174,14 +176,15 @@ void UpdateFPSDisplay(const char *text)
bool Init()
{
g_Config.Load();
g_Config.GameIniLoad();
g_Config.Load(FULL_CONFIG_DIR "gfx_dx9.ini");
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
g_Config.GameIniLoad(iniFile);
UpdateProjectionHack(g_Config.iPhackvalue); // DX9 projection hack could be disabled by commenting out this line
if (initCount == 0)
{
// create the window
if (!g_Config.renderToMainframe || g_VideoInitialize.pWindowHandle == NULL) // ignore parent for this plugin
if (!g_Config.RenderToMainframe || g_VideoInitialize.pWindowHandle == NULL) // ignore parent for this plugin
{
g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, _T("Loading - Please wait."));
}

View File

@ -75,9 +75,9 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
GROUPBOX "Texture &filtering",IDC_STATIC,7,7,193,50
CONTROL "Force &bi/trilinear (may cause very small glitches)",IDC_FORCEFILTERING,
CONTROL "Force &bi/trilinear (breaks video in several Wii games)",IDC_FORCEFILTERING,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,20,170,9
CONTROL "Force 16x &anisotropy filtering",IDC_FORCEANISOTROPY,
CONTROL "Enable 16x &anisotropy filtering",IDC_FORCEANISOTROPY,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,35,110,10
GROUPBOX "Texture &enhancements",IDC_STATIC,7,61,193,34
CONTROL "Pre-&upscale:",IDC_PREUPSCALE,"Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,16,76,54,10

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Version="9.00"
Name="Plugin_VideoOGL"
ProjectGUID="{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}"
RootNamespace="Plugin_VideoOGL"
@ -929,14 +929,6 @@
>
</File>
</Filter>
<File
RelativePath=".\Src\Config.cpp"
>
</File>
<File
RelativePath=".\Src\Config.h"
>
</File>
<File
RelativePath=".\Src\Globals.h"
>

View File

@ -119,9 +119,9 @@ void SetColorMask(const BPCmd &bp)
void CopyEFB(const BPCmd &bp, const EFBRectangle &rc, const u32 &address, const bool &fromZBuffer, const bool &isIntensityFmt, const u32 &copyfmt, const int &scaleByHalf)
{
// bpmem.zcontrol.pixel_format to PIXELFMT_Z24 is when the game wants to copy from ZBuffer (Zbuffer uses 24-bit Format)
if (!g_Config.bEFBCopyDisable)
if (!g_ActiveConfig.bEFBCopyDisable)
{
if (g_Config.bCopyEFBToRAM) // To RAM
if (g_ActiveConfig.bCopyEFBToRAM) // To RAM
TextureConverter::EncodeToRam(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
else // To OGL Texture
TextureMngr::CopyRenderTargetToTexture(address, fromZBuffer, isIntensityFmt, copyfmt, scaleByHalf, rc);
@ -160,9 +160,9 @@ bool GetConfig(const int &type)
case CONFIG_ISWII:
return g_VideoInitialize.bWii;
case CONFIG_DISABLEFOG:
return g_Config.bDisableFog;
return g_ActiveConfig.bDisableFog;
case CONFIG_SHOWEFBREGIONS:
return g_Config.bShowEFBCopyRegions;
return g_ActiveConfig.bShowEFBCopyRegions;
default:
PanicAlert("GetConfig Error: Unknown Config Type!");
return false;

View File

@ -19,7 +19,7 @@
#include "IniFile.h"
#include "Debugger.h"
#include "../Config.h"
#include "Config.h"
#include "../Globals.h"
extern int g_Preset;

View File

@ -188,7 +188,7 @@ void FramebufferManager::Shutdown()
void FramebufferManager::CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc)
{
if (g_Config.bUseXFB)
if (g_ActiveConfig.bUseXFB)
copyToRealXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
else
copyToVirtualXFB(xfbAddr, fbWidth, fbHeight, sourceRc);
@ -196,7 +196,7 @@ void FramebufferManager::CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const
const XFBSource* FramebufferManager::GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
{
if (g_Config.bUseXFB)
if (g_ActiveConfig.bUseXFB)
return getRealXFBSource(xfbAddr, fbWidth, fbHeight);
else
return getVirtualXFBSource(xfbAddr, fbWidth, fbHeight);

View File

@ -129,9 +129,9 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
int _twidth, _theight;
if (g_Config.bFullscreen)
{
if (strlen(g_Config.iFSResolution) > 1)
if (strlen(g_Config.cFSResolution) > 1)
{
sscanf(g_Config.iFSResolution, "%dx%d", &_twidth, &_theight);
sscanf(g_Config.cFSResolution, "%dx%d", &_twidth, &_theight);
}
else // No full screen reso set, fall back to default reso
{
@ -141,9 +141,9 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight
}
else // Going Windowed
{
if (strlen(g_Config.iInternalRes) > 1)
if (strlen(g_Config.cInternalRes) > 1)
{
sscanf(g_Config.iInternalRes, "%dx%d", &_twidth, &_theight);
sscanf(g_Config.cInternalRes, "%dx%d", &_twidth, &_theight);
}
else // No Window resolution set, fall back to default
{

View File

@ -24,7 +24,7 @@
#include "ConfigDlg.h"
#include "../Globals.h"
#include "../Config.h"
#include "Config.h"
#include "../TextureMngr.h"
#include "VertexShaderManager.h"
#include "../PostProcessing.h"
@ -89,9 +89,6 @@ END_EVENT_TABLE()
GFXConfigDialogOGL::GFXConfigDialogOGL(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
g_Config.Load();
g_Config.GameIniLoad();
g_Config.UpdateProjectionHack();
}
@ -188,9 +185,9 @@ void GFXConfigDialogOGL::CreateGUIControls()
wxStaticText *WM2Text = new wxStaticText(m_PageGeneral, ID_WM2TEXT, wxT("Window mode:"), wxDefaultPosition, wxDefaultSize , 0 );
wxStaticText *FMText = new wxStaticText(m_PageGeneral, ID_FMTEXT, wxT("Separate window:"), wxDefaultPosition, wxDefaultSize , 0 );
m_WindowResolutionCB = new wxComboBox(m_PageGeneral, ID_WINDOWRESOLUTIONCB, arrayStringFor_WindowResolutionCB[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_WindowResolutionCB, wxCB_READONLY, wxDefaultValidator);
m_WindowResolutionCB->SetValue(wxString::FromAscii(g_Config.iInternalRes));
m_WindowResolutionCB->SetValue(wxString::FromAscii(g_Config.cInternalRes));
m_WindowFSResolutionCB = new wxComboBox(m_PageGeneral, ID_WINDOWFSRESOLUTIONCB, arrayStringFor_FullscreenCB[0], wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenCB, wxCB_READONLY, wxDefaultValidator);
m_WindowFSResolutionCB->SetValue(wxString::FromAscii(g_Config.iFSResolution));
m_WindowFSResolutionCB->SetValue(wxString::FromAscii(g_Config.cFSResolution));
// Aspect ratio / positioning controls
wxStaticText *KeepARText = new wxStaticText(m_PageGeneral, wxID_ANY, wxT("Keep aspect ratio:"), wxDefaultPosition, wxDefaultSize, 0);
@ -285,7 +282,7 @@ void GFXConfigDialogOGL::CreateGUIControls()
m_MaxAnisotropyCB->Append(wxT("8x"));
m_MaxAnisotropyCB->Append(wxT("16x"));
m_MaxAnisotropyCB->SetSelection(g_Config.iMaxAnisotropy - 1);
m_ForceFiltering = new wxCheckBox(m_PageGeneral, ID_FORCEFILTERING, wxT("Force bi/trilinear filtering"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ForceFiltering = new wxCheckBox(m_PageGeneral, ID_FORCEFILTERING, wxT("Force bi/trilinear filter. (Breaks FMV in many Wii games)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator);
m_ForceFiltering->SetValue(g_Config.bForceFiltering);
wxStaticText *PostShaderText = new wxStaticText(m_PageGeneral, ID_POSTSHADERTEXT, wxT("Post-processing shader:"), wxDefaultPosition, wxDefaultSize, 0);
@ -633,10 +630,10 @@ void GFXConfigDialogOGL::GeneralSettingsChanged(wxCommandEvent& event)
break;
#endif
case ID_WINDOWRESOLUTIONCB:
strcpy(g_Config.iInternalRes, m_WindowResolutionCB->GetValue().mb_str() );
strcpy(g_Config.cInternalRes, m_WindowResolutionCB->GetValue().mb_str() );
break;
case ID_WINDOWFSRESOLUTIONCB:
strcpy(g_Config.iFSResolution, m_WindowFSResolutionCB->GetValue().mb_str() );
strcpy(g_Config.cFSResolution, m_WindowFSResolutionCB->GetValue().mb_str() );
break;
case ID_MAXANISOTROPY:
g_Config.iMaxAnisotropy = m_MaxAnisotropyCB->GetSelection() + 1;
@ -755,7 +752,7 @@ void GFXConfigDialogOGL::AdvancedSettingsChanged(wxCommandEvent& event)
void GFXConfigDialogOGL::CloseWindow()
{
// Save the config to INI
g_Config.Save();
g_Config.Save(FULL_CONFIG_DIR "gfx_opengl.ini");
EndModal(1);
}

View File

@ -263,7 +263,7 @@ void GLVertexFormat::EnableComponents(u32 components)
// tex
for (int i = 0; i < 8; ++i)
{
if (!g_Config.bDisableTexturing)
if (!g_ActiveConfig.bDisableTexturing)
{
if ((components & (VB_HAS_UV0 << i)) != (s_prevcomponents & (VB_HAS_UV0 << i)))
{
@ -283,7 +283,7 @@ void GLVertexFormat::EnableComponents(u32 components)
// Disable Lighting
// TODO - Is this a good spot for this code?
if (g_Config.bDisableLighting)
if (g_ActiveConfig.bDisableLighting)
{
for (int i = 0; i < xfregs.nNumChans; i++)
{

View File

@ -24,7 +24,7 @@
#include <wx/aboutdlg.h>
#include "../Globals.h"
#include "../Config.h"
#include "Config.h"
#include "main.h"
#include "Win32.h"
#include "OnScreenDisplay.h"
@ -269,21 +269,23 @@ void OnKeyDown(WPARAM wParam)
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch( iMsg )
switch (iMsg)
{
case WM_CREATE:
PostMessage(m_hParent, WM_USER, OPENGL_WM_USER_CREATE, (int)m_hParent);
break;
case WM_PAINT:
hdc = BeginPaint( hWnd, &ps );
EndPaint( hWnd, &ps );
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
}
return 0;
case WM_SYSKEYDOWN:
switch( LOWORD( wParam ))
switch (LOWORD(wParam))
{
case VK_RETURN:
// Pressing Alt+Enter switch FullScreen/Windowed
@ -298,7 +300,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_KEYDOWN:
// Don't process this as a child window to avoid double events
if (!g_Config.RenderToMainframe) OnKeyDown(wParam);
if (!g_Config.RenderToMainframe)
OnKeyDown(wParam);
break;
/* Post thes mouse events to the main window, it's nessesary becase in difference to the
@ -307,7 +310,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
PostMessage(GetParentWnd(), iMsg, wParam, lParam);
break;
break;
/* The reason we pick up the WM_MOUSEMOVE is to be able to change this option
during gameplay. The alternative is to load one of the cursors when the plugin
@ -335,7 +338,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
else
SetCursor(hCursorBlank);
}
if (wParam == OPENGL_WM_USER_KEYDOWN) OnKeyDown(lParam);
if (wParam == OPENGL_WM_USER_KEYDOWN)
OnKeyDown(lParam);
break;
// This is called when we close the window when we render to a separate window
@ -445,8 +449,8 @@ void ToggleFullscreen(HWND hParent)
g_Config.bFullscreen = false;
RECT rc = {0, 0, w_fs, h_fs};
if (strlen(g_Config.iInternalRes) > 1)
sscanf(g_Config.iInternalRes, "%dx%d", &w_fs, &h_fs);
if (strlen(g_Config.cInternalRes) > 1)
sscanf(g_Config.cInternalRes, "%dx%d", &w_fs, &h_fs);
// FullScreen -> Desktop
ChangeDisplaySettings(NULL, 0);
@ -456,8 +460,8 @@ void ToggleFullscreen(HWND hParent)
ShowCursor(TRUE);
// SetWindowPos to the center of the screen
int X = (rcdesktop.right-rcdesktop.left)/2 - (rc.right-rc.left)/2;
int Y = (rcdesktop.bottom-rcdesktop.top)/2 - (rc.bottom-rc.top)/2;
int X = (rcdesktop.right - rcdesktop.left)/2 - (rc.right - rc.left)/2;
int Y = (rcdesktop.bottom - rcdesktop.top)/2 - (rc.bottom - rc.top)/2;
// Note: we now use the same res for fullscreen and windowed, so we need to check if the window
// is not too big here
@ -478,8 +482,8 @@ void ToggleFullscreen(HWND hParent)
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
if (strlen(g_Config.iFSResolution) > 1)
sscanf(g_Config.iFSResolution, "%dx%d", &w_fs, &h_fs);
if (strlen(g_Config.cFSResolution) > 1)
sscanf(g_Config.cFSResolution, "%dx%d", &w_fs, &h_fs);
// Desktop -> FullScreen
dmScreenSettings.dmSize = sizeof(dmScreenSettings);

View File

@ -199,7 +199,7 @@ FRAGMENTSHADER* PixelShaderCache::GetShader(bool dstAlphaEnable)
dstAlphaEnable);
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS && code) {
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%s/ps_%04i.txt", FULL_DUMP_DIR, counter++);

View File

@ -45,11 +45,11 @@ void ReloadShader()
bool ApplyShader()
{
if (s_currentShader != "User/Shaders/" + g_Config.sPostProcessingShader + ".txt")
if (s_currentShader != "User/Shaders/" + g_ActiveConfig.sPostProcessingShader + ".txt")
{
// Set immediately to prevent endless recompiles on failure.
if (!g_Config.sPostProcessingShader.empty())
s_currentShader = "User/Shaders/" + g_Config.sPostProcessingShader + ".txt";
if (!g_ActiveConfig.sPostProcessingShader.empty())
s_currentShader = "User/Shaders/" + g_ActiveConfig.sPostProcessingShader + ".txt";
else
s_currentShader.clear();

View File

@ -176,10 +176,11 @@ void HandleCgError(CGcontext ctx, CGerror err, void* appdata)
// Init functions
bool Renderer::Init()
{
UpdateActiveConfig();
bool bSuccess = true;
s_blendMode = 0;
s_MSAACoverageSamples = 0;
switch (g_Config.iMultisampleMode)
switch (g_ActiveConfig.iMultisampleMode)
{
case MULTISAMPLE_OFF: s_MSAASamples = 1; break;
case MULTISAMPLE_2X: s_MSAASamples = 2; break;
@ -217,7 +218,7 @@ bool Renderer::Init()
(const char*)glGetString(GL_RENDERER),
(const char*)glGetString(GL_VERSION)).c_str(), 5000);
s_bFullscreen = g_Config.bFullscreen;
s_bFullscreen = g_ActiveConfig.bFullscreen;
glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &numvertexattribs);
if (numvertexattribs < 11) {
@ -258,12 +259,12 @@ bool Renderer::Init()
// TODO: FILL IN
#elif defined _WIN32
if (WGLEW_EXT_swap_control)
wglSwapIntervalEXT(g_Config.bVSync ? 1 : 0);
wglSwapIntervalEXT(g_ActiveConfig.bVSync ? 1 : 0);
else
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)Does your video card support OpenGL 2.x?");
#elif defined(HAVE_X11) && HAVE_X11
if (glXSwapIntervalSGI)
glXSwapIntervalSGI(g_Config.bVSync ? 1 : 0);
glXSwapIntervalSGI(g_ActiveConfig.bVSync ? 1 : 0);
else
ERROR_LOG(VIDEO, "no support for SwapInterval (framerate clamped to monitor refresh rate)");
#endif
@ -287,12 +288,12 @@ bool Renderer::Init()
// Decide frambuffer size
int W = (int)OpenGL_GetBackbufferWidth(), H = (int)OpenGL_GetBackbufferHeight();
if (g_Config.bNativeResolution)
if (g_ActiveConfig.bNativeResolution)
{
m_FrameBufferWidth = EFB_WIDTH;
m_FrameBufferHeight = EFB_HEIGHT;
}
else if (g_Config.b2xResolution)
else if (g_ActiveConfig.b2xResolution)
{
m_FrameBufferWidth = 2 * EFB_WIDTH;
m_FrameBufferHeight = 2 * EFB_HEIGHT;
@ -318,7 +319,7 @@ bool Renderer::Init()
m_CustomHeight = (int)OpenGL_GetBackbufferHeight();
// Because of the fixed framebuffer size we need to disable the resolution options while running
g_Config.bRunning = true;
g_ActiveConfig.bRunning = true;
if (GL_REPORT_ERROR() != GL_NO_ERROR)
bSuccess = false;
@ -401,12 +402,14 @@ bool Renderer::Init()
glClientActiveTexture(GL_TEXTURE0);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
UpdateActiveConfig();
return glGetError() == GL_NO_ERROR && bSuccess;
}
void Renderer::Shutdown(void)
{
g_Config.bRunning = false;
UpdateActiveConfig();
delete s_pfont;
s_pfont = 0;
@ -468,13 +471,13 @@ int Renderer::GetCustomHeight()
// Return the rendering target width and height
int Renderer::GetTargetWidth()
{
return (g_Config.bNativeResolution || g_Config.b2xResolution) ?
(g_Config.bNativeResolution ? EFB_WIDTH : EFB_WIDTH * 2) : m_CustomWidth;
return (g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution) ?
(g_ActiveConfig.bNativeResolution ? EFB_WIDTH : EFB_WIDTH * 2) : m_CustomWidth;
}
int Renderer::GetTargetHeight()
{
return (g_Config.bNativeResolution || g_Config.b2xResolution) ?
(g_Config.bNativeResolution ? EFB_HEIGHT : EFB_HEIGHT * 2) : m_CustomHeight;
return (g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution) ?
(g_ActiveConfig.bNativeResolution ? EFB_HEIGHT : EFB_HEIGHT * 2) : m_CustomHeight;
}
float Renderer::GetTargetScaleX()
{
@ -716,69 +719,6 @@ bool Renderer::SetScissorRect()
return false;
}
// Aspect ratio functions
static void ComputeBackbufferRectangle(TargetRectangle *rc)
{
float FloatGLWidth = (float)OpenGL_GetBackbufferWidth();
float FloatGLHeight = (float)OpenGL_GetBackbufferHeight();
float FloatXOffset = 0;
float FloatYOffset = 0;
// The rendering window size
const float WinWidth = FloatGLWidth;
const float WinHeight = FloatGLHeight;
// Handle aspect ratio.
if (g_Config.bKeepAR43 || g_Config.bKeepAR169)
{
// The rendering window aspect ratio as a proportion of the 4:3 or 16:9 ratio
float Ratio = (WinWidth / WinHeight) / (g_Config.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
// Check if height or width is the limiting factor. If ratio > 1 the picture is to wide and have to limit the width.
if (Ratio > 1)
{
// Scale down and center in the X direction.
FloatGLWidth /= Ratio;
FloatXOffset = (WinWidth - FloatGLWidth) / 2.0f;
}
// The window is too high, we have to limit the height
else
{
// Scale down and center in the Y direction.
FloatGLHeight *= Ratio;
FloatYOffset = FloatYOffset + (WinHeight - FloatGLHeight) / 2.0f;
}
}
// -----------------------------------------------------------------------
// Crop the picture from 4:3 to 5:4 or from 16:9 to 16:10.
// Output: FloatGLWidth, FloatGLHeight, FloatXOffset, FloatYOffset
// ------------------
if ((g_Config.bKeepAR43 || g_Config.bKeepAR169) && g_Config.bCrop)
{
float Ratio = g_Config.bKeepAR43 ? ((4.0 / 3.0) / (5.0 / 4.0)) : (((16.0 / 9.0) / (16.0 / 10.0)));
// The width and height we will add (calculate this before FloatGLWidth and FloatGLHeight is adjusted)
float IncreasedWidth = (Ratio - 1.0) * FloatGLWidth;
float IncreasedHeight = (Ratio - 1.0) * FloatGLHeight;
// The new width and height
FloatGLWidth = FloatGLWidth * Ratio;
FloatGLHeight = FloatGLHeight * Ratio;
// Adjust the X and Y offset
FloatXOffset = FloatXOffset - (IncreasedWidth / 2.0);
FloatYOffset = FloatYOffset - (IncreasedHeight / 2.0);
//NOTICE_LOG(OSREPORT, "Crop Ratio:%1.2f IncreasedHeight:%3.0f YOffset:%3.0f", Ratio, IncreasedHeight, FloatYOffset);
//NOTICE_LOG(OSREPORT, "Crop FloatGLWidth:%1.2f FloatGLHeight:%3.0f", (float)FloatGLWidth, (float)FloatGLHeight);
//NOTICE_LOG(OSREPORT, "");
}
// round(float) = floor(float + 0.5)
int XOffset = floor(FloatXOffset + 0.5);
int YOffset = floor(FloatYOffset + 0.5);
rc->left = XOffset;
rc->top = YOffset + ceil(FloatGLHeight);
rc->right = XOffset + ceil(FloatGLWidth);
rc->bottom = YOffset;
}
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
{
// Update the view port for clearing the picture
@ -823,7 +763,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
// XXX: Without the VI, how would we know what kind of field this is? So
// just use progressive.
if (!g_Config.bUseXFB)
if (!g_ActiveConfig.bUseXFB)
{
// TODO: Find better name for this because I don't know if it means what it says.
g_VideoInitialize.pCopiedToXFB(false);
@ -835,7 +775,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
// This function has the final picture. We adjust the aspect ratio here.
void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
{
if(s_skipSwap)
if (s_skipSwap)
return;
const XFBSource* xfbSource = g_framebufferManager.GetXFBSource(xfbAddr, fbWidth, fbHeight);
@ -851,11 +791,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
ResetAPIState();
TargetRectangle back_rc;
ComputeBackbufferRectangle(&back_rc);
ComputeDrawRectangle(OpenGL_GetBackbufferWidth(), OpenGL_GetBackbufferHeight(), true, &back_rc);
TargetRectangle sourceRc;
if (g_Config.bAutoScale || g_Config.bUseXFB)
if (g_ActiveConfig.bAutoScale || g_ActiveConfig.bUseXFB)
{
sourceRc = xfbSource->sourceRc;
}
@ -867,7 +807,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
sourceRc.bottom = 0;
}
int yOffset = (g_Config.bUseXFB && field == FIELD_LOWER) ? -1 : 0;
int yOffset = (g_ActiveConfig.bUseXFB && field == FIELD_LOWER) ? -1 : 0;
sourceRc.top -= yOffset;
sourceRc.bottom -= yOffset;
@ -929,7 +869,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
TextureMngr::DisableStage(0);
// Wireframe
if (g_Config.bWireFrame)
if (g_ActiveConfig.bWireFrame)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// Save screenshot
@ -955,7 +895,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
// Frame dumps are handled a little differently in Windows
#ifdef _WIN32
if (g_Config.bDumpFrames)
if (g_ActiveConfig.bDumpFrames)
{
if (!s_tempScreenshotFramebuffer)
glGenFramebuffersEXT(1, &s_tempScreenshotFramebuffer);
@ -1009,7 +949,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
s_bLastFrameDumped = false;
}
#else
if (g_Config.bDumpFrames) {
if (g_ActiveConfig.bDumpFrames) {
s_criticalScreenshot.Enter();
char movie_file_name[255];
int w = OpenGL_GetBackbufferWidth();
@ -1056,6 +996,8 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
GL_REPORT_ERRORD();
g_Config.iSaveTargetId = 0;
UpdateActiveConfig();
// For testing zbuffer targets.
// Renderer::SetZBufferRender();
// SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, GetTargetWidth(), GetTargetHeight());
@ -1152,10 +1094,10 @@ void Renderer::DrawDebugText()
char *p = debugtext_buffer;
p[0] = 0;
if (g_Config.bShowFPS)
if (g_ActiveConfig.bShowFPS)
p+=sprintf(p, "FPS: %d\n", s_fps);
if (g_Config.bShowEFBCopyRegions)
if (g_ActiveConfig.bShowEFBCopyRegions)
{
// Store Line Size
GLfloat lSize;
@ -1200,99 +1142,62 @@ void Renderer::DrawDebugText()
stats.efb_regions.clear();
}
if (g_Config.bOverlayStats)
if (g_ActiveConfig.bOverlayStats)
{
p+=sprintf(p,"textures created: %i\n",stats.numTexturesCreated);
p+=sprintf(p,"textures alive: %i\n",stats.numTexturesAlive);
p+=sprintf(p,"pshaders created: %i\n",stats.numPixelShadersCreated);
p+=sprintf(p,"pshaders alive: %i\n",stats.numPixelShadersAlive);
p+=sprintf(p,"vshaders created: %i\n",stats.numVertexShadersCreated);
p+=sprintf(p,"vshaders alive: %i\n",stats.numVertexShadersAlive);
p+=sprintf(p,"dlists called: %i\n",stats.numDListsCalled);
p+=sprintf(p,"dlists called(f): %i\n",stats.thisFrame.numDListsCalled);
p+=sprintf(p,"dlists alive: %i\n",stats.numDListsAlive);
// not used.
//p+=sprintf(p,"dlists created: %i\n",stats.numDListsCreated);
//p+=sprintf(p,"dlists alive: %i\n",stats.numDListsAlive);
//p+=sprintf(p,"strip joins: %i\n",stats.numJoins);
p+=sprintf(p,"primitives: %i\n",stats.thisFrame.numPrims);
p+=sprintf(p,"primitive joins: %i\n",stats.thisFrame.numPrimitiveJoins);
p+=sprintf(p,"buffer splits: %i\n",stats.thisFrame.numBufferSplits);
p+=sprintf(p,"primitives (DL): %i\n",stats.thisFrame.numDLPrims);
p+=sprintf(p,"XF loads: %i\n",stats.thisFrame.numXFLoads);
p+=sprintf(p,"XF loads (DL): %i\n",stats.thisFrame.numXFLoadsInDL);
p+=sprintf(p,"CP loads: %i\n",stats.thisFrame.numCPLoads);
p+=sprintf(p,"CP loads (DL): %i\n",stats.thisFrame.numCPLoadsInDL);
p+=sprintf(p,"BP loads: %i\n",stats.thisFrame.numBPLoads);
p+=sprintf(p,"BP loads (DL): %i\n",stats.thisFrame.numBPLoadsInDL);
p+=sprintf(p,"vertex loaders: %i\n",stats.numVertexLoaders);
p = Statistics::ToString(p);
}
if (g_Config.bOverlayProjStats)
if (g_ActiveConfig.bOverlayProjStats)
{
p+=sprintf(p,"Projection #: X for Raw 6=0 (X for Raw 6!=0)\n\n");
p+=sprintf(p,"Projection 0: %f (%f) Raw 0: %f\n", stats.gproj_0, stats.g2proj_0, stats.proj_0);
p+=sprintf(p,"Projection 1: %f (%f)\n", stats.gproj_1, stats.g2proj_1);
p+=sprintf(p,"Projection 2: %f (%f) Raw 1: %f\n", stats.gproj_2, stats.g2proj_2, stats.proj_1);
p+=sprintf(p,"Projection 3: %f (%f)\n\n", stats.gproj_3, stats.g2proj_3);
p+=sprintf(p,"Projection 4: %f (%f)\n", stats.gproj_4, stats.g2proj_4);
p+=sprintf(p,"Projection 5: %f (%f) Raw 2: %f\n", stats.gproj_5, stats.g2proj_5, stats.proj_2);
p+=sprintf(p,"Projection 6: %f (%f) Raw 3: %f\n", stats.gproj_6, stats.g2proj_6, stats.proj_3);
p+=sprintf(p,"Projection 7: %f (%f)\n\n", stats.gproj_7, stats.g2proj_7);
p+=sprintf(p,"Projection 8: %f (%f)\n", stats.gproj_8, stats.g2proj_8);
p+=sprintf(p,"Projection 9: %f (%f)\n", stats.gproj_9, stats.g2proj_9);
p+=sprintf(p,"Projection 10: %f (%f) Raw 4: %f\n\n", stats.gproj_10, stats.g2proj_10, stats.proj_4);
p+=sprintf(p,"Projection 11: %f (%f) Raw 5: %f\n\n", stats.gproj_11, stats.g2proj_11, stats.proj_5);
p+=sprintf(p,"Projection 12: %f (%f)\n", stats.gproj_12, stats.g2proj_12);
p+=sprintf(p,"Projection 13: %f (%f)\n", stats.gproj_13, stats.g2proj_13);
p+=sprintf(p,"Projection 14: %f (%f)\n", stats.gproj_14, stats.g2proj_14);
p+=sprintf(p,"Projection 15: %f (%f)\n", stats.gproj_15, stats.g2proj_15);
p = Statistics::ToStringProj(p);
}
// Render a shadow, and then the text.
Renderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
Renderer::RenderText(debugtext_buffer, 20, 20, 0xFF00FFFF);
if (p != debugtext_buffer)
{
Renderer::RenderText(debugtext_buffer, 21, 21, 0xDD000000);
Renderer::RenderText(debugtext_buffer, 20, 20, 0xFF00FFFF);
}
// OSD Menu messages
if (OSDChoice > 0 && g_Config.bEFBCopyDisableHotKey)
if (OSDChoice > 0 && g_ActiveConfig.bEFBCopyDisableHotKey)
{
OSDTime = timeGetTime() + 3000;
OSDChoice = -OSDChoice;
}
if ((u32)OSDTime > timeGetTime() && g_Config.bEFBCopyDisableHotKey)
if ((u32)OSDTime > timeGetTime() && g_ActiveConfig.bEFBCopyDisableHotKey)
{
std::string T1 = "", T2 = "";
std::vector<std::string> T0;
int W, H;
sscanf(g_Config.iInternalRes, "%dx%d", &W, &H);
sscanf(g_ActiveConfig.cInternalRes, "%dx%d", &W, &H);
std::string OSDM1 =
g_Config.bNativeResolution || g_Config.b2xResolution ?
(g_Config.bNativeResolution ?
g_ActiveConfig.bNativeResolution || g_ActiveConfig.b2xResolution ?
(g_ActiveConfig.bNativeResolution ?
StringFromFormat("%i x %i (native)", OSDInternalW, OSDInternalH)
: StringFromFormat("%i x %i (2x)", OSDInternalW, OSDInternalH))
: StringFromFormat("%i x %i (custom)", W, H);
std::string OSDM21 =
!(g_Config.bKeepAR43 || g_Config.bKeepAR169) ? "-": (g_Config.bKeepAR43 ? "4:3" : "16:9");
!(g_ActiveConfig.bKeepAR43 || g_ActiveConfig.bKeepAR169) ? "-": (g_ActiveConfig.bKeepAR43 ? "4:3" : "16:9");
std::string OSDM22 =
g_Config.bCrop ? " (crop)" : "";
g_ActiveConfig.bCrop ? " (crop)" : "";
std::string OSDM31 =
g_Config.bCopyEFBToRAM ? "RAM" : "Texture";
g_ActiveConfig.bCopyEFBToRAM ? "RAM" : "Texture";
std::string OSDM32 =
g_Config.bEFBCopyDisable ? "No" : "Yes";
g_ActiveConfig.bEFBCopyDisable ? "No" : "Yes";
// If there is more text than this we will have a collission
if (g_Config.bShowFPS)
if (g_ActiveConfig.bShowFPS)
{ T1 += "\n\n"; T2 += "\n\n"; }
// The rows
T0.push_back(StringFromFormat("3: Internal Resolution: %s\n", OSDM1.c_str()));
T0.push_back(StringFromFormat("4: Lock Aspect Ratio: %s%s\n", OSDM21.c_str(), OSDM22.c_str()));
T0.push_back(StringFromFormat("5: Copy Embedded Framebuffer to %s: %s\n", OSDM31.c_str(), OSDM32.c_str()));
T0.push_back(StringFromFormat("6: Fog: %s\n", g_Config.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_Config.bDisableLighting ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("6: Fog: %s\n", g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
// The latest changed setting in yellow
T1 += (OSDChoice == -1) ? T0.at(0) : "\n";
@ -1347,9 +1252,9 @@ THREAD_RETURN TakeScreenshot(void *pArgs)
float FloatH = (float)threadStruct->H;
// Handle aspect ratio for the final ScrStrct to look exactly like what's on screen.
if (g_Config.bKeepAR43 || g_Config.bKeepAR169)
if (g_ActiveConfig.bKeepAR43 || g_ActiveConfig.bKeepAR169)
{
float Ratio = (FloatW / FloatH) / (g_Config.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
float Ratio = (FloatW / FloatH) / (g_ActiveConfig.bKeepAR43 ? (4.0f / 3.0f) : (16.0f / 9.0f));
// If ratio > 1 the picture is too wide and we have to limit the width.
if (Ratio > 1)
@ -1438,30 +1343,11 @@ void Renderer::FlipImageData(u8 *data, int w, int h)
}
}
// This function does not have the final picture. Use Renderer::Swap() to adjust the final picture.
// Call schedule: Called from VertexShaderManager
// Called from VertexShaderManager
void UpdateViewport()
{
// ---------
// Logging
// ---------
// reversed gxsetviewport(xorig, yorig, width, height, nearz, farz)
// [0] = width/2
// [1] = height/2
// [2] = 16777215 * (farz - nearz)
// [3] = xorig + width/2 + 342
// [4] = yorig + height/2 + 342
// [5] = 16777215 * farz
/*INFO_LOG(VIDEO, "view: topleft=(%f,%f), wh=(%f,%f), z=(%f,%f)",
rawViewport[3]-rawViewport[0]-342, rawViewport[4]+rawViewport[1]-342,
2 * rawViewport[0], 2 * rawViewport[1],
(rawViewport[5] - rawViewport[2]) / 16777215.0f, rawViewport[5] / 16777215.0f);*/
// --------
int scissorXOff = bpmem.scissorOffset.x * 2; // 342
int scissorYOff = bpmem.scissorOffset.y * 2; // 342
// -------------------------------------
float MValueX = Renderer::GetTargetScaleX();
float MValueY = Renderer::GetTargetScaleY();
@ -1477,30 +1363,4 @@ void UpdateViewport()
// Update the view port
glViewport(GLx, GLy, GLWidth, GLHeight);
glDepthRange(GLNear, GLFar);
// -------------------------------------
// Logging
/*
RECT RcTop, RcParent, RcChild;
HWND Child = EmuWindow::GetWnd();
HWND Parent = GetParent(Child);
HWND Top = GetParent(Parent);
GetWindowRect(Top, &RcTop);
GetWindowRect(Parent, &RcParent);
GetWindowRect(Child, &RcChild);
//Console::ClearScreen();
DEBUG_LOG(CONSOLE, "----------------------------------------------------------------");
DEBUG_LOG(CONSOLE, "Top window: X:%03i Y:%03i Width:%03i Height:%03i", RcTop.left, RcTop.top, RcTop.right - RcTop.left, RcTop.bottom - RcTop.top);
DEBUG_LOG(CONSOLE, "Parent window: X:%03i Y:%03i Width:%03i Height:%03i", RcParent.left, RcParent.top, RcParent.right - RcParent.left, RcParent.bottom - RcParent.top);
DEBUG_LOG(CONSOLE, "Child window: X:%03i Y:%03i Width:%03i Height:%03i", RcChild.left, RcChild.top, RcChild.right - RcChild.left, RcChild.bottom - RcChild.top);
DEBUG_LOG(CONSOLE, "----------------------------------------------------------------");
DEBUG_LOG(CONSOLE, "Res. MValue: X:%f Y:%f XOffs:%f YOffs:%f", OpenGL_GetXmax(), OpenGL_GetYmax(), OpenGL_GetXoff(), OpenGL_GetYoff());
DEBUG_LOG(CONSOLE, "GLViewPort: X:%03i Y:%03i Width:%03i Height:%03i", GLx, GLy, GLWidth, GLHeight);
DEBUG_LOG(CONSOLE, "GLDepthRange: Near:%f Far:%f", GLNear, GLFar);
DEBUG_LOG(CONSOLE, "GLScissor: X:%03i Y:%03i Width:%03i Height:%03i", GLScissorX, GLScissorY, GLScissorW, GLScissorH);
DEBUG_LOG(CONSOLE, "----------------------------------------------------------------");
*/
}

View File

@ -11,7 +11,6 @@ name = "Plugin_VideoOGL"
files = [
'BPFunctions.cpp',
'Config.cpp',
'DLCache.cpp',
'rasterfont.cpp',
'Render.cpp',

View File

@ -116,7 +116,7 @@ FRAGMENTSHADER &GetOrCreateEncodingShader(u32 format)
const char* shader = TextureConversionShader::GenerateEncodingShader(format);
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS && shader) {
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && shader) {
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%s/enc_%04i.txt", FULL_DUMP_DIR, counter++);

View File

@ -112,9 +112,9 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode)
{
// very limited!
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER,
(newmode.mag_filter || g_Config.bForceFiltering) ? GL_LINEAR : GL_NEAREST);
(newmode.mag_filter || g_ActiveConfig.bForceFiltering) ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER,
(g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
(g_ActiveConfig.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
if (newmode.wrap_s == 2 || newmode.wrap_t == 2)
DEBUG_LOG(VIDEO, "cannot support mirrorred repeat mode");
@ -129,19 +129,19 @@ void TextureMngr::TCacheEntry::SetTextureParameters(TexMode0 &newmode)
if (bHaveMipMaps) {
int filt = newmode.min_filter;
if (g_Config.bForceFiltering && newmode.min_filter < 4)
if (g_ActiveConfig.bForceFiltering && newmode.min_filter < 4)
newmode.min_filter += 4; // take equivalent forced linear
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, c_MinLinearFilter[filt]);
}
else
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
(g_Config.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
(g_ActiveConfig.bForceFiltering || newmode.min_filter >= 4) ? GL_LINEAR : GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, c_WrapSettings[newmode.wrap_s]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, c_WrapSettings[newmode.wrap_t]);
}
if (g_Config.iMaxAnisotropy >= 1)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)(1 << g_Config.iMaxAnisotropy));
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, (float)(1 << g_ActiveConfig.iMaxAnisotropy));
}
void TextureMngr::TCacheEntry::Destroy(bool shutdown)
@ -149,7 +149,7 @@ void TextureMngr::TCacheEntry::Destroy(bool shutdown)
if (!texture)
return;
glDeleteTextures(1, &texture);
if (!isRenderTarget && !shutdown && !g_Config.bSafeTextureCache) {
if (!isRenderTarget && !shutdown && !g_ActiveConfig.bSafeTextureCache) {
u32 *ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr + hashoffset * 4);
if (ptr && *ptr == hash)
*ptr = oldpixel;
@ -160,7 +160,7 @@ void TextureMngr::TCacheEntry::Destroy(bool shutdown)
void TextureMngr::Init()
{
temp = (u8*)AllocateMemoryPages(TEMP_SIZE);
TexDecoder_SetTexFmtOverlayOptions(g_Config.bTexFmtOverlayEnable, g_Config.bTexFmtOverlayCenter);
TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter);
HiresTextures::Init(((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str());
}
@ -268,10 +268,10 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
u32 texID = address;
u32 texHash;
if (g_Config.bSafeTextureCache || g_Config.bHiresTextures || g_Config.bDumpTextures)
if (g_ActiveConfig.bSafeTextureCache || g_ActiveConfig.bHiresTextures || g_ActiveConfig.bDumpTextures)
{
texHash = TexDecoder_GetSafeTextureHash(ptr, expandedWidth, expandedHeight, tex_format, 0); // remove last arg
if (g_Config.bSafeTextureCache)
if (g_ActiveConfig.bSafeTextureCache)
hash_value = texHash;
if ((tex_format == GX_TF_C4) || (tex_format == GX_TF_C8) || (tex_format == GX_TF_C14X2))
{
@ -284,7 +284,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
// we must make sure that texture with different tluts get different IDs.
u32 tlutHash = TexDecoder_GetTlutHash(&texMem[tlutaddr], (tex_format == GX_TF_C4) ? 32 : 128);
texHash ^= tlutHash;
if (g_Config.bSafeTextureCache)
if (g_ActiveConfig.bSafeTextureCache)
texID ^= tlutHash;
//DebugLog("addr: %08x | texID: %08x | texHash: %08x", address, texID, hash_value);
}
@ -296,7 +296,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
if (iter != textures.end()) {
TCacheEntry &entry = iter->second;
if (!g_Config.bSafeTextureCache)
if (!g_ActiveConfig.bSafeTextureCache)
hash_value = ((u32 *)ptr)[entry.hashoffset];
if (entry.isRenderTarget || ((address == entry.addr) && (hash_value == entry.hash)))
@ -307,7 +307,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
glBindTexture(entry.isRectangle ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D, entry.texture);
if (entry.mode.hex != tm0.hex)
entry.SetTextureParameters(tm0);
//DebugLog("%cC addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_Config.bSafeTextureCache ? 'S' : 'U'
//DebugLog("%cC addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_ActiveConfig.bSafeTextureCache ? 'S' : 'U'
// , address, tex_format, entry.hash, width, height);
return &entry;
}
@ -335,7 +335,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
TCacheEntry& entry = textures[texID];
PC_TexFormat dfmt = PC_TEX_FMT_NONE;
if (g_Config.bHiresTextures)
if (g_ActiveConfig.bHiresTextures)
{
//Load Custom textures
char texPathTemp[MAX_PATH];
@ -361,14 +361,14 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
//entry.paletteHash = hashseed;
entry.oldpixel = ((u32 *)ptr)[entry.hashoffset];
if (g_Config.bSafeTextureCache)
if (g_ActiveConfig.bSafeTextureCache)
entry.hash = hash_value;
else
{
entry.hash = (u32)(((double)rand() / RAND_MAX) * 0xFFFFFFFF);
((u32 *)ptr)[entry.hashoffset] = entry.hash;
}
//DebugLog("%c addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_Config.bSafeTextureCache ? 'S' : 'U'
//DebugLog("%c addr: %08x | fmt: %i | e.hash: %08x | w:%04i h:%04i", g_ActiveConfig.bSafeTextureCache ? 'S' : 'U'
// , address, tex_format, entry.hash, width, height);
@ -462,7 +462,7 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
entry.fmt = tex_format;
entry.SetTextureParameters(tm0);
if (g_Config.bDumpTextures) // dump texture to file
if (g_ActiveConfig.bDumpTextures) // dump texture to file
{
char szTemp[MAX_PATH];
@ -731,7 +731,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
GL_REPORT_ERRORD();
if (g_Config.bDumpEFBTarget)
if (g_ActiveConfig.bDumpEFBTarget)
{
static int count = 0;
SaveTexture(StringFromFormat("%s/efb_frame_%i.tga", FULL_DUMP_TEXTURES_DIR, count++).c_str(), GL_TEXTURE_RECTANGLE_ARB, entry.texture, entry.w, entry.h);

View File

@ -156,7 +156,7 @@ void Flush()
_assert_(s_pCurBufferPointer != s_pBaseBufferPointer);
#if defined(_DEBUG) || defined(DEBUGFAST)
PRIM_LOG("frame%d:\n texgen=%d, numchan=%d, dualtex=%d, ztex=%d, cole=%d, alpe=%d, ze=%d", g_Config.iSaveTargetId, xfregs.numTexGens,
PRIM_LOG("frame%d:\n texgen=%d, numchan=%d, dualtex=%d, ztex=%d, cole=%d, alpe=%d, ze=%d", g_ActiveConfig.iSaveTargetId, xfregs.numTexGens,
xfregs.nNumChans, (int)xfregs.bEnableDualTexTransform, bpmem.ztex2.op,
bpmem.blendmode.colorupdate, bpmem.blendmode.alphaupdate, bpmem.zmode.updateenable);
@ -242,7 +242,7 @@ void Flush()
// texture is hires - pass the scaling size
if (tentry->scaleX != 1.0f || tentry->scaleY != 1.0f)
PixelShaderManager::SetCustomTexScale(i, tentry->scaleX, tentry->scaleY);
if (g_Config.iLog & CONF_SAVETEXTURES)
if (g_ActiveConfig.iLog & CONF_SAVETEXTURES)
{
// save the textures
char strfile[255];
@ -287,7 +287,7 @@ void Flush()
}
// run through vertex groups again to set alpha
if (!g_Config.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
if (!g_ActiveConfig.bDstAlphaPass && bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
{
ps = PixelShaderCache::GetShader(true);
@ -317,22 +317,22 @@ void Flush()
}
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS)
if (g_ActiveConfig.iLog & CONF_SAVESHADERS)
{
// save the shaders
char strfile[255];
sprintf(strfile, "%sframes/ps%.3d.txt", FULL_DUMP_DIR, g_Config.iSaveTargetId);
sprintf(strfile, "%sframes/ps%.3d.txt", FULL_DUMP_DIR, g_ActiveConfig.iSaveTargetId);
std::ofstream fps(strfile);
fps << ps->strprog.c_str();
sprintf(strfile, "%sframes/vs%.3d.txt", FULL_DUMP_DIR, g_Config.iSaveTargetId);
sprintf(strfile, "%sframes/vs%.3d.txt", FULL_DUMP_DIR, g_ActiveConfig.iSaveTargetId);
std::ofstream fvs(strfile);
fvs << vs->strprog.c_str();
}
if (g_Config.iLog & CONF_SAVETARGETS)
if (g_ActiveConfig.iLog & CONF_SAVETARGETS)
{
char str[128];
sprintf(str, "%sframes/targ%.3d.tga", FULL_DUMP_DIR, g_Config.iSaveTargetId);
sprintf(str, "%sframes/targ%.3d.tga", FULL_DUMP_DIR, g_ActiveConfig.iSaveTargetId);
Renderer::SaveRenderTarget(str, Renderer::GetTargetWidth(), Renderer::GetTargetHeight());
}
#endif

View File

@ -41,8 +41,7 @@ bool VertexShaderCache::s_displayCompileAlert;
static VERTEXSHADER *pShaderLast = NULL;
static int s_nMaxVertexInstructions;
static float lastVSconstants[C_FOGPARAMS+8][4];
static float GC_ALIGNED16(lastVSconstants[C_FOGPARAMS+8][4]);
void SetVSConstant4f(int const_number, float f1, float f2, float f3, float f4)
{
@ -144,7 +143,7 @@ VERTEXSHADER* VertexShaderCache::GetShader(u32 components)
const char *code = GenerateVertexShader(components, false);
#if defined(_DEBUG) || defined(DEBUGFAST)
if (g_Config.iLog & CONF_SAVESHADERS && code) {
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && code) {
static int counter = 0;
char szTemp[MAX_PATH];
sprintf(szTemp, "%s/vs_%04i.txt", FULL_DUMP_DIR, counter++);

View File

@ -70,6 +70,11 @@ GFXDebuggerOGL *m_DebuggerFrame = NULL;
#endif // HAVE_WX
#include "Config.h"
// Having to include this is TERRIBLY ugly. FIXME x100
#include "Globals.h"
#include "../../../Core/Core/Src/ConfigManager.h" // FIXME
#include "LookUpTables.h"
#include "ImageWrite.h"
#include "Render.h"
@ -280,6 +285,12 @@ void CocaAddResolutions() {
void DllConfig(HWND _hParent)
{
g_Config.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
// UGLY
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
g_Config.GameIniLoad(iniFile);
g_Config.UpdateProjectionHack();
UpdateActiveConfig();
#if defined(HAVE_WX) && HAVE_WX
// Prevent user to show more than 1 config window at same time
if (allowConfigShow) {
@ -314,14 +325,17 @@ void Initialize(void *init)
g_VideoInitialize = *(_pVideoInitialize);
InitXFBConvTables();
g_Config.Load();
g_Config.GameIniLoad();
g_Config.Load(FULL_CONFIG_DIR "gfx_opengl.ini");
// UGLY
IniFile *iniFile = ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.gameIni;
g_Config.GameIniLoad(iniFile);
#if defined(HAVE_WX) && HAVE_WX
g_Config.UpdateProjectionHack();
//Enable support for PNG screenshots.
wxImage::AddHandler( new wxPNGHandler );
#endif
UpdateActiveConfig();
if (!OpenGL_Create(g_VideoInitialize, 640, 480)) {
g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE);
@ -460,7 +474,7 @@ void VideoFifo_CheckSwapRequest()
{
if (Common::AtomicLoadAcquire(s_swapRequested))
{
if (ForceSwap || g_Config.bUseXFB)
if (ForceSwap || g_ActiveConfig.bUseXFB)
{
Renderer::Swap(s_beginFieldArgs.xfbAddr, s_beginFieldArgs.field, s_beginFieldArgs.fbWidth, s_beginFieldArgs.fbHeight);
g_VideoInitialize.pCopiedToXFB(false);
@ -481,7 +495,7 @@ inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
// Run from the graphics thread (from Fifo.cpp)
void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
{
if (Common::AtomicLoadAcquire(s_swapRequested) && g_Config.bUseXFB)
if (Common::AtomicLoadAcquire(s_swapRequested) && g_ActiveConfig.bUseXFB)
{
u32 aLower = xfbAddr;
u32 aUpper = xfbAddr + 2 * fbWidth * fbHeight;