mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Update vulkan replay initialisation to new RDCFile mechanism
This commit is contained in:
@@ -125,6 +125,16 @@ void VkMarkerRegion::End(VkCommandBuffer cmd)
|
||||
ObjDisp(scope.cmd)->CmdDebugMarkerEndEXT(Unwrap(scope.cmd));
|
||||
}
|
||||
|
||||
bool VkInitParams::IsSupportedVersion(uint64_t ver)
|
||||
{
|
||||
if(ver == CurrentVersion)
|
||||
return true;
|
||||
|
||||
// we can check other older versions we support here.
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
VkAccessFlags MakeAccessMask(VkImageLayout layout)
|
||||
{
|
||||
switch(layout)
|
||||
@@ -1439,3 +1449,18 @@ StencilOp MakeStencilOp(VkStencilOp op)
|
||||
|
||||
return StencilOp::Keep;
|
||||
}
|
||||
|
||||
template <typename SerialiserType>
|
||||
void DoSerialise(SerialiserType &ser, VkInitParams &el)
|
||||
{
|
||||
SERIALISE_MEMBER(AppName);
|
||||
SERIALISE_MEMBER(EngineName);
|
||||
SERIALISE_MEMBER(AppVersion);
|
||||
SERIALISE_MEMBER(EngineVersion);
|
||||
SERIALISE_MEMBER(APIVersion);
|
||||
SERIALISE_MEMBER(Layers);
|
||||
SERIALISE_MEMBER(Extensions);
|
||||
SERIALISE_MEMBER(InstanceID);
|
||||
}
|
||||
|
||||
INSTANTIATE_SERIALISE_TYPE(VkInitParams);
|
||||
@@ -37,30 +37,26 @@
|
||||
using std::vector;
|
||||
using std::list;
|
||||
|
||||
struct VkInitParams : public RDCInitParams
|
||||
struct VkInitParams
|
||||
{
|
||||
VkInitParams();
|
||||
ReplayStatus Serialise();
|
||||
|
||||
void Set(const VkInstanceCreateInfo *pCreateInfo, ResourceId inst);
|
||||
|
||||
static const uint32_t VK_SERIALISE_VERSION = 0x0000006;
|
||||
|
||||
// backwards compatibility for old logs described at the declaration of this array
|
||||
static const uint32_t VK_NUM_SUPPORTED_OLD_VERSIONS = 1;
|
||||
static const uint32_t VK_OLD_VERSIONS[VK_NUM_SUPPORTED_OLD_VERSIONS];
|
||||
|
||||
// version number internal to vulkan stream
|
||||
uint32_t SerialiseVersion;
|
||||
|
||||
string AppName, EngineName;
|
||||
std::string AppName, EngineName;
|
||||
uint32_t AppVersion, EngineVersion, APIVersion;
|
||||
|
||||
vector<string> Layers;
|
||||
vector<string> Extensions;
|
||||
std::vector<std::string> Layers;
|
||||
std::vector<std::string> Extensions;
|
||||
ResourceId InstanceID;
|
||||
|
||||
// check if a frame capture section version is supported
|
||||
static const uint64_t CurrentVersion = 0x7;
|
||||
static bool IsSupportedVersion(uint64_t ver);
|
||||
};
|
||||
|
||||
DECLARE_REFLECTION_STRUCT(VkInitParams);
|
||||
|
||||
struct VulkanDrawcallTreeNode
|
||||
{
|
||||
VulkanDrawcallTreeNode() {}
|
||||
@@ -241,6 +237,7 @@ private:
|
||||
VulkanReplay m_Replay;
|
||||
|
||||
VkInitParams m_InitParams;
|
||||
uint64_t m_SectionVersion;
|
||||
|
||||
VkResourceRecord *m_FrameCaptureRecord;
|
||||
Chunk *m_HeaderChunk;
|
||||
@@ -700,7 +697,7 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
WrappedVulkan(const char *logFilename);
|
||||
WrappedVulkan();
|
||||
virtual ~WrappedVulkan();
|
||||
|
||||
ResourceId GetContextResourceID() { return m_FrameCaptureRecord->GetResourceID(); }
|
||||
@@ -717,11 +714,11 @@ public:
|
||||
|
||||
bool ReleaseResource(WrappedVkRes *res);
|
||||
|
||||
ReplayStatus Initialise(VkInitParams ¶ms);
|
||||
uint32_t GetLogVersion() { return m_InitParams.SerialiseVersion; }
|
||||
ReplayStatus Initialise(VkInitParams ¶ms, uint64_t sectionVersion);
|
||||
uint64_t GetLogVersion() { return m_SectionVersion; }
|
||||
void Shutdown();
|
||||
void ReplayLog(uint32_t startEventID, uint32_t endEventID, ReplayLogType replayType);
|
||||
void ReadLogInitialisation();
|
||||
void ReadLogInitialisation(RDCFile *rdc);
|
||||
|
||||
FrameRecord &GetFrameRecord() { return m_FrameRecord; }
|
||||
const APIEvent &GetEvent(uint32_t eventID);
|
||||
|
||||
@@ -424,7 +424,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev)
|
||||
// during capture we only need one text descriptor set, so rather than
|
||||
// trying to wait and steal descriptors from a user-side pool, we just
|
||||
// create our own very small pool.
|
||||
if(m_State >= WRITING)
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
descpoolInfo.maxSets = 2;
|
||||
descpoolInfo.poolSizeCount = ARRAY_COUNT(captureDescPoolTypes);
|
||||
@@ -997,7 +997,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev)
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
// if we're writing, only create text-rendering related resources,
|
||||
// then tidy up early and return
|
||||
if(m_State >= WRITING)
|
||||
if(IsCaptureMode(m_State))
|
||||
{
|
||||
{
|
||||
VkDescriptorSetLayoutBinding layoutBinding[] = {
|
||||
|
||||
@@ -361,7 +361,7 @@ private:
|
||||
static const uint32_t FONT_TEX_WIDTH = 256;
|
||||
static const uint32_t FONT_TEX_HEIGHT = 128;
|
||||
|
||||
LogState m_State;
|
||||
CaptureState m_State;
|
||||
|
||||
float m_FontCharAspect;
|
||||
float m_FontCharSize;
|
||||
|
||||
@@ -163,7 +163,7 @@ VkResult VKAPI_CALL hooked_vkCreateInstance(const VkInstanceCreateInfo *pCreateI
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkInstance *pInstance)
|
||||
{
|
||||
WrappedVulkan *core = new WrappedVulkan("");
|
||||
WrappedVulkan *core = new WrappedVulkan();
|
||||
return core->vkCreateInstance(pCreateInfo, pAllocator, pInstance);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "driver/ihv/amd/amd_isa.h"
|
||||
#include "maths/camera.h"
|
||||
#include "maths/matrix.h"
|
||||
#include "serialise/rdcfile.h"
|
||||
#include "strings/string_utils.h"
|
||||
#include "vk_core.h"
|
||||
#include "vk_debug.h"
|
||||
@@ -658,9 +659,9 @@ APIProperties VulkanReplay::GetAPIProperties()
|
||||
return ret;
|
||||
}
|
||||
|
||||
void VulkanReplay::ReadLogInitialisation()
|
||||
void VulkanReplay::ReadLogInitialisation(RDCFile *rdc)
|
||||
{
|
||||
m_pDriver->ReadLogInitialisation();
|
||||
m_pDriver->ReadLogInitialisation(rdc);
|
||||
}
|
||||
|
||||
void VulkanReplay::ReplayLog(uint32_t endEventID, ReplayLogType replayType)
|
||||
@@ -734,21 +735,6 @@ ResourceId VulkanReplay::GetLiveID(ResourceId id)
|
||||
return m_pDriver->GetResourceManager()->GetLiveID(id);
|
||||
}
|
||||
|
||||
void VulkanReplay::InitCallstackResolver()
|
||||
{
|
||||
m_pDriver->GetMainSerialiser()->InitCallstackResolver();
|
||||
}
|
||||
|
||||
bool VulkanReplay::HasCallstacks()
|
||||
{
|
||||
return m_pDriver->GetMainSerialiser()->HasCallstacks();
|
||||
}
|
||||
|
||||
Callstack::StackResolver *VulkanReplay::GetCallstackResolver()
|
||||
{
|
||||
return m_pDriver->GetMainSerialiser()->GetCallstackResolver();
|
||||
}
|
||||
|
||||
FrameRecord VulkanReplay::GetFrameRecord()
|
||||
{
|
||||
return m_pDriver->GetFrameRecord();
|
||||
@@ -5345,7 +5331,7 @@ void VulkanReplay::SetProxyBufferData(ResourceId bufid, byte *data, size_t dataS
|
||||
VULKANNOTIMP("SetProxyTextureData");
|
||||
}
|
||||
|
||||
ReplayStatus Vulkan_CreateReplayDevice(const char *logfile, IReplayDriver **driver)
|
||||
ReplayStatus Vulkan_CreateReplayDevice(RDCFile *rdc, IReplayDriver **driver)
|
||||
{
|
||||
RDCDEBUG("Creating a VulkanReplay replay device");
|
||||
|
||||
@@ -5369,28 +5355,53 @@ ReplayStatus Vulkan_CreateReplayDevice(const char *logfile, IReplayDriver **driv
|
||||
}
|
||||
|
||||
VkInitParams initParams;
|
||||
RDCDriver driverType = RDC_Vulkan;
|
||||
string driverName = "VulkanReplay";
|
||||
uint64_t machineIdent = 0;
|
||||
if(logfile)
|
||||
|
||||
uint64_t ver = VkInitParams::CurrentVersion;
|
||||
|
||||
// if we have an RDCFile, open the frame capture section and serialise the init params.
|
||||
// if not, we're creating a proxy-capable device so use default-initialised init params.
|
||||
if(rdc)
|
||||
{
|
||||
auto status = RenderDoc::Inst().FillInitParams(logfile, driverType, driverName, machineIdent,
|
||||
(RDCInitParams *)&initParams);
|
||||
int sectionIdx = rdc->SectionIndex(SectionType::FrameCapture);
|
||||
|
||||
if(status != ReplayStatus::Succeeded)
|
||||
return status;
|
||||
if(sectionIdx < 0)
|
||||
return ReplayStatus::InternalError;
|
||||
|
||||
ver = rdc->GetSectionProperties(sectionIdx).version;
|
||||
|
||||
if(!VkInitParams::IsSupportedVersion(ver))
|
||||
{
|
||||
RDCERR("Incompatible Vulkan serialise version %llu", ver);
|
||||
return ReplayStatus::APIUnsupported;
|
||||
}
|
||||
|
||||
StreamReader *reader = rdc->ReadSection(sectionIdx);
|
||||
|
||||
ReadSerialiser ser(reader, Ownership::Stream);
|
||||
|
||||
SystemChunk chunk = ser.ReadChunk<SystemChunk>();
|
||||
|
||||
if(chunk != SystemChunk::DriverInit)
|
||||
{
|
||||
RDCERR("Expected to get a DriverInit chunk, instead got %u", chunk);
|
||||
return ReplayStatus::FileCorrupted;
|
||||
}
|
||||
|
||||
SERIALISE_ELEMENT(initParams);
|
||||
|
||||
if(ser.IsErrored())
|
||||
{
|
||||
RDCERR("Failed reading driver init params.");
|
||||
return ReplayStatus::FileIOFailed;
|
||||
}
|
||||
}
|
||||
|
||||
// initParams.SerialiseVersion is guaranteed to be valid/supported since otherwise the
|
||||
// FillInitParams (which calls VkInitParams::Serialise) would have failed above, so no need to
|
||||
// check it here.
|
||||
|
||||
InitReplayTables(module);
|
||||
|
||||
VulkanReplay::PreDeviceInitCounters();
|
||||
|
||||
WrappedVulkan *vk = new WrappedVulkan(logfile);
|
||||
ReplayStatus status = vk->Initialise(initParams);
|
||||
WrappedVulkan *vk = new WrappedVulkan();
|
||||
ReplayStatus status = vk->Initialise(initParams, ver);
|
||||
|
||||
if(status != ReplayStatus::Succeeded)
|
||||
{
|
||||
@@ -5400,7 +5411,7 @@ ReplayStatus Vulkan_CreateReplayDevice(const char *logfile, IReplayDriver **driv
|
||||
|
||||
RDCLOG("Created device.");
|
||||
VulkanReplay *replay = vk->GetReplay();
|
||||
replay->SetProxy(logfile == NULL);
|
||||
replay->SetProxy(rdc == NULL);
|
||||
|
||||
*driver = (IReplayDriver *)replay;
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ public:
|
||||
const VKPipe::State &GetVulkanPipelineState() { return m_VulkanPipelineState; }
|
||||
void FreeTargetResource(ResourceId id);
|
||||
|
||||
void ReadLogInitialisation();
|
||||
void ReadLogInitialisation(RDCFile *rdc);
|
||||
void ReplayLog(uint32_t endEventID, ReplayLogType replayType);
|
||||
|
||||
vector<uint32_t> GetPassEvents(uint32_t eventID);
|
||||
|
||||
@@ -89,12 +89,10 @@ static void StripUnwantedLayers(vector<string> &Layers)
|
||||
}
|
||||
}
|
||||
|
||||
ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms)
|
||||
ReplayStatus WrappedVulkan::Initialise(VkInitParams ¶ms, uint64_t sectionVersion)
|
||||
{
|
||||
if(m_pSerialiser->HasError())
|
||||
return ReplayStatus::FileIOFailed;
|
||||
|
||||
m_InitParams = params;
|
||||
m_SectionVersion = sectionVersion;
|
||||
|
||||
params.AppName = string("RenderDoc @ ") + params.AppName;
|
||||
params.EngineName = string("RenderDoc @ ") + params.EngineName;
|
||||
|
||||
Reference in New Issue
Block a user