3DFX emulation

Discussion of development and patch submission.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

Core i5-something or other (3.6 GHz Ivy Bridge), 4 GB RAM, Windows 7 64-bit.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Streets of Simcity in 3dfx crashes PCem itself after splash. Software mode is OK. Voodoo 2MB FB 4MB TM. PMMX233 in Win98SE. Plain i686 build, no profiling. or other flags.

End of the log:

Code: Select all


Swap buffer 00000003 5 0FF70350
Swap buffer 00000003 4 0FF70350
Swap buffer 00000003 3 0FF70350
Swap buffer 00000003 2 0FF70350
Swap buffer 00000003 1 0FF70350
onesec
Swap buffer 00000001 1 0FF70350
voodoo_fb_writel : bad LFB format 00000112
PIC1 : MASK 28 PEND 00 INS 00 VECTOR 50
PIC2 : MASK 1D PEND 00 INS 00 VECTOR 58
Dumping rram.dmp
Double fault 553658614
Abrt reading from 8009B040
Triple fault - reset
PIC1 : MASK 28 PEND 00 INS 00 VECTOR 50
PIC2 : MASK 1D PEND 00 INS 00 VECTOR 58
Dumping rram4.dmp
Dumping done
EAX=00C90F9E EBX=00000002 ECX=C6690120 EDX=00F4FAF4
EDI=00000002 ESI=10040498 EBP=00F4FA28 ESP=C5B0DFA8
PC=0000 CS=FFFF DS=016F ES=016F SS=0030 FLAGS=0002
0167:10014727 0000:0000
553658614 ins
In real mode
CS : base=0FFFF0 limit=0000FFFF access=00  limit_low=00000000 limit_high=0000FFFF
DS : base=000000 limit=0000FFFF access=00  limit_low=00000000 limit_high=0000FFFF
ES : base=000000 limit=0000FFFF access=00  limit_low=00000000 limit_high=0000FFFF
FS : base=8158D0F8 limit=0000FFFF access=00  limit_low=00000000 limit_high=0000FFFF
GS : base=FFFFFFFF limit=0000FFFF access=00  limit_low=00000000 limit_high=0000FFFF
SS : base=000000 limit=0000FFFF access=00  limit_low=00000000 limit_high=0000FFFF
GDT : base=C0FDE000 limit=0FFF
LDT : base=80004000 limit=3FFF
IDT : base=000000 limit=02FF
TR  : base=C000D7A4 limit=2069
386 in 16-bit mode   stack in 16-bit mode
CR0=00000000 CR2=0002F5E3 CR3=0079F000
Entries in readlookup : 12204    writelookup : 516
Entries in readlookup : 256    writelookup : 2
ST(0)=0.000000	ST(1)=366.125000	ST(2)=-36.000000	ST(3)=0.027778	
ST(4)=-0.000000	ST(5)=0.000000	ST(6)=380.500000	ST(7)=-29.000000	
Status = 0100  Control = 037F  Tag = 0003
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

Fixed in rev 255.

Incidentally, Streets of Simcity is probably the worst game I've played during the development of this emulator.
Orchidsworn
Posts: 65
Joined: Sun 22 Mar, 2015 10:16 pm

Re: 3DFX emulation

Post by Orchidsworn »

TomWalker wrote:Fixed in rev 255.

Incidentally, Streets of Simcity is probably the worst game I've played during the development of this emulator.
Performance wise or just as a game on its own?
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

As a game. It's pretty awful.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Gamma and filter updates against revision 256. Can't make a diff patch at the moment but there's this whole file. Tried to organize my stuff further
Attachments
vid_voodoo.c
(163.96 KiB) Downloaded 582 times
pcemgta.jpg
pcemgta.jpg (239.5 KiB) Viewed 28478 times
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

Looking good!

I've had a look into the 8-bit paletted alpha issue with Q3V, and the hardware is being sent commands for 8-bit paletted textures without alpha, so I don't think this is an emulation bug. In fact, Voodoo 1 doesn't support 8-bit paletted alpha textures, only a 16-bit form of 8-bit colour + 8-bit alpha, which probably isn't what you want. Voodoo 2 does add a proper 8-bit paletted alpha format.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Thanks. Looks like i'll have to add a fallback to that 16bit texture format in the q3v/OA code, I only developed it with Voodoo2/3 in mind anyway.

Also here is a hopefully 60fps video running Turok in 512x384 with the filter/gamma


There IS still the annoying feedback streak bug that is somewhat noticable (can be seen from the command menu text of this screenshot. Makes me want to backport the PCemFX HLSL stuff just to have the pixel shader ported over just for better precision and speed
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

A diff patch for the filter.
Attachments
voodoo_filter.patch
(9.98 KiB) Downloaded 579 times
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

Hah, reddit has picked up on the NFS video for some reason, and there's a 100+ comment thread commenting on how pointless is all is.

Unreal doesn't have anything like as much love :(
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Virtualbox fanbase? not surprising

There's lots of comments that it's hopelessly slow, so I marked my turok video public to help that
Orchidsworn
Posts: 65
Joined: Sun 22 Mar, 2015 10:16 pm

Re: 3DFX emulation

Post by Orchidsworn »

So many people think all the good games are already emulated, some think that a virtualmachine can do everything. Had this conversation with someone who said if it is not emulated by this point and over 15 years old it just was not worth emulating. So I pointed out a few examples of emulators and where they fail and that they are still being actively developed. And he ask me why I care so much and I asked him why should you care that I do.

I just don't understand how you can tell someone they are wrong for doing what they want with what they got to work with in life. It does the person mocking them no harm why type/say anything. Just ignore it. Sorry I just get so angry when people say something is useless emulators in particular for they preserve history. It is much like how my heart sinks when I hear a developer of an emulator say they will never support this or that function, utility, or emulate a specific piece of hardware.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Fortunately on the third time around with Turok at a more acceptable framerate on Reddit the unappreciative virtualization snob got buried.
Orchidsworn
Posts: 65
Joined: Sun 22 Mar, 2015 10:16 pm

Re: 3DFX emulation

Post by Orchidsworn »

leilei wrote:Fortunately on the third time around with Turok at a more acceptable framerate on Reddit the unappreciative virtualization snob got buried.
:) Score one for the good guys.
Zilog
Posts: 51
Joined: Wed 13 May, 2015 8:01 pm

Re: 3DFX emulation

Post by Zilog »

Hi,
how driver version you use on windows 95?

Thanks.
by.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

I tried to expand the supported threads to 4 (2 is actually enough for the original V1, but...why not), not knowing a thing about multithreaded programming.

learning by trial and error is fun though
Attachments
pcem3dfx4.png
pcem3dfx4.png (86.5 KiB) Viewed 27578 times
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

I posted a video of Unreal Tournament running on v10 a little while ago - https://www.youtube.com/watch?v=UhmoUNMmsrM.

I also noticed that someone has recorded a bunch of games running in 3DFX mode - https://www.youtube.com/watch?v=d7ZMBLGC0Wo. A few interesting failures to look at!
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Many of these "too slow/unplayable" looks playable to me. WipeoutXL especially, it's made for more of that low 15-25 framerate.

Star Wars Racer is float/cache heavy, when I tried the FakeCyrix stuff with iit (which had larger timings for FPU ops upon PMMX instructions mostly) it emulated much faster.
A. Naim
Posts: 139
Joined: Thu 09 Jul, 2015 5:06 pm

Re: 3DFX emulation

Post by A. Naim »

Ok, I've written shaders before, but I dunno how hard this would be - I understand the 3DFX is software-emulated? How hard would it be to emulate it in shaders? There's some effort to write a filter shader, it looks like.

Edit: Er, I'm not offering; sorry if any mis-understanding. I'm up to my eyeballs in stuff to do. I'm just wondering about the possibility.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

3dfx is software rendered. The screen filter is a port of my D3D9/GL2 pixel shader to C - entirely in software. It's not as precise as i'd like it to be though (some slight dithering is untouched and there's terrible streaking feedback in places), and it's close enough for now.

I'd imagine you'd be missing on important timing stuff and per-scanline stuff if you were to implement 3dfx hardware in shaders. PCem's implementation is not like the classic 'as fast as possible' glide wrapper. It's aiming for all of the old Voodoo Graphics limitations and features, which is a good realistic target for CPU-bound stuff anyway, gives a reasonable bottleneck for the CPU to go with. The DAC processing is not tied to the clocks so it should be fine to do that portion on a HLSL postprocess alone.

EDIT: here's two comparison pics of my glsl shader and my C 'shader'. Disregard the mipmap bias in the top picture
Attachments
filter-oa.png
filter-oa.png (14.93 KiB) Viewed 26619 times
filter-pcem.png
filter-pcem.png (12.95 KiB) Viewed 26619 times
A. Naim
Posts: 139
Joined: Thu 09 Jul, 2015 5:06 pm

Re: 3DFX emulation

Post by A. Naim »

Thanks.
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

Rev 418 adds a 3DFX recompiler, currently for x86-32 only. This should give at least a 2x fillrate speedup on most games, though I've seen up to 4x. There are probably some bugs, do let me know if you see any...
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Just tried it. Indeed it's a nice speedup! Though so far i've only tried to choke it with my OA3 grass map which has lots of alpha shells of both alpha test and blend, animated to look like complex waving grass. It jumped from 5fps to 11fps with P200MMX Infinite. and i've only done a -flto build
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Recompiler bug found with Starsiege Tribes, involving a lightmap blending issue something like that causing some crazy moire and discoloration.

I've unchecked it in the second screenshot
Attachments
pcem-tribes-recompiler.jpg
pcem-tribes-recompiler.jpg (89.51 KiB) Viewed 26241 times
pcem-tribes.jpg
pcem-tribes.jpg (72.73 KiB) Viewed 26241 times
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

Should be fixed in rev 422.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

I've noticed 3dfx Voodoo doesn't seem to show up/detect in AMI WinBIOS 486

my real M919 3.4 WinBIOS 486 system (10/10/94) can use a Voodoo2 and it works, curious if this is a bug on an older '93 bios or a pcem bug or something..
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

The board emulated by the WinBIOS 486 setting doesn't have PCI - it's ISA/VLB only.
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

here's a UT video on a more recent PCem state. It's fast enough to win

I recorded in VirtualDub having PCem's affinity take the first 3 cores, and VirtualDub on the last one core.

EDIT: Tribes. The choppiness and appearance is normal, it's how Tribes performed in the day in a busy game. It was notorious for its partial lightmap uploads for dynamic lights (resulting in those lighting artifacts as a chunk of lightstep loses its lerping to have more definition for the dynamic light over it)

EDIT2: Turok in benchmark mode (partially)
User avatar
leilei
Posts: 1039
Joined: Fri 25 Apr, 2014 4:47 pm

Re: 3DFX emulation

Post by leilei »

Postfilter update.

I just realized what's causing the feedback bug all along and nailed it. I also tweaked some generation things trying to ensure there's floating precision with the table's differences to hopefully make a smoother and more stable filter. There should be 200% less long streaks now, the 3 pixel wide streaks should be the only streaks allowed.

BUGS:
- the rightmost vertical line is melted with the line left to it
- there's still some banding in some extreme close ups of filtered dither - might be too minor anyway
- still a bit slow

replace the voodoo filter block with #include "vid_voodoo_filter.c" and drop this in. i might be doing this instead of blind diffing

EDIT: Updated again fixing a typo on one line.
Attachments
vid_voodoo_filter.c
(4.07 KiB) Downloaded 423 times
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: 3DFX emulation

Post by SarahWalker »

Rev 557 adds support for the fancy Quantum 3D V1 boards with twin TMUs. This should give a bit of a speedup on the handful of Glide & OpenGL games that support twin TMUs - sadly, the V1 D3D drivers don't seem to support it.

Note that Unreal Tournament seems to have some intermittent palette issues. I believe this is a driver issue.
Post Reply