PocketMatrix forums

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

A FillRect() bug?

Hi,

I just noticed something weird. The minimal sample debug windowed version fills the screen with RGB(128,128,128) and write some text. It works as it should.

However the release version in full-screen does not fill the screen with grey. It stays black. The text is properly written, but no grey background.

I tried both the compiled version in the gapidraw distribution file and to recompile the source, no change.

I then tried the MFC demo and here is the screen that I got from the release version:

http://www.techlogic.ca/aw/gd.png

This is again the exec from the GD201d release.

Is it possible that there's a problem with FillRect()? I just checked but it doesn't return any error code.

--Eric
Hi Eric,

Wow, that's one slow graphics card.. 9 ms for 50 sprites in the MFC demo (!).. It's 3 ms on my machine with a slow graphics card built-in on the motherboard... Something is apparantly not correct here..

What gfx card are you using? What DirectX driver? How many MB of video memory? This is apparantly an issue and should be fixed... Thanks!
sbl wrote:Wow, that's one slow graphics card.. 9 ms for 50 sprites in the MFC demo (!).. It's 3 ms on my machine with a slow graphics card built-in on the motherboard... Something is apparantly not correct here..

What gfx card are you using? What DirectX driver? How many MB of video memory? This is apparantly an issue and should be fixed... Thanks!

Hi,

Here is my system: Athlon XP 2000+, MB MSI KT4 Ultra, 768 MB ram, GeForce 3 Ti200 128 MB. Video drivers are the WHQL certified 41.07 drivers from MSI. Any version of nVidia drivers after 30.82 (including latest one) make my system blue screen when using any DX 9 specific feature. I need good DX 9 for my game editor.

Most nVidia drivers after 30.82 are either not WHQL certified, WHQL candidate or certified only for GeForce FX (like 44.03). Boo nVidia.

I have DirectX 9.0a installed. I can run games like Thief and Unreal 2 without video problems at 30 FPS. HW acceleration is turned on in the display settings. All files report OK in dxdiag, all tests complete correctly without problems.

The speed of the MFC demo in release mode varies from 6 MS to 8 MS. The debug version complains about the MFC42D (or somesuch) DLL missing.

The Plasma and Tile demo work without problem on my system.

The "Simple" demo also works correctly, no visual problem both in debug and release form, the full-screen background is grey. It reports around 7-7.5 MS for rendering the frame.

The Collision demo also has a few problems. Here is the picture:

http://www.techlogic.ca/aw/gd1.png

The collision work correctly, it's just that the blue part inside the green region isn't drawn, nor I believe is it detected by the collision check.

I can't think of anything else for now. I hope it helps. Let me know if you need anything else, or want me to run other tests.

--Eric
This is most likely another NVidia issue with DirectDraw.. The reason why the "Simple" demo application works is that the backbuffer is stored in system memory, and FillRect is not hardware accelerated then. This is what we have so far:

(1) HW-accelerated FillRect does not work on all NVidia drivers
(2) HW-accelerated Blt with stretch (dest rectangle != source rectangle) does not work on any NVidia driver

//Johan
You might want to check this out:

http://www.gapidraw.com/gf2/

I have tested this even with the latest drivers and the results are identical. Apparantly it's the hardware that's incorrect and NVidia don't bother with fixing it..
The reason why the "Simple" demo application works is that the backbuffer is stored in system memory, and FillRect is not hardware accelerated then.


I tried to add the flags GDDISPLAY_BACKBUFFERSYSMEM to the Minimal sample, and sure enough the grey background was correctly display with this "fix".


This is most likely another NVidia issue with DirectDraw.


I remember trying the small blit test app last year and the issue is still unresolved. This is pretty annoying.

One way for GapiDraw to go around this issue might be to switch to DirectX 9 since it re-introduced some 2D support.

I use DX 9 Line, font and sprite interfaces for 2D in my game editor since I'm using Borland C++, and everything works nicely even with transparency and rotation or mirrorring, etc.

However I know plenty of people that play games and still don't have DX 9 installed. It wouldn't be a good move to force people to install DX 9 to try something out. It's not like most of us supply our apps on a CDROM. And the DX download is long on a 56K modem.

--Eric
sbl wrote:You might want to check this out:

http://www.gapidraw.com/gf2/


Is it possible to have the source to this app? I'd be interesting in seeing if a workaround of some kind can be found...

I emailed the author, but the email address on that page is dead.

