D3D11Max2DDriver() - Part II

BlitzMax Forums/BlitzMax Programming/D3D11Max2DDriver() - Part II

BlitzSupport(Posted 2012) [#1]
Continued from here.


From col:
Presenting a Direct3D11 driver for Max2D.



From last thread...



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.




Last edited 2012


Richard Betson(Posted 2012) [#2]
Part two. . . the saga continues. :) D3D11Max2DDriver()!!!


col(Posted 2012) [#3]
Hey Rich,

How did you get on with that testing of the Intel GPU - Dx10.1??


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

No, I have not been able to reach the guy with the system. But I am planing on releasing a new version of my game Sunday and the D3D11Max2DDriver() (newest version) should get tested on several types of systems then.

I will let you know.

BTW, Thanks for this great driver! And so anyone searching who finds this thread first the D3D11Max2DDriver() is available here:

https://github.com/SRSSoftware/d3d11max2d.mod

- Rich -


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

It will be another week (maybe sooner) before I get the next version of my game out. I am coding a server (using client prediction model) and aside from the math/physics is quite challenging.

I let ya know as soon as it's up and report the D3D11Max2DDriver()'s performance among users.

- Rich -


col(Posted 2012) [#6]
Cool :-)

Looking forward to seeing the newer version.


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

I have a working server up and a new client posted using your driver. No complaints so far. :)

Phoenix SS client:
http://www.subspace.co/topic/26399-server-up-download-the-new-phoenix-ss-client-and-come-test/

- Rich -


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

Looks good. I did not have any complaints about graphics drivers or related problems. Which is good for both of us. :D

BTW, to be clear I am using your latest driver. ;)

Thanks,

- Rich -

Last edited 2012


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

That's cool its working out great :-)
I posted in your other thread about trying out the newer version of your game.

All great so far :D


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

Do you have any example code on using shadows and the other features in your D3D11Max2DDriver()?

Thanks,
- Rich -


col(Posted 2012) [#11]
Hiya Rich!

Lights and shadows are still very much in an alpha experimental stage. However, I do have a small example, a tech demo, that you can play with. But I won't be able to iron out the bugs just yet as I'm working hard on a GUI, but hey, feel free to have a play! :D


Some setup:-
In the d3d11max2D.bmx file, uncomment lines 19,20,21 then Rebuild Modules.
Download this .png test pic and place it the same folder as this code :-



Last edited 2012


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

Great. Will play around with it. GUI? :)

Thanks,
- Rich -


col(Posted 2012) [#13]

GUI? :)



Uh huh ;-)

It can co-exist with MaxGUI so you can either mix them or use one or the other. Its a native alternative for Vista-sp2 / Win7.

I've also started working on a multi-thread version of the D3D11 driver that will remain 100% compatible with existing code, a complete rewrite, tidier code, introduction of new bugs :D

GUI first though ;-)


