Skip to content

Commit

Permalink
[CKPE]
Browse files Browse the repository at this point in the history
nop
  • Loading branch information
Perchik71 committed Feb 6, 2025
1 parent ecc69bb commit 65b54b9
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 47 deletions.
11 changes: 9 additions & 2 deletions Creation Kit Platform Extended Core/Core/D3D11Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -187,6 +191,9 @@ namespace CreationKitPlatformExtended
{
auto SamplerDesc = const_cast<D3D11_SAMPLER_DESC*>(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
Expand Down
1 change: 1 addition & 0 deletions Creation Kit Platform Extended Core/Core/D3D11Proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace CreationKitPlatformExtended
D3D11DeviceContextProxy* m_ContextProxy;

float m_MipLODBias;
int m_MaxAnisotropy;

D3D11DeviceProxy(ID3D11Device* Device);
D3D11DeviceProxy(ID3D11Device2* Device);
Expand Down
4 changes: 2 additions & 2 deletions Creation Kit Platform Extended Core/Patches/FO4/CreateDDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace CreationKitPlatformExtended

bool CreateDDSPatch::HasOption() const
{
return false;
return true;
}

bool CreateDDSPatch::HasCanRuntimeDisabled() const
Expand All @@ -147,7 +147,7 @@ namespace CreationKitPlatformExtended

const char* CreateDDSPatch::GetOptionName() const
{
return nullptr;
return "CreationKit:bWarningCreateTexture2D";
}

const char* CreateDDSPatch::GetName() const
Expand Down
52 changes: 12 additions & 40 deletions Creation Kit Platform Extended Core/Patches/SSE/LoadDDSFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace CreationKitPlatformExtended

bool LoadDDSFilePatch::HasOption() const
{
return false;
return true;
}

bool LoadDDSFilePatch::HasCanRuntimeDisabled() const
Expand All @@ -31,7 +31,7 @@ namespace CreationKitPlatformExtended

const char* LoadDDSFilePatch::GetOptionName() const
{
return nullptr;
return "CreationKit:bWarningCreateTexture2D";
}

const char* LoadDDSFilePatch::GetName() const
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace CreationKitPlatformExtended
virtual bool HasDependencies() const;
virtual Array<String> 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,
Expand Down
Binary file modified Creation Kit Platform Extended Core/Version/build_version.txt
Binary file not shown.
Binary file modified Creation Kit Platform Extended Core/Version/resource_version2.h
Binary file not shown.
2 changes: 2 additions & 0 deletions Stuffs/FO4/CreationKitPlatformExtended.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ 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.
bWarningCreateTexture2D=false ; Make CK react to poor texture loading.

; Set charset for font ListView, ListBox, TreeView controls (worked only bUIDarkTheme > 0)
; ANSI_CHARSET 0
Expand Down Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions Stuffs/SSE/CreationKitPlatformExtended.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 65b54b9

Please sign in to comment.