--Eric
Hello! I'm Kevin Reems (the guy who wrote BltTest). About a week ago I replaced my Radeon with a GeForce4Ti4800. I was shocked when I fired up my current project only to see that four year old bug still exists even in the beast I just spent $175 on.
Needless to say I started working on a workaround and discovered what you already have.. the issue only happens when the blt is to a surface in video memory.
Obviously you'd want your primary or backbuffer(s) in video memory so the solution I've come up with is to do two blts.
The first to a surface in system memory. This is when you do your scaling, mirroring etc.
Then you blt That image to your destination in video memory (using BltFast if you'd like).

Last night I got bored and wondered if anyone else has their nuts in a vice due to this issue and stumbled on http://www.gapidraw.com/gf2/ which is a page I wrote back when GeForce2's were considered badass. So I've been looking into this site and think you guys really got something cool going on here.

I figured if someone took the time to host this page then there must be others looking for a fix or at least an explination. No doubt there's people who are new to programming and think their graphics look like ass because of something wrong with their code.

Without furthor ado, I've released BltTest2.

http://members.cox.net/kreems/dev/BltTest2.zip

This is a cleaned up version of BltTest1. It also features the workaround. The source code is included as are VisualC project files. It's kept as simple as possible. I don't think Borland users should have trouble getting the source to compile.

Please feel free to distribute this file.
I appreciate that the webmaster at gapidraw left my page unedited but if you wish to update the links or add a link to BltTest2 that's fine by me.

I don't currently have a domain so my addresses will probably change within a year. My current e-mail is kreems@cox.net if anyone has questions or comments.

-LBt1st
Hi,

Thanks a lot for that new version, and for the workaround!

I just made a new demo from scratch, with my own bitmap graphic and the problem is still there. Ok, I'm convinced! ;)

If I was to use double-buffering and flip those to the primary using the Flip() function, would I still get the problem?

I think you cannot flip when in window mode, but in full screen flipping is indeed the best way to go.

This is really an annoying issue. I can't believe no one ever fixed this problem.

Anyway, thanks for the post and source code! It'll keep me busy for a while ;)

--Eric

PS: If anyone wants to try a simple app that will easily show the problem, it's really easy using the latest DDUTIL.CPP (from the DX9 SDK), where you can use CDisplay and CSurface instead of having to manually call all the DX functions:

Code:

CDisplay D1;
if(SUCCEEDED(D1.CreateFullScreenDisplay(hWnd,1024,768,32)))
{
D1.Clear(RGB(0,0,0));
CSurface *S1;
if(SUCCEEDED(D1.CreateSurfaceFromBitmap(&S1;,"sprite1.bmp",64,64)))
{
if(SUCCEEDED(S1->SetColorKey(RGB(255,0,255))))
{
RECT R1 = {0,0,128,128};
if(SUCCEEDED(D1.GetBackBuffer()->Blt(&R1;,S1->GetDDrawSurface(),NULL,DDBLT_KEYSRC,NULL)))
{
D1.Present();
}
}
}
}
Hi Kevin,

Thanks for the feedback. I'll drop you an email later..

//Johan
www.gapidraw.com
http://members.cox.net/kreems/dev/BltTest21.zip
(New Version 2.1)

I have made another discovery.
It seems I was wrong in stating the bug happens when the destination blt is into video memory.
My latest findings prove that the bug only happens when the source AND the destination surfaces are in video memory.
This can be seen by adding DDSCAPS_SYSTEMMEMORY to the test surface's caps in BltTest2.
This is good news because we now have another option in dealing with this bug by forcing into system memory any surfaces that will be scaled from.
Depending on what your doing it may be better to do this then the previous workaround. I'll be experimenting with performance differences of the two methods. Considering how fast AGP has become it may not be such a bad idea to simply toss some surfaces into RAM.

btw I found a minor bug in BltTest2. I forgot to NULL a couple of ddbltfx.dwDDFX's so one of the images mirror when it shouldn't. This is a bug with my code and not the card/driver.

-Kevin Reems
Eric:
Did the FillRect issue go away with the older drivers?
sbl wrote:Did the FillRect issue go away with the older drivers?

In gapidraw yes, I have not seen any anomaly in anything GapiDraw-related.

However in the BltTest program the visual anomaly is even worse.

I'm still using the v15.xx, and have not seen any problem in any other area of Windows.

--Eric