Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cdl: fix problems found in application testing #103

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/generators/command_recorder_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ def generateSource(self):
out.append(f' for (uint32_t j = 0; j < {vkmember.fixedSizeArray[0]}; ++j) {{\n')
out.append(f' ptr[i].{vkmember.name}[j] = {src_struct}.{vkmember.name}[j];\n')
out.append(' }\n')
elif vkmember.pointer and 'void' != vkmember.type and vkmember.name != 'pNext':
# https://github.com/LunarG/CrashDiagnosticLayer/issues/102 we need to deep copy the pNext chain here
elif vkmember.name == 'pNext':
out.append(f' ptr[i].{vkmember.name} = nullptr; // pNext deep copy not implemented\n')
elif vkmember.pointer and 'void' != vkmember.type:
out.append(f' ptr[i].{vkmember.name} = nullptr;\n')
out.append(f' if ({src_struct}.{vkmember.name}) {{\n')
if vkmember.length is not None and len(vkmember.length) > 0:
Expand Down
20 changes: 18 additions & 2 deletions src/checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,42 @@ std::unique_ptr<Checkpoint> BufferMarkerCheckpointMgr::Allocate(uint32_t initial
return checkpoint;
}

void BufferMarkerCheckpointMgr::Free(Checkpoint &c) {}
void BufferMarkerCheckpointMgr::Free(Checkpoint &c) {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
checkpoint_data_.erase(c.Id());
}

void BufferMarkerCheckpointMgr::WriteTop(Checkpoint &c, VkCommandBuffer cmd, uint32_t value) {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);

auto iter = checkpoint_data_.find(c.Id());
assert(iter != checkpoint_data_.end());
iter->second.top_marker->Write(cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, value);
}

void BufferMarkerCheckpointMgr::WriteBottom(Checkpoint &c, VkCommandBuffer cmd, uint32_t value) {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
auto iter = checkpoint_data_.find(c.Id());
assert(iter != checkpoint_data_.end());
iter->second.bottom_marker->Write(cmd, VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, value);
}

uint32_t BufferMarkerCheckpointMgr::ReadTop(const Checkpoint &c) const {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
auto iter = checkpoint_data_.find(c.Id());
assert(iter != checkpoint_data_.end());
return iter->second.top_marker->Read();
}

uint32_t BufferMarkerCheckpointMgr::ReadBottom(const Checkpoint &c) const {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
auto iter = checkpoint_data_.find(c.Id());
assert(iter != checkpoint_data_.end());
return iter->second.bottom_marker->Read();
}

void BufferMarkerCheckpointMgr::Reset(Checkpoint &c) {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
auto iter = checkpoint_data_.find(c.Id());
assert(iter != checkpoint_data_.end());
iter->second.top_marker->Write(0);
Expand All @@ -95,11 +104,15 @@ std::unique_ptr<Checkpoint> DiagnosticCheckpointMgr::Allocate(uint32_t initial_v
Data data;
data.top_value = initial_value;
data.bottom_value = initial_value;
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
checkpoint_data_.emplace(std::make_pair(checkpoint->Id(), std::move(data)));
return checkpoint;
}

void DiagnosticCheckpointMgr::Free(Checkpoint &c) { checkpoint_data_.erase(c.Id()); }
void DiagnosticCheckpointMgr::Free(Checkpoint &c) {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
checkpoint_data_.erase(c.Id());
}

// NV checkpoints are both top and bottom markers.
void DiagnosticCheckpointMgr::WriteTop(Checkpoint &c, VkCommandBuffer cmd, uint32_t value) {}
Expand All @@ -110,18 +123,21 @@ void DiagnosticCheckpointMgr::WriteBottom(Checkpoint &c, VkCommandBuffer cmd, ui
}

uint32_t DiagnosticCheckpointMgr::ReadTop(const Checkpoint &c) const {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
auto iter = checkpoint_data_.find(c.Id());
assert(iter != checkpoint_data_.end());
return iter->second.top_value;
}

uint32_t DiagnosticCheckpointMgr::ReadBottom(const Checkpoint &c) const {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
auto iter = checkpoint_data_.find(c.Id());
assert(iter != checkpoint_data_.end());
return iter->second.bottom_value;
}

void DiagnosticCheckpointMgr::Reset(Checkpoint &c) {
std::lock_guard<std::mutex> lock(checkpoint_mutex_);
auto iter = checkpoint_data_.find(c.Id());
assert(iter != checkpoint_data_.end());
iter->second.top_value = 0;
Expand Down
3 changes: 3 additions & 0 deletions src/checkpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#pragma once

#include "marker.h"
#include <mutex>

namespace crash_diagnostic_layer {

Expand Down Expand Up @@ -79,6 +80,7 @@ class BufferMarkerCheckpointMgr : public CheckpointMgr {

BufferMarkerMgr markers_;

mutable std::mutex checkpoint_mutex_;
std::unordered_map<CheckpointId, Data> checkpoint_data_;
uint32_t next_id_{1};
};
Expand Down Expand Up @@ -108,6 +110,7 @@ class DiagnosticCheckpointMgr : public CheckpointMgr {
};

Device &device_;
mutable std::mutex checkpoint_mutex_;
std::unordered_map<CheckpointId, Data> checkpoint_data_;
uint32_t next_id_{1};
};
Expand Down
Loading