Various patches for OpenGlide

Developer's Forum, for discussion of bugs, code, and other developmental aspects of OpenGLide.

Re: Various patches for OpenGlide

Postby `Moe` » 2007-9-21 @ 11:29

Indeed. The name Voodoo is a trademark, as far as I can see, at least it has been. I guess our working title SDL_3dfx needs some adjustment as well. I don't know what laws apply to a company name that has ceased to exist/to be used 6 years ago.
User avatar
`Moe`
Oldbie
 
Posts: 1169
Joined: 2004-4-29 @ 01:06
Location: Oldenburg, Germany

Re: Various patches for OpenGlide

Postby DosFreak » 2007-9-21 @ 11:34

heh. I was watching supernatural (tv show) last night and they always refer to "Hoodoo", it's not the same as "Voodoo" but there are similarities.

If you want to stick to the "Voodoo" name you could always use "Vodou".

GLVodou anyone?
User avatar
DosFreak
l33t++
 
Posts: 9817
Joined: 2002-6-30 @ 16:35
Location: Your Head

Re: Various patches for OpenGlide

Postby MiniMax » 2007-9-21 @ 12:28

(ANAL) Trademarks ceases to apply if the owner does not use it any more, and don't actively pursue their misuse.

http://www.nolo.com/article.cfm/ObjectI ... 0/274/ART/
DOSBox 0.73 ReadMe | DOSBox Wiki | DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Win 10 Pro
User avatar
MiniMax
Moderator
 
Posts: 5128
Joined: 2004-1-18 @ 04:15
Location: Stockholm, Sweden, Europe, Earth Interests: Old games & young women

Re: Various patches for OpenGlide

Postby collector » 2007-9-22 @ 06:58

Yeah, I thought of Lindows a little after posting.
User avatar
collector
l33t
 
Posts: 4229
Joined: 2003-1-15 @ 10:39

Re: Various patches for OpenGlide

Postby lumyk » 2007-12-11 @ 19:58

Hi, I tried OpenGlide patches on Linux x86_64. Tomb Raider 1 running under DOSBox works very well. (Of cause with correct tomb.exe + glide2x.ovl + dosbox glide patch) Thanks, great work!

Anyway, I have few questions. I applied patches against latest OpenGlide CVS from sourceforge. It was not quite smooth. I had to apply some rejected changes by hand, but fortunately at the end everything works ok :). Is there any more appropriate version of OpenGlide that could be used as base for the patches?
I noticed at the beginning of this thread something about further development of OpenGlide, particularly gulikoza mentioned some personal CVS. Is there any possibility to access/try those sources?

Is there any possibility to play the game in scaled window? Well, I noticed somewhere negative answer, but things sometimes changes. I applied little hack to window creation/glViewport in my build to be able to play the game in 1280x960 window, but it could be good to know if (possibly new) API of OpenGlide have support for that.
lumyk
Newbie
 
Posts: 3
Joined: 2007-12-10 @ 20:51

Re: Various patches for OpenGlide

Postby gulikoza » 2007-12-11 @ 22:57

Hi,

I think the patches applied cleanly to cvs when I released them. Yes, that was some time ago, I didn't review them since. Moe has done a tremendous job merging OpenGlide and MACGlide (yes, including window scaling) and even improving it a bit further. I, on the other hand, haven't done much :). I promised to take a look at broken LFB support, but haven't got the time... :depressed:
User avatar
gulikoza
Oldbie
 
Posts: 1705
Joined: 2004-6-25 @ 14:53

Re: Various patches for OpenGlide

Postby Glidos » 2007-12-11 @ 23:26

I'll take a look at committing these patches to OpenGlide. Maybe at the weekend.
User avatar
Glidos
l33t
 
Posts: 3116
Joined: 2002-8-08 @ 02:55

Re: Various patches for OpenGlide

Postby lumyk » 2007-12-12 @ 23:54

Thank you for the answers. I will try new CVS version as soon as it will be available :).
lumyk
Newbie
 
Posts: 3
Joined: 2007-12-10 @ 20:51

Re: Various patches for OpenGlide

Postby Glidos » 2007-12-15 @ 17:58

There, sorted. I haven't given it any testing, besides checking the non-SDL version builds under Windows.

I'll generate another release sometime soon.
User avatar
Glidos
l33t
 
Posts: 3116
Joined: 2002-8-08 @ 02:55

Re: Various patches for OpenGlide

Postby lumyk » 2007-12-16 @ 12:30

I have just tried to compile and run CVS version. Everything looks OK on my Linux x86_64.
lumyk
Newbie
 
Posts: 3
Joined: 2007-12-10 @ 20:51

Re: Various patches for OpenGlide

Postby Glidos » 2007-12-16 @ 13:30

Great. Thanks
User avatar
Glidos
l33t
 
Posts: 3116
Joined: 2002-8-08 @ 02:55

Re: Various patches for OpenGlide

Postby gulikoza » 2007-12-21 @ 09:05

