More vertical tearing

BlitzMax Forums/BlitzMax Programming/More vertical tearing

Grey Alien(Posted 2006) [#1]
OK, this doesn't seem good. I was experiencing vertical tearing in Windowed Mode and Skidracer suggested setting the HZ of the windowed mode to be the same as the dekstop. Sounds logical, and it IS an improvement if Flip -1 (still bad on Flip 0 or Flip 1) BUT there is still at least one big tear that stays at the same place on the screen each time.

Does anyone else get this and are there any suggested fixes? It's fine in full-screen mode btw.

DesktopRefreshRate = GetDeviceCaps(GetDC(0),VREFRESH)

Graphics 800,600,0,DesktopRefreshRate 
'Graphics 800,600,32

While Not KeyHit(KEY_ESCAPE)
  Cls
   
  mx = MouseX()
  my = MouseY() 
  
  DrawRect mx,my,100,600
    
  Flip -1 'try changing this. 0 and 1 are no good on my PC, -1 is best
Wend
End


thanks for any suggestions!


Grey Alien(Posted 2006) [#2]
I gotta bump this as it's still an issue...


xlsior(Posted 2006) [#3]
Same here... One tear with -1 (which moves from the top to the bottom of the screen over ~30 seconds or so), half a dozen tears in the other modes.


Robert Cummings(Posted 2006) [#4]
why are you using -1 ?


xlsior(Posted 2006) [#5]
why are you using -1 ?


From his code:

"Flip -1 'try changing this. 0 and 1 are no good on my PC, -1 is best"


Robert Cummings(Posted 2006) [#6]
Does that answer my question?


Yan(Posted 2006) [#7]
I dunno, does it?


Grey Alien(Posted 2006) [#8]
-1 cos it's the default. I don't want no Vsync i.e 0 but I could use 1 I guess except that it makes more tears in windowed mode.


Kuron(Posted 2006) [#9]
The only time I have experienced "tearing" with BMax in windowed mode is when using the DX drivers.


Grey Alien(Posted 2006) [#10]
That's what I'm using, DX Drivers i.e. the default ones in BMax.


Robert Cummings(Posted 2006) [#11]
Oh right, well thats just "flip" then without the -1.

Have you tried it without -1 or even verified the docs aren't out of date regarding -1 as the parameter? Changes often happen and the docs aren't updated.

If you have vysnc disabled in your drivers, there's absolutely nothing blitzmax can do to help you.


Grey Alien(Posted 2006) [#12]
Without -1 = same effect, 0 and 1 have worse tearing therefore I conclude that -1 is still the default.

Vysnc is enabled in my drivers, well it says "On unless app specifies otherwise" so unless BMax or Windows is switching it off, it should behave. Certainly in full screen Vsync IS occuring properly.

It can't just me (and Xlsior) though can it. Anyone else get this problem?


xlsior(Posted 2006) [#13]
It can't just me (and Xlsior) though can it. Anyone else get this problem?


Probably... Although I must admit, before running your example that shows it pretty clearly, I had never noticed any tearing in my own programs in windowed mode...

It's just not as obvious when you are using smaller sprites & stepping sizes.


Kuron(Posted 2006) [#14]
That's what I'm using, DX Drivers i.e. the default ones in BMax.
Use the OpenGL driver, it should fix the problem.

I don't think BRL should have ever switched the default drivers. They should have left OpenGL as the default. BMax was supposed to be OpenGL based. DX support was added as an after-thought, but unfortunately, even though they have tried some tweaks on it, the DX drivers are still not as fast and reliable as the OpenGL drivers and there seems to be more compatibility issues with the DX drivers :c(

With the way things are right now, it would really be best to provide your EU with the option to choose OpenGL or DX so they can select what looks and works best for their system.


Grey Alien(Posted 2006) [#15]
Xlsior: Yes, it's less obvious on smaller sprites unless they are moving sideways and fall right on the split. What's "stepping sizes" btw?

Kuron: I could offer users the option but a lot of the target market (most) won't have a clue what this means. Also a debate rages on which is the most supported on the widest range of PCs and which is fastest, and it *seems* that at the moment the answer is DirectX, which is why I'm battling with getting it working OK.


kenshin(Posted 2006) [#16]
Yeah I get the tearing when I move the box quickly. VSync is set to always on.


Grey Alien(Posted 2006) [#17]
OK thanks, and you don't have a Radeon, so it's definitely a DirectX and BlitzMax problem. Can't remember if I ever tested this in Blitz Plus. I'll do so now ...

[edit] This Blitz Plus code is PERFECT, no tearing. This issue is now officially a bummer (in my books).

Graphics 800,600,0,2

While Not KeyHit(1)
  Cls
   
  mx = MouseX()
  my = MouseY() 
  
 Rect mx,my,100,600
    
  Flip
Wend
End



Kuron(Posted 2006) [#18]
I could offer users the option but a lot of the target market (most) won't have a clue what this means.
Unfortunately, so.

Also a debate rages on which is the most supported on the widest range of PCs
DX hands down.

and which is fastest, and it *seems* that at the moment the answer is DirectX
Unfortunately, with BMax all tests people do show that the OpenGL driver is the fastest (by a huge margin). BRL have not been able to bring the D3D driver up to par with the OpenGL one yet. :c(

IMHO, the DX side of BMax is still not ready for prime time and IMHO, the DX side of BMax is NOT getting the attention from BRL that it should.

Grey: You have been spoiled by B+, B2D & B3D. Sadly, BMax in is not up to par with the previous products. DX performance is the biggest issue with the sound issues a close second.


Grey Alien(Posted 2006) [#19]
yes this is a little worrying. BMax gives me the extra fancy effects to make a pro game and OO code too which is great. But there are some issues, I've spent the last week or so working them all out and getting fixes for them.


Robert Cummings(Posted 2006) [#20]
Curious, I tried your example, and I get this. However I do not notice any tearing in my actual game. It should be noted that this phenomenon occurs with ogl and dx, and I can't be bothered to worry about it... surely everything isn't flip false?


It's probably because it is more noticable with black and white. I have an LCD. What do you have?


dmaz(Posted 2006) [#21]
[quote]Also a debate rages on which is the most supported on the widest range of PCs

DX hands down.[/quote]

Can I ask which GFX card or chipset sold in the last 5 years currently doesn't have a competent OpenGL driver?


Robert Cummings(Posted 2006) [#22]
Sorry to have to bring you up sharply dmaz, but dx7 compatiblity is a REQUIREMENT of the majority of online publishers. They have a huge base of customers who have DX7.

For example www.realarcade.com

This isn't about your personal preference, but about a market you know nothing about - people who genuinely make up the majority of computer users and do not install new drivers. I know it is insane, but there you have it.


Kuron(Posted 2006) [#23]
Can I ask which GFX card or chipset sold in the last 5 years currently doesn't have a competent OpenGL driver?
any of the POS chips built into motherboards, which are the video chips your average home user will have?

Like it or not, Windows uses DX. If you are making a game for Windows, DX is the preferred API.

Most people will be using the drivers that ship with Windows, in which case OpenGL support will be "software" only and provide lousy performance.

Even for the few who would update drivers, "MS Certified" drivers will often knacker OpenGL performance.


Grey Alien(Posted 2006) [#24]
One Eyed Jack: I have a CRT. I am just making a mini game with large coloured sprites, and in windowed mode you *can* see the tearing on them as they move sideways, this is RUBBISH!

Flip 0 and 1 have tearing that is more random as opposed to -1 which gives tearing in the same place (for a while at least). Maybe random tearing is actually better as it may quickly move off of a sprite rather than staying on the sprite making it look rubbish for it's entire sideways movement.


xlsior(Posted 2006) [#25]
What's "stepping sizes" btw?


I just meant that it's a lot less visible if you don't have much horizontal movement, since the size of the tear itself will obviously be smaller.


Robert Cummings(Posted 2006) [#26]
findings and a cure

Here's my findings: it's definally not waiting for sync, that is genuine tearing. My conclusion is that max2D is not doing something right. If you add the following code that forces DX to wait till the flip is finished, ie a manual sync, then the tearing is cured in full screen.

Coincidentially it's the same code that fixes mouse lag under dx.

If TD3D7Max2DDriver(_max2dDriver)
While DDERR_WASSTILLDRAWING = PrimaryDevice.PrimarySurface.GetBltStatus(DDGBS_ISBLTDONE)
Wend
EndIf

Problem is it does not fix windowed mode nor full screen, and the tearing is still present under open gl.

This is your problem to deal with as I don't have time to get involved. Not being nasty, just really got no time for this issue. I hope you can use the information for a bug report or some such thing.


TartanTangerine (was Indiepath)(Posted 2006) [#27]
You might also want to modify the flip code, this will prevent additional flips if they are not required.
	Method Flip()
		Device.EndScene()
		If state&DX7FULLSCREEN
			If PrimarySurface.GetFlipStatus(DDGFS_CANFLIP) = DD_OK
				PrimarySurface.Flip Null,flipflags
			EndIf
		Else
			If PrimarySurface.GetBltStatus(DDGBS_ISBLTDONE) =  DD_OK
				Local src[]=[0,0,width,height]
				Local dest[]=[0,0,width,height]
				ClientToScreen hwnd,dest
				dest[2]:+dest[0]
				dest[3]:+dest[1]
				PrimarySurface.Blt dest,BackBuffer,src,0,Null
			EndIf
		EndIf
		Device.BeginScene()
	End Method



IPete2(Posted 2006) [#28]
The reason why this is happening in the first place is surprising, based on the bmax docs, either they are wrong or it is not as simple to lock into the vertical sync as it should be.

There should be absolutely NO graphic tearing if all the drawing is done to the buffer. Tearing only occurs when you are drawing to the area of memory which is being drawn onto the screen. Which in this case - as Grey states, should not be happening.

So does that mean something is broken or not working properly or that we don't understand what is happening when we use the draw rect command properly?

IPete2.


Grey Alien(Posted 2006) [#29]
One Eyed Jack: My example doesn't tear in full-screen mode and thus doesn't need the lag fix. Having said that, in the game framework I've just made I HAVE used the lag fix but might change it to Indiepath's one if it works properly. I understand you have no more time, fine. This issue is just not very good that's all, and I'd like to get it sorted.

Indiepath: Is that a complete replacement function or should it be modified in one of the modules.

IPete2: Just to clarify: It happens with DrawImage too, not just DrawRect.

Does anyone know how to clear the screen and draw a rectangle in OpenGL as this code

SetGraphicsDriver GLGraphicsDriver()

'DesktopRefreshRate = GetDeviceCaps(GetDC(0),VREFRESH)

If Graphics(1024,768,0,DesktopRefreshRate)=Null Then
	RuntimeError("Graphics Returned Null")
EndIf
'Graphics 800,600,32

While Not KeyHit(KEY_ESCAPE)
'  Cls
   
  mx = MouseX()
  my = MouseY() 
  
'  DrawRect mx,my,100,768
    
  Flip -1 'try changing this. 0 and 1 are no good on my PC, -1 is best
Wend
End


won't compile if I uncomment CLS and DrawRect! So I can't test tearing in OpenGL Mode. I have tested it with GLMax2DDriver() and D3D7Max2DDriver() and the tearing is present on both.


Robert Cummings(Posted 2006) [#30]
Agreed IPete2.

I have tried it with images and tearing still happens. I think this part of Blitzmax needs some official attention.

Tim: That flip code refers to DX, and the problem still remains under OpenGL. Which I think is unusual?


Grey Alien(Posted 2006) [#31]
OEJ: You probably missed my post, but how have you tested it under OpenGL?


TartanTangerine (was Indiepath)(Posted 2006) [#32]
Sorry guys, I really don't think this is a problem worthly of any time spent on it, I suspect BRL are of the same opinion.


Grey Alien(Posted 2006) [#33]
How can vertical tearing, which ruins the look of a windowed game, be not worthy of any attention, esp. when it's fine in Blitz Plus! It's going to mean that any professional BMax games are going to sub-par in windowed mode compared to other commericial titles. Great way to compete!

I'm going to stuff it in the bugs forum now, but if anyone can add more to this one, then great, please do so.


TartanTangerine (was Indiepath)(Posted 2006) [#34]
'cmon do you really think that a having a little vertical tearing is going to make a good game sub-par? I don't think so.


Robert Cummings(Posted 2006) [#35]
I personally don't care for this issue, but I believe it is still a minor problem...

Grey: SetGraphicsDriver GLMax2DDriver()


Grey Alien(Posted 2006) [#36]
OK, well you guys don't care, but I do. So I've posted it as a bug for now. It really makes the mini game I'm working on ugly as it has sideways moving UFOs and ship.

OEJ: Thanks, I had tested that one, shoulda realised it was open GL, doh. However what is GLGraphicsDriver()? Is it a pure OpenGL driver that you ahve to use only OpenGL commands on? I guess so...


IPete2(Posted 2006) [#37]
Jake,

I care too - I think that accepting it is not a good idea, living with it for now while it is sorted is okay as long as it gets fixed.

It makes the difference between games which look sloppily coded and solidily coded even though its not the programmers fault.

IPete2.


TartanTangerine (was Indiepath)(Posted 2006) [#38]
I just wanted to check, have you tried Flip() without any flags at all?

I also found this on the web (posted by nVidia on Microsoft), it refers to DX7.

Windowed Apps:

1) When blitting to a Windowed app the blit is not synched to VBlank. There is presently no way to ask for this. Microsoft are implying that this may change in the future to improve the visual quality of the desktop. In theory drivers can tell applications the current scanline being processed by the RAMDAC (via the GetScanLine method) but most drivers do not export this data and instead return 0.


Grey Alien(Posted 2006) [#39]
IPete2: I agree, it's a shame if the game looks worse and it's the fault of the engine not your code.

Indie: Yes Flip() defaults to -1 so it's the same. That text is interesting, implying there may be no fix. Shame that it works fine using DirectX 1 which BlitzPlus uses!


TartanTangerine (was Indiepath)(Posted 2006) [#40]
@Grey, actually if I put -1 I get different results than I would if I left it blank.

[edit] And looking at the Interval code there are settings for 0,2,3 and 4!


Grey Alien(Posted 2006) [#41]
weird you get different results. Basically -1 gives a single tear that remains in the same place as the app runs. Re-run the app and the tear is somewhere else. Change the flag and you'll get loads of random tears, i.e. much worse.

What's the "Interval Code", you mean there are other settings for Flip?


TartanTangerine (was Indiepath)(Posted 2006) [#42]
Accorinding to the BMAX directX module source there are 4 different interval settings.


Grey Alien(Posted 2006) [#43]
lol, you still didn't explain what an interval setting is...