Fix serialisation of number of subresource in D3D11 initial state

* The serialised value changes the number of serialised buffers later, so it
  must be saved exactly right and not post-multiplied with data that won't be
  available during structured import.
This commit is contained in:
baldurk
2018-08-01 16:36:15 +01:00
parent 34b1d0ecf9
commit 05dd4e1946
3 changed files with 24 additions and 6 deletions
+4 -1
View File
@@ -467,7 +467,10 @@ bool D3D11InitParams::IsSupportedVersion(uint64_t ver)
if(ver == CurrentVersion)
return true;
// we can check other older versions we support here.
// 0x0F -> 0x10 - serialised the number of subresources in resource initial states after
// multiplying on sample count rather than before
if(ver == 0x0F)
return true;
return false;
}
+1 -1
View File
@@ -64,7 +64,7 @@ struct D3D11InitParams
D3D_FEATURE_LEVEL FeatureLevels[16];
// check if a frame capture section version is supported
static const uint64_t CurrentVersion = 0xF;
static const uint64_t CurrentVersion = 0x10;
static bool IsSupportedVersion(uint64_t ver);
};
+19 -4
View File
@@ -663,12 +663,27 @@ bool WrappedID3D11Device::Serialise_InitialState(SerialiserType &ser, ResourceId
tex->GetDesc(&desc);
uint32_t NumSubresources = desc.MipLevels * desc.ArraySize;
SERIALISE_ELEMENT(NumSubresources);
bool multisampled = desc.SampleDesc.Count > 1 || desc.SampleDesc.Quality > 0;
if(multisampled)
NumSubresources *= desc.SampleDesc.Count;
// in version 0xF and before, we mistakenly multiplied on the sample count to the number of
// subresources after serialisation - meaning the loop below breaks for pure structured data
// serialisation.
// After version 0x10 we pre-multiply before serialising, because the result is the same either
// way and we don't need the un-multiplied value.
if(ser.VersionAtLeast(0x10))
{
if(multisampled)
NumSubresources *= desc.SampleDesc.Count;
SERIALISE_ELEMENT(NumSubresources);
}
else
{
SERIALISE_ELEMENT(NumSubresources);
if(multisampled)
NumSubresources *= desc.SampleDesc.Count;
}
// this value is serialised here for compatibility with pre-v1.1 captures. In prior versions the
// 'save all initials' option, if disabled, meant a heuristic was used to determine if this