From 73646c4da8731004ce37ad026401d6794eee1246 Mon Sep 17 00:00:00 2001 From: PixelyIon Date: Tue, 16 Nov 2021 09:45:20 +0530 Subject: [PATCH] Implicitly decompose `Address` into `u64` The semantics of implicitly decomposing the `Address` class into a `u64` were determined to be appropriate for the class. As it is an integer type this effectively retains all semantics from using an integer directly for the most part. --- app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h | 3 ++- app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h index 69bb0e67..3d690254 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell/types.h @@ -11,12 +11,13 @@ namespace skyline::soc::gm20b::engine::maxwell3d::type { /** * @brief A 40-bit GMMU virtual address with register-packing + * @note The registers pack the address with big-endian ordering (but with 32 bit words) */ struct Address { u32 high; u32 low; - u64 Pack() { + operator u64() { return (static_cast(high) << 32) | low; } }; diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp index 0611d2be..72ea2120 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp @@ -450,7 +450,7 @@ namespace skyline::soc::gm20b::engine::maxwell3d { switch (registers.semaphore->info.structureSize) { case type::SemaphoreInfo::StructureSize::OneWord: - channelCtx.asCtx->gmmu.Write(registers.semaphore->address.Pack(), static_cast(result)); + channelCtx.asCtx->gmmu.Write(registers.semaphore->address, static_cast(result)); break; case type::SemaphoreInfo::StructureSize::FourWords: { @@ -461,7 +461,7 @@ namespace skyline::soc::gm20b::engine::maxwell3d { i64 nsTime{util::GetTimeNs()}; i64 timestamp{(nsTime / NsToTickDenominator) * NsToTickNumerator + ((nsTime % NsToTickDenominator) * NsToTickNumerator) / NsToTickDenominator}; - channelCtx.asCtx->gmmu.Write(registers.semaphore->address.Pack(), + channelCtx.asCtx->gmmu.Write(registers.semaphore->address, FourWordResult{result, static_cast(timestamp)}); break; }