Skip to content
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
3 changes: 2 additions & 1 deletion src/gpgmm/common/BlockAllocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@

#include "gpgmm/common/MemoryBlock.h"
#include "gpgmm/common/Object.h"
#include "gpgmm/utils/NonCopyable.h"

namespace gpgmm {

// Allocates a sub-range [offset, offset + size) in usually a byte-addressable range.
class BlockAllocator : public ObjectBase {
class BlockAllocator : public ObjectBase, public NonCopyable {
public:
~BlockAllocator() override = default;

Expand Down
2 changes: 2 additions & 0 deletions src/gpgmm/common/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ namespace gpgmm {
public:
// Empty result
Result() : mErrorCode(kInternalFailureResult) {
mResult = {};
}

// Error only result
Result(ErrorT&& error) : mErrorCode(std::move(error)) {
mResult = {};
}

// Result but with no error
Expand Down
4 changes: 3 additions & 1 deletion src/gpgmm/common/EventTraceWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ namespace gpgmm {
};

EventTraceWriter::EventTraceWriter()
: mTraceFile(kDefaultTraceFile), mPlatformTime(CreatePlatformTime()) {
: mTraceFile(kDefaultTraceFile),
mIgnoreMask(TraceEventPhase::None),
mPlatformTime(CreatePlatformTime()) {
}

void EventTraceWriter::SetConfiguration(const char* traceFile,
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/CapsD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace gpgmm::d3d12 {

uint64_t mMaxResourceSize = 0;
uint64_t mMaxResourceHeapSize = 0;
D3D12_RESOURCE_HEAP_TIER mMaxResourceHeapTier;
D3D12_RESOURCE_HEAP_TIER mMaxResourceHeapTier = D3D12_RESOURCE_HEAP_TIER_1;
bool mIsCreateHeapNotResidentSupported = false;
bool mIsResourceAllocationWithinCoherent = false;
bool mIsAdapterUMA = false;
Expand Down
6 changes: 3 additions & 3 deletions src/gpgmm/d3d12/ErrorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ namespace gpgmm::d3d12 {
return "Device was not found but removed " + GetErrorMessage(error);
}

HRESULT removedReason = device->GetDeviceRemovedReason();
std::string removedReasonStr;
switch (error) {
const HRESULT removedReason = device->GetDeviceRemovedReason();
std::string removedReasonStr = "Unknown.";
switch (removedReason) {
case DXGI_ERROR_DEVICE_HUNG: {
removedReasonStr = "HUNG";
break;
Expand Down
3 changes: 2 additions & 1 deletion src/gpgmm/d3d12/FenceD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
#define GPGMM_D3D12_FENCED3D12_H_

#include "gpgmm/d3d12/d3d12_platform.h"
#include "gpgmm/utils/NonCopyable.h"

#include <cstdint>

namespace gpgmm::d3d12 {

class Fence {
class Fence : public NonCopyable {
public:
static HRESULT CreateFence(ID3D12Device* device, uint64_t initialValue, Fence** fenceOut);

Expand Down
12 changes: 7 additions & 5 deletions src/gpgmm/d3d12/ResidencyManagerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ namespace gpgmm::d3d12 {
mBudgetNotificationUpdateEvent, &mCookie);
}

~BudgetUpdateTask() override {
CloseHandle(mUnregisterAndExitEvent);
CloseHandle(mBudgetNotificationUpdateEvent);
}

void operator()() override {
HRESULT hr = GetLastError();
bool isExiting = false;
Expand Down Expand Up @@ -273,8 +278,6 @@ namespace gpgmm::d3d12 {
: descriptor.EvictSizeInBytes),
mIsUMA(caps->IsAdapterUMA() &&
!(descriptor.Flags & RESIDENCY_FLAG_DISABLE_UNIFIED_MEMORY)),
mIsBudgetChangeEventsDisabled(descriptor.Flags &
RESIDENCY_FLAG_NEVER_UPDATE_BUDGET_ON_WORKER_THREAD),
mFlushEventBuffersOnDestruct(descriptor.RecordOptions.EventScope &
EventRecordScope::kPerInstance),
mInitialFenceValue(descriptor.InitialFenceValue) {
Expand Down Expand Up @@ -956,9 +959,8 @@ namespace gpgmm::d3d12 {
}

bool ResidencyManager::IsBudgetNotificationUpdatesDisabled() const {
return mIsBudgetChangeEventsDisabled ||
(mBudgetNotificationUpdateEvent != nullptr &&
FAILED(mBudgetNotificationUpdateEvent->GetLastError()));
return (mBudgetNotificationUpdateEvent == nullptr) ||
FAILED(mBudgetNotificationUpdateEvent->GetLastError());
}

void ResidencyManager::StopBudgetNotificationUpdates() {
Expand Down
1 change: 0 additions & 1 deletion src/gpgmm/d3d12/ResidencyManagerD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ namespace gpgmm::d3d12 {
const bool mIsBudgetRestricted;
const uint64_t mEvictSizeInBytes;
const bool mIsUMA;
const bool mIsBudgetChangeEventsDisabled;
const bool mFlushEventBuffersOnDestruct;
const uint64_t mInitialFenceValue;

Expand Down
5 changes: 3 additions & 2 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1617,8 +1617,9 @@ namespace gpgmm::d3d12 {
}
data.IsResourceAllocationWithinCoherent =
mCaps->IsResourceAllocationWithinCoherent();
memcpy_s(pFeatureSupportData, sizeof(pFeatureSupportData), &data,
featureSupportDataSize);
FEATURE_DATA_RESOURCE_ALLOCATION_SUPPORT* pFeatureData =
static_cast<FEATURE_DATA_RESOURCE_ALLOCATION_SUPPORT*>(pFeatureSupportData);
memcpy_s(pFeatureData, featureSupportDataSize, &data, sizeof(data));
return S_OK;
}
default: {
Expand Down
14 changes: 12 additions & 2 deletions src/gpgmm/utils/JSONEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ namespace gpgmm {
}

JSONDict& JSONDict::operator=(const JSONDict& other) {
mSS = std::stringstream(other.mSS.str());
mHasItem = other.mHasItem;
if (this != &other) {
mSS = std::stringstream(other.mSS.str());
mHasItem = other.mHasItem;
}
return *this;
}

Expand Down Expand Up @@ -113,6 +115,14 @@ namespace gpgmm {
mHasItem = other.mHasItem;
}

JSONArray& JSONArray::operator=(const JSONArray& other) {
if (this != &other) {
mSS = std::stringstream(other.mSS.str());
mHasItem = other.mHasItem;
}
return *this;
}

bool JSONArray::IsEmpty() const {
return !mHasItem;
}
Expand Down
1 change: 1 addition & 0 deletions src/gpgmm/utils/JSONEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace gpgmm {
public:
JSONArray();
JSONArray(const JSONArray& other);
JSONArray& operator=(const JSONArray& other);

std::string ToString() const;
bool IsEmpty() const;
Expand Down
37 changes: 35 additions & 2 deletions src/gpgmm/utils/LinkedList.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ namespace gpgmm {
}
}

LinkNode& operator=(LinkNode<T>&& rhs) {
if (this == &rhs) {
return *this;
}

next_ = rhs.next_;
rhs.next_ = nullptr;
previous_ = rhs.previous_;
rhs.previous_ = nullptr;

// If the node belongs to a list, next_ and previous_ are both non-null.
// Otherwise, they are both null.
if (next_) {
next_->previous_ = this;
previous_->next_ = this;
}

return *this;
}

// Insert |this| into the linked list, before |e|.
void InsertBefore(LinkNode<T>* e) {
this->next_ = e;
Expand Down Expand Up @@ -239,6 +259,13 @@ namespace gpgmm {
LinkedList(LinkedList&& other) noexcept : root_(std::move(other.root_)) {
}

LinkedList& operator=(LinkedList&& rhs) {
if (this != &rhs) {
root_ = std::move(rhs.root_);
}
return *this;
}

LinkNode<T>* head() const {
return root_.next();
}
Expand All @@ -255,12 +282,18 @@ namespace gpgmm {
// ~T must check if IsInList and call RemoveFromList to unlink itself or clear
// will ASSERT to indicate programmer error.
void clear() {
for (auto& curr : *this) {
SafeDelete(curr.value());
iterator curr = begin();
while (curr != end()) {
curr = erase(curr);
}
ASSERT(empty());
}

iterator erase(iterator i) {
SafeDelete(i->value());
return ++i;
}

iterator begin() {
return iterator(head());
}
Expand Down
6 changes: 3 additions & 3 deletions src/gpgmm/utils/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ namespace gpgmm {
return ToString(object) + ToString(args...);
}

template <typename T, typename A1, typename A2>
constexpr auto ConstexprConcat(A1 lhs, A2 rhs) {
std::array<T, lhs.size() + rhs.size()> sizeArray{};
template <typename T, std::size_t N1, std::size_t N2>
constexpr auto ConstexprConcat(std::array<T, N1> lhs, std::array<T, N2> rhs) {
std::array<T, N1 + N2> sizeArray{};
size_t i = 0;

for (auto& item : lhs) {
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/utils/WindowsTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace gpgmm {

class WindowsTime final : public PlatformTime {
public:
WindowsTime() : PlatformTime(), mFrequency(0) {
WindowsTime() : PlatformTime(), mFrequency(0), mCounterStart(0) {
}

double GetAbsoluteTime() override {
Expand Down