Richard Betson(Posted 2012) [#14]
Wow,

All good stuff, can't wait. :)

- Rich -


Grisu(Posted 2012) [#15]
Hi,

Does the D3D11Max2DDriver fully support alpha transparency yet?
When using the driver along with maxgui it doesn't seem to work.

Have uploaded a small example code and exe files that show the issue.
http://193.218.154.87/~knot/prp/dx11.zip

Would be great if someone could look into this.

Grisu


therevills(Posted 2012) [#16]
Hey Dave, just noticed your sig: -- Get your BMax DirectX10/11 Max2DDriver here! --

And that link goes to the github for d2d11max2d... so I guess that includes DX10 too?

Last edited 2012


col(Posted 2012) [#17]
Hiya,

Thanks for finding this bug.
I've fixed this 2 hours ago, getting seriously p***** off with git and GitHub :(

Its now deleted the files I've uploaded, so I'm off for an hour to cool off, and try again in a while.

@therevills
Hiya, yes, Dx10 support is built into the same driver. It automatically picks up if Dx11 isnt available and will fallback to Dx10 while still using the Dx11 drivers.

EDITED EDIT:-
Removed source code. Please use the link in my sig. Thanks.

Last edited 2012


Grisu(Posted 2012) [#18]
Getting a new error when compiling the latest version:


Modules rebuild fine though. OS Win7 64 Bit, ATI 6850 card.

In addition could you add a fallback to dx 9 as well?
Means dx11 -> dx10 -> dx9 (last stand :) ).

Grisu

P.S. The two file posted above are not included when you download the module from the main site.


col(Posted 2012) [#19]
I'm going to find an alternative to Git. I just don't get the concept of how it works, and I up getting annoyed at the extreme UN-intuitiveness behind it all. The slightest update just causes nothing but aggravation for me every single time.

For the time being the complete working D3D11Max2DDriver module can be downloaded from :-

*Please use the link in my sig*


In addition could you add a fallback to dx 9 as well?
Means dx11 -> dx10 -> dx9 (last stand :) ).


Blizmax already has a Dx9 driver ;-)


P.S. The two file posted above are not included when you download the module from the main site.


Yes, that's why I posted them here.

I'm just not dancing in step with Git/Github. I don't understand the methodologies behind it all. I don't understand how the files get deleted when they are supposed to be updated. Also the error you have with 'Return' doesn't even exist in the copy of the exact same file i had posted ( now removed ) above. So clearly I'm missing the boat when it comes to using Git :/

Last edited 2012

Last edited 2012


Grisu(Posted 2012) [#20]
Thanks a lot, Dave! Works perfecty now.

For the fallback: Is there a more elegant way to use the newest dx version available on the system?

If D3D11Max2DDriver() Then
    SetGraphicsDriver D3D11Max2DDriver()
    DebugLog "Using DX 11/10!"
Else 
   SetGraphicsDriver D3D9Max2DDriver()
   DebugLog "Using DX 9"
End If



col(Posted 2012) [#21]
Hiya,

You could do something along the lines of

Strict

Import SRS.D3D11Max2D

Global D3DDriver:TGraphicsDriver

D3DDriver = D3D11Max2DDriver()
If Not D3DDriver D3DDriver = D3D9Max2DDriver()

SetGraphicsDriver D3DDriver

DebugLog GetGraphicsDriver().ToString()



therevills(Posted 2012) [#22]
So that code above checks DX11, then DX10 and if neither are found it sets it to DX9?

Last edited 2012


col(Posted 2012) [#23]
Hiya therevills,

Yes it does exactly that.

Just to clarify with some details :-

The D3D11Max2DDriver MUST have DirectX11 installed on the system if you want to support Dx11 or Dx10 cards.

Internally, in the D3D11Max2DDriver initialization stage, it checks if DirectX11 is installed and checks if its up to date. If that check passes it then checks if the gpu card is Dx11 compatible, if not, it then checks to see if the gpu card is Dx10 compatible. So, providing that DirectX11 is installed, and either the card is first Dx11 then Dx10 compatible, then it will complete the initialization and return a valid TGraphicsDriver from the D3D11Max2DDriver() function ( using either Dx11 or Dx10 as appropriate ), otherwise Null is returned from the D3D11Max2DDriver() function.


So bearing in mind the previous paragraph...

The code above sets our own D3DDriver:TGraphicsDriver variable to the result of the D3D11Max2DDriver() function. If the variable is Null ( which means either Dx11 isnt installed or the gpu card doesnt support Dx11 or Dx10 ), then it sets the D3DDriver variable to the result of D3D9Max2DDriver() function, which nowadays on a windows pc will usually return valid anyway ( but never take anything for granted ). It then uses the D3DDriver variable with SetGraphicsDriver.

Hope this helps :-)

Last edited 2012


Grisu(Posted 2012) [#24]
How can one determine which dx driver (11 or 10) is actually in use?
Can I read out that somewhere?

Your code states "DirectX11 - Using DirectX 10.1" on my system, but it should be dx11?

Last edited 2012


col(Posted 2012) [#25]
Yes,

You can use GetGraphicsDriver.ToString()

The D3D11Max2DDriver will output one of the following :-

DirectX11 - Using DirectX 10.0
DirectX11 - Using DirectX 10.1
DirectX11 - Using DirectX 11.0
DirectX11 - 11.1


depending on the capabilities of the gpu card.

EDIT :- Or you can use a debugging function that will tell you the capabilities of the gpu, bear in mind only level 10_0 upwards is supported by this driver:-

D3D11GetFeatureLevel()

to get a return value which will equate to the following :-

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


Last edited 2012


col(Posted 2012) [#26]

Your code states "DirectX11 - Using DirectX 10.1" on my system, but it should be dx11?


What gpu card and gpu drivers are you using?


Grisu(Posted 2012) [#27]
AMD Sapphire 6850 Toxic with the latest stable drivers, i.e 12.6.

Dx 11 is properly installed:
(deleted)

Last edited 2012


col(Posted 2012) [#28]
On DxDiag, click on the 'Display' tab, the gpu details are in the 'Device' panel, top left. Could you post those please? and also the driver details at the top right.

Cheers.

no worries, just saw the data in your post.

Last edited 2012


Grisu(Posted 2012) [#29]
Here ya go:
(deleted)

Last edited 2012


col(Posted 2012) [#30]
Yep, it should be initializing to Dx11.

I'll look into this. What value do you get returned using the D3DFeatureLevel() function after using SetGraphicsDriver? Do you have an on-motherboard gpu?

Last edited 2012


Grisu(Posted 2012) [#31]
"$a100", no motherboard or cpu with gpu only the one mentioned above.


col(Posted 2012) [#32]
Would you mind to post the output from this basic test code? :-



Cheers.


Grisu(Posted 2012) [#33]
HRESULT: (00000000)
D3D Level: (0000B000)
D3D11Device: (00AFBB68)
D3D11DevCon: (009F29A0)
Process complete



col(Posted 2012) [#34]
Cool,

Thanks for the testing, it helped a lot! I'll release an update soon.


col(Posted 2012) [#35]
Hiya,

It appears there's a bug in one of the DirectX11 functions which will incorrectly return that some valid Dx11 gpus don't support Dx11.

The bug is bypassed in the latest version.
The latest version will always be in my sig.

EDIT:-
@Forum mods, would you mind to remove the reference to the GitHub webpage in the very first post please as I won't be keeping that reference up to date, and the latest version will always be available from my sig. Thanks.

Last edited 2012


Grisu(Posted 2012) [#36]
Thanks for fixing this stuff so quickly!


col(Posted 2012) [#37]
You're welcome.

We can't have a broken driver eh.

Before we consider this as a permanent fix could you post the result of this little piece of code please :-



Thanks.

Last edited 2012

Last edited 2012


Grisu(Posted 2012) [#38]
CreateDXGIFactory() : Factory created OK
Querying all adapters :  Found 1 Adapter(s)

Adapter Index : 1
	Name : AMD Radeon HD 6800 Series
	Level : D3D_FEATURE_LEVEL_10_1
Process complete


Awk, still stating Dx10.1, my card may be broken... :)


col(Posted 2012) [#39]

Awk, still stating Dx10.1, my card may be broken... :)



Nah, but you have proved its a bug within DirectX11. Maybe a driver issue but it doubt it very much.

It reports ok when using the code in Post #21 with the latest version yes?


Grisu(Posted 2012) [#40]
Yes, it does.


col(Posted 2012) [#41]
Excellent stuff.

Thats the one that really matters.

Thankyou for your help :)


Grisu(Posted 2012) [#42]
D3Dcommon.bmx lacks the CONST "D3D_FEATURE_LEVEL_11_1=$b100". Did u miss that?

Could you please add a function to return a simple string/int for which gfx driver is currently in use, like:



It would help quite a bit. As the code above seems not to be very efficient.

Last edited 2012


Hotshot2005(Posted 2012) [#43]
What does this really mean when person have Direct x 11 code in Blitz Max?

Does it mean open graphics direct x 11 possibly?


col(Posted 2012) [#44]

D3Dcommon.bmx lacks the CONST "D3D_FEATURE_LEVEL_11_1=$b100". Did u miss that?


Oops :D Yes, I didn't bother with it at the time of writing the driver as Win8 wasn't quite out and I forgot all about it once Win8 was released. Just for record Dx11.1 is Win8 only at the moment and I can't see MS updating Win7 support just yet. Thanks for the heads up and they will be included for the next release.


Could you please add a function to return a simple string/int for which gfx driver is currently in use


Due to the nature of how Max2D works, which is to allow easy swap in and out of the graphics drivers, it's not feasible for me to write that. You could modify the Max2D source to suit your own needs, but bear in mind that any updates that BRL release will overwrite your modifications.


Does it mean open graphics direct x 11 possibly?


Yep . Certainly does. You have full access to the 3D interface, but there is only 95% of Dx11 ported - I didn't port over the D3D11Effects framework and there are a few structures and constants that I didn't need to write that wouldn't take no more than 20mins at most. The Effects code would take a lot longer and you don't really need it anyway, its a convenience framework thats wrapped around the native code. I only did that amount as it is already way more than enough to support Max2D.

What were you thinking of doing with it? I've written the Dx11 code so that you can pretty much use the MSDN for reference. If you'd like some help understanding how to use it separately from Max2D, maybe for 3D work, I'd gladly help out, however it may be better to start another thread as it would be off topic for this one.

Last edited 2012


Grisu(Posted 2012) [#45]
So far your driver works fine under Dx11 (Win7) and Dx9 (XP).
Just testing it for a new relase of my app: http://193.218.154.87/~knot/prp/prp_tech.zip

I'm sure I will find more bugs somewhere... ;)


Doc Holliday(Posted 2012) [#46]
Hi folks,

it's a while ago, that I did my last Bmax project (about a year ago or so). Now I have a new idea for a Bmax project and I read the forum to come into Bmax again. And I found this interesting thread here about this D3D11Max2DDriver.

So I downloaded the latest release from Daves sig, put it into my mod-folder. Then I rebuilded all modules. All worked fine.

To play around with it and look how it works I copied the code from the fireworks example further above in this thread to a clear bmx-file. I added the import statement for D3D11Max2DDriver at the very top of the file and tried to compile.

Then the compiler stopped me with the following error:

Compile Error: Can't find interface for module 'srs.d3d11max2d'
Build Error: failed to compile D:/D3D11Max2D Fireworks/D3D11Max2D Fireworks/fireworks.bmx


I thought a while about this, but I can't figure out, what is wrong, or what I'm doing wrong ...

Maybe, someone out there can help - thank you very much :-)

Doc Holliday


col(Posted 2012) [#47]
Hiya,

First things first - making sure the file hierarchy is correct.

Does your BlitzMax/mod folder look like this -

BlitzMax/mod/srs.mod/d3d11graphics.mod/[various files]
BlitzMax/mod/srs.mod/d3d11max2d.mod/[various files]
BlitzMax/mod/srs.mod/directx11.mod/[various files]


Doc Holliday(Posted 2012) [#48]
Hi Dave,

Thanks for the fast reply. Yes, the file hierarchy matches exactly with that in your post above. :-)

Doc Holliday


col(Posted 2012) [#49]
Maybe you could try deleting all of the .bmx folder, .i, and .a files in each of the 3 new module folders, then try rebuilding the modules again. When you get the error you have it's BlitzMax not finding the mentioned .i file, usually associated with the modules not building correctly.

I've just tried it using

MaxIDE 1.42
BCC 1.48
FASM 1.69.14
GCC/G++ 4.6.2

and it builds and works ok.

Due to slight changes in the driver as time has progressed the Fireworks demo needs just one line changing to account for the newer updates. There's only one line different ( the parameters for the CreateBatchImage have changed ) but I'll post the complete working source here to make it easier.



This also exposed a bug in one of the helper functions, In d3d11max2d.bmx, the function 'VerifyD3D11Max2DDriver()'. All fixed in the latest version.

Last edited 2012


Doc Holliday(Posted 2012) [#50]
Hi Dave,

I followed your advice, deleted all .bmx-folders, all .i and .a files. Then I rebuilded all modules again.

And it works! I copied the changed fireworks-code to an empty bmx-file. It compiles with no errors. Yeahhh! :-)

But now I ran into next trouble: The programm executes and pressing space counts the number of fireworks up, and a few secounds later it counts down. That's ok - but I can't see any visual fireworks in the window like in the original fireworks.exe I downloaded yesterday from this thread.

My first thought was, that the particle-image was not in the right place, but it is (it's in the same folder like the exe).

My gfx-card is a NVIDIA GTX460 - full DirectX11 compliant.

I compiled with the latest BCC 1.48

Maybe you want to test MY compiled exe on your system - you can download it here:

http://www.jeknet.de/downloads/fireworks.zip

Thanks a lot ...

Doc Holliday


col(Posted 2012) [#51]
Hiya,

As bugs are found, I fix them pretty much immediately and release an updated version. Try the latest version from my sig, I updated it this morning :-)


Grisu(Posted 2012) [#52]
Hi,

same problem here: the code compiles fine, but I don't see fireworks at all.

-> LoadImage("spark.png") is missing!

Grisu

Last edited 2012


Doc Holliday(Posted 2012) [#53]
Hi Dave,

whatever caused the problem - with your latest release from this morning all works fine!

Thank you very much for your great work and for the very fast help.

Have a nice day :-)

Doc Holliday


col(Posted 2012) [#54]
@Doc Holiday
Have fun :)

@grisu
This TBatchImage fireworks example is an adaption of 'simonh' original example of the same name that can be found in

BlitzMax/samples/simonh/fireworks/

It uses the media from his example. You'll find the 'spark.png' in that folder.


Doc Holliday(Posted 2012) [#55]
Hi Dave,

it's me again. Sorry for bothering you with one more question that appears while im playing around with your gfx-driver.

When I switch to fullscreen, is it right that your driver switches to the highest available resolution and if necessary centers the screen output?

For example, I switched to 800x600 fullscreen with this lines of code:

SetGraphicsDriver D3D11Max2DDriver()
Graphics 800, 600, 32


I see, that my 24 inch display switches to the resolution of 1920x1080 and centers the output.

Is it possible with your driver to switch to the really native resolution of for example 800x600? How to do this, if it's possible?

Thank you in advance and

have a nice day :-)

Doc Holliday


TaskMaster(Posted 2012) [#56]
Doc,

That is most likely your monitor doing that, and not the BlitzMax program. Many LCDs will only go to actual modes that are direct ratios of their native resolution.


Doc Holliday(Posted 2012) [#57]
@TaskMaster

I had this idea too. But when I use the original max2d-driver it switches really to the native resolution (for example 800x600) and not to the max resolution the monitor is capable of.

A mystery thing? Maybe Dave can explain what happens?

Doc Holliday


col(Posted 2012) [#58]
Hiya,

I've had the same issues, after updating the gpu drivers and monitor driver it was ok.


Doc Holliday(Posted 2012) [#59]
Hi Dave,

you are so right. I noticed that I didn't update my gpu drivers for a long while. I'am such a bad boy ;-)

Now it works right with the native resolution.

Thanks again and ...

... have a nice day :-)

Doc Holliday


Grisu(Posted 2012) [#60]
Hi Dave!
I downloaded the latest files from your link and get a "Access Null error" with "SetBlend SolidBLEND". Did you change anything regarding this?

Grisu


col(Posted 2012) [#61]
Hiya Grisu,

No - nothing has changed in that respect for the longest time.
Do you have an example that reproduces it? Does it happen with other blend modes or Max2D commands?

EDIT:-
Oops! I left the driver in testing mode! Sorry, I've re-upped it to GitHub, but its a simple fix :

In d3d11graphics.bmx, comment out Line 114 !! and rebuild the modules.

Last edited 2012


Grisu(Posted 2012) [#62]
I see everything ;) - Thanks that did it.

Could you please add some kind of overal changelog, so it's easier to track what fixes / adjustments you have made to the modules?


col(Posted 2012) [#63]
Hiya,

I've pushed the module back onto github, it keeps track of all changes there.


Grisu(Posted 2012) [#64]
Moved here.

Last edited 2012


col(Posted 2012) [#65]
Hiya,

Is that a typo with you saying Dx9 and you meant the Dx11 driver?
Either way, if you post or send a working example with the offending media, then I'm sure I and/or others can take a look for you.

Just to keep things all fun and equal, if it is Dx9 you meant then you would be better to start a new thread so more people will see it.


Grisu(Posted 2012) [#66]
I have moved the topic to the bmx bug forum. It is a dx9 issue but looks the same as the one you fixed with the dx11 driver (using blend modes). So I thought you might know where to dig.


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

Been busy as you know. I'll get a copy of the latest DX11 driver and use it with the next release of my project. Let ya know. :)


Richard Betson(Posted 2013) [#68]
Hi Dave,

I have not forgot about you. ;)

Going to be releasing a beta version of my project soon. Anything new?


col(Posted 2013) [#69]
Hiya Rich,

Good to hear that you're getting closer! I guess as far as the driver goes - no news is good news :)

Nothing new to 'show' just yet for the latest MT version. I'm working on the ribbon editor whenever I get free time, which is disappointingly scarce these passed couple of months. Funny thing is that I prefer coding rather than my day job :P


Richard Betson(Posted 2013) [#70]
Funny thing is that I prefer coding rather than my day job :P

Don't we all. ;)


col(Posted 2013) [#71]
I've updated the driver to use the WindowsAPI so as to get all available display modes, particularly for HDTVs. Any duplicate modes are also removed. Because some TVs report some strange frequencies to be available it may be a good idea to filter them to 50/60hz. I've left that for the programmer to decide whether to filter or not.


Grisu(Posted 2013) [#72]
Thanks for the update!


Richard Betson(Posted 2013) [#73]
Hi Dave,

I'll have a new version of my project out to soon. I'll report back as I have a few beta testers that have the HD TV setup. Thank's for the fix. So cool of you to update this. :D

You Rock,
- Rich -


Richard Betson(Posted 2013) [#74]
Hi Dave,

All good so far. The one users I have with an HD display and DX11 has gone MIA for the moment. So as soon as he gets back I let you know how it works. But all good so far. ;)

Thanks,


col(Posted 2013) [#75]
Hi Rich,

For me... no news is good news ;)

The game is starting to look really cool and polished with the light effects. Excellent!


Grisu(Posted 2013) [#76]
Wil you add some stuff to support DX 11.2 features as well?


col(Posted 2013) [#77]
Hiya Grisu,

What features from 1.2 would you like?


Grisu(Posted 2013) [#78]
It would be nice if the module could detect future Dx 11.2 cards via GetGraphicsDriver() and make use of any speed improvements that might have been done to the normal functions.

I'm no Dx guru, the functions added with Dx 11.2 should be overkill for the average bmx user: http://msdn.microsoft.com/en-us/library/windows/desktop/dn312084%28v=vs.85%29.aspx


Richard Betson(Posted 2013) [#79]
I so love this module :D

make use of any speed improvements that might have been done to the normal functions


Tiled resources looks interesting especially if it can handle rotation. Speed improvement?

- Rich -


Grisu(Posted 2013) [#80]
Hello Dave,

I think that I found glitch with your module. Recently my AMD gfx-card (6850) died and I had to replace it via my old NVidia one (8800gts).

When running my radio player app, I get different results from Dx 10 (=maximum the old card supports).

The left screenshot shows, that the logo is misplaced by 1,1 pixels (Black border line missing). When I force OpenGL it looks normal again, like you see on the right screenshot:


Do you have any idea what might cause this?
Can someone else please confirm this issue by testing it on an AMD or NV card please?

Cheers!
Grisu


xlsior(Posted 2013) [#81]
Can someone else please confirm this issue by testing it on an AMD or NV card please?


When I run pocket radio player 310313 on my PC (Radeon HD 6750) the screen looks like your right-hand screenshot.
(No idea what graphics drivers it's using, though)


Grisu(Posted 2013) [#82]
Thanks for the report. So this seems to be NVidia related.

You can check the driver used via the about window. PRP will use the latest directx drivers supported on windows systems. In the screenshot below "Dx 10" stands for "DirectX 10". Apart from that you can force the usage of OpenGL via the options menu (restart needed!).



P.S.: The internal updater only checks for new radio stations and not app updates. The Frankenstein build is the current Halloween release... :)


col(Posted 2013) [#83]
Hiya Grisu,xlsior

I can also confirm that the image is correctly placed on a Radeon card, but it's 1 pixel right and 1 down on an NVidia card. I've just tested it on 2 laptops with appropriate gpus running the exact same version of your player.

Tested with Radeon 3400 and Geforce GT650.

Edit: On the newer laptop with the Geforce - it has 2 gpus inside - a basic Radeon and the NVidia, I can select which gpu I want the app to use and the same problems still exists. Weirdest bug ever!


col(Posted 2013) [#84]
This is a pic of your app using the 2 different gpus on the one laptop at the same time.

The left image is using the NVidia gpu, the right hand side is using the Radeon gpu.



col(Posted 2013) [#85]
@Grisu...

How are you creating/display the image/pixmap? I'm trying to reproduce the same effect on this machine and I can't do it at all.


Grisu(Posted 2013) [#86]
It's just a simple Drawimage command. If I use -1,-1 as coordinates it works fine.

Some code snippets.


When needed, I will try to dig up a complete example code later.

Thanks a lot for looking into this.


Grisu(Posted 2013) [#87]
This is a full example code. It reproduces the glitch for me:

Bug Example:


Image used inside code: (i.e. prp_noico.png)


Hope that helps you.


xlsior(Posted 2013) [#88]
Grisu: Just re-checkesd mine, it was using DX 11.0 by default, and looks OK. (Radeon). Still looks OK after switching to OpenGL as well.


col(Posted 2013) [#89]
Hiya,

THanks for the working example - worked a treat!

This a *fix candidate*.
If there are no reported issues with this fix after a couple of weeks then I'll upload it to GitHub.

It now displays as expected on my machine using the Radeon and the NVidia.

In d3d11max2d.bmx -> TD3D11Max2DDriver -> SetResolution :-

Method SetResolution( w#,h# )
	_matrixproj = [2.0/w,0.0,0.0,-1-(1.0/w),..
			0.0,-2.0/h,0.0,1+(1.0/h),..
			0.0,0.0,1.0,0.0,..
			0.0,0.0,0.0,1.0]
	MapBuffer (_projbuffer,0,D3D11_MAP_WRITE_DISCARD,0,_matrixproj,SizeOf(_matrixproj))
EndMethod



Cheers :)


Grisu(Posted 2013) [#90]
Seems to work so far. Need to test it further.

Make sure you add the missing "(" at the MapBuffer part, else it won't compile. 8)

Thanks for the über fast response time.


col(Posted 2013) [#91]
Added the '('.

Lol.

Thanks!

Awesome awesome music player! It truly is a great app.


Grisu(Posted 2013) [#92]
Glad that you like the app.

I'm going to add you to the Credits window for this module. Without it, my app would still depend on ancient DirectX9. What Name or Nick would you like to see there?


col(Posted 2013) [#93]
Wow. Thats really cool :)

It would be ok to use my real name - Dave Camp.

Thanks!!!!


Grisu(Posted 2013) [#94]
Replaced my Geforce 8800gts with a GTX 650Ti.
So far everything displays as it should. :)

You can grab the Halloween build from the PRP website. I used your real name for the credits.


col(Posted 2013) [#95]
Cool!!

It really is a cool player. I use it all the time.
Thanks for sharing this!


Grisu(Posted 2015) [#96]
Hi Dave!
Please make sure that your download link includes the latest fix for the resolution problem. - It currently doesn't.
Grisu


col(Posted 2015) [#97]
Hi Grisu!

Updated, thanks for noting!


Richard Betson(Posted 2015) [#98]
fix for the resolution problem.

What was the issue?


Richard Betson(Posted 2015) [#99]
BTW,

This driver works on DX12 with no problems as reported to me by beta team. Also my BlitzMax game runs on Windows 10.

All good news. :)


col(Posted 2015) [#100]

What was the issue?



Hey Rich!

on some select gpu cards... pixmaps/images would display 1 pixel off of vertical and 1 off of horizontal as in post #84. A simple matrix issue.

Thanks for the update. Good news with everything running sound on Win10 eh. Thats cool.

Also congratulations for the demo release tomorrow! I hope everything goes well. If there are any issues with the driver, don't worry. I pass by here most days so I'll pick up your feedback pretty quickly. The game is sure to be a big hit in its genre. Awesome game and the dev work that you show is truly inspiring stuff.


Grisu(Posted 2015) [#101]
Hi Dave!

Now with Win 10 out of the door. Do you have any plans on extending the module to DX 12? It would be nice to be able to detect DX 12 and benefit a bit from the lesser API overhead.

Stefan


col(Posted 2015) [#102]
Hey Grisu,

I'm working on something else at the mo but Dx12 is looking good. I think to take advantage of this lower level infrastructure is to use a scene graph or multiple scene graphs which would be a better system for a multi-thread environment than the current unoptimised state mechanism that max2d drivers are currently using. In fact max2d current system isnt suited at all for multithreading. This would also be better written in c++ rather than bmax so as to take advantage of a more advanced compiler. This would mean a completely new module rather than extending the existing one. One important factor though would be to keep the existing max2d api so that you don't have to change any your existing code to use it - same as the existing graphics drivers work, that is: being able to change driver on the fly with a couple of commands - to pull that off could be a whole ton of work, but its all doable :-)

One day I'll probably find time to get it done for max2d but probably not within the next couple of months though.


Grisu(Posted 2016) [#103]
Hi Dave,

could you try to make your module compatible with Brucey's 64 Bit version of BMX: http://www.blitzbasic.com/Community/posts.php?topic=105537 ?

[ 86%] Processing:dxgi.bmx
Compile Error: Unable to convert from Byte Ptr to Int.
[C:/BlitzMax/mod/srs.mod/directx11.mod/DXGI.bmx;350;0]
Compile Error: Unable to convert from Byte Ptr to Int.
[C:/BlitzMax/mod/srs.mod/directx11.mod/dxgi.bmx;350;0]
Compile Error: Unable to convert from Byte Ptr to Int.
[C:/BlitzMax/mod/srs.mod/directx11.mod/d3dcompiler.bmx;31;0]
Build Error: failed to compile (-1) C:/BlitzMax/mod/srs.mod/directx11.mod/dxgi.bmxBuild Error: failed to compile (-1) C:/BlitzMax/mod/srs.mod/directx11.mod/DXGI.bmx
Process complete



col(Posted 2016) [#104]
Will do, as soon as I can get the latest updates to build :-)


Grisu(Posted 2016) [#105]
Thanks!


col(Posted 2016) [#106]
Just a heads up as I haven't forgotten about this, still working on the low level interface mechanism for NG with Brucey - which is turning out to be much better than originally thought ;-)


therevills(Posted 2016) [#107]
Hey Dave!

Just a quick thank you for creating this driver :)

Also in you signature you name it " Get your BMax DirectX10/11 Max2DDriver here!"... so does it support DX10 as well as DX11 (even though all the code talks about DX11)?

Cheers,
Steve


col(Posted 2016) [#108]
Hey therevills!

What that means is that it will also work for Dx10 only gpus. As long as Dx11 is installed, even though the gpu is Dx10 only, then the D3D11Max2DDriver will use DirectX11 interfaces to make the Dx10 only gpu work as expected.

Hope it helps!


therevills(Posted 2016) [#109]
Ah cool - thanks Dave :)

My memory might be wrong, but didnt you also create a DX10 wrapper too?


col(Posted 2016) [#110]
didnt you also create a DX10 wrapper too?

Nah, there was never a Dx10 only wrapper for 'Max by anyone.


My memory might be wrong

No worries, as we progress though life we should expect it more often :D


col(Posted 2016) [#111]
Hiya all,

The D3D11Max2DDriver is now also compatible with Bruceys NG version of BlitzMax.
Simply download and use as normal. This is a 'drop-in replacement' for the older driver ie swap out the complete older driver and put this one in its place, rebuild the module and your existing code *should* just work.

This version supports the original BlitzMax and NG.

Have fun!


Brucey(Posted 2016) [#112]
Awesome job! :-)


therevills(Posted 2016) [#113]
Cool!


BlitzSupport(Posted 2016) [#114]
Wow, well done, Col.


Grisu(Posted 2016) [#115]
Awesome +64!


xlsior(Posted 2016) [#116]
Very, very, very nice!


xlsior(Posted 2016) [#117]
This is a 'drop-in replacement' for the older driver ie swap out the complete older driver and put this one in its place, rebuild the module and your existing code *should* just work.


Hmm... Probably not related, but I noticed that doing a force recompile of my entire NG install, it's bombing out on the pub.directx now: (gcc version 5.1.0 (tdm64-1)
[ 92%] Processing:d3d7.bmx
[ 92%] Processing:d3d9x.bmx
[ 93%] Processing:dd.bmx
[ 93%] Processing:dsound.bmx
[ 93%] Archiving:freetype.release.win32.x86.a
c:/Code/BlitzMaxNG510/MinGW32/bin/ar.exe: creating c:/Code/BlitzMaxNG510/mod/pub.mod/freetype.mod/freetype.release.win32.x86.a
[ 94%] Compiling:d3d7.bmx.release.win32.x86.c
[ 94%] Compiling:d3d9x.bmx.release.win32.x86.c
[ 95%] Compiling:dd.bmx.release.win32.x86.c
[ 95%] Compiling:dsound.bmx.release.win32.x86.c
[ 97%] Processing:d3d9.bmx
[ 98%] Compiling:d3d9.bmx.release.win32.x86.c
[ 98%] Processing:directx.bmx
Compile Error: Syntax error - expecting identifier.
[c:/Code/BlitzMaxNG510/mod/pub.mod/directx.mod/.bmx/dd.bmx.release.win32.x86.i;543;0]
Build Error: failed to compile (-1) c:/Code/BlitzMaxNG510/mod/pub.mod/directx.mod/directx.bmx



col(Posted 2016) [#118]
Hiya,

NG is being constantly updated, sometimes by the hour but definitely every few days/weeks.

I get the same error with the latest bcc but the previous commit compiles everything ok as long as you also have the latest brl/pub modules too.


Derron(Posted 2016) [#119]
Maybe it just needs another "elseif" in the current BCC ... let's wait for the next commit which surely fixes that issue.


bye
Ron


col(Posted 2016) [#120]
After making the d3d11 driver SuperStrict and then also forcing a rebuild of all modules, NG also doesn't like it so for the moment if you could use the previous commit then everything works harmoniously.


Derron(Posted 2016) [#121]
If you are brave, add the suggested else-if and check if it compiles then, if so, feel free to PR it to Brucey. I am currently not able to try it out.

bye
Ron


xlsior(Posted 2016) [#122]
compile error with latest NG:

[ 64%] Compiling:common.bmx.debug.win32.x64.c
[ 64%] Compiling:common.bmx.debug.win32.x64.c
[ 64%] Compiling:common.bmx.debug.win32.x64.c
c:/code/BlitzmaxNG510/mod/srs.mod/d3d11max2d.mod/.bmx/d3d11max2d_ng.bmx.debug.win32.x64.c: In function 'srs_d3d11max2d_d3d11max2d_ng_CreateD3D11Max2DResources':
c:/code/BlitzmaxNG510/mod/srs.mod/d3d11max2d.mod/.bmx/d3d11max2d_ng.bmx.debug.win32.x64.c:5719:8: error: void value not ignored as it ought to be
  bbt_hr=srs_directx11_d3dcompiler_ng_D3DCompile(bbt_3,(srs_d3d11max2d_d3d11max2d_ng__max2dshaders->_srs_d3d11max2d_d3d11max2d_ng_td3d11max2dshaders__max2dvs ->length),0,0,0,bbt_4,bbt_5,32768,0,&bbt_vscode,&bbt_pErrorMsg);
        ^
c:/code/BlitzmaxNG510/mod/srs.mod/d3d11max2d.mod/.bmx/d3d11max2d_ng.bmx.debug.win32.x64.c:5845:8: error: void value not ignored as it ought to be
  bbt_hr=srs_directx11_d3dcompiler_ng_D3DCompile(bbt_8,(srs_d3d11max2d_d3d11max2d_ng__max2dshaders->_srs_d3d11max2d_d3d11max2d_ng_td3d11max2dshaders__max2dps ->length),0,0,0,bbt_9,bbt_10,32768,0,&bbt_pscode,&bbt_pErrorMsg);
        ^
c:/code/BlitzmaxNG510/mod/srs.mod/d3d11max2d.mod/.bmx/d3d11max2d_ng.bmx.debug.win32.x64.c:5919:8: error: void value not ignored as it ought to be
  bbt_hr=srs_directx11_d3dcompiler_ng_D3DCompile(bbt_11,(srs_d3d11max2d_d3d11max2d_ng__max2dshaders->_srs_d3d11max2d_d3d11max2d_ng_td3d11max2dshaders__max2dps ->length),0,0,0,bbt_12,bbt_13,32768,0,&bbt_pscode,&bbt_pErrorMsg);
        ^
c:/code/BlitzmaxNG510/mod/srs.mod/d3d11max2d.mod/.bmx/d3d11max2d_ng.bmx.debug.win32.x64.c:5993:8: error: void value not ignored as it ought to be
  bbt_hr=srs_directx11_d3dcompiler_ng_D3DCompile(bbt_14,(srs_d3d11max2d_d3d11max2d_ng__max2dshaders->_srs_d3d11max2d_d3d11max2d_ng_td3d11max2dshaders__max2dps ->length),0,0,0,bbt_15,bbt_16,32768,0,&bbt_pscode,&bbt_pErrorMsg);
        ^
Build Error: failed to compile (1) c:/code/BlitzmaxNG510/mod/srs.mod/d3d11max2d.mod/.bmx/d3d11max2d_ng.bmx.debug.win32.x64.c



Brucey(Posted 2016) [#123]
Good point, D3DCompile return type hasn't been specified, whilst the module is SuperStrict :
Global D3DCompile(pSrcData:Byte Ptr,SrcDa...


On NG, SuperStrict will assume you really aren't returning anything from a function if you don't specify a return type - as opposed to the legacy compiler, which adds :Int to *all* your functions.


col(Posted 2016) [#124]
Thanks guys, corrected.


therevills(Posted 2016) [#125]
Hey Dave - any idea what is happening here:

http://www.blitzmax.com/Community/posts.php?topic=105798

With the Steam Overlay?

Cheers,
Steve


therevills(Posted 2016) [#126]
Hi Dave,

Couple of issues I've found:

* DrawOval has an issue when switching between graphics drivers, it doesnt draw.
* Also when Alt-Tabbing, the "game" is displayed on the desktop in a windowless version




col(Posted 2016) [#127]
Thanks Steve,

The oval issue and alt-tab issues should be fixed now in both version.
There was also a full screen infinite loop bug in NG that's also fixed.


therevills(Posted 2016) [#128]
Thanks Dave - Just downloaded the latest master and tested.

The oval has been fixed, but not the alt-tab bug from full screen, here you can see that the "windowless" screen has been displayed behind MaxIDE after alt-tabbing:



With the virtual resolution, here is a screenshot of the DX11 issue:



As you can see we dont get the black vertical bars and we can still see the rects & oval passed the "virtual" display.

Cheers,
Steve


col(Posted 2016) [#129]
The vertical bars is because of the way DirectX 10+ now clear the back buffer(s).

From MSDN

Differences between Direct3D 9 and Direct3D 11/10:
Unlike Direct3D 9, the full extent of the resource view is always cleared. Viewport and scissor settings are not applied.



I don't actually get that 'after effect' at all of my machine. I do get the same colour borders though. I do have a solution in mind. I'll implement it and put it out for testing.


I see what you mean about the window becoming a standard borderless window. I'm not sure on the best way to handle this. Here's why... When you're in fullscreen and you alt-tab then the OS has no choice but to come out of fullscreen so that it can display the desktop. DXGI, which the window handling of DirectX, intercepts the OS message and automatically handles bringing your app out of fullscreen and displays it as a regular window.

I think most other games now ignore exclusive fullscreen altogether and do a regular borderless full desktop sized window that simply covers the whole desktop giving the illusion of the exclusive fullscreen mode, or I could just minimize the window?


therevills(Posted 2016) [#130]
I do have a solution in mind. I'll implement it and put it out for testing.

Ready and willing :)

or I could just minimize the window?

That sounds like a good fix.

Cheers,
Steve


Grisu(Posted 2016) [#131]
Hi!

A user reported that the graphics canvas is no longer updated properly when the window is coming back from the background. Or if you bring up the window from the trayicon.

See screenshot:


OS: WinXP Pro (32 Bit)
GFX: Nvidia GeForce 6600GT, DirectX 9c
Res: 1152x864 @ 32 Bit colour

Not sure, if this has to do with your module. But I thought to better report it. It also exists when using OpenGL as driver.

Stefan


col(Posted 2016) [#132]
Jeez!
Been away for a while - fixed the alt-tab issue.

@therevills
The SetViewport hack should be implemented yourself as opposed to it being a standard part of the D3D11Max2D code, otherwise it runs the risk of breaking other peoples code. It's a Steam fault for not resetting the direct3d state to what it was before they changed it.

I'll take a look Grisu...
[edit]You're not using the 'SetViewport' hack above are you? I did include the hack in the previous commit by mistake and have removed it in the latest commit.


xlsior(Posted 2016) [#133]
Jeez!
Been away for a while - fixed the alt-tab issue.


FWIW, it is throwing some warnings compiling in Blitzmax-NG:




therevills(Posted 2016) [#134]
Jeez!
Been away for a while - fixed the alt-tab issue.


Did you go anywhere nice?

Thanks for the fix... I looked at the code but didnt know where or how to implement it! I'll test it soon :)

@therevills
The SetViewport hack should be implemented yourself as opposed to it being a standard part of the D3D11Max2D code, otherwise it runs the risk of breaking other peoples code. It's a Steam fault for not resetting the direct3d state to what it was before they changed it.


Yeah that's fine, could you let me know what I have to do? Is it just commenting out the _d3d11devcon.RSSetScissorRects(1,[x,y,x+width,y+height]) command in SetViewport?


col(Posted 2016) [#135]
@xlsior
Cheers! I'll be updating to the latest ng today.

@therevills
Yep, you're correct... just comment out that one line while using your black border fix :-)


Did you go anywhere nice?


Nah, life is full of twists and turns, highs and lows ;-)


Grisu(Posted 2016) [#136]
Hi Dave!

I'm currently on holiday and haven't got access to my pc. Will report back asap. I get your latest changes via the link in your signature, right?

Btw: Could you look into the fmod encoding issue, if you have some time to spare?

Stefan


col(Posted 2016) [#137]
@Grisu
Yep, the repo will always be the best place for the latest version.


Could you look into the fmod encoding issue, if you have some time to spare?


Yeah sure. The whole encoder process, except the gui, will need to be written in c/cpp. I'll have a play over the next few days for ya.

Enjoy your vacation!!


Derron(Posted 2016) [#138]
When using this code:

SuperStrict

Import SRS.D3D11Max2D

SetGraphicsDriver D3D11Max2DDriver()

Global g:TGraphics = Graphics(400,400,0,0)

If not g Then print "fail"



I get an EAV in release, and in Debug the error of a null access (thrown by brl.graphics)

CreateGraphics failed:Attempt to access field or mehtod of Null object



Tried this on a fresh Windows 10 installation (as a user uses this OS and reported crashs of my game when selecting DX11).


What could be the culprit there? Why is it failing that hard (no check within the SRS-modules)


Edit:
D3D11GetFeatureLevel() returns "0"

So could I skip to DX9 in that case (of a returned 0) ?


Ron


Derron(Posted 2016) [#139]
Edit 2:
Think I just missed to read thread part 1 ... first check "if D3D11GraphicsDriver()", then set graphics (if driver was valid)...




When using this code:

SuperStrict

Import SRS.D3D11Max2D

SetGraphicsDriver D3D11Max2DDriver()

Global g:TGraphics = Graphics(400,400,0,0)

If not g Then print "fail"



I get an EAV in release, and in Debug the error of a null access (thrown by brl.graphics)

CreateGraphics failed:Attempt to access field or mehtod of Null object



Tried this on a fresh Windows 10 installation (as a user uses this OS and reported crashs of my game when selecting DX11).


What could be the culprit there? Why is it failing that hard (no check within the SRS-modules)


Edit:
D3D11GetFeatureLevel() returns "0"

So could I skip to DX9 in that case (of a returned 0) ?


Ron


col(Posted 2016) [#140]
.


col(Posted 2016) [#141]
Hey Derron,

Updated to load the default shader compiler thats installed with Win10.


So could I skip to DX9 in that case (of a returned 0) ?


You could do yes. And/or you could also check if the driver is valid too


Derron(Posted 2016) [#142]
For now I adjusted my Code to:



It tries to use DX11, DX9, DX7 and finally OGL. It is wrapped in an external file so I could use the NG flags (which wont be possible within a "?win32"-conditional). The external file is only used within code wrapped with "?win32".


bye
Ron


therevills(Posted 2016) [#143]
Thanks for the Win10 fix :)


therevills(Posted 2016) [#144]
I'm doing some performance tuning on my game and noticed that when using the DX11 driver on my Win 8.1 machine, it is quite a bit slower than DX9... I would have thought that DX11 would be faster?

A little extreme test case:


In release mode:
DX11: 16FPS
DX9: 31FPS
OpenGL: 38FPS



Derron(Posted 2016) [#145]
Sorry, cannot help that much, but there is a minor:
	SetBlend SOLIDBLEND
	SetColor (255, 255, 255)
	SetBlend ALPHABLEND


The solidblend isn't needed at all. "SetBlend" seems to do a bit more in the DX11 driver than it has to do with DX9. But it happens only once per tick ... so that should be neglectable.

But similar "changes" happen to SetAlpha() and other calls. Maybe the pure "mass" of sprites (and their drawing/alpha/color/...calls) add up a bit?


bye
Ron


col(Posted 2016) [#146]
Hiya guys, I can't test anything for a month as im on vacation in Thailand but I just checked in for a flying visit o see what was happening in blitzmax land :-)

Dx11 is geared around batching and instancing but it obviously does allow for single operations. On top of which you can multitask to a certain fashion to squeeze some more out out it. After working with vulkan for a good few months i want to at least add some additions to the dx11 driver to take advantage of its features.

If you guys wouldn't mind to think up some things that you'd like to have included then we can plan on getting them in. I can either add to existing driver or if features clash with existing driver code then I'll make a new v2 . I've already seen significant speed gains for a quad renderer that uses the geometry shader to create the vertices etc.


Derron(Posted 2016) [#147]
I would like to see things being backported to DX9 as much as possible ... as most of my devices here lack on DX11 support (IGP of ancient laptops).

What people would surely like to see too , is some kind of cross platform shader support (at least post processing) and or cross-engine (DX + OGL) render2texture.


Dunno what could be "useable" for others ... but that's are things I would surely see benefits for "casual game/prototype" developers.


bye
Ron


therevills(Posted 2016) [#148]
The solidblend isn't needed at all.

Thanks for looking Ron, I know the SOLID_BLEND isnt needed in this case but I was trying to mirror what was happening in my proper game code.

But similar "changes" happen to SetAlpha() and other calls. Maybe the pure "mass" of sprites (and their drawing/alpha/color/...calls) add up a bit?


On this PC at work (Core i5 650, 8GB, 64Bit Win7, Intel HD graphics) I get the following:
DX11: 4FPS
DX9: 18FPS
OpenGL: 21FPS


If I remove the alpha calls in the render:
DX11: 6-7FPS
DX9: 19FPS
OpenGL: 18FPS


So remove all the alpha calls do help a tiny bit.

Dx11 is geared around batching and instancing

I think this may be the issue - Thanks for replying Dave, hope you are enjoying your holiday! (Keep safe too!)

Also the game is using fixed rate logic at 200Hz, so it is going thru the update loop quite a few times! In the game I have "only" 1000 snow flakes but I can still see performance issues.


col(Posted 2016) [#149]
Render to texture is easy enough for dx and gl, which can also make the virtual resolution feature of 'max redundant when you just render to a quad
what existing things are you referring to'to be back ported'? Or do you mean any newer features?

For dx11 there already exists a function to draw instanced / batched sprites, I can't remember the name of it but i remember demoing the fireworks example with it, maybe it's works investigating?


Derron(Posted 2016) [#150]
@ backport

I was talking about eg. "render to texture". I would like to see such features for the supported engines (DX 7 ...ok no must ;-), DX9, DX11, OGL - and maybe even GL2SDL from BMX-NGs SDL.mod - for android/IOS targets).

So you as BlitzMax developer are able to use it for all platforms ... just like "SetAlpha" or "DrawImage".

I think "render to texture" is one of the most "benefit providing" extension for casual game developers (just think of that "popping up" dialogues ... which are not that easily doable currently, with all that scaling GUI elements, text rendered on the dialogue ... ). It also makes "text caching" (1 texture instead of 5000 glyphs rendered each time) a breeze.



Shaders: I think together with "render to texture" it allows for "fade out background while modal dialogue is active" effects and other "simpler ones" (of course you could achieve way more ... eg. making a water-rendered-to-texture-surface get displaced a bit for wavyness).


I do not need 3D or so - just to make life for 2D-game/tool-devs easier on BlitzMax.


AND ... why am I "requesting" it here? If ONE dev writes that thing, it will be made similar for all engines - instead of one knowing about OGL and DX9 but not DX11 or only about DX9 and DX11 ...
I just want to avoid that it is a kludge out of multiple different solutions - not accepting the same params or having different meanings (0 - 1.0 VS 0-255) and so on.


@ virtual resolution
Hmm, yes, you then could get rid of that - IF that was as fast as using a scaling + offset (not sure about that "IF").



PS: have fun on your vacation.


bye
ron


col(Posted 2016) [#151]
Ok, no probs, what kind of api types/methods/funcitons do you think woud be best?

I think

Type TRenderTarget
Method Create:TRenderTarget(Width, Height, [Depth])
Method SetAsRenderTarget()


col(Posted 2016) [#152]
Ok, no probs, what kind of api types/methods/functions do you think would be best?

I think

Interface IRenderTarget
Method Create:TRenderTarget(Width, Height)
Method Destroy
Method SetAsRenderTarget

Interface IGLRenderTarget Extends IRenderTarget

Interface ID3D11RenderTarget Extends IRenderTarget

Interface ID3D9RenderTarget Extends IRenderTarget
Method OnD3DDeviceLost()
Method OnD3DDeviceReset()



Type TGLRenderTarget Implements IGLRenderTarget
Type TD3DRenderTarget Implements ID3DRenderTarget

For Dx9, as you can see we need to handle device lost/reset scenarios because the resource needs to be destroyed and recreated. We'll need a callback function for freeing up the resources when the device is lost - via fullscreen changes for eg. GL/D3D11 doesn't need that. That's not so difficult but will need a small change in a BRL/D3D9 module.

Any thoughts?


Derron(Posted 2016) [#153]
I am fine with changes in the "BRL/D3D9-Module" - if the changes are acceptable by Brucey for "maxmods" (as long as "backwards compatibility" is there, I think it is ok).


@ Interface
Remember that "vanilla" does not have interfaces, so you surely will stay with types. Your code does not really need interfaces as it does not mix in things from different "parentS"... does it?


@ functions
Yes, and as people do not like to do "img.draw()" but "DrawImage()" you need "SetRenderTarget(img:Timage)" as convenience function.

So your sample code would look like that:


'graphics initialization ...
'... done

global rtt:TImage = CreateImage(DeviceWidth(), DeviceHeight())
global rttPix:TPixmap = LockImage(rtt)
rttPix.Clear(0)

SetRenderTarget(rtt)
For local i :int = 0 to 1000
  SetColor rand(0,255), rand(0,255), rand(0,255) 
  DrawText("Hey there", rand(0, rtt.width-1), rand(0, rtt.height-1))
Next
SetColor 255,255,255
SetRenderTarget(null)
'or ?
RemoveRenderTarget() 

Repeat
  cls
  DrawImage(rtt, MouseX(), MouseY())
  Flip
Until KeyHit(KEY_ESCAPE) or AppTerminate()


(code untested for syntax errors, just a "sketch")


bye
Ron


Grisu(Posted 2016) [#154]
Happy holidays Dave! :)


therevills(Posted 2016) [#155]
Looks like the driver has a memory leak of some kind in Windows 10 at least...

Just testing my latest game and after about 20 mins in an automated mode (ie the computer clicks on the onscreen buttons), the screen rendering stops updating and I have to kill it via Task Manager.

Using the win32 extern GlobalMemoryStatus, after 20 mins, it states it has eaten 1300MB... when using OpenGL after an hour its only eaten 120MB and doesnt stop, and when using DX9 it has only used 260MB after an hour and a half.


Derron(Posted 2016) [#156]
@ therevills
Are you able to reproduce this with a smaller example?
... just to also narrow it down to a specific function-constellation.


bye
Ron


therevills(Posted 2016) [#157]
Once my current game is done, I'll look into trying to create a sample - good idea Ron.


col(Posted 2016) [#158]
Thanks guys! I had a great time in Thailand. What a beautiful place with beautiful people! Everyone is always smiling :-)

Back on topic...
I'm initially against the idea of having a TPixmap available from a 'rendered to' image. The whole point of being able to render to a texture/image is to be able to do it in the main loop 'on the fly'. 'Offline' rendering, ie rendering outside of the mainloop is already achievable with TPixmaps and TImages. The issue being that an image is loaded from disk as a TPixmap, then a TImage is created from it. That TImage is sent to the display when needed. To get a TPixmap from a 'rendered to' image would mean grabbing the backbuffer, and we all know how terribly slow that is. I'm open to change my mind though if you have a very good reason(s).

Your initial code also proposes that all TImages should have the capability of being rendered to, similar to b3d, is that what you envisage?

@therevills
Do you have an example to reproduce the memory leak?


Derron(Posted 2016) [#159]
@ render to Timage
Yes i thought of using timage / pixmap for targets.
Couldnt you create a kind of extended types for "gpu images" rather "tpixmap images"?

I mean somethIng which grabs from the gpu if needed but else does everything on the gpu. so lockimage() would additionally fetch the image data from the gpu while drawing to the image would try to do that purly on the gpu.


Intention is to be able to create images without grabpixmap calls or to fall back to software rendering. And the less adjustments to code have to be done...the better. So I thought using TImage/Tpixmap would be a good thing.


Bye
Ron


col(Posted 2016) [#160]
I've not had a chance to get to this since I came back from vacation.
I have some free time this weekend so will get the render to texture feature up and running this weekend.


col(Posted 2016) [#161]
I've started a new thread for the render to texture addition over here


seriouslee(Posted 2016) [#162]
Hey Col, encountered a couple of errors using the latest in Git on the latest of NG. I put in an issue on github, not sure if that's what you'd like or not.

Thanks!


col(Posted 2016) [#163]
Hiya,

Yes, all comments/issues are welcome :O)

Thanks!


xlsior(Posted 2016) [#164]
Didn't compile anymore for me either using latest Blitzmax NG, don't remember the error but IIRC it was a duplicate identifier or something similar.


col(Posted 2016) [#165]
Should be fixed now.

Thanks!!


xlsior(Posted 2016) [#166]
Still giving me an error: I checked out the latest NG pub.mod and NG brl.mod, as well as srs.mod, and compiling srs.mod tells me the following:




col(Posted 2016) [#167]
The srs.win32 code has been removed in the latest commit.
It was only home to a single interface that Brucey has now put into the pub.win32 code - hence the duplicate error.

I can only think that the error comes from not being rebuilt properly. Perhaps you hit compile as opposed to rebuild modules?

If so then it might be necessary to go in and delete the .bmx folders inside each of the folders inside the srs.mod folder.
Also, as I say the srs.mod/win32.mod folder can safely be deleted if it's still there.


xlsior(Posted 2016) [#168]
It looks like it's still in the github repository -- just now I deleted the srs.mod folder again, and after cloning https://github.com/SRSSoftware/srs.mod.git it did download srs.mod/win32.mod among others.

I tried to delete the win32.mod folder manually, but still can't compile it afterwards:

[c:/code/BlitzmaxNG510/mod/srs.mod/directx11.mod/dxgi_ng.bmx;4;0]
Build Error: failed to compile (-1) c:/code/BlitzmaxNG510/mod/srs.mod/directx11.mod/dxgi_ng.bmx
c:\Code\BlitzMaxNG510\mod\srs.mod>Compile Error: Can't find interface for module 'srs.win32'
[c:/code/BlitzmaxNG510/mod/srs.mod/directx11.mod/.bmx/d3dcommon_ng.bmx.release.win32.x86.i;3;0]



col(Posted 2016) [#169]
uugghhh I can see what's going on here.
Try again...


xlsior(Posted 2016) [#170]
That did the trick, thanks!