Software Render Anyone?
BlitzMax Forums/BlitzMax Programming/Software Render Anyone?
| ||
Yeah I've been at it again, this time I've really gone and done it! So you want to set you DX Render Mode? BMAX defaults to IID_IDirect3DHalDevice which means : Enables the Hardware (3D Card) Acceleration. Now you can have :- IID_IDirect3DRGBDevice : Uses CPU Emulation in RGB Mode (More Slow than HAL). IID_IDirect3DMMXDevice : Uses CPU Emulation and Enables MMX Alpha Blending Acceleration (From Intel) IID_IDirect3DHALDevice : Enables the Hardware (3D Card) Acceleration. IID_IDirect3DTnLHalDevice : Uses the Hardware Acceleration (3D Card) and Enables Hardware Transformations And Lightings. Heres how :- Locate the d3d7.bmx file in the Mods folders, add the following lines at the bottom of the code. Global IID_IDirect3DRGBDevice[]=[$A4665C60,$11CF2673,$AA001AA3,$5633B900] Global IID_IDirect3DMMXDevice[]=[$881949a1,$11d0d6f3,$A000AB89,$294105C9] Global IID_IDirect3DTnLHalDevice[]=[$f5049e78,$11d24861,$A00007a4,$a82906c9] Locate the d3d7graphics.bmx file in the Mods folders and add these lines at the top of the code (after Strict):- Global DXRenderType:Byte Const RGB = 1 Const MMX = 2 Const TnL = 3 Now locate the Reset() Method in the same file and replace the line : res=d3d.CreateDevice(IID_IDirect3DHALDevice,primarysurface,Varptr device) with : Select DXRenderType Case RGB res=d3d.CreateDevice(IID_IDirect3DRGBDevice,primarysurface,Varptr device) Case MMX res=d3d.CreateDevice(IID_IDirect3DMMXDevice,primarysurface,Varptr device) Case TnL res=d3d.CreateDevice(IID_IDirect3DTnLHalDevice,primarysurface,Varptr device) Default res=d3d.CreateDevice(IID_IDirect3DHALDevice,primarysurface,Varptr device) End Select To change the rendermode put the following line of code BEFORE the Graphics statement. DXRenderType = MMX ' **OR WHATEVER MODE YOU WANT** Do a bmk makemods and have fun. The software emulation is very slow, if you want to go software then I would suggest not using the Cls command and implementing something like "Dirty Rects" to handle the screen clears and re-draws. |
| ||
I just did some tests and setting the DXRenderType to TnL gave me a 28% speed increase over the default render mode. |
| ||
OR you might want BMAX to fallback to whatever the hardware supports, replace the Select......End Select Code with :-If Not d3d.CreateDevice(IID_IDirect3DTnLHalDevice,primarysurface,Varptr device) If Not d3d.CreateDevice(IID_IDirect3DHALDevice,primarysurface,Varptr device) If Not d3d.CreateDevice(IID_IDirect3DMMXDevice,primarysurface,Varptr device) If Not d3d.CreateDevice(IID_IDirect3DRGBDevice,primarysurface,Varptr device) Assert Not res,"CreateDevice Failed result="+res+", Do you really have a grahpics card?" EndIf EndIf EndIf EndIf And Rem out this line :- Assert Not res,"CreateDevice Failed result="+res |
| ||
Great stuff! Hardware T & L - I can't keep up with your speed improvements. I haven't had time to test your single surface type (within a real program) so I'll have to take your word for the speed increase results. But why isn't Mark doing this sort of thing? |
| ||
No comment about what BRL are doing. My Findings so Far using "untweaked" command set based on 10,000 images rendered over 100 frames. SOLIDBLEND and no Rotations : 28% Faster with T&L ALPHABLEND and no Rotations : 34% Faster with T&L SOLIDBLEND with Rotations : 28% Faster with T&L ALPHABLEND with Rotations : 30% Faster with T&L ***IMPORTANT POINT - ALPHABLEND with T&L is 10% faster than SOLIDBLEND with T&L in all tests!!!!! |
| ||
Another top tweak from Tim. Thanks AGAIN. |
| ||
Thanks people, if you use this with my Single Surface stuff then your going to see some massive savings in render time. |
| ||
I would like you to post your single surface stuff in module tweaks. I think it stands a good chance of being included if you go about it the right way. |
| ||
Hi Rob, you might be right. |
| ||
Looks good! I'm not on a PC here but good work. |
| ||
Wow! Went from 1,900 to over 2,400 FPS in TnL mode. Thanks again for your great work IndiePath. If only BRL would optimize 2D before moving on to other things... |
| ||
The software rendering mode in DX is a joke and only for driver testing. It's sloooooo...oow. I think it should be safe to turn on TnL in DX standard for BMax, as pretty much every card supports it :) |
| ||
If only BRL would optimize 2D before moving on to other things... Exactly! Good work Indiepath! btw Sorry to be a pain but how do you make mods exacly? I had a few goes when BlitzMax first came out with no success - but then not many people knew what they were doing then anyway. My build/re-build all modules options are greyed out in the program menu in the editor which seems strange. |
| ||
My build/re-build all modules options are greyed out in the program menu in the editor which seems strange. Same for me. It didn't used to be like that until an update or two ago. Thankfully the Alt + D shortcut still builds them. |
| ||
Assuming you have GCC installed and the environment variables set, you should also be able to do it from the command prompt from the blitzmax\bin folder with : bmk makemods You can also specify the modfolder and modname ( eg: bmk makemods brl.d3d7max2d ) if you only want to do one mod, but since this tweak requires updating two mods, it's probably quicker to do em all. |
| ||
Hopefully this will be added to the official mods as well... Great stuff. |
| ||
Thanks - rebuilt the mods now. LOL - but what a disappointment! No change in FPS whatsoever - 470 FPS before 470 FPS after (TnL). No improvement on the laptop either. Any idea why? |
| ||
I too dont see any speed increase with using TnL. I'm using a gForceTi4200/128. |
| ||
Bmax is still doing all the transformations in software. I'm in the process of trying to get Vertex Buffers working, if I do then I'll stand a good chance of getting hardware transformations working also. |
| ||
TnL won't change the framerate where your performance is capped by fill rate and program execution. However, people with slow cpus - think Pentium 2-3, but with a TnL card, will see huge leaps in performance where fill rate isn't a problem. For example certain laptops or older pcs - they have ancient radeons and mx cards and perhaps even some intel chipsets... which support TnL. Big speed boost for the lower end pcs. |
| ||
I would like to implement this, but I don't seem to have this file: d3d7graphics.bmx And I can't find any mention of it in the Mod threads. Can anyone help? |
| ||
^ On my system, d3d7graphics.bmx is in the BlitzMax\mod\brl.mod\dxgraphics.mod folder. I believe that it was introduced with BlitzMax 1.10, so if it's not there on your system, you might try reinstalling the 1.10 update and doing a syncmods. |
| ||
Thank you Wendel, I've never done a synchmods before, that's likely it. Now the problem is that my forum username and password aren't working. I enter "drew" and my forum password in the synchmods window, right? |
| ||
Yes, your forum password, but you use your member account name, not your nickname. So that would be andrew. |
| ||
Well I've tried drew and andrew in combination with this forum password and passwords for other things. I tried each with variations in caps/non caps. Still no luck. Is there a place where I can go that will show me what the name and password are? They obviously aren't what I thought they were. There has to be a better way to do this. This is silly. [edit] is the Proxy server box important? |
| ||
I just tried it now and everything worked as usual. I entered my user name and my forum password, and I left proxy blank. After allowing it to go through my firewall, I got the expected "everything is already up to date" message. Is there a place where I can go that will show me what the name and password are? Yes. On this website, if you click the "Account" tab at the top, then "Edit Profile," you'll be able to see your Name, Nick name, and Username. It's that Username that syncmods is asking for. You can also change your password below that (or make sure that it's what you think it is by entering that). |
| ||
Ahh! Wonderful! Thank you, thank you. So it turns out my account with Blitz uses three names. That third one was hiding. What relief! [edit] Woah, After installing the new Modules, my game speed has been reduced by about 800 fps. What's that about? |
| ||
You're welcome; I'm glad that it worked. Yes, the hidden one is your "true name" <g>. Since you didn't have d3d7graphics.bmx before, it sounds like you were using 1.09. 1.10 changed the default to DirectX from OpenGL, so it might be that you were getting better framerates with it. To change back to OpenGL, you'd put "SetGraphicsDriver GLMax2DDriver()" before your Graphics command. |
| ||
Ah Wendell you are amazing, my friend! I'd be lost without your help. Framerates are back up to a healthy 1540 avg. So, does this mean DirectX is that much slower than OpenGl? That's insane. Or does Indiepath's fix negate this and bring Dx up to OpenGl's speed? |
| ||
I haven't really messed with Indiepath's stuff here, but it looks like it might speed DX up. However, drivers have major effects on framerate, too, so a lot could depend on your video card, what drivers it's using, and what their speed-vs-quality settings are. At least with SetGraphicsDriver you can offer the user/player a choice of DX or OpenGL if one works better than the other on his system. And with Indiepath's additions, it looks like you can offer DX render mode choices, too. |
| ||
And with Indiepath's additions, it looks like you can offer DX render mode choices, too. Use the fallback code I posted further up the thread, it will try to create a device with TnL, the HAL and then Software. |
| ||
So, does this mean DirectX is that much slower than OpenGl? That's insane. Or does Indiepath's fix negate this and bring Dx up to OpenGl's speed? That does sound like DX is slower than GL on your computer, yes... But for many people it will be the other way around. I do hope that Indiepath's Software rendering options also become a part of the official modules though, more available choices may make a game playable when before it may not have been on some systems. |
| ||
Well I don't know what could be wrong with my DX, it's version 9.0c. Maybe my 6800 GT simply prefers openGl? Does that make any sense? In the meantime, it doesn't seem to make sense to apply Indiepath's fix if my openGl is so bloody fantastic. Curses, I was hoping for a speed boost. |
| ||
I think nVidia cards will always perform at least slightly better on OpenGL... I know that's been my experience. ATI's OGL support was worthless until Doom3 was released and apparently their latest drivers are an improvement again... so maybe things are on a turn around on that front. Anyways, this is the golden reason to always provide people with their choice of OpenGL or DX, I mean... it's not like -we- have any extra coding to do because of it... |
| ||
Bump. Interesting as I ran a Blitzmax exe recently on a pc with no hardware acceleration and I want to do a clean exit. Also couple of other questions: Is hw TnL now enabled by default in the max2D driver? just curious what has changed since five months ago. |
| ||
hmm, I want to be able to cleanly exit with an error if the user has no 3D hardware too... |
| ||
Toby: ATI had an other, far more important reason for decent OpenGL drivers: Apple :-) Earlier it was NV doing the graphic card job, but recently, they were kicked out quite a bit on the mainstream systems. And IntelMacs even do only use ATI (beside Intel GMA 950 which is a nice, shader 3 chip as well. More powerfull than a GF6200 which would have drained more power) OEJ: Yes HWTnL is the first thing the driver tries and after that it has 2 fallback steps till it totally fails. |
| ||
Well I tried it on a non accelerated machine today and it didn't fail, it just froze there. It was Max Gui with a canvas. |
| ||
I think they implemented by Fallback code but left out the software render stuff. You could modify the modules and stick it back in. At least you'd be able to detect the mode and do a clean exit. |
| ||
One Eyed Jack: Did you find out how to cleanly exit if the PC isn't suitable yet? |
| ||
Just try the graphics command. The DX fallback will throw an error if it fails. |
| ||
it doesn't dreamora. not on pcs with no 3d card / correct drivers. grey: too busy with son at the moment to code :/ |
| ||
no worries, just wondered if anyone had cracked this yet. I'm going to test it bombing out on a crap office PC now, but with some new code. |