New Release D3D9Client Development

So, since I can't really work on D3D9 anymore because of my new engineering school I'm attending, I spent some time thinking about my Lens Flare shader and the performance loss. There was something I knew all along but had forgotten to retrieve when I was making the shader.

Since I want it to be modular (as in, customizeable so that everybody can set its own to their liking), I did group code into functions that I thought would be simple enough to work with.
Now that I think of it, it's almost cringey; how would anyone that never touched shader code (or any code for that matter, since I'm setting a low knowledge level to try to include as much users as possible) modify the right part of the shader, without making mistakes, even if well documented? That seems a bit too much to ask.
So I had thought about a configuration file: that would bring the best of two worlds. But getting a configuration file to work, that the D3D9 Client would load and send arguments to the shader would be too complicated, and the amount of branching needed...

Wait.

That's what I knew all along but somehow forgot: GPUs are good at raw calculations, but very bad at branching. And my shader hit all the red zones with the modular setup. Any remotely confident shader code guy must be wanting to hit me in the head so bad right now. :hide:

So, here's what I'm thinking:
- Use a configuration file that will be read by an utility that will generate a flattened LensFlare.hlsl shader file based on that lens flare configuration. I'm even thinking of doing a GUI tool with a neat realtime preview, if possible.
- The flattened Lens Flare code should run wayyyy faster than the current one.

I'm writing a command line utility that should be run every time the config file is changed, and I am still thinking about the syntax of the config file itself. If I can find a HLSL flattener tool somewhere, I should be able to flatten the code and measure the speed improvement.

That is, if I find time for myself...
 
It was implemented a long ago and a quick test reveals that it still works:thumbup:

Ok, yes it works.... I had messed up the testing.... :facepalm:
Thanks! :hailprobe:

BTW: this feature should probably be added to the documentation.
 
That's what I knew all along but somehow forgot: GPUs are good at raw calculations, but very bad at branching. And my shader hit all the red zones with the modular setup. Any remotely confident shader code guy must be wanting to hit me in the head so bad right now. :hide:

I checked the shader code and didn't find any problematic branch conditions. Branch is o.k. if it's controlled by uniform Boolean. Extensive use of pow instructions is more likely a problem. It's the slowest instruction that exists.
 
But function calling means stack layer creation, branch creation, and all the other neat stuff that CPUs can afford to do, but not GPUs computing for millions of pixels every single frame. By flattening the shader I hope to delete as much function calls as possible and make it as linear as possible.

Use of pow is extensive, but that's like a butterfly wings flap next to a hurricane.
 
But function calling means stack layer creation, branch creation, and all the other neat stuff that CPUs can afford to do, but not GPUs computing for millions of pixels every single frame. By flattening the shader I hope to delete as much function calls as possible and make it as linear as possible.

There are no function calls nor stack in ShaderModel 3.0. All functions declared in HLSL are "inline" type.

Best ways to optimize the code is to:
1) Pre-compute all constant equations on CPU
2) Arithmetic optimizations like: pow(length(x), 2) = dot(x,x)
3) A use of parallelism by packing scalars into a vectors like: a/=x, b/=y, c/=z ---> (a,b,c)/(x,y,z) For functions those are executed for every component. Does not work with "pow".
4) Using a lookup table to replace a complex functions (if possible)
 
Last edited:
I noticed, that for some time I can't get proper reflections with d3d9 debugger, tried to change "refl" and other values, but to no avail...
I mean those metalic foil look (environment mapping etc.). It was working quite well (last time in April)...
 
Alt tab to desktop does not work with full screen mode,I keep getting a d3d9 client needs to quit error.

Which full screen mode are you using. It should work with board less window full screen.


*-------------------------

Also, is it possible to fix this color banding with some noise or something.

deRWgPe.png
 
is it possible to fix this color banding with some noise or something.

Most likely not. The banding comes from the texture compression and storage type. Dithering should be applied on the texture directly, or better, saved as another (better) DXT format.
 
HI JMW, what post has the "D3D9ClientBeta25.1-forBETA r64(r795)"? I have not been able to locate it in any search of this thread so far...(been using rev 61 D3D9 client with 2016 beta rev 61...working nicely, clicked update on svn and ran into trouble so i assume I need to update to this D3D9 rev :-) Thanks!
 
The SSU Crawler produces alot of these error messages in D3D9Client RC1 for Orbiter 2016 in addition to producing a CTD.

Code:
000000.020: D3D9: ERROR: Scene.cpp Line:871 Error:-2005530516 pDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER|D3DCLEAR_STENCIL, 0, 1.0f, 0L)
These only show up in the standard orbiter.log file and not in the D3D9Client log file even with the log level set to 4.
 
...These only show up in the standard orbiter.log file and not in the D3D9Client log file even with the log level set to 4.
Where should the D3D9client log file be created?
I can't find mine (both in 2010 and 2016 folders).
 
I am seeing a flickering black border on the horizon when orbiting mars, this doesn't happen when using the default orbiter 2016 client.
 
Where should the D3D9client log file be created?
I can't find mine (both in 2010 and 2016 folders).
Modules\D3D9Client\D3D9Clientlog.html.
 
Hello guys, which version of DX9 is the latest for Orbiter 2010? On codeplex I notice R15 but I also found a link to 15.1.
 
I have R15.1 running since ages, and it works great.
As far as I remember, the R15.1 has a workaround for the DGIV implemented:
-When in DGIV-cockit and releasing the air from the airlock, it would crash the graphics-client.
The reason is, that the DGIV, while right before airlock-vacuum, deletes a texture, which is still in use.
R15.1 has a catched this DGIV-bug and does not crash anymore.

Short story....R15.1 is a good choice..
 
Hi guys!

do you know why this is happening with d3d9?

D3D9:
clip_d3d9.jpg


INLINE:
clip_inline.jpg
 
Back
Top