diff --git a/renderdoc/driver/d3d11/d3d11_common.cpp b/renderdoc/driver/d3d11/d3d11_common.cpp index 44c949c6b..f731bf138 100644 --- a/renderdoc/driver/d3d11/d3d11_common.cpp +++ b/renderdoc/driver/d3d11/d3d11_common.cpp @@ -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; } diff --git a/renderdoc/driver/d3d11/d3d11_device.h b/renderdoc/driver/d3d11/d3d11_device.h index 454271fa6..5152c35f3 100644 --- a/renderdoc/driver/d3d11/d3d11_device.h +++ b/renderdoc/driver/d3d11/d3d11_device.h @@ -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); }; diff --git a/renderdoc/driver/d3d11/d3d11_initstate.cpp b/renderdoc/driver/d3d11/d3d11_initstate.cpp index e920ede68..c6092c6f9 100644 --- a/renderdoc/driver/d3d11/d3d11_initstate.cpp +++ b/renderdoc/driver/d3d11/d3d11_initstate.cpp @@ -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