mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-08-27 08:36:44 +00:00
Merge branch 'master' of https://github.com/cdozdil/CyberXeSS
This commit is contained in:
+76
-11
@@ -37,6 +37,7 @@ static PFN_vkGetPhysicalDeviceProperties2KHR o_vkGetPhysicalDeviceProperties2KHR
|
||||
static PFN_vkEnumerateInstanceExtensionProperties o_vkEnumerateInstanceExtensionProperties = nullptr;
|
||||
static PFN_vkEnumerateDeviceExtensionProperties o_vkEnumerateDeviceExtensionProperties = nullptr;
|
||||
static PFN_vkCreateDevice o_vkCreateDevice = nullptr;
|
||||
static PFN_vkCreateInstance o_vkCreateInstance = nullptr;
|
||||
|
||||
static uint32_t vkEnumerateInstanceExtensionPropertiesCount = 0;
|
||||
static uint32_t vkEnumerateDeviceExtensionPropertiesCount = 0;
|
||||
@@ -640,6 +641,36 @@ static void hkvkGetPhysicalDeviceProperties2KHR(VkPhysicalDevice phys_dev, VkPhy
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult hkvkCreateInstance(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance)
|
||||
{
|
||||
spdlog::debug("hkvkCreateInstance for {0}", pCreateInfo->pApplicationInfo->pApplicationName);
|
||||
|
||||
spdlog::debug("hkvkCreateInstance extensions ({0}):", pCreateInfo->enabledExtensionCount);
|
||||
for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++)
|
||||
spdlog::debug("hkvkCreateInstance {0}", pCreateInfo->ppEnabledExtensionNames[i]);
|
||||
|
||||
spdlog::debug("hkvkCreateInstance layers ({0}):", pCreateInfo->enabledLayerCount);
|
||||
for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++)
|
||||
spdlog::debug("hkvkCreateInstance {0}", pCreateInfo->ppEnabledLayerNames[i]);
|
||||
|
||||
// Skip spoofing for Intel Arc
|
||||
Config::Instance()->dxgiSkipSpoofing = true;
|
||||
auto result = o_vkCreateInstance(pCreateInfo, pAllocator, pInstance);
|
||||
Config::Instance()->dxgiSkipSpoofing = false;
|
||||
|
||||
spdlog::debug("hkvkCreateInstance o_vkCreateInstance result: {0:X}", (INT)result);
|
||||
|
||||
auto head = (VkBaseInStructure*)pCreateInfo;
|
||||
|
||||
while (head->pNext != nullptr)
|
||||
{
|
||||
head = (VkBaseInStructure*)head->pNext;
|
||||
spdlog::debug("hkvkCreateInstance o_vkCreateInstance type: {0:X}", (UINT)head->sType);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static VkResult hkvkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice)
|
||||
{
|
||||
spdlog::debug("hkvkCreateDevice");
|
||||
@@ -647,14 +678,19 @@ static VkResult hkvkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCreate
|
||||
if (!Config::Instance()->VulkanExtensionSpoofing.value_or(false))
|
||||
{
|
||||
spdlog::debug("hkvkCreateDevice extension spoofing is disabled");
|
||||
|
||||
Config::Instance()->dxgiSkipSpoofing = true;
|
||||
return o_vkCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
|
||||
Config::Instance()->dxgiSkipSpoofing = false;
|
||||
}
|
||||
|
||||
spdlog::debug("hkvkCreateDevice layers ({0}):", pCreateInfo->enabledLayerCount);
|
||||
for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++)
|
||||
spdlog::debug("hkvkCreateDevice {0}", pCreateInfo->ppEnabledLayerNames[i]);
|
||||
|
||||
std::vector<const char*> newExtensionList;
|
||||
|
||||
|
||||
auto bVK_KHR_get_memory_requirements2 = false;
|
||||
//auto GL_EXT_shader_image_load_formatted = false;
|
||||
|
||||
spdlog::debug("hkvkCreateDevice checking extensions and removing VK_NVX_BINARY_IMPORT & VK_NVX_IMAGE_VIEW_HANDLE from list");
|
||||
for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++)
|
||||
@@ -667,30 +703,29 @@ static VkResult hkvkCreateDevice(VkPhysicalDevice physicalDevice, VkDeviceCreate
|
||||
{
|
||||
spdlog::debug("hkvkCreateDevice adding {0}", pCreateInfo->ppEnabledExtensionNames[i]);
|
||||
newExtensionList.push_back(pCreateInfo->ppEnabledExtensionNames[i]);
|
||||
}
|
||||
|
||||
if (std::strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME) == 0)
|
||||
bVK_KHR_get_memory_requirements2 = true;
|
||||
//else if (std::strcmp(pCreateInfo->ppEnabledExtensionNames[i], "GL_EXT_shader_image_load_formatted") == 0)
|
||||
// GL_EXT_shader_image_load_formatted = true;
|
||||
if (std::strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME) == 0)
|
||||
bVK_KHR_get_memory_requirements2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!bVK_KHR_get_memory_requirements2)
|
||||
newExtensionList.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
|
||||
|
||||
//if(!GL_EXT_shader_image_load_formatted)
|
||||
// newExtensionList.push_back("GL_EXT_shader_image_load_formatted");
|
||||
|
||||
pCreateInfo->enabledExtensionCount = static_cast<uint32_t>(newExtensionList.size());
|
||||
pCreateInfo->ppEnabledExtensionNames = newExtensionList.data();
|
||||
|
||||
spdlog::debug("hkvkCreateDevice final extension count: {0}", pCreateInfo->enabledExtensionCount);
|
||||
spdlog::debug("hkvkCreateDevice final extensions:");
|
||||
|
||||
for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++)
|
||||
spdlog::debug("hkvkCreateDevice {0}", pCreateInfo->ppEnabledExtensionNames[i]);
|
||||
|
||||
// Skip spoofing for Intel Arc
|
||||
Config::Instance()->dxgiSkipSpoofing = true;
|
||||
auto result = o_vkCreateDevice(physicalDevice, pCreateInfo, pAllocator, pDevice);
|
||||
spdlog::debug("hkvkCreateDevice o_vkCreateDevice result: {0:X}", (UINT)result);
|
||||
Config::Instance()->dxgiSkipSpoofing = false;
|
||||
spdlog::debug("hkvkCreateDevice o_vkCreateDevice result: {0:X}", (INT)result);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -813,6 +848,32 @@ static void DetachHooks()
|
||||
o_vkGetPhysicalDeviceProperties2KHR = nullptr;
|
||||
}
|
||||
|
||||
if (o_vkEnumerateInstanceExtensionProperties)
|
||||
{
|
||||
DetourDetach(&(PVOID&)o_vkEnumerateInstanceExtensionProperties, hkvkEnumerateInstanceExtensionProperties);
|
||||
o_vkEnumerateInstanceExtensionProperties = nullptr;
|
||||
}
|
||||
|
||||
if (o_vkEnumerateDeviceExtensionProperties)
|
||||
{
|
||||
DetourDetach(&(PVOID&)o_vkEnumerateDeviceExtensionProperties, hkvkEnumerateDeviceExtensionProperties);
|
||||
o_vkEnumerateDeviceExtensionProperties = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if (o_vkCreateDevice)
|
||||
{
|
||||
DetourDetach(&(PVOID&)o_vkCreateDevice, hkvkCreateDevice);
|
||||
o_vkCreateDevice = nullptr;
|
||||
}
|
||||
|
||||
|
||||
if (o_vkCreateInstance)
|
||||
{
|
||||
DetourDetach(&(PVOID&)o_vkCreateInstance, hkvkCreateInstance);
|
||||
o_vkCreateInstance = nullptr;
|
||||
}
|
||||
|
||||
DetourTransactionCommit();
|
||||
|
||||
FreeLibrary(shared.dll);
|
||||
@@ -887,6 +948,7 @@ static void AttachHooks()
|
||||
o_vkEnumerateInstanceExtensionProperties = reinterpret_cast<PFN_vkEnumerateInstanceExtensionProperties>(DetourFindFunction("vulkan-1.dll", "vkEnumerateInstanceExtensionProperties"));
|
||||
o_vkEnumerateDeviceExtensionProperties = reinterpret_cast<PFN_vkEnumerateDeviceExtensionProperties>(DetourFindFunction("vulkan-1.dll", "vkEnumerateDeviceExtensionProperties"));
|
||||
o_vkCreateDevice = reinterpret_cast<PFN_vkCreateDevice>(DetourFindFunction("vulkan-1.dll", "vkCreateDevice"));
|
||||
o_vkCreateInstance = reinterpret_cast<PFN_vkCreateInstance>(DetourFindFunction("vulkan-1.dll", "vkCreateInstance"));
|
||||
|
||||
if (o_vkEnumerateInstanceExtensionProperties != nullptr || o_vkEnumerateDeviceExtensionProperties != nullptr)
|
||||
{
|
||||
@@ -904,6 +966,9 @@ static void AttachHooks()
|
||||
if (o_vkCreateDevice)
|
||||
DetourAttach(&(PVOID&)o_vkCreateDevice, hkvkCreateDevice);
|
||||
|
||||
if (o_vkCreateInstance)
|
||||
DetourAttach(&(PVOID&)o_vkCreateInstance, hkvkCreateInstance);
|
||||
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
}
|
||||
|
||||
+12
-5
@@ -1310,7 +1310,6 @@ bool SkipSpoofing()
|
||||
void* callers[100];
|
||||
unsigned short frames = CaptureStackBackTrace(0, 100, callers, NULL);
|
||||
HANDLE process = GetCurrentProcess();
|
||||
//std::string list = "slInit|slGetPluginFunction|nvapi_QueryInterface";
|
||||
|
||||
if (SymInitialize(process, NULL, TRUE))
|
||||
{
|
||||
@@ -1365,7 +1364,9 @@ HRESULT WINAPI detGetDesc3(IDXGIAdapter4* This, DXGI_ADAPTER_DESC3* pDesc)
|
||||
std::wstring name(L"NVIDIA GeForce RTX 4090");
|
||||
const wchar_t* szName = name.c_str();
|
||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||
std::memcpy(pDesc->Description, szName, 54);
|
||||
std::memcpy(pDesc->Description, szName, 50);
|
||||
|
||||
spdlog::debug("detGetDesc3 spoofing");
|
||||
}
|
||||
|
||||
AttachToAdapter(This);
|
||||
@@ -1386,7 +1387,9 @@ HRESULT WINAPI detGetDesc2(IDXGIAdapter2* This, DXGI_ADAPTER_DESC2* pDesc)
|
||||
std::wstring name(L"NVIDIA GeForce RTX 4090");
|
||||
const wchar_t* szName = name.c_str();
|
||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||
std::memcpy(pDesc->Description, szName, 54);
|
||||
std::memcpy(pDesc->Description, szName, 50);
|
||||
|
||||
spdlog::debug("detGetDesc2 spoofing");
|
||||
}
|
||||
|
||||
AttachToAdapter(This);
|
||||
@@ -1407,7 +1410,9 @@ HRESULT WINAPI detGetDesc1(IDXGIAdapter1* This, DXGI_ADAPTER_DESC1* pDesc)
|
||||
std::wstring name(L"NVIDIA GeForce RTX 4090");
|
||||
const wchar_t* szName = name.c_str();
|
||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||
std::memcpy(pDesc->Description, szName, 54);
|
||||
std::memcpy(pDesc->Description, szName, 50);
|
||||
|
||||
spdlog::debug("detGetDesc1 spoofing");
|
||||
}
|
||||
|
||||
AttachToAdapter(This);
|
||||
@@ -1428,7 +1433,9 @@ HRESULT WINAPI detGetDesc(IDXGIAdapter* This, DXGI_ADAPTER_DESC* pDesc)
|
||||
std::wstring name(L"NVIDIA GeForce RTX 4090");
|
||||
const wchar_t* szName = name.c_str();
|
||||
std::memset(pDesc->Description, 0, sizeof(pDesc->Description));
|
||||
std::memcpy(pDesc->Description, szName, 54);
|
||||
std::memcpy(pDesc->Description, szName, 50);
|
||||
|
||||
spdlog::debug("detGetDesc spoofing");
|
||||
}
|
||||
|
||||
AttachToAdapter(This);
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "ffx_framegeneration.h"
|
||||
#include "dx12/ffx_api_dx12.h"
|
||||
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <dxgi1_6.h>
|
||||
|
||||
|
||||
Vendored
+1
-1
Submodule external/xess updated: 420343044e...1d593fd8a2
Reference in New Issue
Block a user