D3D11Max2DDriver..... is it worth it?

BlitzMax Forums/BlitzMax Programming/D3D11Max2DDriver..... is it worth it?

col(Posted 2011) [#1]
Hiya all,
I've written a 95% complete ( but as yet unoptimized ) DirectX11 version of Max2D. I'm wondering if its worth optimizing and releasing or just chock it up as an exercise.

Two functions yet to implement - GrabPixmap and DrawPixmap - No big deal really. And, I imagine, possibly a basket of bugs :D

What's your thoughts on this? Is it worth the effort to pursue any further?


Gabriel(Posted 2011) [#2]
What does it have that other drivers don't?


therevills(Posted 2011) [#3]
Isnt DirectX9 emulated on Windows 7? (or is that DirectX7? I'm getting old :()

Is so, I would say its worth doing :)


BladeRunner(Posted 2011) [#4]
Keeping max up2date can'T be wrong - if you have the energy to remove all bugs from it you will have lots of people who will use this.


GaryV(Posted 2011) [#5]
It would be nice to have DX drivers that actually support default installs of Windows 7. The DX7 drivers run under emulation. DirectX 9 support doesn't ship with Windows 7 and DirectX 9 hasn't seen an update in a year.

DX11 would be very useful to many and help prolong the life of BlitzMax.


xlsior(Posted 2011) [#6]
Isnt DirectX9 emulated on Windows 7? (or is that DirectX7? I'm getting old :()


DX7 is always emulated on Win7, DX9 can be installed seperately and co-exist with DX11.


Kryzon(Posted 2011) [#7]
Col, weren't you working on a Direct3D9 3D engine for BMax? I think you should pursue that instead :)


col(Posted 2011) [#8]
@Kryzon
Yep, I still am :)

A couple of things in my mind and I find myself so torn and indecisive with these thoughts....

I've done experiments and exploring of Dx11 and it can be made to work nicely with Dx9 and Dx10 GPUs ( including sub version updates of each ) by creating the Dx11 device with different feature levels that suit the capabilities of the GPU.
With decent drivers you can query the GPU before setting up 11Device and set it up according to the maximum feature level the GPU can work with. This, potentially, exposes the best of the GPU to D3D11 even if it can't actually use D3D11 features. You can simply fall back nicely and making the whole thing use shader based makes it even easier to fall back by choosing an appropriate shader set. All within a D3D11 environment.

Plus Dx11 is nicer to use. The pain in the arse resource management is practically transparent now, no need to check for the lost/reset device scenario. Well unless you hot-swap the GPU. Who does that?

All in all its nicer to use, 'near future' proof, Vista,Win7 and ( assuming ) Win8 compatible, and also 'can be made' faster than native Dx9 and Dx10. I stress that part - 'it can be' ;)

So I'm thinking.... write 2 engines - Dx9 and a separate Dx11.... or one that uses Dx11 that's compatible with Dx9 and 10 setups. After all the SpillEngine is shader based already :P So its not like its going to need a re-write.

The real reason I decided to write the D3D11Max2DDriver is to use it as a test bench for myself and maybe get some real world feedback as whether to go this route or not.

I'm still torn :P

All thoughts of all flavours are appreciated.


ima747(Posted 2011) [#9]
Personally I use OpenGL, so this opinion is just me butting in... but I really like the sound of a DX11 driver with safe fallbacks. Real world targets for a game you have to make certain assumptions about your user's min specs and design up from there. If you could design for a reasonable dx9 config and get extra bonuses on higher end hardware that's win win for the majority of realistic targets. It may not apply if you're targeting really low end stuff, but if you're doing that then emulated DX7 should be enough on a higher end system since you're supporting low end DX7 systems in theory anyway...

Would love to see this get built out as I think it's a really good direction to take things. Again I don't know if I would ever use it since I'm stuck in my OpenGL ways, but if I were to target something at windows only this could be a real boon, especially looking forwards towards *shudder* windows 8.

Good luck!


xlsior(Posted 2011) [#10]
Definitely sounds interesting, especially if there's a fallback for incompatible systems....


GaryV(Posted 2011) [#11]
So I'm thinking.... write 2 engines - Dx9 and a separate Dx11.... or one that uses Dx11 that's compatible with Dx9 and 10 setups.
There is not much need for a fall back to DX9:

~ There has never been a version of Windows that ships with DX9.
~ Since January 2007, when Vista shipped, DX10 has been the minimum spec for new machines.
~ DX10 and above cards are required by Vista and 7 just to properly run Aero.
~ Once you get to systems older than 2007, you are talking about XP systems which ship with DX8 and fully support DX7 and there is no need to even use the DX9 driver when the default DX7 one would more than suffice for these legacy systems.
~ DirectX 9 has not been updated in over a year and since it has never shipped with any version of Windows you can't be guaranteed your EU will have it installed. Installing DX9 will be beyond the capabilities of some EUs.


col(Posted 2011) [#12]
@GaryV
Interesting information there, Thankyou. I agree with you on all of your points.
Except ...


Installing DX9 will be beyond the capabilities of some EUs.



Part of the license agreement for distributing software that uses DirectX states ( not in the exact words and terms ) that the DirectX Installer must be distributed and run along with the installation of your own software that will use that same version of DirectX in said installer. This guarantees that your own software will run when its installed. So as long as the EU can actually install software then DirectX will be installed/updated ( if need be ) during the same process.

On a different note....
I've just got GrabPixmap working and it has a big speed increase of Max2Ds Dx9 and Dx7 versions, although still not fast for real-time full screen grabs. This is unoptimized at the moment but I cant see much more a speed increase coming from this just yet.

Using the example in the Docs for 'GrabImage' and using basic MilliSecs() timing either side of the CreateImage and GrabImage, I'm getting -
D3D7 : 537ms
D3D9 : 311ms
D3D11: 35ms
OGL: 39ms

Last edited 2011


GaryV(Posted 2011) [#13]
Part of the license agreement for distributing software that uses DirectX states ( not in the exact words and terms ) that the DirectX Installer must be distributed and run along with the installation of your own software that will use that same version of DirectX in said installer.
Thankfully people rarely do this for downloadable games :)


I've just got GrabPixmap working and it has a big speed increase of Max2Ds Dx9 and Dx7 versions.

Using the example in the Docs for 'GrabImage' and using basic MilliSecs() timing either side of the CreateImage and GrabImage, I'm getting -
D3D7 : 537ms
D3D9 : 311ms
D3D11: 35ms
OGL: 39ms
Simply awesome!!


col(Posted 2011) [#14]

Thankfully people rarely do this for downloadable games :)


Point taken ;) hehe.


SLotman(Posted 2011) [#15]
I don't get it. My games in DX9 runs fine on Seven and Vista, and I didn't have to install any DX9 SDK.

Also, most publishers *want* DX9 games - not DX10 or DX11. Some even refuse OpenGL games.

So, if you really want the best compatibility - use DX9. I can practically bet DX11 will give you trouble on those pesky Intel chips...

That being said, I's say go for it! Not a problem having new tech implemented, may be useful in the future :)

Last edited 2011


col(Posted 2011) [#16]
Hiya SLotman,
I would think Dx9 has been installed during installation of a game.


I can practically bet DX11 will give you trouble on those pesky Intel chips...


We'll see soon ><


SLotman(Posted 2011) [#17]

Hiya SLotman,
I would think Dx9 has been installed during installation of a game.



Nope, no "game" installed on the machine - just a pure Windows used for testing my stuff. And it works without any problems.


Czar Flavius(Posted 2011) [#18]
Doesn't Windows Update give you DX stuff?


col(Posted 2011) [#19]
@SLotman
Okey dokey :P

This is almost ready for some testing now... *takes a deep breathe* :|

Couple of things first...

Batch calls:
What batch calls would people like? If any?

PlotPoints - render an array of points
DrawLines - render an array of lines
DrawImages - render an array of images - including rotations and scales.
TileImages - render an array of images as tiles

Batch calls bring a massive speed increase. In fact Dx11 is designed around this paradigm, so this is where the real benefits will come into play.

What others do you think could be a benefit?

As an example, instead of using...

For Local n=0 Until 2048
	Plot 400+(ang/2)*Sin(rot + ang),300+(ang/2)*Cos(rot + ang)
	ang :+ 360.0/2048.0
Next


on my laptop, looping this in a 800x600 window with a basic FPS counter displayed, it achieves around 170fps.

But batching it using an array such as

'Plot optimised
Global points#[4096] 'Array needs to hold both X and Y coords

'Store the points in the array
For Local n=0 Until 2048 Step 2
	points[n*2] = 400+(ang/2)*Sin(rot+ang)
	points[n*2+1] = 300+(ang/2)*Cos(rot+ang)
	ang :+ 360.0/2048.0
Next

'Batch render
PlotPoints(points)


my little laptop now blasts this out hovering around 1000fps.

I know it may not be a good example to actually use in real world but you can easily see the speed gains by using a batching mechanism. Is it even worth it ?

Are people even getting to the point of the rendering causing a bottle neck at all ?

Last edited 2011


col(Posted 2011) [#20]
@Czar Flavius
Hiya,
Windows Update can be selective. So yes and no.


col(Posted 2011) [#21]
Douple post. lol

Last edited 2011


xcessive(Posted 2011) [#22]
This looks great, I'm all for new features.


Yasha(Posted 2011) [#23]
Is it even worth it ?


Introducing it beats not introducing it.

Anyway, it also seems more elegant, so you'd be making a design improvement.


seriouslee(Posted 2011) [#24]
Moving things forward is always a good thing, I think. The speed increases you posted definitely is a move forward. Awesome job, man!


col(Posted 2011) [#25]
Hiya all.

The D3D11Max2DDriver is now complete.
Well, the first iteration is :)
I suspect there will some kind of obscure errors that may creep in, but I've tested it using all of the BMax files in the Archive section and also pretty much every file I can find in the forums, and it seems stable... so far :)

There is an issue from my point with the speed. Its just not as fast as D3D9 is some areas, and much faster in others. The MAIN areas are slower on my laptop!! After a lot of testing I think this could just be that I'm ROP bound using D3D10/D3D11 on my little laptop. They're not powerful GPU's even though have the features.

I've not taken any advantage of the Geometry Shader or Multi-threading functions just yet, so it may get a nice little boost when using that. We'll see how this iteration fairs up to real world use first, then after ironing out the silly bugs etc I'll go on a mission to optimize it.

So I'll release it REAL soon and let you all loose on it to see how it performs on your machines.

There's one issue stopping me releasing it:-

On ( maybe a legal ) not wanting to piss anyone off, note...
Does anyone know or know where I can get information as far as adding to the BRL.mod files ? Would BRL get upset as I need to add in d3d11graphics and d3d11max2d to the BRL files? If not, what info do I need to add in to keep everyone sweet so I can play along nicely? As I'll be releasing this to the public and it requires modifying one line in a BRL file and adding 2 others in there too, I'm just not sure where I stand on this situation,.

Cheers

Last edited 2011


xlsior(Posted 2011) [#26]
Adding files into the brl tree could be a slight issue, in that those folders get erased IIRC with each blitzmax update. To ensure that they survive an upgrade, it should be in its own mod folder.

However, you may want to contact BRL and see if they might be interested in making it part of the standard distribution?


col(Posted 2011) [#27]
Thanks for the advice.
I did know those files can get over-written but what can you do when you don't want people to use Import at the top of their files :P

Asking BRL now :-)

EDIT :- Fixed the speed issue , i was asking too much from my shader :P. Still waiting for BRL to reply.

Last edited 2011


BladeRunner(Posted 2011) [#28]
I'd gladly add that import into my code if that means I can use DX11.


xlsior(Posted 2011) [#29]
I'd gladly add that import into my code if that means I can use DX11.


Likewise -- having to add an 'import' is a MUCH better approach than dinking around in someone else's module folders instead of creating your own.


Richard Betson(Posted 2011) [#30]
Hi COL,

This looks very interesting. I like the design as you have outlined it and the batching feature would be cool.

Have you considered adding features that exist using 'oddmod' such as screen rotation and zoom?

Can't wait to try this. :)

Last edited 2011


col(Posted 2011) [#31]
Hi Richard,

The download is available in this thread:
http://www.blitzbasic.com/Community/posts.php?topic=96014