Vulkan CP: Override frame traces if renderdoc is attached

This commit is contained in:
Dr. Chat 2016-05-23 13:16:13 -05:00
parent 729152a58b
commit 5f764730ae
3 changed files with 20 additions and 11 deletions

View File

@ -84,9 +84,9 @@ class CommandProcessor {
swap_request_handler_ = fn;
}
void RequestFrameTrace(const std::wstring& root_path);
void BeginTracing(const std::wstring& root_path);
void EndTracing();
virtual void RequestFrameTrace(const std::wstring& root_path);
virtual void BeginTracing(const std::wstring& root_path);
virtual void EndTracing();
void InitializeRingBuffer(uint32_t ptr, uint32_t page_count);
void EnableReadPointerWriteBack(uint32_t ptr, uint32_t block_size);

View File

@ -37,9 +37,22 @@ VulkanCommandProcessor::VulkanCommandProcessor(
VulkanCommandProcessor::~VulkanCommandProcessor() = default;
void VulkanCommandProcessor::RequestFrameTrace(const std::wstring& root_path) {
// Override traces if renderdoc is attached.
if (device_->is_renderdoc_attached()) {
trace_requested_ = true;
return;
}
return CommandProcessor::RequestFrameTrace(root_path);
}
void VulkanCommandProcessor::ClearCaches() {
CommandProcessor::ClearCaches();
auto status = vkQueueWaitIdle(queue_);
CheckResult(status, "vkQueueWaitIdle");
buffer_cache_->ClearCache();
pipeline_cache_->ClearCache();
render_cache_->ClearCache();
@ -349,12 +362,6 @@ void VulkanCommandProcessor::PerformSwap(uint32_t frontbuffer_ptr,
if (device_->is_renderdoc_attached() && capturing_) {
device_->EndRenderDocFrameCapture();
capturing_ = false;
// HACK(DrChat): Used b/c I disabled trace saving code in the CP.
// Remove later.
if (!trace_writer_.is_open()) {
trace_state_ = TraceState::kDisabled;
}
}
if (queue_mutex_) {
queue_mutex_->unlock();
@ -459,13 +466,13 @@ bool VulkanCommandProcessor::IssueDraw(PrimitiveType primitive_type,
static uint32_t frame = 0;
if (device_->is_renderdoc_attached() && !capturing_ &&
(FLAGS_vulkan_renderdoc_capture_all ||
trace_state_ == TraceState::kSingleFrame)) {
(FLAGS_vulkan_renderdoc_capture_all || trace_requested_)) {
if (queue_mutex_) {
queue_mutex_->lock();
}
capturing_ = true;
trace_requested_ = false;
device_->BeginRenderDocFrameCapture();
if (queue_mutex_) {

View File

@ -49,6 +49,7 @@ class VulkanCommandProcessor : public CommandProcessor {
kernel::KernelState* kernel_state);
~VulkanCommandProcessor() override;
virtual void RequestFrameTrace(const std::wstring& root_path) override;
void ClearCaches() override;
RenderCache* render_cache() { return render_cache_.get(); }
@ -103,6 +104,7 @@ class VulkanCommandProcessor : public CommandProcessor {
// Last copy base address, for debugging only.
uint32_t last_copy_base_ = 0;
bool capturing_ = false;
bool trace_requested_ = false;
std::unique_ptr<BufferCache> buffer_cache_;
std::unique_ptr<PipelineCache> pipeline_cache_;