Great to see the patches in cvs :wink:
There's another issue remaining which I haven't mentioned: sdk2_3dfx.h.
The problem is, that the header defines Fx*32 as long. Long is 64-bit on x86_64 linux, so this breaks anything that expects Fx*32 to be 32-bit. At the moment, my configure patch will recreate this header in config.h with the detected sizes. This is fine for openglide, but unfortunately any applications that include openglide headers will not compile with the correct data types. I don't know what is the best way to solve this. Recreating the sdk2_3dfx.h at compile time means the headers will not be portable across machines. Or maybe stdint.h can be used, but I don't know if it's available on all platforms.
User avatar
gulikoza
Oldbie
 
Posts: 1705
Joined: 2004-6-25 @ 14:53

Re: Various patches for OpenGlide

Postby Glidos » 2007-12-21 @ 10:27

How about moving the define into platform.h, of which we have a version per platform? Or is that a bit yukky?
User avatar
Glidos
l33t
 
Posts: 3116
Joined: 2002-8-08 @ 02:55

Re: Various patches for OpenGlide

Postby MiniMax » 2007-12-21 @ 11:03

I don't know if this article is of any help?
http://www.unix.org/whitepapers/64bit.html

Assuming that long = 32 bits is (IMO) dangerous. If some C-type needs to map to some hardware registers, it should be made clear in the code, using some type-definition that says int32, uint32, reg32 or something.

Sometimes old code needs to break before it can be fixed...
DOSBox 0.73 ReadMe | DOSBox Wiki | DOSBox 60 seconds guide | How to ask questions
_________________
Lenovo M58p | Core 2 Quad Q8400 @ 2.66 GHz | Radeon R7 240 | LG HL-DT-ST DVDRAM GH40N | Win 10 Pro
User avatar
MiniMax
Moderator
 
Posts: 5128
Joined: 2004-1-18 @ 04:15
Location: Stockholm, Sweden, Europe, Earth Interests: Old games & young women

Re: Various patches for OpenGlide

Postby pk » 2007-12-22 @ 21:45

Firstly, let me just say that this is fantastic work from everyone responsible! Tomb Raider 1 runs really well on my Linux system using Dosbox and these patches.

I'm having a problem compiling some of the inline assembly inside the Convert565to8888 function (Line 486 of openglide-mmx.diff). In particular, I'm running out of registers of class 'GENERAL_REGS' using gcc 4.2.3 compiling for 32bit architecture:

Code: Select all
can't find a register in class 'GENERAL_REGS' while reloading 'asm'


My assembly is really rusty, but are there enough registers available on 32bit CPUs to satisfy those constraints?:

Code: Select all
         : /* No outputs */
         : "r" ((FxU)NumberOfPixels), "r" (Src), "r" (Dst), /*Inputs */
         "m" (Mask565A), "m" (Mask565B), "m" (Mask565G), "m" (Mask565R)
          : "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5",
            "%mm6", "%mm7", "memory" /* Clobbers */


Are there 8 general purpose registers and the mmx registers are considered an additional 8? How many are available when using -fomit-frame-pointer with gcc on 32bit CPUs? If I use 1 less register, then it compiles. Can someone more knowledgeable let me know if that makes sense?
pk
Newbie
 
Posts: 5
Joined: 2007-12-22 @ 21:11

Re: Various patches for OpenGlide

Postby gulikoza » 2007-12-22 @ 22:06

This sounds familiar. I think I got the same error. But IIRC I've changed the Mask565* parameters to be memory operands ("m") not "r", so gcc shouldn't be loading them in registers. The rest is the same as unpatched code.
User avatar
gulikoza
Oldbie
 
Posts: 1705
Joined: 2004-6-25 @ 14:53

Re: Various patches for OpenGlide

Postby pk » 2007-12-22 @ 22:43

Thanks for the solution. It does seem to solve the issue. I've changed it to:

Code: Select all
         : /* No outputs */
         : "m" ((FxU)NumberOfPixels), "r" (Src), "r" (Dst), /*Inputs */
           "m" (Mask565A), "m" (Mask565B), "m" (Mask565G), "m" (Mask565R)
         : "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5",
           "%mm6", "%mm7", "memory" /* Clobbers */


However, I couldn't change all three parameters to memory operands because it resulted in the following error:

