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
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Sun Sep 05, 2010 5:44 am
Has thanked: 0
Been thanked: 0

Re: New Open GL API Released

Post by Indiket »

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: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: New Open GL API Released

Post by BlueCrab »

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: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: New Open GL API Released

Post by BlueCrab »

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: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: New Open GL API Released

Post by PH3NOM »

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 thanked: 0
Been thanked: 0

Re: New Open GL API Released

Post by Indiket »

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: 88
Joined: Wed Feb 05, 2014 5:58 am
Has thanked: 9 times
Been thanked: 3 times

Re: New Open GL API Released

Post by bbmario »

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 thanked: 1 time
Been thanked: 0
Contact:

Re: New Open GL API Released

Post by SWAT »

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 thanked: 0
Been thanked: 0

Re: New Open GL API Released

Post by Indiket »

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: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: New Open GL API Released

Post by PH3NOM »

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: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: New Open GL API Released

Post by BlueCrab »

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 thanked: 1 time
Been thanked: 0
Contact:

Re: New Open GL API Released

Post by SWAT »

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: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: New Open GL API Released

Post by PH3NOM »

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 thanked: 0
Been thanked: 0

Re: New Open GL API Released

Post by Indiket »

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: 1873
Joined: Mon Mar 22, 2004 4:55 pm
Location: #%^&*!!!11one Super Sonic
Has thanked: 79 times
Been thanked: 61 times
Contact:

Re: New Open GL API Released

Post by GyroVorbis »

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.
User avatar
SWAT
Insane DCEmu
Insane DCEmu
Posts: 191
Joined: Sat Jan 31, 2004 2:34 pm
Location: Russia/Novosibirsk
Has thanked: 1 time
Been thanked: 0
Contact:

Re: New Open GL API Released

Post by SWAT »

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: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: New Open GL API Released

Post by BlueCrab »

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: 3712
Joined: Sun Nov 04, 2001 5:12 pm
Has thanked: 0
Been thanked: 0
Contact:

Re: New Open GL API Released

Post by mankrip »

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: 5652
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has thanked: 9 times
Been thanked: 69 times
Contact:

Re: New Open GL API Released

Post by BlueCrab »

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: 576
Joined: Fri Jun 18, 2010 9:29 pm
Has thanked: 0
Been thanked: 5 times

Re: New Open GL API Released

Post by PH3NOM »

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 thanked: 1 time
Been thanked: 0
Contact:

Re: New Open GL API Released

Post by SWAT »

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 151 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 141 times
Image
Post Reply