Skip to content

Commit

Permalink
Fixed Starfield HDR remastering artifacts by ignoring compute-only re…
Browse files Browse the repository at this point in the history
…sources
  • Loading branch information
Kaldaien committed Sep 8, 2023
1 parent 5e3e180 commit bfd9f6e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 26 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
23.9.7
23.9.7.1
========
+ Fixed a few visual glitches in Starfield HDR remastering, by restricting the feature
to render-passes only and ignoring compute-only resources.

The resolution restrictions are not necessary when ignoring compute, and have been removed.

23.9.7
======
+ Added HDR Pipeline Remastering to Starfield

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 7
#define SK_REV_N 0
#define SK_REV 0
#define SK_REV_N 1
#define SK_REV 1

#ifndef _A2
#define _A2(a) #a
Expand Down
55 changes: 32 additions & 23 deletions src/render/d3d12/d3d12_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2043,27 +2043,27 @@ _COM_Outptr_opt_ void **ppvResource )
{
if (pDesc != nullptr) // Not optional, but some games try it anyway :)
{
switch (SK_GetCurrentGameID ())
{
case SK_GAME_ID::Starfield:
{
if (__SK_HDR_16BitSwap && pDesc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && pDesc->Format == DXGI_FORMAT_R8G8B8A8_TYPELESS)
{
SK_LOGi0 (L"D3D12Device_CreateCommittedResource: %hs (%dx%d)", SK_DXGI_FormatToStr (pDesc->Format).data (), pDesc->Width, pDesc->Height);

auto desc = *pDesc;
desc.Format = DXGI_FORMAT_R16G16B16A16_TYPELESS;

HRESULT hr =
D3D12Device_CreateCommittedResource_Original ( This,
pHeapProperties, HeapFlags, &desc, InitialResourceState,
pOptimizedClearValue, riidResource, ppvResource );

if (SUCCEEDED (hr))
return hr;
}
} break;
}
//switch (SK_GetCurrentGameID ())
//{
// case SK_GAME_ID::Starfield:
// {
// if (__SK_HDR_16BitSwap && pDesc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && pDesc->Format == DXGI_FORMAT_R8G8B8A8_TYPELESS)
// {
// SK_LOGi0 (L"D3D12Device_CreateCommittedResource: %hs (%dx%d)", SK_DXGI_FormatToStr (pDesc->Format).data (), pDesc->Width, pDesc->Height);
//
// auto desc = *pDesc;
// desc.Format = DXGI_FORMAT_R16G16B16A16_TYPELESS;
//
// HRESULT hr =
// D3D12Device_CreateCommittedResource_Original ( This,
// pHeapProperties, HeapFlags, &desc, InitialResourceState,
// pOptimizedClearValue, riidResource, ppvResource );
//
// if (SUCCEEDED (hr))
// return hr;
// }
// } break;
//}

if ( ppvResource != nullptr &&
riidResource == IID_ID3D12Resource &&
Expand Down Expand Up @@ -2158,8 +2158,17 @@ _COM_Outptr_opt_ void **ppvResource )
{
case SK_GAME_ID::Starfield:
{
if (__SK_HDR_16BitSwap && pDesc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D && pDesc->Format == DXGI_FORMAT_R8G8B8A8_TYPELESS && (pDesc->Width > 1024 || pDesc->Height > 1024) && ( ( pDesc->Flags & ( D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET |
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS ) ) ) )
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->Height == swapDesc.BufferDesc.Height && */((pDesc->Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET))))
{
SK_LOGi0 (L"D3D12Device_CreatePlacedResource: %hs (%dx%d)", SK_DXGI_FormatToStr (pDesc->Format).data (), pDesc->Width, pDesc->Height);

Expand Down

0 comments on commit bfd9f6e

Please sign in to comment.