mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 20:11:49 +01:00
Introduce TrivialObject concept and use where appropriate
Simplifies type checking and handles excluding container types that are trivially copyable but contain pointers
This commit is contained in:
parent
f2cc25ee9f
commit
dcef597345
@ -187,13 +187,12 @@ namespace skyline {
|
||||
void Write(VaType virt, u8 *source, VaType size);
|
||||
|
||||
template<typename T>
|
||||
void Write(VaType virt, span <T> source) {
|
||||
void Write(VaType virt, span<T> source) {
|
||||
Write(virt, reinterpret_cast<u8 *>(source.data()), source.size_bytes());
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Write(VaType virt, T source) {
|
||||
Write(virt, reinterpret_cast<u8 *>(&source), sizeof(T));
|
||||
void Write(VaType virt, util::TrivialObject auto source) {
|
||||
Write(virt, reinterpret_cast<u8 *>(&source), sizeof(source));
|
||||
}
|
||||
|
||||
void Copy(VaType dst, VaType src, VaType size);
|
||||
|
@ -13,6 +13,12 @@
|
||||
#include "exception.h"
|
||||
|
||||
namespace skyline::util {
|
||||
/**
|
||||
* @brief Concept for any trivial non-container type
|
||||
*/
|
||||
template<typename T>
|
||||
concept TrivialObject = std::is_trivially_copyable_v<T> && !requires(T v) { v.data(); };
|
||||
|
||||
/**
|
||||
* @brief Returns the current time in nanoseconds
|
||||
* @return The current time in nanoseconds
|
||||
@ -241,8 +247,7 @@ namespace skyline::util {
|
||||
std::generate(in.begin(), in.end(), [&]() { return dist(detail::generator); });
|
||||
}
|
||||
|
||||
template<class T>
|
||||
requires (std::is_trivially_copyable_v<T> && !requires (T v) { v.data(); })
|
||||
template<TrivialObject T>
|
||||
void FillRandomBytes(T &object) {
|
||||
FillRandomBytes(std::span(reinterpret_cast<typename IntegerFor<T>::Type *>(&object), IntegerFor<T>::Count));
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace skyline::soc::gm20b::engine {
|
||||
if (state.launchDma.layout == RegisterState::DmaDstMemoryLayout::Pitch && state.lineCount == 1) {
|
||||
// TODO: we can do this with the buffer manager to avoid some overhead in the future
|
||||
Logger::Debug("range: 0x{:X} -> 0x{:X}", u64{state.offsetOut}, u64{state.offsetOut} + buffer.size() * 0x4);
|
||||
addressSpaceContext->gmmu.Write(state.offsetOut, buffer);
|
||||
addressSpaceContext->gmmu.Write(state.offsetOut, span(buffer));
|
||||
} else {
|
||||
Logger::Warn("Non-linear I2M uploads are not supported!");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user