Skip to content

Commit

Permalink
Active and deactive trimming drawcalls
Browse files Browse the repository at this point in the history
  • Loading branch information
locke-lunarg committed Aug 22, 2024
1 parent bf029b2 commit 63b0e0c
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
42 changes: 42 additions & 0 deletions framework/encode/capture_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,30 @@ void CommonCaptureManager::CheckContinueCaptureForWriteMode(format::ApiFamilyId
}
}

void CommonCaptureManager::DeactivateTrimmingDrawcalls()
{
if (trim_enabled_)
{
if ((capture_mode_ & kModeWrite) == kModeWrite)
{
// Stop recording and close file.
DeactivateTrimming();
GFXRECON_LOG_INFO("Finished recording graphics API capture");

// No more trim ranges to capture. Capture can be disabled and resources can be released.
trim_enabled_ = false;
trim_boundary_ = CaptureSettings::TrimBoundary::kUnknown;
capture_mode_ = kModeDisabled;
// Clean up all of the capture manager's state trackers
for (auto& manager_it : api_capture_managers_)
{
manager_it.first->DestroyStateTracker();
}
compressor_ = nullptr;
}
}
}

void CommonCaptureManager::CheckStartCaptureForTrackMode(format::ApiFamilyId api_family,
uint32_t current_boundary_count)
{
Expand Down Expand Up @@ -783,6 +807,24 @@ void CommonCaptureManager::CheckStartCaptureForTrackMode(format::ApiFamilyId api
}
}

void CommonCaptureManager::ActivateTrimmingDrawcalls(format::ApiFamilyId api_family)
{
if (((capture_mode_ & kModeWrite) != kModeWrite) && ((capture_mode_ & kModeTrack) == kModeTrack))
{
bool success = CreateCaptureFile(api_family, CreateTrimDrawcallsFilename(base_filename_, trim_drawcalls_));
if (success)
{
ActivateTrimming();
}
else
{
GFXRECON_LOG_FATAL("Failed to initialize capture for trim drawcalls; capture has been disabled");
trim_enabled_ = false;
capture_mode_ = kModeDisabled;
}
}
}

bool CommonCaptureManager::ShouldTriggerScreenshot()
{
bool triger_screenshot = false;
Expand Down
4 changes: 4 additions & 0 deletions framework/encode/capture_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ class CommonCaptureManager

void CheckStartCaptureForTrackMode(format::ApiFamilyId api_family, uint32_t current_boundary_count);

void ActivateTrimmingDrawcalls(format::ApiFamilyId api_family);

void DeactivateTrimmingDrawcalls();

bool IsTrimHotkeyPressed();

CaptureSettings::RuntimeTriggerState GetRuntimeTriggerState();
Expand Down
4 changes: 4 additions & 0 deletions framework/encode/d3d12_capture_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1821,6 +1821,8 @@ void D3D12CaptureManager::OverrideID3D12CommandQueue_ExecuteCommandLists(ID3D12C
CaptureSettings::TrimDrawcalls trim_drawcalls = GetTrimDrawcalls();
if (common_manager_->GetQueueSubmitCount() == trim_drawcalls.submit_index)
{
common_manager_->ActivateTrimmingDrawcalls(format::ApiFamilyId::ApiFamily_D3D12);

std::vector<ID3D12CommandList*> cmdlists;

// target of splitted
Expand All @@ -1841,6 +1843,8 @@ void D3D12CaptureManager::OverrideID3D12CommandQueue_ExecuteCommandLists(ID3D12C

Encode_ID3D12CommandQueue_ExecuteCommandLists(wrapper, cmdlists.size(), cmdlists.data());

common_manager_->DeactivateTrimmingDrawcalls();

cmdlists.clear();

// after of splitted and lists
Expand Down

0 comments on commit 63b0e0c

Please sign in to comment.