mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
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:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+96
-13
@@ -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));
|
||||
}
|
||||
@@ -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_
|
||||
@@ -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
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
Import('env')
|
||||
|
||||
files = [
|
||||
'Config.cpp',
|
||||
'GlobalControl.cpp',
|
||||
'BPMemory.cpp',
|
||||
'CPMemory.cpp',
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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__)}
|
||||
|
||||
@@ -689,6 +689,14 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\Src\Config.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\GlobalControl.cpp"
|
||||
>
|
||||
|
||||
@@ -1291,14 +1291,6 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath=".\Src\Config.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Config.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Src\Globals.h"
|
||||
>
|
||||
|
||||
@@ -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 ©fmt, 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
|
||||
}
|
||||
|
||||
};
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "IniFile.h"
|
||||
#include "Debugger.h"
|
||||
|
||||
#include "../Config.h"
|
||||
#include "Config.h"
|
||||
#include "../Globals.h"
|
||||
#include "../D3DBase.h"
|
||||
|
||||
|
||||
@@ -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)))
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user