From d7ec031419f7eef3f85210659cf7f6dc8c50d791 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 29 Nov 2022 08:04:40 -0500 Subject: engines: Remove unnecessary casts In a few cases we have some casts that can be trivially removed. --- src/video_core/engines/maxwell_3d.h | 73 +++++++++++++------------------------ 1 file changed, 25 insertions(+), 48 deletions(-) (limited to 'src/video_core/engines/maxwell_3d.h') diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 84c497ebd..cd334f188 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -96,8 +96,7 @@ public: u32 type; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -106,8 +105,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -124,8 +122,7 @@ public: Mode mode; GPUVAddr Address() const { - return static_cast((static_cast(offset_high) << 32) | - offset_low); + return (GPUVAddr{offset_high} << 32) | GPUVAddr{offset_low}; } }; @@ -468,8 +465,7 @@ public: INSERT_PADDING_BYTES_NOINIT(0xC); GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; static_assert(sizeof(Buffer) == 0x20); @@ -511,12 +507,11 @@ public: u32 default_size_per_warp; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } u64 Size() const { - return (static_cast(size_high) << 32) | size_low; + return (u64{size_high} << 32) | u64{size_low}; } }; @@ -538,13 +533,11 @@ public: u32 storage_limit_address_low; GPUVAddr StorageAddress() const { - return static_cast((static_cast(storage_address_high) << 32) | - storage_address_low); + return (GPUVAddr{storage_address_high} << 32) | GPUVAddr{storage_address_low}; } GPUVAddr StorageLimitAddress() const { - return static_cast( - (static_cast(storage_limit_address_high) << 32) | - storage_limit_address_low); + return (GPUVAddr{storage_limit_address_high} << 32) | + GPUVAddr{storage_limit_address_low}; } }; @@ -1138,8 +1131,7 @@ public: INSERT_PADDING_BYTES_NOINIT(0x18); GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; static_assert(sizeof(RenderTargetConfig) == 0x40); @@ -1482,8 +1474,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1533,8 +1524,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1561,8 +1551,7 @@ public: u32 array_pitch; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1910,8 +1899,7 @@ public: Mode mode; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1921,8 +1909,7 @@ public: u32 limit; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1932,8 +1919,7 @@ public: u32 limit; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -1981,8 +1967,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -2027,8 +2012,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -2224,19 +2208,16 @@ public: } GPUVAddr StartAddress() const { - return static_cast((static_cast(start_addr_high) << 32) | - start_addr_low); + return (GPUVAddr{start_addr_high} << 32) | GPUVAddr{start_addr_low}; } GPUVAddr EndAddress() const { - return static_cast((static_cast(limit_addr_high) << 32) | - limit_addr_low); + return (GPUVAddr{limit_addr_high} << 32) | GPUVAddr{limit_addr_low}; } /// Adjust the index buffer offset so it points to the first desired index. GPUVAddr IndexStart() const { - return StartAddress() + - static_cast(first) * static_cast(FormatSizeInBytes()); + return StartAddress() + size_t{first} * size_t{FormatSizeInBytes()}; } }; @@ -2464,8 +2445,7 @@ public: } query; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; @@ -2479,8 +2459,7 @@ public: u32 frequency; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } bool IsEnabled() const { @@ -2494,8 +2473,7 @@ public: u32 address_low; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; static_assert(sizeof(VertexStreamLimit) == 0x8); @@ -2543,8 +2521,7 @@ public: std::array buffer; GPUVAddr Address() const { - return static_cast((static_cast(address_high) << 32) | - address_low); + return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low}; } }; -- cgit v1.2.3 From 96ffc174aae2f2ac0662d770613ee7ed48e54c74 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 29 Nov 2022 08:39:31 -0500 Subject: maxwell_3d: Mark shifted value as unsigned Otherwise this is technically creating a signed int result that gets converted. Just a consistency change. While we're in the area, we can mark Samples() as const. --- src/video_core/engines/maxwell_3d.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/video_core/engines/maxwell_3d.h') diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index cd334f188..deba292a5 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -184,7 +184,7 @@ public: default: // Thresholds begin at 0x10 (1 << 4) // Threshold is in the range 0x1 to 0x13 - return 1 << (4 + threshold.Value() - 1); + return 1U << (4 + threshold.Value() - 1); } } }; @@ -822,11 +822,11 @@ public: struct CompressionThresholdSamples { u32 samples; - u32 Samples() { + u32 Samples() const { if (samples == 0) { return 0; } - return 1 << (samples - 1); + return 1U << (samples - 1); } }; -- cgit v1.2.3