Skip to content

Commit

Permalink
Added fixes for Metaphor: ReFantazio using wrong SRV formats for text…
Browse files Browse the repository at this point in the history
…ures
  • Loading branch information
Kaldaien committed Nov 15, 2024
1 parent 6952bbb commit 2057536
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 12 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
24.11.15.2
24.11.15.3
==========
+ Fix various problems with games that use (Low Level) Keyboard hooks thinking
Alt/Tab are stuck.
+ Allow mouselook in games even if Mouse Input is set to Disable in Background
+ Added fixes for Metaphor: ReFantazio using wrong SRV formats for textures

24.11.15.2
==========
+ Use synchronous init when loading ReShade as a plug-in for maximum compat.

Expand Down
4 changes: 2 additions & 2 deletions include/SpecialK/DLL_VERSION.H
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#define SK_YEAR 24
#define SK_MONTH 11
#define SK_DATE 15
#define SK_REV_N 2
#define SK_REV 2
#define SK_REV_N 3
#define SK_REV 3

#ifndef _A2
#define _A2(a) #a
Expand Down
49 changes: 40 additions & 9 deletions src/render/d3d11/hooks/d3d11_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,30 @@ D3D11Dev_CreateShaderResourceView_Override (
pDesc != nullptr &&
pDesc->ViewDimension == D3D11_SRV_DIMENSION_TEXTURE2D)
{
((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Texture2D.MostDetailedMip = 0;
((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Texture2D.MipLevels = (UINT)-1;
SK_ComQIPtr <ID3D11Texture2D>
pTex (pResource);
D3D11_TEXTURE2D_DESC texDesc = {};
pTex->GetDesc (&texDesc);

if (DirectX::IsCompressed (pDesc->Format))
{
if (pDesc->Format == DXGI_FORMAT_BC7_UNORM_SRGB &&
texDesc. Format == DXGI_FORMAT_BC7_UNORM)
{
((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Format = DXGI_FORMAT_BC7_UNORM;
return E_INVALIDARG;
}

((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Texture2D.MostDetailedMip = 0;
((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Texture2D.MipLevels = (UINT)-1;
}

else if (pDesc->Format == DXGI_FORMAT_R8_UNORM &&
(texDesc. Format == DXGI_FORMAT_BC7_UNORM ||
(texDesc. Format == DXGI_FORMAT_BC7_UNORM_SRGB)))
{
return E_INVALIDARG;
}
}

#ifdef _SK_D3D11_VALIDATE_DEVICE_RESOURCES
Expand Down Expand Up @@ -488,8 +510,11 @@ D3D11Dev_CreateShaderResourceView1_Override (
pDesc != nullptr &&
pDesc->ViewDimension == D3D11_SRV_DIMENSION_TEXTURE2D)
{
((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Texture2D.MostDetailedMip = 0;
((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Texture2D.MipLevels = (UINT)-1;
if (DirectX::IsCompressed (pDesc->Format))
{
((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Texture2D.MostDetailedMip = 0;
((D3D11_SHADER_RESOURCE_VIEW_DESC*)pDesc)->Texture2D.MipLevels = (UINT)-1;
}
}

#ifdef _SK_D3D11_VALIDATE_DEVICE_RESOURCES
Expand Down Expand Up @@ -1467,18 +1492,24 @@ D3D11Dev_CreateSamplerState_Override
}
}

#if 1
if (SK_GetCurrentGameID () == SK_GAME_ID::Metaphor)
{
if ( new_desc.Filter <= D3D11_FILTER_ANISOTROPIC &&
if ( new_desc.Filter <= D3D11_FILTER_ANISOTROPIC &&
new_desc.Filter > D3D11_FILTER_MIN_MAG_MIP_POINT &&
(new_desc.ComparisonFunc == D3D11_COMPARISON_ALWAYS ||
new_desc.ComparisonFunc == D3D11_COMPARISON_NEVER) )
{
new_desc.Filter = D3D11_FILTER_ANISOTROPIC;
new_desc.MipLODBias = std::max (0.0f, new_desc.MipLODBias);
new_desc.MaxLOD = D3D11_FLOAT32_MAX;
new_desc.MinLOD = -D3D11_FLOAT32_MAX;
//if (new_desc.AddressU == D3D11_TEXTURE_ADDRESS_WRAP)
{
new_desc.Filter = D3D11_FILTER_ANISOTROPIC;
//new_desc.MipLODBias = std::max (0.0f, new_desc.MipLODBias);
new_desc.MaxLOD = D3D11_FLOAT32_MAX;
new_desc.MinLOD = -D3D11_FLOAT32_MAX;
}
}
}
#endif

switch (new_desc.Filter)
{
Expand Down

0 comments on commit 2057536

Please sign in to comment.