-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
When running a Release build, performing a (ushort)(uint) cast on int and storing the result in a ushort* seems to write out 32 bits instead of 16 bits.
Reproduction Steps
- Clone repo https://github.com/TechPizzaDev/SoftwareRasterizer
- Checkout branch
net8-upgrade - Download Castle folder from https://github.com/rawrunprotected/rasterizer/tree/master/SoftwareRasterizer and put next to built SoftwareRasterizer.exe
- Run project in Release mode to see broken render (it works in Debug mode)
- Remove
BUGdefine (https://github.com/TechPizzaDev/SoftwareRasterizer/blob/318adc376bcdaee1b6c863dd9384871aed82897e/SoftwareRasterizer/Avx2Rasterizer.cs#L2) - Run project again to see correct render
Expected behavior
Actual behavior
Regression?
Regression in net8, worked on net7 and net6.
Known Workarounds
Rewriting the code seems like the only workaround. The project also works in Debug mode.
Configuration
.NET: 8.0.0-rc.1.23419.4
OS: Microsoft Windows 11 Home (10.0.22621 version 22621)
CPU: 11th Gen Intel(R) Core(TM) i3-1115G4 @ 3.00GHz
Arch: x64
Env variables
DOTNET_EnableAVX512F=0: Required since net8 seems to cause unexpected AccessViolationExceptions.
Other information
Sse41.MinHorizontal(Vector128<ushort>) returns a Vector128<ushort> where the first ushort element is the minimum value from the vector, and the second ushort element is the index of the min element within the vector.
Problematic code: https://github.com/TechPizzaDev/SoftwareRasterizer/blob/318adc376bcdaee1b6c863dd9384871aed82897e/SoftwareRasterizer/Avx2Rasterizer.cs#L1262-L1264

