Skip to content
Closed
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
13 changes: 13 additions & 0 deletions runtime/test/d3d12_test_shaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <filesystem>
#include <fstream>
#include <string>
#include <utility>
#include <vector>

#include "../shims/d3d12_xs_rootsig.h"
Expand Down Expand Up @@ -169,6 +170,18 @@ inline D3D12_RESOURCE_BARRIER transition(ID3D12Resource* resource, D3D12_RESOURC
template<class T>
struct Ref {
T* p = nullptr;
Ref() = default;
// One owner: a copy would Release twice, and `ref = {}` must Release what it held.
Ref(const Ref&) = delete;
Ref& operator=(const Ref&) = delete;
Ref(Ref&& other) noexcept : p(std::exchange(other.p, nullptr)) {}
Ref& operator=(Ref&& other) noexcept {
if (this != &other) {
reset();
p = std::exchange(other.p, nullptr);
}
return *this;
}
~Ref() { reset(); }
void reset() {
if (p) p->Release();
Comment on lines 186 to 187

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reset() does clear it: if (p) p->Release(); p = nullptr; (the second line is just below the shown hunk), so calling it twice, or reset() then the destructor, releases once.

Expand Down