use shader_amd.farc for AMD patches (now toggling Novidia changes shaders between original and patched for multi-GPU users)

users of old versions need to repatch shaders or rename shader.farc in MAMD to use this option in Novidia.
This commit is contained in:
somewhatlurker
2020-07-27 14:15:38 +10:00
parent e42e6d6ff5
commit fb7c46774d
5 changed files with 24 additions and 2 deletions
@@ -3,7 +3,7 @@ FarcPack ..\rom\shader.farc shader_unpacked
mkdir ..\mdata\MAMD
mkdir ..\mdata\MAMD\rom
copy info.txt ..\mdata\MAMD\
FarcPack -c shader_patched ..\mdata\MAMD\rom\shader.farc
FarcPack -c shader_patched ..\mdata\MAMD\rom\shader_amd.farc
del /Q shader_unpacked
rmdir shader_unpacked
del /Q shader_patched
+1 -1
View File
@@ -3,7 +3,7 @@ FarcPack ..\rom\shader.farc shader_unpacked
mkdir ..\mdata\MAMD
mkdir ..\mdata\MAMD\rom
copy info.txt ..\mdata\MAMD\
FarcPack -c shader_patched ..\mdata\MAMD\rom\shader.farc
FarcPack -c shader_patched ..\mdata\MAMD\rom\shader_amd.farc
del /Q shader_unpacked
rmdir shader_unpacked
del /Q shader_patched
@@ -157,6 +157,12 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
DetourAttach(&(PVOID&)uploadModelTransformBuf, h_uploadModelTransformBuf_TexImage);
DetourTransactionCommit();
if (shader_amd_farc)
{
const char* shaderpath = "./rom/shader_amd.farc";
InjectCode((void*)0x140a41018, std::vector<uint8_t>(shaderpath, shaderpath + strlen(shaderpath)));
}
}
return TRUE;
@@ -169,6 +175,7 @@ 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 } },
{ CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"force_BGRA_upload", L"general", CONFIG_FILE, L"Force BGRA Texture Uploads", L"BGRA format uploads seem to run faster (on some hardware), but drivers may suggest RGBA instead.\nUsing this forces uploads to use the BGRA format.\n\nDisabling this may decrease or improve performance.", true, false } },
{ CONFIG_BOOLEAN, new PluginConfigBooleanData{ L"shader_amd_farc", L"general", CONFIG_FILE, L"Load shader_amd.farc", L"Novidia can manage loading of alternate shaders automatically.\nLeave this enabled for current and future versions of AMDPack.", true, false } },
};
extern "C" __declspec(dllexport) LPCWSTR GetPluginName(void)
@@ -1,6 +1,7 @@
#pragma once
#include "glStuff.h"
#include <vector>
// use this as a hook to perform initialisation
void(__cdecl* glutSetCursor)(int cursor) = *(void(__cdecl**)(int))0x140966068;
@@ -27,6 +28,7 @@ int __stdcall stub() { return 1; }
bool use_TexSubImage;
bool force_BGRA_upload;
GLint tex_upload_format;
bool shader_amd_farc;
std::wstring ExePath() {
WCHAR buffer[MAX_PATH];
@@ -48,4 +50,16 @@ void loadConfig()
{
use_TexSubImage = GetPrivateProfileIntW(L"general", L"use_TexSubImage", 1, CONFIG_FILE) > 0 ? true : false;
force_BGRA_upload = GetPrivateProfileIntW(L"general", L"force_BGRA_upload", 1, CONFIG_FILE) > 0 ? true : false;
shader_amd_farc = GetPrivateProfileIntW(L"general", L"shader_amd_farc", 1, CONFIG_FILE) > 0 ? true : false;
}
void InjectCode(void* address, const std::vector<uint8_t> data)
{
const size_t byteCount = data.size() * sizeof(uint8_t);
DWORD oldProtect;
VirtualProtect(address, byteCount, PAGE_EXECUTE_READWRITE, &oldProtect);
memcpy(address, data.data(), byteCount);
VirtualProtect(address, byteCount, oldProtect, nullptr);
}
@@ -40,6 +40,7 @@ typedef char GLchar;
#define GL_TEXTURE8 0x84c8
#define GL_BUFFER_SIZE 0x8764
#define GL_RGBA32F 0x8814
#define GL_RGBA16F 0x881a
#define GL_ARRAY_BUFFER 0x8892
#define GL_ARRAY_BUFFER_BINDING 0x8894
#define GL_READ_ONLY 0x88b8