-
Notifications
You must be signed in to change notification settings - Fork 123
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
A handful of interface changes to support OpenXR future rebasing #1846
Changes from all commits
ceb0d2e
e4c807b
a7988bf
3037a86
d18f7d9
267d30b
fe0b46d
a08a7ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,10 +39,35 @@ | |
|
||
#include <cassert> | ||
#include <memory> | ||
#include <type_traits> | ||
#include <utility> | ||
|
||
GFXRECON_BEGIN_NAMESPACE(gfxrecon) | ||
GFXRECON_BEGIN_NAMESPACE(decode) | ||
|
||
template <typename T, typename = void> | ||
struct DecoderHasOutputAllocator : std::false_type | ||
{}; | ||
|
||
template <typename T> | ||
struct DecoderHasOutputAllocator<T, std::void_t<decltype(std::declval<T>().AllocateOutputData(size_t(1)))>> | ||
: std::true_type | ||
{}; | ||
|
||
template <typename T> | ||
std::enable_if_t<!DecoderHasOutputAllocator<T>::value, typename T::struct_type*> | ||
StructPointerOutputDataAllocator(T*, size_t len) | ||
{ | ||
return DecodeAllocator::Allocate<typename T::struct_type>(len); | ||
} | ||
|
||
template <typename T> | ||
std::enable_if_t<DecoderHasOutputAllocator<T>::value, typename T::struct_type*> | ||
StructPointerOutputDataAllocator(T* decoded_value, size_t len) | ||
{ | ||
return decoded_value->AllocateOutputData(len); | ||
} | ||
|
||
template <typename T> | ||
class StructPointerDecoder : public PointerDecoderBase | ||
{ | ||
|
@@ -68,12 +93,13 @@ class StructPointerDecoder : public PointerDecoderBase | |
typename T::struct_type* AllocateOutputData(size_t len) | ||
{ | ||
output_len_ = len; | ||
output_data_ = DecodeAllocator::Allocate<typename T::struct_type>(len); | ||
output_data_ = StructPointerOutputDataAllocator(decoded_structs_, len); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change for a new use of StructPointerDecoder? Or is there an existing use that wasn't being handled correclty? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New use. |
||
return output_data_; | ||
} | ||
|
||
typename T::struct_type* AllocateOutputData(size_t len, const typename T::struct_type& init) | ||
{ | ||
assert(!DecoderHasOutputAllocator<T>::value); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of this file is all assert(...) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine. For new code please prefer |
||
output_len_ = len; | ||
output_data_ = DecodeAllocator::Allocate<typename T::struct_type>(len); | ||
|
||
|
@@ -222,7 +248,10 @@ class StructPointerDecoder<T*> : public PointerDecoderBase | |
|
||
typename T::struct_type* inner_struct_memory = | ||
DecodeAllocator::Allocate<typename T::struct_type>(inner_lens_[i]); | ||
T* inner_decoded_structs = DecodeAllocator::Allocate<T>(inner_lens_[i]); | ||
// TODO: We initialize == true because the nexe field isn't always cleared on kIsNull in the lower | ||
// level decoders. If this is a performance bottleneck, can clean up the lower decoders to | ||
// initialize all fields. | ||
T* inner_decoded_structs = DecodeAllocator::Allocate<T>(inner_lens_[i], true); | ||
|
||
for (size_t j = 0; j < inner_lens_[i]; ++j) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Put a blank line above this.