From 65b54b99ee1e60c581dcaa26f17411aca3a4bb29 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 6 Feb 2025 19:00:38 +0300 Subject: [PATCH] [CKPE] nop --- .../Core/D3D11Proxy.cpp | 11 +++- .../Core/D3D11Proxy.h | 1 + .../Patches/FO4/CreateDDS.cpp | 4 +- .../Patches/SSE/LoadDDSFile.cpp | 52 ++++-------------- .../Patches/SSE/LoadDDSFile.h | 2 +- .../Version/build_version.txt | Bin 12 -> 14 bytes .../Version/resource_version2.h | Bin 2004 -> 2006 bytes Stuffs/FO4/CreationKitPlatformExtended.ini | 2 + Stuffs/SSE/CreationKitPlatformExtended.ini | 6 +- 9 files changed, 31 insertions(+), 47 deletions(-) diff --git a/Creation Kit Platform Extended Core/Core/D3D11Proxy.cpp b/Creation Kit Platform Extended Core/Core/D3D11Proxy.cpp index c97637af..bb650df0 100644 --- a/Creation Kit Platform Extended Core/Core/D3D11Proxy.cpp +++ b/Creation Kit Platform Extended Core/Core/D3D11Proxy.cpp @@ -15,8 +15,10 @@ namespace CreationKitPlatformExtended m_Device->GetImmediateContext2(&temp); m_ContextProxy = new D3D11DeviceContextProxy(temp); - m_MipLODBias = std::min(3.f, std::max(-3.f, + m_MipLODBias = std::min(5.f, std::max(-5.f, _READ_OPTION_FLOAT("Graphics", "fMipLODBias", 0.f))); + m_MaxAnisotropy = std::min(16ul, std::max(0ul, + _READ_OPTION_UINT("Graphics", "uMaxAnisotropy", 0))); } D3D11DeviceProxy::D3D11DeviceProxy(ID3D11Device2 *Device) @@ -27,8 +29,10 @@ namespace CreationKitPlatformExtended m_Device->GetImmediateContext2(&temp); m_ContextProxy = new D3D11DeviceContextProxy(temp); - m_MipLODBias = std::min(3.f, std::max(-3.f, + m_MipLODBias = std::min(5.f, std::max(-5.f, _READ_OPTION_FLOAT("Graphics", "fMipLODBias", 0.f))); + m_MaxAnisotropy = std::min(16ul, std::max(0ul, + _READ_OPTION_UINT("Graphics", "uMaxAnisotropy", 0))); } HRESULT STDMETHODCALLTYPE D3D11DeviceProxy::QueryInterface(REFIID riid, void **ppvObj) @@ -187,6 +191,9 @@ namespace CreationKitPlatformExtended { auto SamplerDesc = const_cast(pSamplerDesc); + if (SamplerDesc->Filter == D3D11_FILTER_ANISOTROPIC) + SamplerDesc->MaxAnisotropy = m_MaxAnisotropy; + SamplerDesc->MipLODBias = m_MipLODBias; // mipmap level bias value SamplerDesc->MinLOD = 0.0f; // alternative minimum mipmap level SamplerDesc->MaxLOD = D3D11_FLOAT32_MAX; // alternative maximum mipmap level diff --git a/Creation Kit Platform Extended Core/Core/D3D11Proxy.h b/Creation Kit Platform Extended Core/Core/D3D11Proxy.h index ceebfbc9..a169c201 100644 --- a/Creation Kit Platform Extended Core/Core/D3D11Proxy.h +++ b/Creation Kit Platform Extended Core/Core/D3D11Proxy.h @@ -13,6 +13,7 @@ namespace CreationKitPlatformExtended D3D11DeviceContextProxy* m_ContextProxy; float m_MipLODBias; + int m_MaxAnisotropy; D3D11DeviceProxy(ID3D11Device* Device); D3D11DeviceProxy(ID3D11Device2* Device); diff --git a/Creation Kit Platform Extended Core/Patches/FO4/CreateDDS.cpp b/Creation Kit Platform Extended Core/Patches/FO4/CreateDDS.cpp index a5ea4e08..b218f229 100644 --- a/Creation Kit Platform Extended Core/Patches/FO4/CreateDDS.cpp +++ b/Creation Kit Platform Extended Core/Patches/FO4/CreateDDS.cpp @@ -137,7 +137,7 @@ namespace CreationKitPlatformExtended bool CreateDDSPatch::HasOption() const { - return false; + return true; } bool CreateDDSPatch::HasCanRuntimeDisabled() const @@ -147,7 +147,7 @@ namespace CreationKitPlatformExtended const char* CreateDDSPatch::GetOptionName() const { - return nullptr; + return "CreationKit:bWarningCreateTexture2D"; } const char* CreateDDSPatch::GetName() const diff --git a/Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.cpp b/Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.cpp index ccdafb4d..376308fe 100644 --- a/Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.cpp +++ b/Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.cpp @@ -21,7 +21,7 @@ namespace CreationKitPlatformExtended bool LoadDDSFilePatch::HasOption() const { - return false; + return true; } bool LoadDDSFilePatch::HasCanRuntimeDisabled() const @@ -31,7 +31,7 @@ namespace CreationKitPlatformExtended const char* LoadDDSFilePatch::GetOptionName() const { - return nullptr; + return "CreationKit:bWarningCreateTexture2D"; } const char* LoadDDSFilePatch::GetName() const @@ -81,63 +81,35 @@ namespace CreationKitPlatformExtended return false; } - HRESULT LoadDDSFilePatch::TryCheckArgs(__int64 a2) + void LoadDDSFilePatch::FailedMessage(HRESULT error, __int64 a2) { auto Resource = ((EditorAPI::SkyrimSpectialEdition::BSResourceNiBinaryStream*)a2); __try { - if (!Resource->GetStream()) - { - _CONSOLE("ERROR: DirectX::LoadFromDDSFile empty stream."); - return E_FAIL; - } - - auto FileName = Resource->GetStream()->GetFileName(); - if (!FileName.data) - { - _CONSOLE("ERROR: DirectX::LoadFromDDSFile empty filename."); - return E_FAIL; - } - - FileName.data[0] = FileName.data[0]; + _CONSOLE("Error while trying to load texture \"%s\" due to an incompatible file format or something else." + " (0x%08X) \"%s\".", Resource->GetStream()->GetFileName().data, error, _com_error(error).ErrorMessage()); } __except (EXCEPTION_EXECUTE_HANDLER) { - _CONSOLE("ERROR: DirectX::LoadFromDDSFile fatal error has occurred (invalid pointer Filename or NiStream)."); - return E_FAIL; + _CONSOLE("Error while trying to load texture, but from the bad .nif, unknown filename or your mod is broken."); } - - return S_OK; } HRESULT LoadDDSFilePatch::sub(__int64 a1, __int64 a2, __int64 a3, __int64 a4, unsigned int a5, int a6) { - if (!a1 || !a2) - return E_FAIL; - - auto Resource = ((EditorAPI::SkyrimSpectialEdition::BSResourceNiBinaryStream*)a2); - AssertMsg(SUCCEEDED(TryCheckArgs(a2)), "Fatal load unknown texture"); - - if (!Resource->GetStream()->GetFileName().data[0]) - // Skips empty filename - return E_FAIL; - // Modified DirectX::LoadFromDDSFile from DDSTextureLoader (DirectXTex) HRESULT hr = ((HRESULT(__fastcall*)(__int64, __int64, __int64, __int64, unsigned int, int))pointer_LoadDDSFile_sub) (a1, a2, a3, a4, a5, a6); + if (FAILED(hr)) { - _CONSOLE("ERROR: DirectX::LoadFromDDSFile returned failed (0x%08X) \"%s\" \"%s\".", - hr, _com_error(hr).ErrorMessage(), Resource->GetStream()->GetFileName().data); - - AssertMsgVa((hr == E_FAIL), - "Fatal error while trying to load texture \"%s\" due to an incompatible file format. This " - "indicates a problem with your mod or game files. Note that B5G6R5 and B5G5R5A1 texture " - "formats are not supported on Windows 7. HR = 0x%08X.", - Resource->GetStream()->GetFileName().data, hr); + auto Resource = ((EditorAPI::SkyrimSpectialEdition::BSResourceNiBinaryStream*)a2); + if (!Resource->GetStream()->GetFileName().data[0]) + // Skips + return E_FAIL; - return hr; + FailedMessage(hr, a2); } //_CONSOLE("DirectX::LoadFromDDSFile opened file \"%s\".", Resource->GetStream()->GetFileName().data); diff --git a/Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.h b/Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.h index c45c656a..d410e299 100644 --- a/Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.h +++ b/Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.h @@ -28,7 +28,7 @@ namespace CreationKitPlatformExtended virtual bool HasDependencies() const; virtual Array GetDependencies() const; - static HRESULT TryCheckArgs(__int64 a2); + static void FailedMessage(HRESULT error, __int64 a2); static HRESULT sub(__int64 a1, __int64 a2, __int64 a3, __int64 a4, unsigned int a5, int a6); protected: virtual bool QueryFromPlatform(EDITOR_EXECUTABLE_TYPE eEditorCurrentVersion, diff --git a/Creation Kit Platform Extended Core/Version/build_version.txt b/Creation Kit Platform Extended Core/Version/build_version.txt index 96f7b18961a1f62175b520e36619a084cbeb7ce8..96a058da1b23946ed35abe8614af419287648dc7 100644 GIT binary patch literal 14 TcmezW&yc|Y2n`u{8Mqh#A^-x{ literal 12 QcmezW&yoQIc^SAE033<}zyJUM diff --git a/Creation Kit Platform Extended Core/Version/resource_version2.h b/Creation Kit Platform Extended Core/Version/resource_version2.h index f3fedf675b4350132770e5f14fe9b766930ec170..f7a54c6b95ce8809e1d9db21a155965308c61b8e 100644 GIT binary patch delta 32 kcmcb@e~o{`J!Wo01_LnUW#F33$SgfMf>mm>49gB?0E 0) ; ANSI_CHARSET 0 @@ -67,6 +68,7 @@ bGenerateFullDump=false ; Generates a full dump with more information, inclu [Graphics] fMipLODBias=-1.3 ; Force set mipmap level bias value (value must be [-3.0 : 3.0] where there is less than 0.0, the further away the 0 mipmap is). +uMaxAnisotropy=16 ; Distortion visible in the texels of a three-dimensional object whose surface is oriented at an angle relative to the screen plane is called anisotropy (value must be [0 : 16]). [FaceGen] bAutoCompressionDDS=true ; Texture compression during generation diff --git a/Stuffs/SSE/CreationKitPlatformExtended.ini b/Stuffs/SSE/CreationKitPlatformExtended.ini index 2232bba0..be8598b5 100644 --- a/Stuffs/SSE/CreationKitPlatformExtended.ini +++ b/Stuffs/SSE/CreationKitPlatformExtended.ini @@ -22,9 +22,10 @@ bAllowMasterESP=true ; Allow ESP files to act as master files while saving. bUIClassicTheme=false ; Enable classic theme. Incompatible with bUIDarkTheme and may cause graphical problems. bUIDarkTheme=true ; Enable dark theme. Requires a Windows theme with styling (Aero) to be enabled and may cause graphical problems. uUIDarkThemeId=1 ; Theme version, 0 - lighter, 1 - darker, 2 - night blue, 3 - custom. -bLipDebugOutput=false ; Enable verbose logging output when generating LIP files (In version 1.6.1130, does not work). +bLipDebugOutput=false ; Enable verbose logging output when generating LIP files (In version 1.6.1130 and later, does not work). bOwnArchiveLoader=true ; Loading mod archives. bNavMeshPseudoDelete=false ; Remove a triangle from a navmesh without deleting it. +bWarningCreateTexture2D=false ; Make CK react to poor texture loading. ; Options that are linked to the version of the editor, read the description @@ -58,7 +59,8 @@ nCharset=1 bGenerateFullDump=false ; Generates a full dump with more information, including personal information. Use it yourself to find the cause of the crash. Tool WinDbg x64 from Windows SDK. [Graphics] -fMipLODBias=-1.3 ; Force set mipmap level bias value (value must be [-3.0 : 3.0] where there is less than 0.0, the further away the 0 mipmap is). +fMipLODBias=-1.3 ; Force set mipmap level bias value (value must be [-5.0 : 5.0] where there is less than 0.0, the further away the 0 mipmap is). +uMaxAnisotropy=16 ; Distortion visible in the texels of a three-dimensional object whose surface is oriented at an angle relative to the screen plane is called anisotropy (value must be [0 : 16]). [FaceGen] bAutoCompressionDDS=true ; Texture compression during generation