D3D11Max2DDriver()

BlitzMax Forums/BlitzMax Programming/D3D11Max2DDriver()

col(Posted 2011) [#1]
I've uploaded the latest version to GitHub at :-
https://github.com/SRSSoftware/d3d11max2d.mod










DOWNLOAD HERE

LATEST VERSION HERE featuring TBatchImage ( Please make sure you read Post#28 in this thread. )

Presenting a Direct3D11 driver for Max2D.

There are some install instructions in the archive to help get things going. Seasoned 'mod'ders will know exactly what/how to do it.
I'd much prefer to integrate this as I originally planned, but BRL aren't replying to 3 attempts to contact them. I need more patience I guess :D


*deep breathe*
There may be some issues with some gpu cards.
If you do have any problems/issues, post some source and any media that would help isolate it and I'll get it fixed, IF i can :p

KNOWN ISSUES
07.02.2011 - In fullscreen only, something isn't released properly and can cause a crash when changing to other Max2D DirectX drivers. - 08.02.2012 - Fixed but not uploaded
/KNOWN ISSUES

There are a couple of extra commands in there:-

DrawLines(LineArray#[],Separate=False)

DrawLines with draw a series of lines.
LineArray will be an array of points as X,Y. You can specify points in a 'daisy-chain' fashion to simply link the points, one after the after. Or you can specify 'True' for 'Separate' to specify that the data in the array is treated as sets of separate lines. Selecting 'True' for 'separate' will require a StartX,StartY and an EndX,EndY for EACH line that you want to draw.

PlotPoints[PointArray#[])

PlotPoints will allow you to pass a whole array of points, as X,Y, to be plotted in one go.

DrawImageTiled(Image:TImage,x#,y#)

This is the exact same command as TileImage, it's just it can a little more efficient when tiling a small image to the screen, which would normally result in lots of draw calls. If you want to tile a large image to the screen, then you may not see any benefit in using this command.

Any problems/queries, please use this thread to post.

EDIT :- During extracting this back out of BRL tree, if the file DXGI.bmx doesnt build it's because I've left a line out that should been included. LOL.

In DXGI.bmx, after
Import Pub.Win32


add this line
Import BRL.System


Last edited 2012


col(Posted 2011) [#2]
Found a bug already :D
In d3d11graphics.bmx

Change the little nested loop at line 64 from
If depth
	For Local i = 0 Until modes.length
		If width = modes[i].Width
			If height = modes[i].Height
				numerator = modes[i].RefreshRate_Numerator
				denominator = modes[i].RefreshRate_Denominator
				target = modes[i]
			EndIf
		EndIf
	Next
EndIf


to

If depth
	For Local i = 0 Until modes.length
		If width = modes[i].Width
			If height = modes[i].Height
				If hz = (modes[i].RefreshRate_Numerator/modes[i].RefreshRate_Denominator)
					numerator = modes[i].RefreshRate_Numerator
					denominator = modes[i].RefreshRate_Denominator
					target = modes[i]
				EndIf
			EndIf
		EndIf
	Next
EndIf



What would happen is that when going full screen, it would select the first valid entry when matching the desired width and height regardless of the refresh rate requested.

Last edited 2011


SLotman(Posted 2011) [#3]
Why all those changes into the pub folder?

Couldn't you just write the driver in it's own mod (as it was done some time ago by DStatny with his DX9 module)?


col(Posted 2011) [#4]
I was going to release this as integrated directly into BMax, so I just moved the files from what would have gone into the BRL mod folder into the SRS mod folder.

EDIT :- I also have my own 3D engine tied in to using this same approach. It keeps everything clean and tidy on my machine instead of having various 'global' files all over the place in different folders. There's nothing wrong in adding the Dx11 files into the pub.directx mod folder as that's where they should be, no? Correct me if I'm wrong and I'll look into it.

Cheers.

Last edited 2011


Richard Betson(Posted 2011) [#5]
Got it!

I'll test this out later today. :)


col(Posted 2011) [#6]
There are a couple of issues that I've fixed already.
Its amazing no matter how many times you test something there's always issues :P

2 of which are rectified above.

Some more:-
:All drawing is 1 pixel out! - Fixed for next release.
:'SetAlpha' not working correctly when 'AlphaBlend' ISN'T selected as a BlendMode for non-textured drawing ( I actually removed the code thinking its not needed for some reason! DOH! ) - Fixed for next release.
:When minimizing the window and focusing back to it, the display is lost - Fixed for next release.

When drawing a line, It looks as though I'm getting a 1.5 pixel line being drawn instead of a single pixel width. This is a similar effect to the older DirectX versions in drawing texels to pixels which needed an adjustment to correct it. According to the MSDN docs this problem has supposed to be rectified in Dx10 and Dx11 so there isn't any need to add the offset. I'll look further into this. Is anyone else getting this issue too?

Last edited 2011


Richard Betson(Posted 2011) [#7]
Hi,

I have got the module compiled but, I get an error that I need "d3dcompiler_43.dll". So my version of DX11 is out of date?

Last edited 2011


col(Posted 2011) [#8]
Hiya,

Yep, you can download from MS. The link is in the 'Install' guide.


BladeRunner(Posted 2011) [#9]
EDIT :- I also have my own 3D engine tied in to using this same approach. It keeps everything clean and tidy on my machine instead of having various 'global' files all over the place in different folders. There's nothing wrong in adding the Dx11 files into the pub.directx mod folder as that's where they should be, no? Correct me if I'm wrong and I'll look into it

The Pub-scope suffers the same restrictions as BRL does.
BRL are modules by BRL, PUB are open source, 3rd Party things. They all get wiped out with every new install.
It would be best if you'd use your one scope, lets say COL.mod.


Kryzon(Posted 2011) [#10]
I agree; giving your own namespace to the module doesn't make it less official :)

(Not to mention more important reasons, like it's easier to mantain and update.)


col(Posted 2011) [#11]
Ahh. I totally understand now and I agree. It does make a lot of sense. I knew that the BRL files get overwritten with updates but I thought the PUB modules were untouched! Live and learn :)

With the next update I'll keep everything for this totally within its own module folder, which will mean you initially delete a couple of files from the pub folder that I asked you to move in there, but it is better in the long run.

Thankyou all for that insight :P


I'm currently working on a method for batching the DrawImage call with different scales and rotations as that is the slowest and, more than likely, the most used command. This should bring a wealthy increase in speed in particular when using particle systems.

Cya.


Jesse(Posted 2011) [#12]
I didn't comment on here earlier as I am on a mac and really can't try it. I have it dual booting but the windows setup is crashing giving me the blue screen randomly. so I don't even have BMax installed on it.

based on my readings, it sounds really good. I wish there was an update to the GLmax2d with similar functionality.

Great job on this Col!

Last edited 2011


Richard Betson(Posted 2011) [#13]
Sadly my video card is not DX10/11. But your driver did detect it, which is great. I'll be upgrading my system here soon (just went to the computer store), but in the meantime I would like to include this driver as a 'test driver' in the next release of my project. Is this driver going to be public domain?

Keep up the good work. :) Would love to see screen rotation. ;)

Last edited 2011


col(Posted 2011) [#14]
Double post! Sorry.

Last edited 2011


col(Posted 2011) [#15]
@Jesse
Thanks for the good words and encouragement :-)

@Richard
Thankyou too for good words and encouragement. The driver is still in testing phases :-) but I see no reason not to use it. The posted source at the 1st post has some issues that are noted above and all of those issues are now fixed, just not released. There will be some license restrictions in place to basically prevent anyone to modifying the source and claiming it as their own etc, so I'll draw that up before I release it. We can work together if you have any issues etc, thats not a problem at all.
Screen rotation eh :) Sounds great and not too difficult to do. What kind of commands and how do you propose we would use them for this feature? I'm open to suggestions :P

@All
Can I assume this driver is relatively stable as no one has posted any unknown issues so far ? :D

Update:
EDIT:-Theres no reason to restrict TBatchImage to use the same image that was used during the CreateBatchImage call. I'll change the DrawBatchImage call to include an extra optional image parameter so you can pass in another image. There will be restrictions in that any 'newer' image passed in during the DrawBatchImage call will take the initial size and handle of the image that is used during the CreateBatchImage call and of course it will still be that one image used to render to all the other instances in the data.

I've been really busy working hard deciding how to get the DrawBatchImage working efficiently. The only way I could get it work in a respectable fashion was to create a new TBatchImage type and use arrays containing the data that goes in. You can now batch call using different positions,colors,rotations and scales for EACH image within the batch list, although with 1 image texture per TBatchImage :P

This means there will be 4 new commands for batching images:

CreateBatchImage:TBatchImage(image:TImage,data#[]=Null,color#[]=Null,rotation#[]=Null,scale#[]=Null,frame=0)
UpdateBatchImage(batchimage:TBatchImage,data#[]=Null,color#[]=Null,rotation#[]=Null,scale#[]=Null)
DrawBatchImage(batchimage:TBatchImage)
DestroyBatchImage(batchimage:TBatchImage)


I've made TBatchImage use the instancing features in the GPU, and I have to say that I am completely shocked at how great it's performing :D I'm thinking of seeing where else I can use it within the driver :P
I've still not even starting to make use of the geometry shader pipeline yet :-), so god knows how many polys this will manage to get onscreen :D

As the driver needs a little tidying before I release it for testing again, I've put together a little demo that uses the original source from the fireworks demo by simonh which is in the examples folder but takes advantage of the DrawBatchImage functionality.
EDIT:-As a comparison, using simonh original source code as is, my little laptop manages to push about 15 fireworks before dropping below 60fps. Using DrawBatchImage I can push well over 200 before it slows down to ( but still above ) 60fps.

D3D11Max2D Firework Demo is available for testing.

I couldn't believe what my little laptop was actually doing in this demo. The only difference between the pic and the demo is that I put instructions to Press 'R' on the screen :D

Some facts about the demo:-
Each firework creates 500 sparks, which are basically little billboard images made of 2 triangles each. I can get over 200 fireworks on screen at just over 60fps ( 800x600 Fullscreen, DebugOff ). This equates to 100,000 ( 200,000 polys ) individually positioned,coloured,rotated and scaled 'sprites' on screen at one time! The only restriction using a single image for each TBatchImage, but you can have as many batches as you want, with any number of items under individual control in that batch. Perfect for particle effects :D
I was so sure something was wrong with my calculations so I posted the source and the exe for the you all to try.



This is the EXACT source code for the Fireworks.exe in the demo.



Last edited 2011


BladeRunner(Posted 2011) [#16]
Hi, do you happen to have an scope-updated version of your driver. I'D really like to test it :)
Ah, one more thing: Would it be possible to make this batchimage with frames, i Mean, adding an extra array which contains the info which part of the texture should be drawn?


Richard Betson(Posted 2011) [#17]
col,

I can wait until you have everything together. An option to change the uv coordinates for an image would be cool if possible. I do like the batch functions and I would like to see what the batch plot does for speed.

Upgrading my system in 2 weeks and can't wait. ;)

L8r,


col(Posted 2011) [#18]
Hiya,

I guess I got so excited with the speed increase, that I posted a little early with respect to the syntax used in the commands :D
I've made some major changes to the commands. Sending initial data into the CreateBatchImage command seemed a bit pointless and didn't really seem to fit correctly. I've changed that command to use flags and depending on those flags is what data you then send into UpdateBatchImage command. No doubt this may change again before release :o

For eg.. The commands will now be...


CreateBatchImage:TBatchImage(Image:TImage,Color=False,Rotation=False,Scale=False)
UpdateBatchImage(BImage:TBatchImage,Position#[],Color#[]=Null,Rotation#[]=Null,Scale#[]=Null)
DrawBatchImage(BImage:TBatchImage,frame=0)


So if you use..

BImage = CreateBatchImage(MyImage,True,False,True)

will require that you call UpdateBatchImage in this way:

UpdateBatchImage(BImage,Pos[],Col[],Null,Sca[])
or
UpdateBatchImage(BImage,Pos[],Col[],,Sca[])

Position data is now required in UpdateBatchImage. If the array size changes during runtime of using the same TBatchImage, the data is rejected and nothing will be rendered. This is to help prevent GPU resource thrashing which 'could' break your GPU. Different TBatchImages can have different sized arrays.
This also allows you to omit any data arrays that you don't want to include. Which wasn't the case before due to the shader setup.
And if you send in arrays that arent setup as True in CreateBatchImage, it will just exit without rendering anything.
To get it working efficiently I have to be a little strict on the setup, but I've also tried to keep it as flexible as possible.

@BladeRunner
I'll look into the array of frame data, I'm not sure if this will work as the image/frame selection is setup on the CPU rather GPU where the batching actually takes place. You can select a frame to use already, just not an array of frames.

@Richard

An option to change the uv coordinates for an image would be cool if possible


Hmm, do you mean an array of uv coords to send in?

Thinking about those questions...
If I get it working to use uv array data, then with some cleverness on your side, you could use an image as a texture atlas which would also overcome the frame array problem.

I'll see what I can do here as I'd also like the feature of being able to show different images throughout the same batch.
Batched animations :-)

Last edited 2011

Last edited 2011


Richard Betson(Posted 2011) [#19]
An option to change the uv coordinates for an image would be cool if possible


Yes. I would like to emulate the TextureCoordinates() command in Blitz3D or the OpenGl equivalent glTexCoord2f(). I am assuming that images are textured quads.

I can certainly live with the batchimages changes. ;)

Rock on,


col(Posted 2011) [#20]
It just so happens, I think can do both, uvs and a 'live' frame change.
Watch this space.

I'm looking forward to seeing what you have planned :P

:-)

UPDATE :- UVs are in...
UPDATE2 :- Frames are in now too...


CreateBatchImage:TBatchImage(Image:TImage,Colors=False,Rotations=False,Scales=False,UVs=False,Frames=False)
UpdateBatchImage(BImage:TBatchImage,Position#[],Color#[]=Null,Rotation#[]=Null,Scale#[]=Null,UV#[]=Null,Frame[]=Null)
DrawBatchImage(BImage:TBatchImage,Frame=0)


Notice that the frame array is an integer array and rotations are now in degrees to fit with BMax existing angle setup.

If you pass a value for Frame into DrawBatchImage that value will override any Frame[] data.

I should sell this ;-)

Last edited 2011


Richard Betson(Posted 2011) [#21]
Well I'd like to do some diffusion type effects that would allow a diffusion effect much in the way Window Media player does with the cool effects that play to music. I would also like to do the same effect for a single image so that I could have some cool effects in my game project maybe something like smoke or fire coming of an object.

Here is a link of an OpenGL example. http://www.blitzbasic.com/Community/posts.php?topic=96014

I have not looked over yet but from memory it basically sets up a grid of quads, draws on them and then changes the UV for each vertices. I'm going to read it over again to see if my feature request is valid. :)

Screen rotation though is one feature that I would really need.

I am very happy with your driver project and believe it will have a very positive influence on BlitzMax. Keep up the good work.

L8r,

Last edited 2011


col(Posted 2011) [#22]
Hi Richard, that links back to this page :p


Richard Betson(Posted 2011) [#23]
Dag-Nabit! Late night coding sessions, uhg. :P

http://sylefeb.aracknea-core.net/gltut/diffusion/

LOL!


col(Posted 2011) [#24]
Nice effect.
That is now more than achievable with the new batch array capabilities.
I'm working on a 2d dynamic shadow system at the mo. Should be interesting as you can as many lights as you want and any shape shadow casters which can all move and update dynamically.


Richard Betson(Posted 2011) [#25]
Awesome. Wow, lights and shadows. Can't wait to see it. It would be of great to include that in my project.

Now if this could all be compatible with DX-9 (wink, nudge). :p

This is what I am working on and its all Max2D so a driver like yours gives it more longevity and features. The demo is rotation mode the first half and fixed mode in the 2nd.

http://www.youtube.com/watch?v=AhObNL5dkW4

Last edited 2011


BladeRunner(Posted 2011) [#26]
Hi Col,
do you think there will be a new release for testing soon? I'd really like to test your stuff :)


col(Posted 2011) [#27]
@Richard
That looks to be a smart little game base there :)

@BladeRunner
Yeah sure. The next couple of days. I've been too busy with work, 16 to 18 hours a day.

I've fixed multiple windows. Still need to fix some alt-tab issues. It works just not correctly.

With respect to line widths, are people getting more than a single pixel line width when expecting it, using the above driver code?


col(Posted 2011) [#28]
Hey all,

The latest scope version is available is the 1st thread.
Its also available HERE

I was going to sell this driver as its been quite time consuming to build, but I may sell additions to it.

Any problems let me know :D

I'd like to see some creations that people will make that take advantage of the extra features :P

EDIT:- VERY IMPORTANT :-
Delete the existing installation and any files associated with the first driver. Then copy this srs.mod folder into the BlitzMax/mod/ folder. 'Build Modules' as usual, then use


Import SRS.D3D11Max2D
SetGraphicsDriver D3D11Max2DDriver()


to use it as you normally would any other driver.

Last edited 2011


col(Posted 2011) [#29]
TBatchImage is the latest feature in this release apart from a huge tidy up in the code.

There are several restrictions in using these commands :-


CreateBatchImage:TBatchImage(Image:TImage,Colors=False,Rotations=False,Scales=False,UVs=False,Frames=False)

Image is a usual TImage loaded or created in the usual way. It now supports frames too for animated images. Handles are taken into consideration as is the origin. These need to be BEFORE you create the TBatchImage. The other parameters are flags and should be set to True or False in you intend to pass the associated data into the UpdateBatchImage command. Pay attention to what you set up and the data passed in as it will simply reject ALL data if its incorrect.

UpdateBatchImage(BImage:TBatchImage,Position#[],Color#[]=Null,Rotation#[]=Null,Scale#[]=Null,UV#[]=Null,Frame[]=Null)
BImage is a TBatchImage instance handle returned by CreateBatchImage.
The data:-
Position is to be X,Y screen coord pairs for EACH instance.
Colors are to be Red,Green,Blue,Alpha for EACH instance. RGB ranges are 0 to 255 inclusive. Alpha is 0 to 1 inclusive.
Rotation is 1 single angle of rotation in degrees for EACH instance. Rotations are treated in the same way as the usual BMax rotations.
Scale is to be X,Y scale pairs for EACH instance.
UV is very advanced and should only be used if you know what UVs are. This is to be in 4 x U,V pairs for EACH instance. This means 8 bits of data for each instance. The order of UV data pairs is TopLeft, TopRight, BottomLeft, BottomRight. UVs are in the range 0 to 1 inclusive.
Frame This is a single INTEGER value PER INSTANCE to index into the frame data.

DrawBatchImage(BImage:TBatchImage,Frame=0)
This will draw the TBatchImage. The Frame parameter will override any data in the Frames[] array that may be passed into the UpdateBatchImage command.

The UpdateBatchImage command data NEEDS to be accurate. If it isn't accurate and any data items are missing, or the arrays are the incorrect length then the whole data will be rejected and NOTHING will be rendered. This is prevent GPU resource thrashing which can lock up or even break your graphics card.

The Positions[] array is the defining array to define the number of instances. Once you submit data into the UpdateBatchImage command, then it will expect the EXACT same number of instances in further calls when using the same TBatchImage.

EDIT:- Also VERY IMPORTANT is that you call DestroyBatchImage when you are finished with it. If you don't call it then you'll end with a CPU memory leak and a GPU memory leak.

Have fun!

Last edited 2011

Last edited 2011


Richard Betson(Posted 2011) [#30]
Got a copy. I should have my new hardware next Friday. I'll give it a thrashing then. The 'TBatchImage' funtcion looks great and the modifiable UV is just an awesome feature. In the mean time I'll see if it compiles here.

Can't wait to test it. Great work


Richard Betson(Posted 2011) [#31]
@col

"I was going to sell this driver as its been quite time consuming to build, but I may sell additions to it."

Why not package this with an updated DX9 driver. If you could add some basic draw mesh and draw poly (for example) it would be something worth paying for IMHO. But even now as it is, having DX10/11 is awesome. It's looking as if 1/2 of the user base I'm aiming at has a DX10 or better video card. It's a good indication that a DX10/11 driver is not only needed but necessary.

L8r,

Last edited 2011


col(Posted 2011) [#32]
Hiya,


If you could add some basic draw mesh and draw poly



Can you elaborate a little on what you mean, as Max2D does already have a basic DrawPoly. Are you referring to 3D meshes?

As a teaser:-
I've written a complete lighting system. It works in the same way as regular 3D lighting works, in that everything is black and you have to add lights and ambient lighting to your liking. It uses a 3D spatial system although everything is 2D :P


Richard Betson(Posted 2011) [#33]
Col,

Ya, I mean 3D meshes, not necessary but would be neat.

The lighting sounds like a winner. :) Shadows to follow?



L8r,

Last edited 2011


col(Posted 2011) [#34]
Yep, working on the shadows :-) This will probably slow things up on the lesser powered gpus but then thats always been the way. I'm trying to make it scalable so the under powered gpus can make things 'acceptable'. We'll see how this pans out :-) I'm trying to implement a relatively new idea that I don't think anyone else has used so far. I'm not even sure how it will be perform, but it's all hardware processed :)

I'm polishing up the lighting system, so I'll post some commands and pics when they are complete.

While I was at it, I've also made a SetBuffer command similar to B3Ds SetBuffer. It was so easy, I'm surprised I didn't do it already. I've added an additional option to the flags parameter when creating or loading a texture :- RENDERIMAGE. Unfortunately a MIPMAPPEDIMAGE cannot be used withh RENDERIMAGE due to DirectX not supporting such a thing. Makes sense really.

These commands are :-
ImageBuffer(Image:TImage,frame=0) for use with the SetBuffer command.
BackBuffer() will return the back buffer for the current back buffer for use with the SetBuffer command.
SetBuffer(..) will take either ImageBuffer(...) or BackBuffer() as a parameter to set where to render to.

@Richard
Hehe, I guess you can easily do fullscreen rotation now by creating a TImage to the same size as the screen or bigger, render into it and then use the SetRotation commands to rotate :D
I was going to introduce a TBuffer type but there's no need to complicate things :D

So now it will also be possible to render straight into an image with almost zero loss of speed, like so -

Strict

Import SRS.D3D11Max2D
AppTitle = "D3D11 SetBuffer Example"

SetGraphicsDriver D3D11Max2DDriver()

Graphics 800,600

Local RenderImage:TImage = CreateImage(400,400,1,RENDERIMAGE)
Local BMaxLogo:TImage = LoadImage("Bmax400x400_logo.png")

While Not KeyDown(KEY_ESCAPE)
	
	'All drawing goes straight into the TImage
	SetBuffer ImageBuffer(RenderImage)
	Cls
	
	DrawImage BmaxLogo,0,0
	DrawText "BMax Rulez!",0,0
	
	'All drawing now goes to the regular back buffer
	SetBuffer BackBuffer()
	Cls
	DrawImage RenderImage,0,0,0
	
	Flip
Wend
End


Dx9 eh ? It already has a driver by BRL :-) To get the batching features means modifying a couple of lines in the driver to expose the hardware handles. As I've already learned, people don't like modifying the BRL and PUB files and folders. It's easily done but you get frowned upon :D And a re-write of the existing driver wasn't in my plans, although it could do with it because of a couple of bugs in there with regards to memory leaks when closing.

As far as 3D meshes go, that should really fall into a Max3DDriver ;-)

Last edited 2011


Richard Betson(Posted 2011) [#35]
Col,

"Hehe, I guess you can easily do fullscreen rotation now by creating a TImage to the same size as the screen or bigger, render into it and then use the SetRotation commands to rotate :D"

Yup. OddMod2 uses such a scheme to do rotation. It looks like this.



I do indeed draw a bit outside the display, but it works great.

DX9
I really was musing on how it would be great to update the DX9 driver. It is something I can live without, but it would be cool to get some of your features in DX9.

Can't wait for the update. Do you have a web home for this project or others you may be working on?

GG!


col(Posted 2011) [#36]
Hey,
I just took a look at the OddMod2 files. It's a great addition to Max2D for sure.


Do you have a web home for this project or others you may be working on?


No, but I really should get something sorted in that department. I.T. isn't ( currently ) my trade that pays the bills, but I'm seriously looking to get into the industry, so I should have a website which would be a great place to show of some of the projects I'm worked on and currently working on.

Did you get your new Dx11 GPU card? How is it?


Richard Betson(Posted 2011) [#37]
@Col

"Did you get your new Dx11 GPU card? How is it?"

The power supply in the new case had the wrong connectors for my motherboard but a new one is coming soon. I should be driving down to the computer store tomorrow.

:p


col(Posted 2011) [#38]
1st version of some dynamic 2d shadows is here


Richard Betson(Posted 2011) [#39]
Awesome!

Shadows look cool in the image.

I had to go a different route on upgrading my system. I have a flex (mini) ATX case and I was going to pull the motherboard and put it in a larger standard size ATX case but it proving to be to difficult. So, I am ordering a new power supply for the case it currently has. I found a 300w (just big enough) but I'm waiting to hear from the retailer (http://www.atxpowersupplies.com/300-Watt-Flex-ATX-Power-Supply-Sparkle-SPI300F4BB.php) to see if they have a 350w. I should hear from them tomorrow.

I so can't wait to try your driver (and demos) and am upgrading just to use it :)


col(Posted 2011) [#40]

I so can't wait to try your driver (and demos) and am upgrading just to use it :)



Oh my god, the pressure on me if there are issues ;)

Seriously though, if there are issues, I'll correct them. I'm pleasantly surprised that no-one has posted bugs already. Either no-one is using it or it works ok.


TomToad(Posted 2011) [#41]
I think I am missing something here with the DX11 driver.
Sample Code:


When I comment out all the DX11 lines and uncomment all the DX9 lines, I get what I expect;



But when I uncomment the dx11 lines and comment the DX9 lines, I get only half the display drawn, plus there is a stray tile at 0,0 (kinda hard to see, it is behind the fps counter)



Also notice that the DX11 version is slower than the DX9 version. The fps on DX11 is even worse when I just use the regular DrawImage command instead of the DrawBatchImage command

Windows 7 Home Premium SP1 64 bit
NVidia GeForce 9100
AMD Phenom 9550 Quad-Core 2.2 GHZ


Last edited 2011

Last edited 2011


col(Posted 2011) [#42]
Hiya TomToad.
Thanks for using the driver.
Don't forget to use 'DestoryBatchImage(...)' to avoid any cpu and gpu memory leaks.

In your code the array locations are being calculated wrong. You should be multiplying by the width of the map and not the height - ie:

Position[(y*20+x)*2] = x*32

as opposed to

Position[(y*10+x)*2] = x*32

Try this:-


I was concerned with the speed of the regular DrawImage command when I was developing the driver, which initially inspired me to make the batching commands. The more work you give the DrawBatchImage command, the greater the benefit will be over using the Dx9 or Dx11 DrawImage. Its designed to replace thousands of draw calls. There is plenty of room for improvements in the standard Dx11 DrawImage command, but they will require drastic changes.
You're the first person to report back any issues, and as I thought it was just my machine I thought it was ok on other peoples machines. Now I know that you have the same issue too, I'll work on optimising it.

Last edited 2011


TomToad(Posted 2011) [#43]
Ack! How can I make such a newbie mistake? Works now, thanks. Still slower than DX9. Faster than DX7 and about the same as OpenGL on my system.


col(Posted 2011) [#44]

Ack! How can I make such a newbie mistake?


We all have it from time to time :D


Still slower than DX9.


EDIT:- Just to be clear-
Is the BatchImage slower than using Dx9?

Last edited 2011


TomToad(Posted 2011) [#45]
Yes, batchImage is slower. At least it is in the way I'm using it in that example.


col(Posted 2011) [#46]
I imagine its like everything else graphics related, in that the performance is machine independent and needs experimenting to find a good balance. You need to take into consideration the cost of actually setting up the batch call, which is why there is more of a gain with 'the more drawing you do with the batch image the better'.

Thanks for the feedback.

Last edited 2011


BladeRunner(Posted 2011) [#47]
TomToad- I wonder if your gfx-card is even able to run dx11? GF9100- isn't this a DX10 card?
Maybe this is resulting in problems too.


col(Posted 2011) [#48]
The next release will return the feature level its using from GetGraphicsDriver().String() to help with identification.

so if the gpu is only Dx10.1 compatible the function will return

DirectX11 - Using DirectX10.1

Compatible versions are Dx10.0,Dx10.1 and Dx11.0. When Windows 8 comes along it will be 11.1.


kfprimm(Posted 2011) [#49]
Hey Dave, do you have an update on the license situation?

I want to implement a D3D11 driver for MaxB3D and would like to use your modules so that I do not have to roll my own.

Thanks!


col(Posted 2011) [#50]
Hiya kfprimm.

I'll email you at the address in your profile....


kfprimm(Posted 2011) [#51]
Thanks.


Richard Betson(Posted 2011) [#52]
Hey Dave, do you have an update on the license situation?


Also interested in licensing for my game project. I sent an email to the address listed here in your user profile.

L8r


col(Posted 2011) [#53]
Hi Richard.

Sorry,
I didn't check my emails for a couple of days!

Cya.


col(Posted 2012) [#54]
After messing with GitHub, getting things right and wrong... :D

All future updates will now be available at :-
https://github.com/SRSSoftware/d3d11max2d.mod

Last edited 2012


xlsior(Posted 2012) [#55]
Note: The URL you posted gives a 404 error, probably should be:
https://github.com/SRSSoftware/d3d11max2d.mod


col(Posted 2012) [#56]
Thats correct.
You must have looked as I changed the URL on Github but before I updated it here :)
I'm a real newbie to GitHub and still learning its little intricacies.

Cheers :P


Richard Betson(Posted 2012) [#57]
Hi Dave,

I am about to implement this driver into my Phoenix SS project. I have a copy of the current driver from github. Does it do screen (display) rotation and if so how do I use it. If it does not could you get it to?

Here is what it looks like.
Client Collision video (shows rotation using Oddmod driver) - http://www.youtube.com/watch?feature=player_detailpage&v=L5tlwyQru-w

Phoenix SS - http://redeyeware.uphero.com/phoenix_ss/main.html

Thanks.


col(Posted 2012) [#58]
Hiya Richard.

The code is already in there to do it. In the file d3d11max2d.mod/TBuffer.bmx.
It's not had much testing so there may be bugs in there. Let me know and I'll correct them.

Thanks.

Here's a simple example usage...




Richard Betson(Posted 2012) [#59]
Dave, Awesome!

I will let you know how it goes. It should get a fair bit of testing on many different systems so hoping for the best.

Again, Thanks! You Rock.


Richard Betson(Posted 2012) [#60]
On second glance at the code posted, I am not sure it does anything to rotate the 'display area' which is what I need to do. But I may be wrong. It looks like the image is being rotated and not the display.

Just to be clear what I am doing now with Odd.mod is drawing all the images to the display (backbuffer) and then using a command, in odd.mod's case its SetScreenRotation(), and rotating the whole screen/display.

I will try to isolate the code that does screen rotation in odd.mod's driver for DX9 so I can have a better reference for you.

Thanks,


col(Posted 2012) [#61]
Hiya,

You can switch to a texture and render directly into it then switch back, similar to Blitz3D style.
I imagine its possible to oversize the texture, render your screen into it then display it as a texture, then render your static graphics after switching back to the backbuffer. I'm not sure how that would pan out in practice just yet as I havent tried it.

Would that then give you the effect of rotating the screen? If not, I'll look into it some more as I'd like that feature available.


Richard Betson(Posted 2012) [#62]
I emailed oddball (author of odd.mod) for some guidance on his technique. I'm looking through his code now.


Richard Betson(Posted 2012) [#63]
Dave,

Check your email. I forwarded a copy of David Williamson (odd.mod author). Interesting. :)

Thanks,


col(Posted 2012) [#64]
Hi Richard,

Thanks for that. I see the difference and I understand what he's doing in there.
I'll incorporate a similar technique for D3D11Max2D driver.

Give me a day or two as I'm busy with other things and I'll have it done :)


Richard Betson(Posted 2012) [#65]
Hi Dave,

COOL!

Looking forward to it. :D

Thanks,
Richard


kfprimm(Posted 2012) [#66]
Hey, great to see this is on GitHub. I've begun merging it with my own Max2D work, so I'll be able to use it as a base for a D3D11 MaxB3D driver.

One thing I've done in my fork is to remove all the calls Notify and End. Instead, I've inserted throws.

I suggest you do the same as it will allow the end user (the coder using your driver) to wrap Graphics in a Try/End Try block and handle the failure in their own way, instead of forcibly ending the program.


col(Posted 2012) [#67]
@kfprimm,

Hiya,

Yes, I agree about the Notifys and I'll change them over to Throws. Good suggestion! Thanks.

Apologies as it was a week ago that I said I'd update this. I've finished what I was doing over the passed days so I'm back on to this, so expect an update within the week... including screen rotation for you Richard :D

Cya


Richard Betson(Posted 2012) [#68]
Dave,

You so rock. :D


therevills(Posted 2012) [#69]
Dave, You so rock. :D


+1

:D

Last edited 2012


col(Posted 2012) [#70]
Aww cheers guys!!!

*group hug* :D
lol

Screen rotation is now in.

As per kfprimm's advice - all critical errors are now handled with a Throw to allow you to manage any errors yourself.

Just in case you're using odd2d.mod for the same effect for the other drivers and so as not to cause a confliction with duplicate function names, I've named the functions the same but with D3D11 on the end...

SetScreenRotationD3D11( ang# ) Set the angle of rotation
SetScreenZoomD3D11( zoom# ) Set the zoom factor
SetScreenFocusD3D11( x#, y# ) Set the center point of rotation

Thanks go to oddball for making his code pd as I've ripped his algos.

Have fun :-)


xlsior(Posted 2012) [#71]
After receiving the update through git, I'm getting a compile error on the module at the moment:

Compiling:d3d11max2d.bmx
Compile Error: Identifier 'VerifyDX11Max2DDriver' not found
[C:/Code/BlitzMax/mod/srs.mod/d3d11max2d.mod/TBatchimage.bmx;366;2]
Build Error: failed to compile C:/Code/BlitzMax/mod/srs.mod/d3d11max2d.mod/d3d11
max2d.bmx


I tried to delete and re-sync the folders, but am still getting the same error afterwards.


col(Posted 2012) [#72]
Not sure how that crept back in as I renamed it as D3D11 and not DX11, but all the code was working before I updated it. Rather strange!

I just checked and it is as it should be, that is it should be referencing 'VerifyD3D11Max2DDriver'.


Sorry Xlsior!!
I read your post wrong and that file was indeed referencing the wrong function name. Updated.

Last edited 2012


xlsior(Posted 2012) [#73]
Thanks, compiled without errors now.


Richard Betson(Posted 2012) [#74]
Look like it compiled fine. :)

I will post a version of the client (game - Phoenix SS see above) I'm working on for testing as I am not near a DX10/11 system at the moment. The client will use the newly added screen rotation. I will also release the client for testing on DX10/11 systems this weekend if all goes right.

Back in a bit.. Te-hee-hee, happy, joy, joy :D


Richard Betson(Posted 2012) [#75]
OK. Here is a version of my project with a DX11 option and using the D3D11Max2DDriver() and screen rotation. Someone will have to let me know if it works (I have no DX10/11 here).

http://redeyeware.uphero.com/phoenix_ss/phoenix_ss_client_a82.zip

Hit 'F1' for help
Hit "F10" for screen rotation. Escape to exit.
Number pad ' + ' and ' - ' to zoom in and out.
Hit 'F12' to change resolutions.
Arrow Keys: Arrow left/right=steer Arrow up/down= thrust
Hit 'Z' to fire

Thanks:)

Last edited 2012

Last edited 2012


xlsior(Posted 2012) [#76]
Hit "F10" for screen rotation. Escape to exit.


Seems to work IN DX10/11 mode for me.

Before F10, the side cursor keys rotate the ship.
After F10, the screen flips instantly to make the ship face upwards, and then the side cursor keys smoothly rotate the screen instead of the ship when you steer.

Although one inconsistency: I have a 24" LCD screen, native resolution of 1920x1200.

In 1366x768, openGL mode shows me the entire screen centered, with black bars on top, bottom, left and right sides of the screen. The planet image in the center looks round.

In DX10/11 mode, there are NO black bars at the top and bottom of the screen, only on the left and right. The screen gets stretched vertically, with the planet in the center appearing as a very obvious oval.

(Update: DX7 and DX9 have black bars on all sides too, with a round planet)

Last edited 2012


Richard Betson(Posted 2012) [#77]
@xlsior

Cool, right on. :)

I will change the setup options to support more resolutions which should fix the above. But it is great to know it is all working aside form that. Thanks for testing it. I think you can set your monitor to correct the aspect and it might look OK that way.


@ Dave
Great job. I'll be posting a new client for testing this weekend and I'll let you know what reports I get back. As far as zoom goes I have not tested it. I use my own zoom technique in the above client, but I will try to get it tested and the rest of the features included in this awesome driver.


col(Posted 2012) [#78]
Hiya Richard,

The rotation looks and works great :D

I can see a couple of possibly minor issues:-
The background of the help text in the OpenGL driver is black instead of transparent, the other drivers are OK:-



Using the Dx10/11 driver, when I zoom in the parts move apart, as if they are in the correct position but not actually being scaled. Zooming back out the parts move together, and once they are together and I keep zooming out then the foreground graphics and the ship completely disappear. Zooming back in they reappear :-



Thing is, I'm not sure if this would be your code or mine?!?!

Last edited 2012


col(Posted 2012) [#79]
Also when zooming in, I mentioned that the parts moved apart... that is until it reaches what seems like a maximum zoom, and they are back together as you'd expect in the maximum zoomed size.


EDIT:- If you are using the same exact same code path but simply swapping out the driver then this is a problem with the driver :/ If that is the case, I understand this is a closed source project, so if you wouldn't mind to either post here or mail me some code that you're using so I nail this down.

Cheers.

Last edited 2012


Oddball(Posted 2012) [#80]
Thanks go to oddball for making his code pd as I've ripped his algos.
You're welcome.

That zooming bug above looks like an Int is being used in some part of the scale/zooming process instead of a Float/Double.

Last edited 2012


col(Posted 2012) [#81]
That zooming bug above looks like an Int

Hiya,

Yeah, I imagine that is more than likely the case, but if Richard is using the exact same code path and simply swapping out the driver then it would be nice to know what/where is causing it as in that case it may well be the driver itself.


Richard Betson(Posted 2012) [#82]
@Dave

I will have to double check, but I am pretty sure all I did was enable the driver. Let me check first though. I will have to get back to you tonight.

- Rich -


xlsior(Posted 2012) [#83]
Note that my monitor IS set to keep the original aspect ratio, that is why it surprised me that the screen was stretched.


col(Posted 2012) [#84]

In 1366x768, openGL mode shows me the entire screen centered, with black bars on top, bottom, left and right sides of the screen. The planet image in the center looks round.

In DX10/11 mode, there are NO black bars at the top and bottom of the screen, only on the left and right. The screen gets stretched vertically, with the planet in the center appearing as a very obvious oval.



This happens just at 1366x768 ?

Last edited 2012


Richard Betson(Posted 2012) [#85]
*Edit- The text should be black background. That is how I have it set.

Dave looking over my code now.

I wonder if there might be a scaling issue. A simple test would rule that out like maybe this:

This code will scale an image to a given pixel size.



l8r,

Last edited 2012


xlsior(Posted 2012) [#86]
This happens just at 1366x768 ?


Yes -- the other resolutions look OK in DX11, it's just stretched in 1366x768.

In DX7/9/OpenGL mode the 1366x768 looks fine, though, so I doubt the monitor is the issue.


Richard Betson(Posted 2012) [#87]
Hi Dave,

The only thing I have changed in my code is the way I use screen rotation. Using SetScreenRotationD3D11() and SetScreenFocusD3D11( x#, y# ) instead of odd.mod's SetScreenRotation() and SetScreenFocus() when your driver is enabled.

I did enable the D3D11Max2DDriver() this way. Problem?
SetGraphicsDriver (D3D11Max2DDriver(), GRAPHICS_BACKBUFFER | GRAPHICS_ALPHABUFFER | GRAPHICS_ACCUMBUFFER )


I'm still looking for a problem on my end but have not found any yet and all the other driver seem to scale images OK. I am 'NOT' using SetScreenZoomD3D11( zoom# ) to do the zooming but instead scaling images in my own algorithm. The only other problem I have noticed ( reaching... ) is some missing parentheses in the SetScale() commands in my code.

One other thing I noticed is GetGraphicsDriver() does not seem to report the D3D11Max2DDriver() as "not" active ie: this does not work

If GetGraphicsDriver()=D3D11Max2DDriver()
	'Driver Enabled
Else
	'Driver Not Enabled
EndIf

'in my case I get driver enabled when it was not


In this case it may not be your drivers fault as my video card is DX9 on a Win7 DX11 system.


Anyway still on the case. :)

Rich

Last edited 2012


xlsior(Posted 2012) [#88]
FWIW, I'm seeing the same breaking apart of the image when I zoom in in DX11 mode. Windows 7 x64, Radeon HD 6750 which is a DX11 card.


Richard Betson(Posted 2012) [#89]
@xisior

Maybe you could compile this code and see if it scales the image in DX11. If it works right you will get a blue box that expands in height and width then cycles.

If it does work could you try it in full screen.




col(Posted 2012) [#90]
Hiya,

The image scaling bug is fixed.

@Richard


This returns 'D3D11Max2D is Set' ?
Or are you referring to that you don't have a Dx11 card but the D3D11Max2D is available?

The latter is the same behaviour will the other drivers. For eg, if you have Dx9 installed on a system which has a Dx8 only card you can still use SetGraphicsDriver D3D9Max2DDriver(), its not until you try to use the graphics commands that you get an error, for eg you'd get an error on Graphics 800,600.

This next part was actually missing from D3D11Max2D so I've added it in. To check the graphics card against the Max2D driver version you want to use :-
If D3D9GraphicsDriver() Print "D3D9Max2D compatible"
If D3D11GraphicsDriver() Print "D3D11Max2D compatible"


Last edited 2012


col(Posted 2012) [#91]
I'm currently looking into the monitor/full screen resolution scaling issue.


Richard Betson(Posted 2012) [#92]
Dave,

Right on. :) I will get a copy of the update and recompile and post my client.

Or are you referring to that you don't have a Dx11 card but the D3D11Max2D is available?


Yes, It would fail on say 1366 x 768 (no gmode) but other resolutions like 800 x 600 would allow the client to run and then crash with no gmode failure.

Off to to recompute:)

Rich


col(Posted 2012) [#93]
Just to clarify for yourself and for others...

There are a couple of things to think about here :-
1. The end user pc doesnt have Dx11 installed.
2. The end user does have Dx11 installed but the gpu isnt Dx10/Dx11 compatible.

It doesn't matter if 1. and/or 2. are True, Max2D will still make a D3D11Max2DDriver().
However if 1. and/or 2. are true then D3D11GraphicsDriver() will be invalid - Null.

So if you are doing a check against D3D11Max2DDriver() in your code to check if you have a valid Dx11 gpu then your code will fail when it comes to actually using the graphics commands. This is the way BRL has made Max2D work and D3D11Max2D follows the same setup configuration.

If you want to know if the end user pc can handle the D3D11Max2DDriver(), you can check if D3D11GraphicsDriver() is True or Null, or use a Try/Catch which may/may not make for easy code reading. Personal preference really :P

And also, now with the latest changes, you shouldn't get any graphics modes returned unless the pc does have a Dx10/Dx11 gpu, it will leave the GraphicsModes() as null, so be sure to check that before trying to look at graphics modes parameters via TGraphicsMode ;-)

Have fun :D


kfprimm(Posted 2012) [#94]
Dave,

I have posted patches to GitHub that change the behavior to what I believe is correct. Take a look at them if you have the time.

I agree with your above points except for one. D3D11Max2DDriver should return Null if D3D11 is not present. This is the behavior of TD3D9Max2DDriver.Create:
	Method Create:TD3D9Max2DDriver()
		If Not D3D9GraphicsDriver() Return Null
		
		Local d3d:IDirect3D9=D3D9GraphicsDriver().GetDirect3D()

		If d3d.CheckDeviceFormat( D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,D3DFMT_X8R8G8B8,0,D3DRTYPE_TEXTURE,D3DFMT_A8R8G8B8 )<0
			Return Null
		EndIf
		
		Return Self
	End Method



By the way, I believe you left out the new GUIDs you are using in TD3D11GraphicsDriver.Create. I have included them as well.

Last edited 2012


col(Posted 2012) [#95]

D3D11Max2DDriver should return Null if D3D11 is not present.


Hiya Kev,

Yeah, you're right, and it does.
I don't know what I'm waffling on about there!!! :/ LOL.


By the way, I believe you left out the new GUIDs you are using in TD3D11GraphicsDriver.Create



Yep I did :/
Thanks for the heads up LOL.
I didn't upload the file to GitHub.
I still can't get used to GitHub for some reason. We just don't 'dance' in time. I'll stick with it though for the meantime and see how I get on with some usage, so people please be patience with my inadequacies with github.

I'd made a couple more changes to it. I was going to incorporate 16bit fullscreen, but there doesnt seem to be any widespread valid back buffer format for that depth. Maybe I'm missing something? Direct3D11 Formats The only 'seemingly' valid option is only valid on Dx11.1

Last edited 2012


kfprimm(Posted 2012) [#96]
Wow. You're right, it doesn't and my pull request doesn't even address that issue. I don't what I was thinking. Keeping all this stuff straight is difficult!

And don't worry about. I think the issue is that you're looking at it as 'GitHub' and not 'git.' Git is where all the real functionality is. GitHub just makes it easy to use in teams and gives you a nice interface to browse the repos.

Look at this pull request, it adds a .gitignore file. If you merge that into your branch, then all those pesky .a and .i files will not longer appear as untracked files, they will simply be ignored. In addition, it adds the .bmx folders and doc/commands.html.


xlsior(Posted 2012) [#97]
Maybe you could compile this code and see if it scales the image in DX11. If it works right you will get a blue box that expands in height and width then cycles.


...It doesn't.

The box stays small, and every three seconds or so I see a short blue flash of a large box, then immediately goes back to the small box.

--Nevermind, just downloaded the latest update, and now it does indeed scale the box smoothly.


Richard Betson(Posted 2012) [#98]
Dave,

Still getting a new client ready to test. I had to isolate some other issues. Should have something out shortly and significantly faster in DX. :)

- Rich -


col(Posted 2012) [#99]
@kfprimm

Thanks for the info, I definitely need to look into more. I kind of just jumped in and started uploading files without giving real thought for the underlying processes. As usual I should RTFM :D

@Richard

Looking forward to it :-)


Richard Betson(Posted 2012) [#100]
Hi Dave,

Here is the latest copy of Phoenix SS. IT should run great in DX11 now. Let me know. :)

http://redeyeware.uphero.com/phoenix_ss/phoenix_ss_client_a83.zip

Thanks,


col(Posted 2012) [#101]
Hey Richard,

Works great and looks really cool :P

Only one thing... the available graphics modes dont show up in Dx11 for my laptop, are you locking to a specific hz?
My laptop returns hz of 59 and 60 for OpenGL/DX7/DX9 but for DirectX11 the laptop driver reports available fullscreen modes as 59 only ( which comes from the ropey graphics drivers installed ), so if you are doing a search for specifically 60hz then this would be something that could trip up.

It does look cool :D


Richard Betson(Posted 2012) [#102]
Hi Dave,

Here is a recompile to catch 59hrz as a valid mode. It's these little things I need to know about so thanks. :D

Let me know if the graphic modes show up.

http://redeyeware.uphero.com/phoenix_ss/phoenix_ss_client_a83b.zip

As a reminder use number pad ' - ' and ' + ' to zoom in and out. Hit ' F10' to toggle screen rotation on/off.

Thanks.


col(Posted 2012) [#103]
Everything worked great in 'a83.zip' except for the odd fullscreen frequencies which are now working ok in 'a83b.zip'.

Sweet :D


Richard Betson(Posted 2012) [#104]
YAY!

Your driver so rocks it. :D So far other users testing Phoenix report no problems in DX10/11 so it is looking good. :)

I will be exploiting shadows and the rest very soon. Keep an eye out for it.

Last edited 2012


Richard Betson(Posted 2012) [#105]
Hi Dave,

I was wondering if you could have your driver check the current DirectX installed before the driver attempts to initialize. On my Win-XP DirectX 9 system the driver throws an error just being an 'imported mod'. Perhaps checking the DX version installed similar to this method :
http://www.blitzbasic.com/Community/posts.php?topic=74071#827657

This may not be workable and I may have to do this kind of setup on my own, but I thought I would see what you think about it.

- Rich -

Last edited 2012


col(Posted 2012) [#106]
Hiya Richard,

What error are you getting? Without looking ( at work at mo ), there shouldn't be any code 'running' until you set the driver using SetGraphicsDriver, but I will check when I get home later. From memory... I'm sure only function pointers and constants are initialized during module loading and only used if valid during execution, but again I will check this.

Last edited 2012


Richard Betson(Posted 2012) [#107]
Hi Dave,

The error is "Cannot find 'dxgi.dll. Please Install DirectX11 from Microsoft Exiting".

I'm just running and compiling 'Import SRS.D3D11Max2D' as the code on my DX9 XP system.

It does this or something similar on DX-10/11 systems as well asking for a file but I'm not sure its same one as above. Updating DX11 will fix the problem but some newer out of the box systems seem not to include it. I will try to get the file name by looking over your driver code late tonight.

I guess what I am getting at is it failing and requesting a driver when DX-10/11 is installed is good but when DX 9 or less is installed it would be great if the driver did not initialize at all and pass a 'null' value to SetGraphicsDriver().

I will be back late tonight. :)

Thanks,
- Rich -

Last edited 2012


col(Posted 2012) [#108]
Hiya Richard,

UPDATED...


It does this or something similar on DX-10/11 systems as well asking for a file but I'm not sure its same one as above.


If it happened on a system with Dx11 already installed then its probably 'd3dcompiler.dll' thats behind the times. This won't happen now, although the driver will still fail.

I thought I'd got rid of all those messages, never mind, they are gone now. It will fail silently and the driver will be null if either D3D11 isnt installed or if it is installed and not up to date.

This means its up to you to deal with this in your own code which you can now do silently in a variety of ways whichever you choose :-
'Silent fallback to D3D9 if no D3D11
Strict

Import SRS.D3D11Max2D

'Is D3D11 installed??
Global D3DDriver:TGraphicsDriver
D3DDriver = D3D11Max2DDriver()

If Not D3DDriver D3DDriver = D3D9Max2DDriver()

SetGraphicsDriver D3DDriver
Graphics 800,600

While Not KeyDown(KEY_ESCAPE) And Not AppTerminate()
	Cls
	
	DrawText "Current GraphicsDriver() is "+GetGraphicsDriver().ToString(),0,0

	Flip
Wend
End


Remember that MS suggest to include the correct run-time install package that your code needs alongside your own game. Doing things the way we are at the moment is a bit 'hacky' although it kindof works to a degree. MS do have a nice install package thats only really suitable when you want to install your game say via InstallShield or simliar.

Last edited 2012


Richard Betson(Posted 2012) [#109]
Hi Dave,

Right on, that is great. :) I can provide a link to the installer for DX11 and all should be good.

Thanks for the update Dave.

*Edit- removed

- Rich -

Last edited 2012


Richard Betson(Posted 2012) [#110]
Hi Dave,

I am not sure GetGraphicDriver() is correctly returning the D3D11Max2DDriver(). I will have an opportunity to test this tomorrow but a test with the updated driver failed to recognize the D3D11Max2DDriver() driver on a qualified DX10 system (within my game). It could be something I have done but I will know tomorrow.

I guess this is a 'has anyone had a problem with the updated driver' moment. :)

Thanks,
- Rich -


col(Posted 2012) [#111]
Hiya Rich,

For testing - there are 3 exposed variables that you could check manually if you wanted to...

_d3d11 : If this is non-zero then the driver has found d3d11.dll
_d3dcompiler : If this is non-zero then the driver has found D3DCompiler_43.dll
_dxgi : If this is non-zero then the driver has found dxgi.dll

If any one of them is zero then the driver will be Null. Also if any one of them is non-zero while any other one is zero its an indication that DirectX needs the latest update - Typically _d3dcompiler could be zero while the others will be ok on a pre-installed system.

Hope this helps.


Richard Betson(Posted 2012) [#112]
Cool, that is very useful to know. :)

I'll be busy the next day or so but will post my results soon. Thursday'ish.

Thanks,
- Rich -


Richard Betson(Posted 2012) [#113]
Hi Dave,

It's a bit past Thursday:)

It appears that the latest version of the driver is not working. I a used the previous version of the driver and it works all right. The constants you listed above all reported greater then null(very useful BTW).

I am looking over what might be the problem, but no luck yet. GetGraphicsDriver() returns null and using SetGraphics(D3D11Max2DDriver()) and drawing to display will fail as well. It is, as if the driver is not initializing.

- Rich -

Last edited 2012


col(Posted 2012) [#114]
Hi Rich,

So there are 2 issues

1. GetGraphicsDriver() - not working
2. SetGraphics([..]) - not working

Issue 1 - Ive fixed - not uploaded just yet.
Issue 2 - Are you using SetGraphics or SetGraphicsDriver ? with D3D11Max2DDriver().

Only reason I ask is that if you try to use SetGraphics(D3D11Max2DDriver()) the compiler should complain about D3D11Max2DDriver not being a TGraphics type, So I assume you mean SetGraphicsDriver ?? I've just tested on a Dx10.1 system and it works ok. Can you give a code example please.

Cheers


col(Posted 2012) [#115]
Also were you using GetGraphicsDriver().ToString() at all?


Richard Betson(Posted 2012) [#116]
Hi Dave,

Ya,I am using SetGraphicsDriver(D3D11Max2DDriver()).

I don't use GetGraphicsDriver().ToString() but instead do something like this:


SetGraphicsDriver(D3D11Max2DDriver())
Local t:TGraphicsDriver=GetGraphicsDriver()

Select GetGraphicsDriver()
     Case D3D11Max2DDriver()	
          If t<>Null
               'driver looks good.
          EndIf
     Case D3D9Odd2DDriver()
          If t<>Null
               'driver looks good.
          EndIf

End Select


In my case the GetGraphicsDriver() reports as null on the DX10 system I used today (previous versions worked on this system). Bypassing the above code and just using SetGraphicsDriver(D3D11Max2DDriver()) fails to work as well on the same DX10 qualified system.

Let me recompile with the new version and see what happens tomorrow. I'll also check compiler output, I may have missed something the driver reported.

Thanks. :)
- Rich -


Richard Betson(Posted 2012) [#117]
Hi Dave,

I just tested the the version of your driver I was having trouble with (not this last update) and it worked fine on DX10.1 Ati v-card. The last system I ran it on was a laptop with a DX10.1 Intel v-card which failed.

I am going to try the new version of your driver on this Ati system and I bet it works. There must have been something wrong with my friends laptop setup, I bet a v-card driver update will fix the problem.

Back soon,
- Rich -


Richard Betson(Posted 2012) [#118]
Hi Dave,

You've not up'ed the latest changes GitHub, right?

I will probably release a new version of my software (server/client, yea:) ) this weekend and the driver will get a good testing.

Thanks,
- Rich -


col(Posted 2012) [#119]
Hiya Rich,

Sorry for the delay.

I've been busy pulling my hair out as to get to grips with some unrelated code trying to understand Microsofts coding conventions :/ I'll never understand how they can actually take a simple task and bastardize it beyond belief?!?!? But still... I digress.

On topic...

It may be a quirk with Intel cards being really fussy with Dx initialisation. In this update I've also exposed a new function for testing only that should not be NULL after SetGraphicsDriver command even if the driver isn't initialised you should still get some value returned...

D3D11GetFeatureLevel()

If you have problems the values return by that command relate to consts defined in d3dcommon.bmx :-

Const D3D_FEATURE_LEVEL_9_1 = $9100
Const D3D_FEATURE_LEVEL_9_2 = $9200
Const D3D_FEATURE_LEVEL_9_3 = $9300
Const D3D_FEATURE_LEVEL_10_0 = $a000
Const D3D_FEATURE_LEVEL_10_1 = $a100
Const D3D_FEATURE_LEVEL_11_0 = $b000

The driver will only initialise if the value of D3D11FeatureLevel() is the value of D3D_FEATURE_LEVEL_10_0 or greater. The same process was used in previous versions except I've just exposed this function to help bug hunting.

Hope this helps.


Richard Betson(Posted 2012) [#120]
Hi Dave,

That is very cool and should help figure out whats going on. I love the fact that there is now some level of error checking. Good job. As an extra it looks that if the D3D11Max2DDriver() fails for a valid reason I can see what DX version is actually installed.

I will give it a test on the the system that was in question and see what happens.

- Rich -


BlitzSupport(Posted 2012) [#121]
Sorry to interrupt, chaps (keep going!), but the thread was getting a bit long. Continued here...