mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Implement texture filter library initialization.
This commit is contained in:
parent
81b19e77b7
commit
244fa5bf83
3
Config.h
3
Config.h
|
@ -45,9 +45,6 @@ struct Config
|
|||
u32 txHresAltCRC; // Use alternative method of paletted textures CRC calculation
|
||||
u32 txHiresCacheCompression; // Zip cache of hires textures
|
||||
u32 txDump; // Dump textures
|
||||
|
||||
|
||||
u32 txFilterEnable; // 1 if texture filtering library is in use, 0 otherwise
|
||||
} textureFilter;
|
||||
|
||||
struct {
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32_ASM;OS_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>TXFILTER_LIB;WIN32_ASM;OS_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
|
@ -139,7 +139,7 @@
|
|||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug_mupenplus|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>MUPENPLUSAPI;WIN32;OS_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>TXFILTER_LIB;MUPENPLUSAPI;WIN32;OS_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>false</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
|
@ -170,7 +170,7 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<PreprocessorDefinitions>WIN32_ASM;OS_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>TXFILTER_LIB;WIN32_ASM;OS_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
|
@ -200,7 +200,7 @@
|
|||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<OmitFramePointers>true</OmitFramePointers>
|
||||
<PreprocessorDefinitions>MUPENPLUSAPI;WIN32;WIN32_ASM;OS_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>TXFILTER_LIB;MUPENPLUSAPI;WIN32;WIN32_ASM;OS_WINDOWS;_USRDLL;NEWGLNINTENDO64_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>true</StringPooling>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
|
|
109
OpenGL.cpp
109
OpenGL.cpp
|
@ -2,9 +2,6 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h> /* time_t, struct tm, difftime, time, mktime */
|
||||
#include "OpenGL.h"
|
||||
#include "RDP.h"
|
||||
#include "RSP.h"
|
||||
|
||||
//// paulscode, added for SDL linkage:
|
||||
#if defined(GLES2)
|
||||
|
@ -12,8 +9,11 @@
|
|||
#endif // GLES2
|
||||
////
|
||||
|
||||
#include "GLideN64.h"
|
||||
#include "Types.h"
|
||||
#include "GLideN64.h"
|
||||
#include "OpenGL.h"
|
||||
#include "RDP.h"
|
||||
#include "RSP.h"
|
||||
#include "N64.h"
|
||||
#include "gSP.h"
|
||||
#include "gDP.h"
|
||||
|
@ -22,6 +22,7 @@
|
|||
#include "GLSLCombiner.h"
|
||||
#include "FrameBuffer.h"
|
||||
#include "DepthBuffer.h"
|
||||
#include "GLideNHQ/Ext_TxFilter.h"
|
||||
#include "VI.h"
|
||||
#include "Config.h"
|
||||
#include "Log.h"
|
||||
|
@ -1191,6 +1192,106 @@ void OGLRender::_setSpecialTexrect() const
|
|||
texturedRectSpecial = NULL;
|
||||
}
|
||||
|
||||
static
|
||||
u32 textureFilters[] = {
|
||||
NO_FILTER, //"None"
|
||||
SMOOTH_FILTER_1, //"Smooth filtering 1"
|
||||
SMOOTH_FILTER_2, //"Smooth filtering 2"
|
||||
SMOOTH_FILTER_3, //"Smooth filtering 3"
|
||||
SMOOTH_FILTER_4, //"Smooth filtering 4"
|
||||
SHARP_FILTER_1, //"Sharp filtering 1"
|
||||
SHARP_FILTER_2, //"Sharp filtering 2"
|
||||
};
|
||||
|
||||
static
|
||||
u32 textureEnhancements[] = {
|
||||
NO_ENHANCEMENT, //"None"
|
||||
NO_ENHANCEMENT, //"Store"
|
||||
X2_ENHANCEMENT, //"X2"
|
||||
X2SAI_ENHANCEMENT, //"X2SAI"
|
||||
HQ2X_ENHANCEMENT, //"HQ2X"
|
||||
HQ2XS_ENHANCEMENT, //"HQ2XS"
|
||||
LQ2X_ENHANCEMENT, //"LQ2X"
|
||||
LQ2XS_ENHANCEMENT, //"LQ2XS"
|
||||
HQ4X_ENHANCEMENT, //"HQ4X"
|
||||
};
|
||||
|
||||
void displayLoadProgress(const wchar_t *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
wchar_t wbuf[INFO_BUF];
|
||||
// char buf[INFO_BUF];
|
||||
|
||||
// process input
|
||||
va_start(args, format);
|
||||
vswprintf(wbuf, INFO_BUF, format, args);
|
||||
va_end(args);
|
||||
|
||||
// XXX: convert to multibyte
|
||||
// wcstombs(buf, wbuf, INFO_BUF);
|
||||
|
||||
OutputDebugStringW(wbuf);
|
||||
}
|
||||
|
||||
void TextureFilterHandler::init()
|
||||
{
|
||||
if (!isInited()) {
|
||||
m_inited = config.textureFilter.txFilterMode | config.textureFilter.txEnhancementMode | config.textureFilter.txHiresEnable;
|
||||
if (m_inited != 0) {
|
||||
u32 options = textureFilters[config.textureFilter.txFilterMode] | textureEnhancements[config.textureFilter.txEnhancementMode];
|
||||
if (config.textureFilter.txFilterCompression != 0)
|
||||
options |= COMPRESS_TEX | S3TC_COMPRESSION;
|
||||
if (config.textureFilter.txHiresCompression)
|
||||
options |= COMPRESS_HIRESTEX | S3TC_COMPRESSION;
|
||||
if (config.textureFilter.txHiresEnable)
|
||||
options |= RICE_HIRESTEXTURES;
|
||||
if (config.textureFilter.txFilterForce16bpp)
|
||||
options |= FORCE16BPP_TEX;
|
||||
if (config.textureFilter.txHiresForce16bpp)
|
||||
options |= FORCE16BPP_HIRESTEX;
|
||||
if (config.textureFilter.txFilterCacheCompression)
|
||||
options |= GZ_TEXCACHE;
|
||||
if (config.textureFilter.txHiresCacheCompression)
|
||||
options |= GZ_HIRESTEXCACHE;
|
||||
if (config.textureFilter.txSaveCache)
|
||||
options |= (DUMP_TEXCACHE | DUMP_HIRESTEXCACHE);
|
||||
if (config.textureFilter.txHiresFullAlphaChannel)
|
||||
options |= LET_TEXARTISTS_FLY;
|
||||
if (config.textureFilter.txDump)
|
||||
options |= DUMP_TEX;
|
||||
|
||||
GLint maxTextureSize;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||
wchar_t wRomName[32];
|
||||
::mbstowcs(wRomName, RSP.romname, 32);
|
||||
|
||||
wchar_t buffer[MAX_PATH];
|
||||
GetModuleFileNameW(NULL, buffer, MAX_PATH);
|
||||
wstring pluginPath(buffer);
|
||||
wstring::size_type pos = pluginPath.find_last_of(L"\\/");
|
||||
|
||||
m_inited = txfilter_init(maxTextureSize, // max texture width supported by hardware
|
||||
maxTextureSize, // max texture height supported by hardware
|
||||
32, // max texture bpp supported by hardware
|
||||
options,
|
||||
config.textureFilter.txCacheSize, // cache texture to system memory
|
||||
pluginPath.substr(0, pos).c_str(), // plugin path
|
||||
wRomName, // name of ROM. must be no longer than 256 characters
|
||||
displayLoadProgress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextureFilterHandler::shutdown()
|
||||
{
|
||||
if (isInited()) {
|
||||
txfilter_shutdown();
|
||||
m_inited = 0;
|
||||
}
|
||||
}
|
||||
|
||||
TextureFilterHandler TFH;
|
||||
|
||||
#ifdef __TRIBUFFER_OPT
|
||||
void OGLRender::_indexmap_init()
|
||||
{
|
||||
|
|
17
OpenGL.h
17
OpenGL.h
|
@ -202,8 +202,25 @@ OGLVideo & video()
|
|||
return OGLVideo::get();
|
||||
}
|
||||
|
||||
class TextureFilterHandler
|
||||
{
|
||||
public:
|
||||
TextureFilterHandler() : m_inited(0) {}
|
||||
// It's not safe to call shutdown() in destructor, because texture filter has its own static objects, which can be destroyed first.
|
||||
~TextureFilterHandler() { m_inited = 0; }
|
||||
void init();
|
||||
void shutdown();
|
||||
bool isInited() const { return m_inited != 0; }
|
||||
private:
|
||||
u32 m_inited;
|
||||
};
|
||||
|
||||
extern TextureFilterHandler TFH;
|
||||
|
||||
void initGLFunctions();
|
||||
bool checkFBO();
|
||||
bool isGLError();
|
||||
|
||||
void GHQ_init();
|
||||
|
||||
#endif
|
||||
|
|
13
RSP.cpp
13
RSP.cpp
|
@ -267,14 +267,19 @@ void RSP_Init()
|
|||
RSP.bLLE = false;
|
||||
|
||||
// get the name of the ROM
|
||||
char romname[21];
|
||||
for (int i = 0; i < 20; ++i)
|
||||
RSP.romname[i] = HEADER[(32 + i) ^ 3];
|
||||
RSP.romname[20] = 0;
|
||||
romname[i] = HEADER[(32 + i) ^ 3];
|
||||
romname[20] = 0;
|
||||
|
||||
// remove all trailing spaces
|
||||
while (RSP.romname[strlen(RSP.romname) - 1] == ' ')
|
||||
RSP.romname[strlen(RSP.romname) - 1] = 0;
|
||||
while (romname[strlen(romname) - 1] == ' ')
|
||||
romname[strlen(romname) - 1] = 0;
|
||||
|
||||
if (strcmp(RSP.romname, romname) != 0)
|
||||
TFH.shutdown();
|
||||
|
||||
strncpy(RSP.romname, romname, 21);
|
||||
if (strstr(RSP.romname, (const char *)"OgreBattle64"))
|
||||
config.hacks |= hack_Ogre64;
|
||||
|
||||
|
|
|
@ -23,6 +23,7 @@ void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx,
|
|||
RSP_Init();
|
||||
GBI.init();
|
||||
video().start();
|
||||
TFH.init();
|
||||
assert(!isGLError());
|
||||
|
||||
while (true) {
|
||||
|
@ -41,6 +42,7 @@ void RSP_ThreadProc(std::mutex * _pRspThreadMtx, std::mutex * _pPluginThreadMtx,
|
|||
VI_UpdateScreen();
|
||||
break;
|
||||
case acRomClosed:
|
||||
TFH.shutdown();
|
||||
video().stop();
|
||||
GBI.destroy();
|
||||
*_pCommand = acNone;
|
||||
|
@ -95,6 +97,7 @@ void PluginAPI::RomClosed()
|
|||
delete m_pRspThread;
|
||||
m_pRspThread = NULL;
|
||||
#else
|
||||
TFH.shutdown();
|
||||
video().stop();
|
||||
GBI.destroy();
|
||||
#endif
|
||||
|
@ -117,6 +120,7 @@ void PluginAPI::RomOpen()
|
|||
RSP_Init();
|
||||
GBI.init();
|
||||
video().start();
|
||||
TFH.init();
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
|
@ -153,7 +153,6 @@ void Config_LoadConfig()
|
|||
config.textureFilter.txHresAltCRC = ConfigGetParamBool(g_configVideoGliden64, "txHresAltCRC");
|
||||
config.textureFilter.txHiresCacheCompression = ConfigGetParamBool(g_configVideoGliden64, "txHiresCacheCompression");
|
||||
config.textureFilter.txDump = ConfigGetParamBool(g_configVideoGliden64, "txDump");
|
||||
config.textureFilter.txFilterEnable = 0; // Disable for now
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -121,7 +121,6 @@ void Config_LoadConfig()
|
|||
config.frameBufferEmulation.N64DepthCompare = FALSE;
|
||||
config.enableLOD = TRUE;
|
||||
config.hacks = 0;
|
||||
config.textureFilter.txFilterEnable = 0;
|
||||
}
|
||||
|
||||
void Config_SaveConfig()
|
||||
|
|
Loading…
Reference in New Issue
Block a user