New Open GL API Released

This forum is for the posting of new newsposts, and it stores the site's news and comments archives. Only newsposters have access to post new news in here; if you wish to submit news, please post it in the discussion section for your particular topic. We may choose to move it here as a newspost if we find that it's worthy for the front page.
User avatar
Indiket
DC Developer
DC Developer
Posts: 99
Joined: Sun Sep 05, 2010 5:44 am
Has liked: 0
Been liked: 0

Re: New Open GL API Released

Post by Indiket » Mon Aug 18, 2014 3:18 pm

Hey there Ph3nom :)

Thanks for your fixes, but still no cigar!! :(

The cpp example compiles fine (just a single cpp file).

My problem is with multiple definitions, not the undefined ones. It seems that C++ links in a different way that C, and of course, problem only arises when there are more than one .cpp file using the <GL/gl.h> lib.

It's strange, because gl.h is already defined to be using the externals C class (the sys/cdefs), but even more curious, it's only with the glVertex definitions!
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5415
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 2 times
Been liked: 18 times
Contact:

Re: New Open GL API Released

Post by BlueCrab » Mon Aug 18, 2014 6:06 pm

Jae686 wrote:
Indiket wrote:Jae686, I've just re-built the toolchain with GCC 4.7.3 and now compiles fines, so yeah, a nasty GCC bug.

I'm still having the second issue with C++ programs, anyone has a clue about it?
You are right, I just did the same thing and it compiled fine.

About C++, I have no idea.

The specular example did not compile due to the .c calling "Font.h" and the file being "font.h".

Now only some modem related examples wont compile with :

Code: Select all

make[2]: Entering directory `/home/jaerder/development/Tools/dreamcast/kallistios/examples/dreamcast/modem/basic'
rm -f example1.elf romdisk.*
kos-cc  -c example1.c -o example1.o
kos-cc -o example1.elf example1.o
/home/jaerder/development/Tools/dreamcast/kallistios/lib/dreamcast/libkallisti.a(modem.o): In function `modemCreateCInfoFromPS':
/home/jaerder/development/Tools/dreamcast/kallistios/kernel/arch/dreamcast/hardware/modem/modem.c:123: undefined reference to `_speedCodeToBPS'
/home/jaerder/development/Tools/dreamcast/kallistios/lib/dreamcast/libkallisti.a(modem.o): In function `modemCreateCInfoFromCC':
/home/jaerder/development/Tools/dreamcast/kallistios/kernel/arch/dreamcast/hardware/modem/modem.c:190: undefined reference to `_speedCodeToBPS'
/home/jaerder/development/Tools/dreamcast/kallistios/lib/dreamcast/libkallisti.a(modem.o): In function `modemSelfTest':
/home/jaerder/development/Tools/dreamcast/kallistios/kernel/arch/dreamcast/hardware/modem/modem.c:422: undefined reference to `_verifyControllerData'
/home/jaerder/development/Tools/dreamcast/kallistios/kernel/arch/dreamcast/hardware/modem/modem.c:422: undefined reference to `_verifyDSPData'
collect2: error: ld returned 1 exit status
make[2]: *** [example1.elf] Error 1
make[2]: Leaving directory `/home/jaerder/development/Tools/dreamcast/kallistios/examples/dreamcast/modem/basic'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/home/jaerder/development/Tools/dreamcast/kallistios/examples/dreamcast/modem'
/bin/sh: 1: exit: Illegal number: -1
make: *** [all] Error 2
I definitely cannot reproduce that particular problem on my end. That example compiles just fine.

All the symbols it is complaining about being undefined are defined in the same file (and should be inlined). Perhaps your compiler is doing something wonky with inlining? Dunno, to be honest.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5415
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 2 times
Been liked: 18 times
Contact:

Re: New Open GL API Released

Post by BlueCrab » Mon Aug 18, 2014 6:25 pm

Indiket wrote:Hey there Ph3nom :)

Thanks for your fixes, but still no cigar!! :(

The cpp example compiles fine (just a single cpp file).

My problem is with multiple definitions, not the undefined ones. It seems that C++ links in a different way that C, and of course, problem only arises when there are more than one .cpp file using the <GL/gl.h> lib.

It's strange, because gl.h is already defined to be using the externals C class (the sys/cdefs), but even more curious, it's only with the glVertex definitions!
I can explain that pretty easily...

The glVertex* functions were defined as function pointers in libgl. The way they were declared in the .h file works differently between C and C++ (at least with GCC). Basically, they needed to be declared as extern in the .h file and actually defined somewhere in a .c file that gets compiled to make sure everything works regardless of whether C or C++ was being used. I've gone ahead and fixed that in the Git repo, although I can't test to make sure everything actually works with that change (beyond that it compiles and that a C++ program can link it successfully).
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 574
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 0

Re: New Open GL API Released

Post by PH3NOM » Tue Aug 19, 2014 7:11 pm

Indiket wrote:Hey there Ph3nom :)

Thanks for your fixes, but still no cigar!! :(

The cpp example compiles fine (just a single cpp file).

My problem is with multiple definitions, not the undefined ones. It seems that C++ links in a different way that C, and of course, problem only arises when there are more than one .cpp file using the <GL/gl.h> lib.
Hey Indiket. I just had a quick look at the project you sent me.

Unfortunately I cannot compile because it is using a non-official fork of SDL that does not come with KOS, I get a "fatal error: SDL/SDL_dreamcast.h: No such file..."
Looking at the makefile, the project is linking to -lSDL_gl_1213. Where is that lib?

Furthermore, the makefile is linking to "-lkglx", note that the new lib is simply "-lgl".
If you are linking to "-lkglx", I can understand the multiple definition errors arising from the fact that my API defines glVertex3f as a function pointer, where in kglx glVertex3f is a standard function call, as BlueCrab pointed out.
User avatar
Indiket
DC Developer
DC Developer
Posts: 99
Joined: Sun Sep 05, 2010 5:44 am
Has liked: 0
Been liked: 0

Re: New Open GL API Released

Post by Indiket » Wed Aug 20, 2014 1:57 am

PH3NOM wrote:
Hey Indiket. I just had a quick look at the project you sent me.

Unfortunately I cannot compile because it is using a non-official fork of SDL that does not come with KOS, I get a "fatal error: SDL/SDL_dreamcast.h: No such file..."
Looking at the makefile, the project is linking to -lSDL_gl_1213. Where is that lib?

Furthermore, the makefile is linking to "-lkglx", note that the new lib is simply "-lgl".
If you are linking to "-lkglx", I can understand the multiple definition errors arising from the fact that my API defines glVertex3f as a function pointer, where in kglx glVertex3f is a standard function call, as BlueCrab pointed out.
Oh yes, you're right. That is the Chui's SDL library we're using in our projects (the one that has a different dc_video.c file). My idea is to update the game from kglx to gl, but do not worry: with latest BlueCrab commit now it will compile OK.

For testing, you can just link to -lSDL and comment SDL/SDL_dreamcast.h and the SDL_DC_mapkey functions. We just need to update the SDL video routines to support the new OpenGL lib :)
User avatar
bbmario
DCEmu Freak
DCEmu Freak
Posts: 75
Joined: Wed Feb 05, 2014 5:58 am
Has liked: 3 times
Been liked: 2 times

Re: New Open GL API Released

Post by bbmario » Wed Aug 20, 2014 12:21 pm

This is so amazing! THANKS A LOT MAN!

:mrgreen: :mrgreen: :mrgreen: :mrgreen:
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: New Open GL API Released

Post by SWAT » Wed Aug 20, 2014 10:35 pm

Have problem with GCC 4.9.1.
It is very sad, because with this compiler your library would work even faster.

Code: Select all

gl-matrix.c: В функции «glhLookAtf2»:
gl-matrix.c:342:1: ошибка: не найден регистр класса «FP0_REGS» для выталкивания в память
 }
 ^
gl-matrix.c:342:1: ошибка: это insn:
(insn 47 46 48 2 (parallel [
            (set (reg/v:SF 64 fr0 [ __x ])
                (fma:SF (reg:SF 65 fr1 [orig:185 D.3395 ] [185])
                    (reg:SF 69 fr5 [orig:171 forward$1 ] [171])
                    (reg:SF 67 fr3 [orig:228 D.3395 ] [228])))
            (use (reg/v:PSI 151 ))
        ]) gl-matrix.c:294 446 {fmasf4_i}
     (expr_list:REG_DEAD (reg:SF 67 fr3 [orig:228 D.3395 ] [228])
        (nil)))
gl-matrix.c:342: невозможно восстановление после предыдущих ошибок
make[1]: *** [gl-matrix.o] Ошибка 1
make[1]: Выход из каталога `/usr/local/dc/kos/kos-ports/libgl'
Sorry for the Russian language.
Image
User avatar
Indiket
DC Developer
DC Developer
Posts: 99
Joined: Sun Sep 05, 2010 5:44 am
Has liked: 0
Been liked: 0

Re: New Open GL API Released

Post by Indiket » Thu Aug 21, 2014 2:11 am

It's the same issue I had with GCC 4.8.2 , yeah maybe can be fixed or do a workarround, dunno!
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 574
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 0

Re: New Open GL API Released

Post by PH3NOM » Thu Aug 21, 2014 7:31 pm

SWAT wrote:Have problem with GCC 4.9.1.
It is very sad, because with this compiler your library would work even faster.

Code: Select all

gl-matrix.c: В функции «glhLookAtf2»:
gl-matrix.c:342:1: ошибка: не найден регистр класса «FP0_REGS» для выталкивания в память
 }
 ^
