Novidia: make use of glTexImage1D or glTexSubImage1D configurable
This commit is contained in:
@@ -4,44 +4,26 @@
|
|||||||
|
|
||||||
|
|
||||||
// upload to the SSBO instead after processing
|
// upload to the SSBO instead after processing
|
||||||
void h_uploadModelTransformBuf(DWORD* a1, int a2)
|
// two versions because apparently TexSubImage can cause major stuttering
|
||||||
|
void h_uploadModelTransformBuf_TexImage(DWORD* a1, int a2)
|
||||||
{
|
{
|
||||||
uploadModelTransformBuf(a1, a2);
|
uploadModelTransformBuf(a1, a2);
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE8);
|
||||||
|
glBindTexture(GL_TEXTURE_1D, buf_tex);
|
||||||
|
glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 0x3000 / sizeof(float) / 4, 0, GL_RGBA, GL_FLOAT, *(float**)0x1411a3330);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
}
|
||||||
|
void h_uploadModelTransformBuf_TexSubImage(DWORD* a1, int a2)
|
||||||
|
{
|
||||||
|
uploadModelTransformBuf(a1, a2);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE8);
|
glActiveTexture(GL_TEXTURE8);
|
||||||
glBindTexture(GL_TEXTURE_1D, buf_tex);
|
glBindTexture(GL_TEXTURE_1D, buf_tex);
|
||||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 0x3000 / sizeof(float) / 4, GL_RGBA, GL_FLOAT, *(float**)0x1411a3330);
|
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 0x3000 / sizeof(float) / 4, GL_RGBA, GL_FLOAT, *(float**)0x1411a3330);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void h_glDrawElements(GLenum mode, GLsizei count, GLenum type, const void* indices)
|
|
||||||
{
|
|
||||||
if (performTransform)
|
|
||||||
{
|
|
||||||
glActiveTexture(GL_TEXTURE8);
|
|
||||||
glBindTexture(GL_TEXTURE_1D, buf_tex);
|
|
||||||
//glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 0x3000 / sizeof(float) / 4, 0, GL_RGBA, GL_FLOAT, *(float**)0x1411a3330);
|
|
||||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 0x3000 / sizeof(float) / 4, GL_RGBA, GL_FLOAT, *(float**)0x1411a3330);
|
|
||||||
//glActiveTexture(GL_TEXTURE0);
|
|
||||||
}
|
|
||||||
glDrawElements(mode, count, type, indices);
|
|
||||||
}
|
|
||||||
|
|
||||||
void h_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void* indices)
|
|
||||||
{
|
|
||||||
if (performTransform)
|
|
||||||
{
|
|
||||||
glActiveTexture(GL_TEXTURE8);
|
|
||||||
glBindTexture(GL_TEXTURE_1D, buf_tex);
|
|
||||||
//glTexImage1D(GL_TEXTURE_1D, 0, GL_RGBA32F, 0x3000 / sizeof(float) / 4, 0, GL_RGBA, GL_FLOAT, *(float**)0x1411a3330);
|
|
||||||
glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 0x3000 / sizeof(float) / 4, GL_RGBA, GL_FLOAT, *(float**)0x1411a3330);
|
|
||||||
//glActiveTexture(GL_TEXTURE0);
|
|
||||||
}
|
|
||||||
glDrawRangeElements(mode,start, end, count, type, indices);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// just a crash fix
|
// just a crash fix
|
||||||
void h_glBindBuffer(GLenum target, GLuint buffer)
|
void h_glBindBuffer(GLenum target, GLuint buffer)
|
||||||
{
|
{
|
||||||
@@ -106,7 +88,8 @@ void h_glutSetCursor(int cursor)
|
|||||||
glGenTextures(1, &buf_tex);
|
glGenTextures(1, &buf_tex);
|
||||||
printf("[Novidia] Buffer texture id: %d\n", buf_tex);
|
printf("[Novidia] Buffer texture id: %d\n", buf_tex);
|
||||||
glBindTexture(GL_TEXTURE_1D, buf_tex);
|
glBindTexture(GL_TEXTURE_1D, buf_tex);
|
||||||
glTexStorage1D(GL_TEXTURE_1D, 1, GL_RGBA32F, 0x3000 / sizeof(float) / 4);
|
if (use_TexSubImage)
|
||||||
|
glTexStorage1D(GL_TEXTURE_1D, 1, GL_RGBA32F, 0x3000 / sizeof(float) / 4);
|
||||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
@@ -127,7 +110,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
|
|
||||||
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
//loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
DisableThreadLibraryCalls(hModule);
|
DisableThreadLibraryCalls(hModule);
|
||||||
|
|
||||||
@@ -135,10 +118,15 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
DetourUpdateThread(GetCurrentThread());
|
DetourUpdateThread(GetCurrentThread());
|
||||||
printf("[Novidia] Hooking glutSetCursor\n");
|
printf("[Novidia] Hooking glutSetCursor\n");
|
||||||
DetourAttach(&(PVOID&)glutSetCursor, h_glutSetCursor);
|
DetourAttach(&(PVOID&)glutSetCursor, h_glutSetCursor);
|
||||||
printf("[Novidia] Hooking uploadModelTransformBuf\n");
|
|
||||||
DetourAttach(&(PVOID&)uploadModelTransformBuf, h_uploadModelTransformBuf);
|
|
||||||
printf("[Novidia] Hooking wglGetProcAddress\n");
|
printf("[Novidia] Hooking wglGetProcAddress\n");
|
||||||
DetourAttach(&(PVOID&)wGlGetProcAddress_forhook, h_wglGetProcAddress);
|
DetourAttach(&(PVOID&)wGlGetProcAddress_forhook, h_wglGetProcAddress);
|
||||||
|
|
||||||
|
printf("[Novidia] Hooking uploadModelTransformBuf\n");
|
||||||
|
if (use_TexSubImage)
|
||||||
|
DetourAttach(&(PVOID&)uploadModelTransformBuf, h_uploadModelTransformBuf_TexSubImage);
|
||||||
|
else
|
||||||
|
DetourAttach(&(PVOID&)uploadModelTransformBuf, h_uploadModelTransformBuf_TexImage);
|
||||||
|
|
||||||
DetourTransactionCommit();
|
DetourTransactionCommit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,6 +137,10 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
|
|
||||||
using namespace PluginConfig;
|
using namespace PluginConfig;
|
||||||
|
|
||||||
|
PluginConfigOption config[] = {
|
||||||
|
{ CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"use_TexSubImage", L"general", CONFIG_FILE, L"Use glTexSubImage", L"glTexSubImage should offer higher performance, but stuttering has been reported when it is used.\nTry disabling this if you have issues.", true, false } },
|
||||||
|
};
|
||||||
|
|
||||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
|
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
|
||||||
{
|
{
|
||||||
return L"Novidia";
|
return L"Novidia";
|
||||||
@@ -157,4 +149,9 @@ extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
|
|||||||
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
|
extern "C" __declspec(dllexport) LPCWSTR GetPluginDescription(void)
|
||||||
{
|
{
|
||||||
return L"Novidia by somewhatlurker\n\nPerforms some model skinning transformations in an alternate way to enable functionality on non-Nvidia hardware.\nAlso fixes crashing on non-Nvidia hardware.";
|
return L"Novidia by somewhatlurker\n\nPerforms some model skinning transformations in an alternate way to enable functionality on non-Nvidia hardware.\nAlso fixes crashing on non-Nvidia hardware.";
|
||||||
|
}
|
||||||
|
|
||||||
|
extern "C" __declspec(dllexport) PluginConfigArray GetPluginOptions(void)
|
||||||
|
{
|
||||||
|
return PluginConfigArray{ _countof(config), config };
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,8 @@ bool checkBufferTargetOk(GLenum target)
|
|||||||
int __stdcall stub() { return 1; }
|
int __stdcall stub() { return 1; }
|
||||||
|
|
||||||
|
|
||||||
/*
|
bool use_TexSubImage;
|
||||||
|
|
||||||
std::wstring ExePath() {
|
std::wstring ExePath() {
|
||||||
WCHAR buffer[MAX_PATH];
|
WCHAR buffer[MAX_PATH];
|
||||||
GetModuleFileNameW(NULL, buffer, MAX_PATH);
|
GetModuleFileNameW(NULL, buffer, MAX_PATH);
|
||||||
@@ -43,6 +44,5 @@ LPCWSTR CONFIG_FILE = CONFIG_FILE_STRING.c_str();
|
|||||||
|
|
||||||
void loadConfig()
|
void loadConfig()
|
||||||
{
|
{
|
||||||
|
use_TexSubImage = GetPrivateProfileIntW(L"general", L"use_TexSubImage", 1, CONFIG_FILE) > 0 ? true : false;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
@@ -54,6 +54,7 @@ typedef char GLchar;
|
|||||||
void(__cdecl* glGenTextures)(GLsizei n, GLuint* textures) = *(void(__cdecl**)(GLsizei, GLuint*))0x140965ad8;
|
void(__cdecl* glGenTextures)(GLsizei n, GLuint* textures) = *(void(__cdecl**)(GLsizei, GLuint*))0x140965ad8;
|
||||||
void(__cdecl* glBindTexture)(GLenum target, GLuint texture) = *(void(__cdecl**)(GLenum, GLuint))0x140965bf8;
|
void(__cdecl* glBindTexture)(GLenum target, GLuint texture) = *(void(__cdecl**)(GLenum, GLuint))0x140965bf8;
|
||||||
void(__cdecl* glTexParameteri)(GLenum target, GLenum pname, GLint param) = *(void(__cdecl**)(GLenum, GLenum, GLint))0x140965a18;
|
void(__cdecl* glTexParameteri)(GLenum target, GLenum pname, GLint param) = *(void(__cdecl**)(GLenum, GLenum, GLint))0x140965a18;
|
||||||
|
void(__cdecl* glTexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void* data) = *(void(__cdecl**)(GLenum, GLint, GLint, GLsizei, GLint, GLenum, GLenum, const void*))0x140965b58;
|
||||||
void(__cdecl* glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels) = (void(__cdecl*)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const void*))GetProcAddress(ogl32, "glTexSubImage1D");
|
void(__cdecl* glTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void* pixels) = (void(__cdecl*)(GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const void*))GetProcAddress(ogl32, "glTexSubImage1D");
|
||||||
|
|
||||||
// these are all imported using wglGetProcAddress and can't be initialised until after the OpenGL context is created
|
// these are all imported using wglGetProcAddress and can't be initialised until after the OpenGL context is created
|
||||||
@@ -73,6 +74,7 @@ struct {
|
|||||||
{&glGenTextures, "glGenTextures", false},
|
{&glGenTextures, "glGenTextures", false},
|
||||||
{&glBindTexture, "glBindTexture", false},
|
{&glBindTexture, "glBindTexture", false},
|
||||||
{&glTexParameteri, "glTexParameteri", false},
|
{&glTexParameteri, "glTexParameteri", false},
|
||||||
|
{&glTexImage1D, "glTexImage1D", false},
|
||||||
{&glTexSubImage1D, "glTexSubImage1D", false},
|
{&glTexSubImage1D, "glTexSubImage1D", false},
|
||||||
{&glActiveTexture, "glActiveTexture", true},
|
{&glActiveTexture, "glActiveTexture", true},
|
||||||
{&glTexStorage1D, "glTexStorage1D", true},
|
{&glTexStorage1D, "glTexStorage1D", true},
|
||||||
|
|||||||
Reference in New Issue
Block a user