Potential Crash issue with D3D7Max2D and D3D9Max2D

Archives Forums/BlitzMax Bug Reports/Potential Crash issue with D3D7Max2D and D3D9Max2D

Brucey(Posted 2014) [#1]
Hallo :o)

There is an Assert in SetGraphics() of each driver which is a no-op in Release mode.
Failure at this point will result in a crash - for example, say you want a D3D9 context, but are happy to fallback to D3D7 if the user doesn't support D3D9, the chances are the app will crash in D3D9's SetGraphics, and not fallback.

A workaround/fix is to change the Assert to a Throw - you can at least catch a Throw and do something else :
Current ...
		Assert _max2dGraphics And _d3d9graphics


Fix ...
		If Not _max2dGraphics Or Not _d3d9graphics Then
			Throw "SetGraphics failed for D3D9"
		End If


This then requires the developer to use Try/Catch, but subsequently the app doesn't crash.

Yay! :o)


TomToad(Posted 2014) [#2]
f the user doesn't support D3D9, the chances are the app will crash in D3D9's SetGraphics, and not fallback.
I thought BlitzMAX stopped supporting Windows 98 several years ago. Xp and later all support DX9


Matty(Posted 2014) [#3]
On the product page it says it supports Win 2000 - as far as I know that came with Directx8? Pedantic I know but....


Derron(Posted 2014) [#4]
As the original report was based on crashes here on my computer ...

I am running XP - one of them without DX support (MicroXP) so only OpenGL is available there.

With the current implementation of the modules you are not able to "Try ...Catch" the initialization of DX. This just leads to a crash.

As I cannot distinct between "old windows" and "new windows" I have to order engines on my own: "dx7, dx9, ogl" on windows. Why? Because I also have testers which have trouble with ogl - so they need to get "DX" as default. Until the problem is fixed in BlitzMax I made the renderer configurable via "appArgs" (as the ingame-setup - storing everything in a config file - cannot get run with an invalid renderer :D).


bye
Ron


Grey Alien(Posted 2015) [#5]
Isn't this sort of code safe though? I just do this:

If D3D9Max2DDriver() Then
  'Use DX9
ElseIf D3D7Max2DDriver() Then
  'Use DX7
ElseIf GLMax2DDriver() Then
  'Use OpenGL
endif



Vignoli(Posted 2015) [#6]
Hi

On my computer (now under windows 10), there are random problems :
* D3D9Max2DDriver() sometimes needs a double Flip, if not, the first Flipped image is replaced by a black screen.
* D3D7Max2DDriver() scale the window out of the screen
* GLMax2DDriver() works, but after a Graphics 800,600,32,60 command, the mouse stay in a 640x480 resolution.


Grisu(Posted 2015) [#7]
I'm using this code:
If ini_force_opengl=0 Then 
	D3DDriver = D3D11Max2DDriver()
	If Not D3DDriver Then D3DDriver = D3D9Max2DDriver() 
	If Not D3DDriver Then D3DDriver = GLMax2DDriver()
Else 
	D3DDriver = GLMax2DDriver()
	GLShareContexts()
EndIf

SetGraphicsDriver D3DDriver



Grey Alien(Posted 2015) [#8]
Yeah looks similar to mine except I'm not using the DX11 driver. That's not standard is it? Is it a mod by Col or someone?


Grisu(Posted 2015) [#9]
Yepp, it's from here: http://www.blitzbasic.com/Community/posts.php?topic=97645

I hope that there will be a Dx 12 driver as well sometime.