Code: Select all
/tmp/cc5tzKmG.s: Assembler messages:
/tmp/cc5tzKmG.s:312: Error: missing ')'
/tmp/cc5tzKmG.s:312: Error: junk `(%esp))' after expression
/tmp/cc5tzKmG.s:312: Error: missing ')'
/tmp/cc5tzKmG.s:312: Error: junk `(%esp))' after expression
/tmp/cc5tzKmG.s:312: Error: junk `(16(%esp))' after expression


which comes from the following intermediate assembly:

Code: Select all
        movq  (%esi), %mm7;movq  (%ecx), %mm6;movq  (%edx), %mm5;movq  (%eax), %mm4;.align 16;MMXConvert565to8888_copying:movq  (12(%esp)), %mm0;addl $8, 12(%esp);movq  %mm0, %mm2;movq  %mm0, %mm1;pand  %mm4, %mm0;pand  %mm6, %mm2;psllw $11, %mm0;pand  %mm5, %mm1;psrlw $8, %mm2;movq  %mm1, %mm3;psllw $13, %mm1;por   %mm2, %mm0;psrlw $3, %mm3;por   %mm3, %mm1;por   %mm7, %mm1;movq  %mm0, %mm2;punpckhbw %mm1, %mm0;punpckhbw %mm1, %mm2;movq  %mm2, (16(%esp));addl $16, 16(%esp);movq  %mm0, -8(16(%esp));subl $4, 20(%esp);jg    MMXConvert565to8888_copying;EMMS;


But with only the NumberOfPixels as a memory operand, it's all working perfectly.
pk
Newbie
 
Posts: 5
Joined: 2007-12-22 @ 21:11

Re: Various patches for OpenGlide

Postby gulikoza » 2007-12-23 @ 10:34

Well, actually those 3 should be in registers. My point was that this function uses 3 registers just like all the other Convert* functions so I don't know why gcc is failing to assemble it... :happy:
User avatar
gulikoza
Oldbie
 
Posts: 1705
Joined: 2004-6-25 @ 14:53

Re: Various patches for OpenGlide

Postby pk » 2007-12-23 @ 13:23

Ahhhh. Okay, now I see what you mean. :blush:

However, that function isn't actually using 3 registers. It's using 7. Those masks (with the m class) still use a register each, because their address is placed into esi, ecx, edx and eax, and then they're referenced from these registers.

Because the ebp and edi registers are also being used for the Src and Dst arguments, that's a total of 6 registers. The original patch tries to put (FxU)NumberOfPixels) into a register as well, which is a total of 7.

Here is the assembly generated by gcc (from FormatConversion.s):

Code: Select all
movq  (%esi), %mm7;movq  (%ecx), %mm6;movq  (%edx), %mm5;movq  (%eax), %mm4;.align 16;MMXConvert565to8888_copying:movq  (%ebp), %mm0;addl $8, %ebp;movq  %mm0, %mm2;movq  %mm0, %mm1;pand  %mm4, %mm0;pand  %mm6, %mm2;psllw $11, %mm0;pand  %mm5, %mm1;psrlw $8, %mm2;movq  %mm1, %mm3;psllw $13, %mm1;por   %mm2, %mm0;psrlw $3, %mm3;por   %mm3, %mm1;por   %mm7, %mm1;movq  %mm0, %mm2;punpckhbw %mm1, %mm0;punpckhbw %mm1, %mm2;movq  %mm2, (%edi);addl $16, %edi;movq  %mm0, -8(%edi);subl $4, 28(%esp);jg    MMXConvert565to8888_copying;EMMS;


As you can see from the first 4 operations, the 4 masks are copied from the locations pointed to by esi, ecx, edx and eax into the mmx registers, so those 4 general purpose registers are still being tied up with these masks.

The strange thing is that my change (using the 'm' class for (FxU)NumberOfPixels) doesn't use a register, it just passes it on the stack (as you can see from the subl $4, 28(%esp); above). So, I guess that a variable already on the stack with a 'm' class constraint stays on the stack. The masks are on the heap, and they do tie up a register when using the 'm' class. Sure enough, if I copy the 4 mask definitions (Mask565A/R/G/B) to inside the Convert565to8888 function - just above the inline assembly- they use the stack instead:

Code: Select all
movq  24(%esp), %mm7;movq  16(%esp), %mm6;movq  8(%esp), %mm5;movq  (%esp), %mm4;.align 16;MMXConvert565to8888_copying:movq  (%ecx), %mm0;addl $8, %ecx;movq  %mm0, %mm2;movq  %mm0, %mm1;pand  %mm4, %mm0;pand  %mm6, %mm2;psllw $11, %mm0;pand  %mm5, %mm1;psrlw $8, %mm2;movq  %mm1, %mm3;psllw $13, %mm1;por   %mm2, %mm0;psrlw $3, %mm3;por   %mm3, %mm1;por   %mm7, %mm1;movq  %mm0, %mm2;punpckhbw %mm1, %mm0;punpckhbw %mm1, %mm2;movq  %mm2, (%edx);addl $16, %edx;movq  %mm0, -8(%edx);subl $4, %eax;jg    MMXConvert565to8888_copying;EMMS;


Is this the best solution? Just declaring the masks on the stack before passing them into the inline assembly?

As a side note, I really need a 64bit box. I am getting a serious case of register envy here. All of you x86_64 users have so many registers, you don't know what to do with them. :happy:
pk
Newbie
 
Posts: 5
Joined: 2007-12-22 @ 21:11

Re: Various patches for OpenGlide

Postby gulikoza » 2007-12-23 @ 13:35

hmm...what happens if you add const to mask initializations? Masks are only used in each function only once, so I guess they could be defined inside the function anyway...
User avatar
gulikoza
Oldbie
 
Posts: 1705
Joined: 2004-6-25 @ 14:53

PreviousNext

Return to OpenGLide Development

Who is online

Users browsing this forum: No registered users and 1 guest