Skip to content

Commit

Permalink
Sped up Starfield Plug-In Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaldaien committed Sep 9, 2023
1 parent 7d9906f commit 1dfd850
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 101 deletions.
13 changes: 6 additions & 7 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
23.9.10.2
23.9.10.x
=========
+ Added PhotoMode Compatibility setting for Starfield

23.9.10.1
=========
+ Added Mipmap LOD Bias and FOV control for Microsoft Store version of Starfield
+ Fixed range and power on LOD Bias control slider in Starfield
[.3] + Sped up Starfield plug-in init
[.3] + Fixed instances of "Removing Corrupted Hook for 'DirectInput8Create'..."
[.2] + Added PhotoMode Compatibility setting for Starfield
[.1] + Added Mipmap LOD Bias and FOV control for Microsoft Store version of Starfield
[.1] + Fixed range and power on LOD Bias control slider in Starfield

23.9.10
=======
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 23
#define SK_MONTH 9
#define SK_DATE 10
#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
6 changes: 3 additions & 3 deletions src/plugins/bethesda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void SK_SEH_InitStarfieldRTs (void)
{
BS_DXGI_FORMAT format;
uint32_t unk04;
const char *bufferName;
const char* bufferName;
uint16_t unk10;
uint16_t unk12;
uint32_t unk14;
Expand Down Expand Up @@ -401,7 +401,7 @@ void SK_SEH_InitStarfieldRTs (void)
__try
{
extern bool __SK_HDR_16BitSwap;
if (StrStrA (buffer_defs [i]->bufferName, "FrameBuffer"))
if (0 == strcmp (buffer_defs [i]->bufferName, "FrameBuffer"))
{
if (__SK_HDR_16BitSwap)
{
Expand All @@ -413,7 +413,7 @@ void SK_SEH_InitStarfieldRTs (void)

for (auto remaster : buffers_to_remaster)
{
if (StrStrIA (buffer_defs [i]->bufferName, remaster) != 0)
if (0 == strcmp (buffer_defs [i]->bufferName, remaster))
{
buffer_defs [i]->format = BS_DXGI_FORMAT::BS_DXGI_FORMAT_R16G16B16A16_FLOAT77;

Expand Down
91 changes: 2 additions & 89 deletions src/render/d3d12/d3d12_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2033,40 +2033,6 @@ _In_ const D3D12_HEAP_DESC *pDesc,
REFIID riid,
_COM_Outptr_opt_ void **ppvHeap)
{
if (pDesc != nullptr) // Not optional, but some games try it anyway :)
{
switch (SK_GetCurrentGameID ())
{
// Reallocate heaps too small for remastering the SwapChain
case SK_GAME_ID::Starfield:
{
SK_ComQIPtr <IDXGISwapChain> pSwapChain (SK_GetCurrentRenderBackend ().swapchain);

if (pSwapChain.p != nullptr)
{
DXGI_SWAP_CHAIN_DESC swapDesc = { };
pSwapChain->GetDesc (&swapDesc);

if (pDesc->SizeInBytes == swapDesc.BufferDesc.Width * swapDesc.BufferDesc.Height * 2)
{
auto desc = *pDesc;

desc.SizeInBytes *= 2;

HRESULT hr =
D3D12Device_CreateHeap_Original (This, &desc, riid, ppvHeap);

if (SUCCEEDED (hr))
return hr;
}
}
} break;

default:
break;
}
}

return
D3D12Device_CreateHeap_Original (This, pDesc, riid, ppvHeap);
}
Expand All @@ -2085,6 +2051,7 @@ _COM_Outptr_opt_ void **ppvResource )
{
if (pDesc != nullptr) // Not optional, but some games try it anyway :)
{
#if 0
switch (SK_GetCurrentGameID ())
{
case SK_GAME_ID::Starfield:
Expand Down Expand Up @@ -2121,6 +2088,7 @@ _COM_Outptr_opt_ void **ppvResource )
}
} break;
}
#endif

if ( ppvResource != nullptr &&
riidResource == IID_ID3D12Resource &&
Expand Down Expand Up @@ -2205,61 +2173,6 @@ _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue,
REFIID riid,
_COM_Outptr_opt_ void **ppvResource )
{
#if 0
switch (SK_GetCurrentGameID ())
{
case SK_GAME_ID::Starfield:
{
auto &rb = SK_GetCurrentRenderBackend ();

SK_ComQIPtr <IDXGISwapChain>
pSwapChain (rb.swapchain);

DXGI_SWAP_CHAIN_DESC swapDesc = { };

if (pSwapChain.p != nullptr)
pSwapChain->GetDesc (&swapDesc);

if (__SK_HDR_16BitSwap && pDesc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && pDesc->Format == DXGI_FORMAT_R8G8B8A8_TYPELESS && ((pDesc->Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET))) && pDesc->Width > 1 && (pDesc->Width != 1024 || pDesc->Height != 1024))
{
D3D12_HEAP_DESC heapDesc =
pHeap->GetDesc ();

SK_LOGi0 (L"D3D12Device_CreatePlacedResource: %hs (%dx%d)", SK_DXGI_FormatToStr (pDesc->Format).data (), pDesc->Width, pDesc->Height);

if (heapDesc.SizeInBytes >= (pDesc->Width * pDesc->Height * 8))
{
auto desc = *pDesc;
desc.Format = DXGI_FORMAT_R16G16B16A16_TYPELESS;

D3D12_CLEAR_VALUE _optimized_clear_value = { };
D3D12_CLEAR_VALUE *_pOptimizedClearValue = nullptr;

if (pOptimizedClearValue != nullptr)
{
_optimized_clear_value = *pOptimizedClearValue;
_optimized_clear_value.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
_optimized_clear_value.DepthStencil = pOptimizedClearValue->DepthStencil;
_optimized_clear_value.Color[0] = pOptimizedClearValue->Color [0]/255.0f;
_optimized_clear_value.Color[1] = pOptimizedClearValue->Color [1]/255.0f;
_optimized_clear_value.Color[2] = pOptimizedClearValue->Color [2]/255.0f;
_optimized_clear_value.Color[3] = pOptimizedClearValue->Color [3]/255.0f;
_pOptimizedClearValue = &_optimized_clear_value;
}

HRESULT hr =
D3D12Device_CreatePlacedResource_Original ( This,
pHeap, HeapOffset, &desc, InitialState,
_pOptimizedClearValue, riid, ppvResource );

if (SUCCEEDED (hr))
return hr;
}
}
} break;
}
#endif

return
D3D12Device_CreatePlacedResource_Original ( This,
pHeap, HeapOffset, pDesc, InitialState,
Expand Down

0 comments on commit 1dfd850

Please sign in to comment.