[ARM] ZDBSP builds incorrect nodes on ARM

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ARM] ZDBSP builds incorrect nodes on ARM

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Csonicgo » Mon Feb 01, 2016 2:10 pm

Blzut3 wrote:The solution was indeed fixing double->unsigned conversion in one function.
Thanks for this. This is now working correctly. Are there any more of these in the code that you could find?

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Blzut3 » Mon Jan 18, 2016 3:12 pm

The solution was indeed fixing double->unsigned conversion in one function.

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Csonicgo » Mon Nov 23, 2015 10:06 am

Blzut3 wrote:Converting a double to fixed_t (aka int32_t) should be just as defined as converting a double to int. If that doesn't work I would indeed call it a compiler bug.

Converting a double to unsigned, like angle_t is a different issue. If it's giving negative floating point values then I suppose I can see how that would be undefined if the intermediate signed cast is not present (I think you shared a link with me in IRC before? It's in my history anyway). In this case ARM seems to be clamping values to be in the range of valid unsigned int values and x86 doesn't.
If it helps, I've been using LLVM Clang 3.5.2 and higher for compilation on the Raspberry Pi (Built from scratch), and I still get the same results from both compilers when compiling ZDBSP and ZDoom. This may be an ARM-specific behaviour after all...

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Blzut3 » Mon Jul 13, 2015 3:16 pm

Converting a double to fixed_t (aka int32_t) should be just as defined as converting a double to int. If that doesn't work I would indeed call it a compiler bug.

Converting a double to unsigned, like angle_t is a different issue. If it's giving negative floating point values then I suppose I can see how that would be undefined if the intermediate signed cast is not present (I think you shared a link with me in IRC before? It's in my history anyway). In this case ARM seems to be clamping values to be in the range of valid unsigned int values and x86 doesn't.

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Graf Zahl » Mon Jul 13, 2015 11:22 am

That sounds like a compiler bug to me. Even fixed_t and angle_t have defined signedness (i.e. fixed_t is signed and angle_t is unsigned)

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Csonicgo » Mon Jul 13, 2015 10:03 am

A little update on a similar issue to this:

Quasar and I ran into an issue with Vela Pax concerning its ZDoom uncompressed nodes. Turns out, on ARMv7 devices, casting a double to a int (or int-like, like fixed_t) will give you undefined behaviour unless you specify precisely what signedness of said type you're casting to.

So for example, in R_PointToAngle2, the return function was originally:

Code: Select all

return angle_t(atan2(double(y), x) * (ANG180/M_PI));
instead of:

Code: Select all

return angle_t(int(atan2(double(y), x) * (ANG180/M_PI)));
When this was corrected, Vela Pax played properly.

Did you get that yet? Instead of giving the value of angle_t as expected, GCC and Clang both decide to punish the unclean casting code, and output 0. This resulted in all overflowing sections of the nodes (so basically facing the bottom angles of the map) to be drawn backwards or not at all, leaving large sections of the map invisible. This never pops up in x86 compiles because, for some reason, ints are always assumed to be signed there.


Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Csonicgo » Wed Jun 10, 2015 9:27 am

ibm5155 wrote:ehm, isn't better just to make a simple c program for detecting if there's some floaiting point iuse?
arms aren't that great with float, and some of them doesn't even have the float part (it's all fixed point), or it supports a low number of houses afert the ','/'.'
I decided to do that just now and the ARMv6 and ARMv7 variants of the Raspberry Pi pass all tests. Whatever is going on, it's not floating point.

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by ibm5155 » Tue Jun 09, 2015 7:59 am

ehm, isn't better just to make a simple c program for detecting if there's some floaiting point iuse?
arms aren't that great with float, and some of them doesn't even have the float part (it's all fixed point), or it supports a low number of houses afert the ','/'.'

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Csonicgo » Tue May 19, 2015 12:24 pm

Here is a test file with five custom maps containing very simple structures. E1M1-E1M5. GLBSP found no warnings.

TEST1.WAD is the GLBSP version.
ZDBSP2.WAD is the ZDBSP version.
The debug output for ZDBSP is also included.
Attachments
ZDBSP2.7z
5 custom maps
(15.09 KiB) Downloaded 57 times

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Graf Zahl » Mon May 18, 2015 3:06 pm

That file is only used in the UDMF reader and was only added to avoid changing that code from how it appears in ZDoom.

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Csonicgo » Mon May 18, 2015 2:58 pm

Graf Zahl wrote:Hm, ok, that was useless, unfortunately that output truncates all fractional parts, making the output pretty worthless for checking precision issues.
Quick question, are ANY casts being done through xs_Float.h ?

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Graf Zahl » Mon May 18, 2015 2:34 pm

Hm, ok, that was useless, unfortunately that output truncates all fractional parts, making the output pretty worthless for checking precision issues.

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Csonicgo » Mon May 18, 2015 2:20 pm

I just did that. Here is the output.
Attachments
stdout.txt.7z
debug output of E1M1 of DTWID.WAD
(83.57 KiB) Downloaded 63 times

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Graf Zahl » Mon May 18, 2015 1:46 pm

Since nobody here owns affected hardware you'll have to find the cause yourself.

The best start would be to enable debug output by changing this:

Code: Select all

#if 0
#define D(x) x
#else
#define D(x) do{}while(0)
#endif
to #if 1

I suspect floating point math precision issues with the CPU.

Re: [ARM] ZDBSP builds incorrect nodes on ARM

by Csonicgo » Mon May 18, 2015 12:58 pm

Thanks for confirming that it glitches out.

Top