gl-matrix.c:342:1: ошибка: это insn:
(insn 47 46 48 2 (parallel [
            (set (reg/v:SF 64 fr0 [ __x ])
                (fma:SF (reg:SF 65 fr1 [orig:185 D.3395 ] [185])
                    (reg:SF 69 fr5 [orig:171 forward$1 ] [171])
                    (reg:SF 67 fr3 [orig:228 D.3395 ] [228])))
            (use (reg/v:PSI 151 ))
        ]) gl-matrix.c:294 446 {fmasf4_i}
     (expr_list:REG_DEAD (reg:SF 67 fr3 [orig:228 D.3395 ] [228])
        (nil)))
gl-matrix.c:342: невозможно восстановление после предыдущих ошибок
make[1]: *** [gl-matrix.o] Ошибка 1
make[1]: Выход из каталога `/usr/local/dc/kos/kos-ports/libgl'
Sorry for the Russian language.
Hi SWAT.

Thanks for having a look.

All I could ask is that you comment out the function body of glhLookAtf2 on gl-matrix.c then try to compile.
If that compiles, can you try to un-comment blocks of code to see if you can narrow it down to a specific function call that seems to freak out GCC 4.9.1.
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5415
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 2 times
Been liked: 18 times
Contact:

Re: New Open GL API Released

Post by BlueCrab » Thu Aug 21, 2014 7:58 pm

Internal compiler errors like that one should be reported to the GCC developers at https://gcc.gnu.org/bugzilla/ , as they are GCC bugs in general. Make sure to include relevant information if you go to file a bug report, including the error message you've included there, the target your compiler is targeting (probably sh-elf, unless you've done some sort of extra patching to your compiler), and the source code file that is causing the problem (preferably as spit out after preprocessing).
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: New Open GL API Released

Post by SWAT » Thu Aug 21, 2014 11:04 pm

PH3NOM wrote: All I could ask is that you comment out the function body of glhLookAtf2 on gl-matrix.c then try to compile.
If that compiles, can you try to un-comment blocks of code to see if you can narrow it down to a specific function call that seems to freak out GCC 4.9.1.
The problem in macro vec3f_normalize
Other code compiles fine.
Image
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 574
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 0

Re: New Open GL API Released

Post by PH3NOM » Fri Aug 22, 2014 6:39 pm

That is strange indeed :o

I utilized that macro on dreamcast/math/matrix3d.c, so the fact that KOS compiles fine for you, tells me there is no problem with the macro.

If I had to guess, the compiler optimizations are likely the source of the problem.

Can you try to test compiling libgl/gl-matrix.c using -O0 on the makefile?

I am curious if the code will compile as-is by disabling compiler optimizations...
User avatar
Indiket
DC Developer
DC Developer
Posts: 99
Joined: Sun Sep 05, 2010 5:44 am
Has liked: 0
Been liked: 0

Re: New Open GL API Released

Post by Indiket » Sat Aug 23, 2014 1:11 pm

Just a mini-bump :)

Tested BlueCrab last commit, works OK now, thanks!!
About GL support for SDL, I changed a few lines to get it compiled again, but still does not work yet. I think it should be quick to fix it btw :)
User avatar
GyroVorbis
Elysian Shadows Developer
Elysian Shadows Developer
Posts: 1808
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has liked: 0
Been liked: 0
Contact:

Re: New Open GL API Released

Post by GyroVorbis » Sat Aug 23, 2014 10:18 pm

Hey dudes, I'm really sorry for not being particularly active in the community lately, but we've been super swamped... I was following this project since the beginning, and I have always been impressed with it. I feel like while ESTk will bring lots of modders and RPG-ers, this has the potential to really hit lots of mobile and GL developers and convince them to start targeting the Dreamcast.

Keep kicking ass, guys, because it looks awesome. I will start telling people when they go "ZOMG HOW U GET ON DRMCSAT" that the scene is working on OpenGL support, so they can migrate their projects over fairly easily.

edit: Dude, you should come shoot the shit with us in the #dreamcastdev IRC channel. I was hoping to look at some of your code and share some of ours with you, because we're both working at the metal trying to push polys here.
Elysian Shadows - "Next-Gen" 2D/3D RPG coming to Sega Dreamcast, Steam, OUYA, and Smartphones
Image
http://www.elysianshadows.com
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: New Open GL API Released

Post by SWAT » Sun Aug 24, 2014 11:17 pm

PH3NOM wrote:That is strange indeed :o

I utilized that macro on dreamcast/math/matrix3d.c, so the fact that KOS compiles fine for you, tells me there is no problem with the macro.

If I had to guess, the compiler optimizations are likely the source of the problem.

Can you try to test compiling libgl/gl-matrix.c using -O0 on the makefile?

I am curious if the code will compile as-is by disabling compiler optimizations...
Compiles fine with "-O2" instead of "-O3".
I compile all files with -O3 and only gl-matrix with -O2 :)
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5415
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 2 times
Been liked: 18 times
Contact:

Re: New Open GL API Released

Post by BlueCrab » Mon Aug 25, 2014 9:18 am

It'd probably be a good idea, in general, to compile the GL library with the normal set of KOS CFLAGS anyway.

That said, that error should still be pointed out to the GCC developers, as it appears to be a GCC optimizer bug.
User avatar
mankrip
DCEmu Ex-Mod
DCEmu Ex-Mod
Posts: 3697
Joined: Sun Nov 04, 2001 5:12 pm
Has liked: 0
Been liked: 0
Contact:

Re: New Open GL API Released

Post by mankrip » Mon Aug 25, 2014 11:25 am

GCC's optimizations were always buggy for me. They rounded down some floats, as if the floats had been converted into integers.

Too bad I can't remember exactly which problem this caused in Quake.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
Image
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5415
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 2 times
Been liked: 18 times
Contact:

Re: New Open GL API Released

Post by BlueCrab » Mon Aug 25, 2014 3:15 pm

The optimizer does seem to do some REALLY weird things for SuperH. That's why the default CFLAGS for KOS have tended to have flags to turn off certain optimizations, at least ever since -O2 was the recommended optimization level in KOS' environ script.

I'm not sure how I missed that the optimization flags were being overridden, but they probably should be toned down to the default set.

That said, this somewhat reinforces why KOS recommends (and only includes patches for) 4.7.x and some earlier versions at this point. :wink:
User avatar
PH3NOM
DC Developer
DC Developer
Posts: 574
Joined: Fri Jun 18, 2010 9:29 pm
Has liked: 0
Been liked: 0

Re: New Open GL API Released

Post by PH3NOM » Mon Aug 25, 2014 7:58 pm

SWAT wrote:Compiles fine with "-O2" instead of "-O3".
I compile all files with -O3 and only gl-matrix with -O2 :)
Glad to get things working for you :lol:
Can you upload your compiled .lib? I am now curious to test the result of using the newer GCC on my API.
BlueCrab wrote:The optimizer does seem to do some REALLY weird things for SuperH. That's why the default CFLAGS for KOS have tended to have flags to turn off certain optimizations, at least ever since -O2 was the recommended optimization level in KOS' environ script.

I'm not sure how I missed that the optimization flags were being overridden, but they probably should be toned down to the default set.

That said, this somewhat reinforces why KOS recommends (and only includes patches for) 4.7.x and some earlier versions at this point. :wink:
Yes, in the makefile I set the optimization to 03.
I cant remember benchmarking 02 vs 03, but I can say for sure that going from O0 to O3 brought some very nice increases in performance.

But now that I think of it, at one point I observed some strange behavior in my old z clipping algorithm when enabling all GCC optimizations.
Honestly, I think it would be best to actually figure out which specific optimizations to enable, as opposed to using the generic -Ox flags.
But for now, for stability reasons, I agree that it might be better to remove the 03 flags from the libgl makefile.
We can leave that as an "experimental" optional compile method.
GyroVorbis wrote:Hey dudes, I'm really sorry for not being particularly active in the community lately, but we've been super swamped... I was following this project since the beginning, and I have always been impressed with it. I feel like while ESTk will bring lots of modders and RPG-ers, this has the potential to really hit lots of mobile and GL developers and convince them to start targeting the Dreamcast.

Keep kicking ass, guys, because it looks awesome. I will start telling people when they go "ZOMG HOW U GET ON DRMCSAT" that the scene is working on OpenGL support, so they can migrate their projects over fairly easily.

edit: Dude, you should come shoot the shit with us in the #dreamcastdev IRC channel. I was hoping to look at some of your code and share some of ours with you, because we're both working at the metal trying to push polys here.
Hey Gyro, Thanks for posting!

Funny thing, when I began working on the API, it was my dream to see it used in a commercial project.
In the back of my mind, I even thought of your project making that a reality :grin:
Congrats to you and your team for really making things happen!

Very inspiring to everyone in the DC homebrew community.

I would be happy to share any code / logic with you guys, but I do not use IRC atm, feel free to shoot me a PM here!
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has liked: 0
Been liked: 0
Contact:

Re: New Open GL API Released

Post by SWAT » Tue Aug 26, 2014 12:42 am

PH3NOM wrote:
SWAT wrote:Compiles fine with "-O2" instead of "-O3".
I compile all files with -O3 and only gl-matrix with -O2 :)
Glad to get things working for you :lol:
Can you upload your compiled .lib? I am now curious to test the result of using the newer GCC on my API.
No problem. In archive two versions (O2 and O3):
libgl_build_gcc_4.9.1.7z
(120.97 KiB) Downloaded 63 times
But I think, for maximum result, you need KOS library compiled on GCC 4.9.1 too:
libkallisti_build_gcc_4.9.1.7z
(688.63 KiB) Downloaded 66 times
Image
Post Reply