-
Notifications
You must be signed in to change notification settings - Fork 22
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
C produces no viewable image, Rust produces a different image from all others. #11
Comments
Performing additional Using For new fast Nim version |
What compiler are you using for C ? I believe that issue is with #pragma pack(push, 1) here if struct is not packed properly then bitmap header is invalid. |
I'm using the C file from the site, compiling with:
on Linux using
|
I think it should work now Linux and 64 bit compiler as fixed sized types are used now in BITMAPFILEHEADER and BITMAPINFOHEADER structs. |
Confirmed the new C version now produces a viewable Have you looked at Rust to determine why its image file has different shading? |
I've looked at the Rust example and the sphere normal was inverted, it should work now. |
Confirmed the new Rust version produces correct The only other thing I've detected between the versions I've been able to run, is that the new faster Nim version, which uses the Quake integer squareroot method, produces slightly smaller spheres in the image versus the original Nim version, and all others. So if that's going to "cheat" (as they say) it should produce the same image, so the timings|images are apples-to-apples. Suggestion: On my system (i7-6700HQ, 3.5GHz), Crystal was 84-85ms, C|C++ between 75-78ms, and fast Nim version 42-45ms. |
I've started tool in C# in tools folder, it should be able to compare image and produce diff so it's easy to spot difference in color. For benchmarking maybe we can use something like hyperfine (https://github.com/sharkdp/hyperfine) like it's used in javascript test. |
Currently I have really old CPU (FX 8120) it's from 2011, so timing shown in readme are much slower usually 2 to 3 slower compared to latest cpus. Nim version has some extra optimization, it uses fast square root algoritham (but it may be less accourate) and instead double it uses float for calculations - I've used double data type for most versions as I think that javascript internaly is using double to store numbers. I've tested crystal in WSL and I am impressed with speed here it takes 195 ms, only 30 ms more than C. |
Yes, something like that for timings would be very nice, to get truer consistent values across all implementations. And it would also be nice to get timings on different newer hardware (i9, AMD Ryzen, ARM, PowerPC, RiscV, etc). Someone ran the Crystal version on an AMD Ryzen 7 3700x, and got 63ms, vs my 84-85ms on an (2016) i7-6700HQ laptop. |
I have a few systems I can help run the comparison script on when ready. |
When I ran the C code version, it produces a bad
*.bmp
file of 1,000,102 bytes, which doesn't show an image.Also, while the Rust code produces a viewable image, the image has different shading from all the others.
Here are comparisons with other *.bmp files that produce correct viewable images.
The text was updated successfully, but these errors were encountered: