PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Developer Thread

This thread is for communication between programmers working on Pocket Quake. Please don't post to this thread if you are not participating in Pocket Quake development. Thanks.

Dan East
Jacco, Carpediem; I've added a new variable which allows the user to control how many particles are rendered at most (the default was 2048 ). The new var is:

r_maxparticles
The range is 0-2048, or if a -particles command line parameter was specified ("-particles p" ), then the range is 0-p.

Previously this could be modified via the command line ("-particles" ), which is not the preferred mechanism for making settings of that kind. The command line parameter can still be used to increase the maximum number of available particles if more than 2048 are desired.

Just to prevent you guys from doing the same thing...

Dan East
Last modification: Dan East - 02/27/01 at 05:05:35
I'm still struggling with CalcGradients. Starting to look better (using some angles I can distuingish textures:), but this will take some time... I have plenty of time tonight (I think), so it should be fixed by tomorrow. Boy, is this a mean bastard. :(
I didn't notice a very big speed gain from your modified actor CalcGradient, btw. Did you time it yourself? I expected it to matter more.
BTW, cool thread. :) To be honest, I just wanted to post something. :))
Chris Edwards · 27 Feb 2001, 09:21 UTC
Want me to move this thread to the General Developer Discussion board?
I get .2 fps increase with the int-based CalcGradients. Even if an optimization results in only a theoretical increase, I'm all for it if it doesn't reduce the visual accuracy. :)

Reducing the particles to 100 using the new r_maxparticles variable increased fps by .3. 100 seems to be a good value because you can still see rocket / grenade trails, blood spray, and enough particles for decent looking explosions. It basically prevents the big slow-down resulting from the massive particle explosions of normal Quake. Those using slower devices could prevent all particle effects from occuring.

I've been having a hard time getting real consistant fps readings regardless of the technique. It seems like I get a substantially higher (.5 fps) reading just after I first build and download a new version, so I've been throwing out the first result. Subsequent runs are slower and consistant. Of course I reset the device and start fresh each test. This is one of the reasons I saw a 24% performance increase with your first optimization, while others didn't realize that large of an increase.

Chris; I'd rather this stay in a Pocket Quake category, because it is totally specific to the project at this time. BTW, according to the Forum List this forum is in the " Developer" category already. Perhaps a new forum could be created for general PQ discussion?

Dan East
Last modification: Dan East - 02/27/01 at 07:52:42
Dan,

I developed my 3D engine and some upcoming stuff on my PC by using OpenPTC for the graphics output. OpenPTC provides you with a very basic window and a buffer (palettized or any other bitdepth) in wich you can simply draw. Maybe it is a good idea to port Quake to OpenPTC, to ease the development. That would allow all coders to work on the PC (I for example don't have an USB cradle, meaning that I have to wait for ONE MINUTE to test EACH NEW VERSION). This could seriously ease the fixed point coding. I'll see what I can do tonight.

Jacco.
Will it work with CE? Besides the user input, Windows is not used at all for output (and shouldn't be) - we directly access the screen buffer. The current code should build for Win32 without too many modifications.
I use the emulator extensively for testing new routines before finally going to the actual device. Besides the inability to do Landscape, the emulator has been very accurate as far as the alogithms go (and besides the fact that it is blistering fast).

Dan East
How hard is it to make pocketquake C++ compatible and then make a fixedpoint class and replace every keywork float or double for the corresponding class name.
I've worked on a class such as that when i was making a fractal test for a benchmarking tool that i made, but quitted on the attempt because i found a much easier solution.

Come on Jacco!, get Windowz 2k! it rocks!

Last modification: CARPEDIEM - 02/27/01 at 09:43:04
Carpediem,

That class is not going to work, since we need varying accuracy in the integer part and the fractional parts of the fixed point numbers. It WOULD however be very nice if we would have a fixed point class with adjustable precision (int/frac), and small pieces of ASM code for multiplications using 64bit intermediate results.

By the way, I finished that CalcGradients function last night. I need to fine tune a couple of things, and I have to fix the sprite code a bit, but after that I have a rather large amount of new stuff for you guys:

1. The CalcGradients function is now fixed point and calculates the texture projection matrix in fixed point too, so the conversion of this matrix to fixed point by the scan renderer is no longer neccessary
2. The span renderer and the z-span code are now merged (that's faster, of course, especially since those functions contain mostly the same code)
3. The sky is now drawn without perspective correction (unnoticeable)

That's about it. Maybe some small changes, but this is the main part. I will fix up the sprite code and send Dan a long list of instructions to merge this with the original code. After that, I consider my job done, and I will continue to work on 'new' software. :)

- Jacco.
Hey all,

I have just sent my latest modifications to Dan. Changes include:
- Affine textured sky
- Completely fixed point texture projection matrix
- Fixed point 'turbulence' textures
- Joined z-buffer/pixel span rendering
and some more that I forgot. I hope Dan can tell you all how much it matters.

I will stop here; I'll let other coders take over now. I'm back to my other pet projects.

Greets,
Jacco.
Well i'll try working on the keyboard this weekend. I know the problem comes from the modifications i did when altering the drawing funcions.
You see Dan, i modified some things on the drawing function, And i know that's why the keyboard is not showing.
the problem is that i have to open "(*GXBeginDraw_)();" and close the frame buffer everytime i want to display the image. Otherwise the screen won't refresh.
Actually, i have no idea of why it works on the ipaq, the only way to display the contents of the framebuffer that i know of is by using
(*GXEndDraw_)();
So, the thing is that when i call (*GXBeginDraw_)(); the framebuffer is filled with the screen contents and they don't include the keyboard, and when i close the framebuffer, the screen is redrawn, Drawing over the keyboard. So i believe that's why people can't see it.
Anyway, i guess you received the new optimizations by jacco, How to instert them is pretty well explained but you'll get 4 simple compilation errors. You can quickly fix them by inserting these lines:

extern int fpxscale;
extern int fpyscale;
extern int fpxcenter;
extern int fpycenter;

Right before

static fpvec3 mo;
static float tmo;
void D_CalcGradients (msurface_t *pface)
{
I've got it built with the modifications. I also had to define fpvec3 in mathlib.h:
typedef int fpvec3[3];

What type of performance boost have you seen? I get around .2 fps increase.

Dan East
Dan, can you help me out with the drawing function?
Can you explain to me how do you draw on the ipaq?
This is the way i know how to write on the framebuffer.

1) Ask for a pointer of the framebuffer.
2) draw over it
3) draw on the screen by closing the framebuffer

You don't seem to do that with the ipaq version i got.
Btw, i get the same speed increase.
these are my scores on my E-125 @ 200.7

Timerefresh: 3.74 fps
demo1: 6.6 fps

These scores using the latest .cfg from 999

It's Pretty playable on the casio i must say. Im also drawing a gray sky, because if i draw it with the optimized functions, framerate on the timerefresh test drops to 3.5


Last modification: CARPEDIEM - 03/02/01 at 10:08:15
That's what I do, I just don't release the buffer every frame. At the beginning of the drawing I see if I have the buffer still. If not, I get it. I have rewritten those routines completely from what you have (I think). Now I calculate all drawing parameters up front, so the actual drawing is totally generic. This allows the exact same drawing routine to work for portrait, both landscape modes, and other types of devices, without having any conditional logic.

The reason I don't release the buffer each frame is because Microsoft says you don't have to, but it does not work that way on MIPS and SH3 devices (apparently you have to release each frame).

Notice the conflicting info, this is straight out of the Game API docs (do a search for GAPI, then select the document "Animating Graphics" ) :

To continue drawing more data on the screen, call GXBeginDraw to get a pointer to the VFB. As soon as drawing is complete and no later, call GXEndDraw.

Note   Consider the performance cost of these calls when implementing them in your application, because they will typically be done 20 or 30 times per second. It is acceptable to draw several frames between the GXBeginDraw and GXEndDraw calls, but you must remember to call GXEndDraw in WM_KILLFOCUS if necessary.


Ok, so they say you should release the buffer "as soon as drawing is complete and no later", and two sentences later say "It is acceptable to draw several frames between the GXBeginDraw and GXEndDraw calls". So to me that means you can hang onto the buffer until you get a WM_KILLFOCUS message. Even then the only reason you give up the buffer is if you want to be nice to whatever application gained the focus.
Thanks again Microsoft!

Dan East
Last modification: Dan East - 03/02/01 at 10:18:13
I have some numbers that you all might find interesting:
(Timming done on my Casio E-125@150mhz)

Gapi BeginDraw : 0.031ms
Gapi EndDraw: 3.052ms

total: 3.083ms per frame for Gapi ( ~324fps)

So calling EndDraw as little as possible isnt super critical, but definately something to think about..especially in Quake where 1fps speedup makes a tremendous difference.

Data Copying on the otherhand is a problem.. Numbers from some of the methods I tested:

Word->Word : 19.928ms(W/GAPI)50fps(~44fps)
Memcpy     : 11.841ms(W/GAPI)85fps(~67fps)

If anyone has some asm blitting routines that would make a huge difference.
Last modification: norvain - 03/02/01 at 15:17:27
Thanks, Norvain. Any idea why the buffer must be retrieved / released every frame with MIPS and SH3 devices? Do you see this behavior?

Dan East
0.2 fps speed increase? :) That's a disaster! I spend at least 10 hours on that! Anyway, apparently I'll have to think better about wich code needs to be changed...
All I can do is speculate but I believe it comes down to 2 things:

first GX.dll is made by Casio, so its possible that they were listening to Microsoft and following the spec directly

secondly, The Casio Pocket PC's have Video DRAM as opposed to a spot in memory like the IPAQ, so it most likely has something to do with the way the DRAM is updated...

Speed could also be another factor, given that Mem->Mem copies are faster than Mem->Video thus updating the screen once should be faster.

Display Memory may also be banked, requiring the driver to do bank switching when it copies the buffer over to DRAM, so direct Writes would be very complicated and slow down the system( as well as make GAPI Platform Specific, which is bad)

Jimmy of Jimmysoftware.com has written his own GAPI less display drivers, maybe he can shed some light on this or share his secret :)Last modification: norvain - 03/03/01 at 14:53:59
Dan, when are you going to send me the 0.05 source?, I have some time now since i failed the exam and that means an extra year of college :(
so send them to carpediem@velocom.com.ar (don't forget the .ar) when you can.

I'm trying to get a fixed point conversion working properly. If I don't have any luck by later today I'll send you what I've got without that improvement.

Dan East
Great Dan.

BTW, the old source you sent me was configured to be optimized for maximum speed, but also inline function expansion was set to: "Any suitable"

You might want to change that to "__only inline" for an extra 2 frames per second.

Thanks, but I already had the iPaq optimization settings at "any suitable" for automatic function inlining. The other targets will have default settings in some cases. I try to make changes to all configurations, but I don't always succeed. :)

Dan East
No no... I don't think i expressed myself properly.
What i mean is that i DO know that you have it set to: "Any suitable", i didn't have it set to that, and when i did my framerate decreased more than 2 frames per second.
What i would like you to try is to set it to:
"Disable*"
or:
"Only__inline"

The "Any suitable" option decreases performance on mips devices, i'd like to see what happens on ARM devices.
Nevermind, 999 tried an ipaq build and he didn't notice a speed increase.
I wonder why it gets so slow on casios when you use the "any suitable" option.
Okay, I reread your last post. So it runs slower with function inlining enabled on MIPS devices? One disadvantage of the MIPS devices is that they require very strict 4 (or is it 8?) byte data alignments, otherwise the processor is severely handicapped (like 5-10 times slower processing unaligned data). I don't know if inlining functions could hurt data alignment or not.

Dan East
Last modification: Dan East - 03/10/01 at 11:43:38
Mips devices use 32-bit data aligning, otherwise they slow to a crawl. So yeah, that would be 4 bytes as you stated.

OOPS, sorry, didn't realize this was the developer thread.

Last modification: randall - 03/10/01 at 11:56:16
Ok here's the deal with the configuration directives of eVC++.
I've been going through the different configurations options and got results ranging from 4.5 fps to 7.0 fps on the demo1 test.

If you select: "Any suitable" and at the same time you choose the DEFAULT processor on code generation, you get a huge fps drop.

In contrast, if you choose procesor 4100 AND "Any suitable" you get 0.3 more fps.

so i guess this is the best config for mips devices:

Optimization: "maximize speed"
Processor: "4100"
Inline function expasion: "Any suitable"
Can't MIPS Casio devices use 64-bit chunks?
I know PocketPC OS doesn't support it, but isn't Pocketquake mostly OS-independent? I think the MIPS cpus are like 64-bit. It sucks that everything only uses 32-bits!
Do all Casio Pocket PC devices have the R4100 CPU?

Dan East
I think so, the E-125 and the EM-500 have the same processor according to casio it's a VR4122. But it works just as fast with the R3900 processor config.

Anyway, i've been going through the sound code and realized that it doesn't use a lot of precision since i have changed most of the code from float to long and there doesn't seem to be a difference. So that might be useful if you plan on converting it to fixed point someday since now you know that precision is not needed so bad in it.

Anyway, i only got 0.3 more fps so far so changing it is not primordial i think, ohh, something else, sound is really great at 22050 so you might want to add an option for that since using it with earphones gives a really inmersive experience.

How is your work going?

Hey dan, do you remember the name of the function that was modified that caused the glitch in the wall textures when you got really close to them?, I'd like to see what speed increase it gives. Perhaps it's not a lot and we could also make it a toggle.


D_DrawSpans8 and D_DrawZSpans.

Dan East

Last modification: Dan East - 03/12/01 at 10:32:45
Whoops, my framerate dropped from 7.8 fps to 5.4 when i switched back to the old D_DrawSpans8
Carp dude,

That's not because of the perspective correction, it's because of the fixed point code in that function. :) You could theoretically put back the perspective correctness and at the same time keep the fixed point code. That takes some coding though.

- Jacco.