VOGONS


Various patches for OpenGlide

Topic actions

Reply 20 of 73, by `Moe`

User metadata
Rank Oldbie
Rank
Oldbie

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.

Reply 21 of 73, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

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?

How To Ask Questions The Smart Way
Make your games work offline

Reply 22 of 73, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

(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/ObjectID/82AB … 5D/310/274/ART/

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 | Fedora 32

Reply 24 of 73, by lumyk

User metadata
Rank Newbie
Rank
Newbie

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.

Reply 25 of 73, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

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... 😢

http://www.si-gamer.net/gulikoza

Reply 31 of 73, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

Great to see the patches in cvs 😉
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.

http://www.si-gamer.net/gulikoza

Reply 33 of 73, by MiniMax

User metadata
Rank Moderator
Rank
Moderator

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 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 | Fedora 32

Reply 34 of 73, by pk

User metadata
Rank Newbie
Rank
Newbie

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:

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?:

         : /* 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?

Reply 35 of 73, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

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.

http://www.si-gamer.net/gulikoza

Reply 36 of 73, by pk

User metadata
Rank Newbie
Rank
Newbie

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

         : /* 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:

/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:

        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.

Reply 37 of 73, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

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... 😀

http://www.si-gamer.net/gulikoza

Reply 38 of 73, by pk

User metadata
Rank Newbie
Rank
Newbie

Ahhhh. Okay, now I see what you mean. 😊

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):

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:

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. 😀

Reply 39 of 73, by gulikoza

User metadata
Rank Oldbie
Rank
Oldbie

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...

http://www.si-gamer.net/gulikoza