Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => Mandelbrot & Julia Set => Topic started by: keldor314 on June 26, 2008, 07:53:52 PM




Title: GPU FractalScreensaver
Post by: keldor314 on June 26, 2008, 07:53:52 PM
I thought you guys might want to know -

Due to popular request, I'm working on a backport of my screensaver to DirectX 9.  It should hopefully do almost as much as the DirectX 10 version.  At least, until (if) I add things like strange attractors and IFS functions to the mix (These would be pretty much impossible to implement without using the geometry shader, which is un-supported with DirectX 9).

At this point, I've broken up the code and isolated the sections that will have to be changed in order to run with DirectX 9, and have the DirectX 9 device up and displaying a blank screen.  Hopefully the port will be finished in a week or so.


Title: GPU FractalScreensaver
Post by: keldor314 on July 01, 2008, 06:19:42 AM
Well, the DirectX 9 version is up and running (at least on this computer...).  You can get it from the same place I linked in a previous post in this thread.


Title: GPU FractalScreensaver
Post by: cKleinhuis on July 01, 2008, 09:21:42 AM
hi there, just checked it out, it says dxgi.dll couldnt be found ... didnt examine further, will try out later
thx
 O0


Title: GPU FractalScreensaver
Post by: keldor314 on July 02, 2008, 07:54:51 AM
That's easy to fix.  You just need to grab the latest Directx distribution. ;)

http://www.microsoft.com/downloads/details.aspx?familyid=2da43d38-db71-4c1b-bc6a-9b6652cd92a3&displaylang=en (http://www.microsoft.com/downloads/details.aspx?familyid=2da43d38-db71-4c1b-bc6a-9b6652cd92a3&displaylang=en)

It's built on the June 2008 distribution, so no wonder you don't have it yet ;-)


Title: GPU FractalScreensaver
Post by: cKleinhuis on July 02, 2008, 10:55:42 AM
oh, i see, thank you then i will go and try it out tonight :D

 O0 O0 O0


Title: GPU FractalScreensaver
Post by: keldor314 on July 08, 2008, 07:08:25 PM
So....

Did you ever get it to work?


Title: GPU FractalScreensaver
Post by: cKleinhuis on July 08, 2008, 08:05:45 PM
ehrm, i somehow forgott it, but i go right now and give it another try  .... :police: :police: :police:


Title: GPU FractalScreensaver
Post by: cKleinhuis on July 08, 2008, 08:13:18 PM
hmm, i installed the dx9c version, but no dxgi.dll was with that, i have tried downloading a dxgi.dll somewhere, but this didnt work either ... :(
hmm, and then i tried another dxgi.dll, and i received another error message:

"Procedure Entry point for _except_handler4_common" not found in msvrt.dll"

have you ever tried it on a windows xp system ?!?!?
 O0 O0

what in special do you use of dx10 ? i think for pixel shader rendering of fractals, there is no geometry shader needed, just plain pixelshader 3.0 architecture would be fine to compile any HLSL language code .... O0 O0 O0


Title: GPU FractalScreensaver
Post by: keldor314 on July 13, 2008, 01:42:47 AM
Sorry it took so long for me to respond - my uncle just visited, so I've been otherwise distracted  ;)

Sounds like you downloaded the DirectX 10 version - You need to download Julia_1_22_DX9 instead of Julia_1_22_DX10 in order for it to run on XP.  It is down under Additional Files. http://sourceforge.net/project/platformdownload.php?group_id=225430&sel_platform=8276 (http://sourceforge.net/project/platformdownload.php?group_id=225430&sel_platform=8276)

Or directly download it from here - http://downloads.sourceforge.net/gpujuliascreens/Julia_1_22_DX9.zip?modtime=1215155000&big_mirror=0&filesize=47603 (http://downloads.sourceforge.net/gpujuliascreens/Julia_1_22_DX9.zip?modtime=1215155000&big_mirror=0&filesize=47603)

I haven't ever tried it on a XP system since I don't have any computer on hand with XP and a graphics card newer than SM 2.0.  I have ran the dependency viewer on it, though, and the dlls it links to appear fine (also, dxgi.dll is not linked from with the DX9 version, but is from the DX10 one, which also makes me think you grabbed the wrong version).




Title: GPU FractalScreensaver
Post by: cKleinhuis on July 13, 2008, 06:44:21 AM
hey, thank you for the update, this version starts and tries to initialise the display, but then it crashes, i hava a nvidia 7600 gpu ;) O0


Title: GPU FractalScreensaver
Post by: keldor314 on July 13, 2008, 10:22:05 AM
When you say it crashes, what exactly does it do?  Any error messages, or does it just silently quit?

If you're getting a 'display device has recovered from a serious error' type of message, then likely Windows is pulling the plug because the shader is taking too long to finish.

Try going into the screensaver settings (from explorer, first select  the file, then right click on it and  choose configure - if that doesn't come up, just run julia.scr straight from the command line.  Screensavers defaut to configuration mode if you don't pass any parameters.) and turn down the number of iterations.

Also, try 'installing' it from that context menu, and see if it runs in the little preview window.

Lastly, make sure your drivers are up to date.


Title: Re: GPU FractalScreensaver
Post by: cKleinhuis on July 13, 2008, 02:06:05 PM
hi there, ok
the config window show up, and i got no particula error just that the program crashed ... :(

after i start the program, the screen blacks out, and after a while of  nothing going on on the screen it crashes ... ;(

cheers
ck


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 13, 2008, 11:35:58 PM
Hrmm...  Try the 1.20 version - I added a couple things in the 1.22 that might be causing the problems.

http://downloads.sourceforge.net/gpujuliascreens/Julia_1_20_DX9.zip?use_mirror=osdn (http://downloads.sourceforge.net/gpujuliascreens/Julia_1_20_DX9.zip?use_mirror=osdn)


Also, when it crashes, does it just dump you to the desktop, or does it do a blue screen or something?  The more you can tell me, the better.

Finally, make sure your drivers are up to date.

In any case, if none of those work, I can try some other things to fix it, though that will have to wait a few days since my development computer is in the process of being upgraded at the moment.

[EDIT]  Actually, I think I know what the problem might be.  It'll have to wait until my development computer is back up and running for me to fix it, though.[/EDIT]


Title: Re: GPU FractalScreensaver
Post by: cKleinhuis on July 14, 2008, 04:25:44 PM
hello, sorry but i have to say the 1.20 version crashes likewise,
there is no special information,

1. run the program
2. both screens go to black
3. error message: Application Detected a severe error and has to quit. no more information sorry.
 O0 O0


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 15, 2008, 11:32:00 PM
Interesting...  it sounds like it's causing your driiver to crash...

I have a hunch about what might be causing it, involving unsupported texture caps, but again, we'll have to wait for my computer to be online again first. ;)


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 16, 2008, 02:43:48 AM
Well, I got my computer up and running again!  With a brand new geforce GTX 280!  Adaptive supersampling now maintains a smooth framerate even with some of the worst case formulas.
 O0

Anyway, I'll see about putting up a updated version which *hopefully* will work sometime later tonight.  Cross your fingers that my guess is on target concerning why it's not working on your computer. ;)


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 16, 2008, 04:09:08 AM
Version 1.23 is up!

http://downloads.sourceforge.net/gpujuliascreens/Julia_1_23_DX9.zip?use_mirror=voxel&filesize=47669 (http://downloads.sourceforge.net/gpujuliascreens/Julia_1_23_DX9.zip?use_mirror=voxel&filesize=47669)

Let me know if this solves the problems.

 :)


Title: Re: GPU FractalScreensaver
Post by: cKleinhuis on July 16, 2008, 09:42:29 AM
jipii, thank you, now it works nicely and runs smooth on my 1650x1024 display ...

thank you and great work !

is there an option for auto slide the fractal types ??!?!?

and, can you make me a file with an external compiled hlsl file ? so that i can show you the alternating method, you will be astonished !
 :evil1:

and it is right that the saver has to be exited with ESC ? ???

great coloring options :D


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 17, 2008, 03:32:30 AM
Alright!  I'm glad to hear that it finally works! :D

BTW, you don't have to hit ESC to exit the saver - any input other than just moving the mouse should do the trick.  The reason that I have it ignoring mouse movement is that switching screen modes (i.e. when the saver starts) sends spurious mouse movement messages, so the saver would instantly exit as soon as it started.  I suppose I could add a timer or something, but it annoys me when I'm watching the screensaver, and accidently bump the table...

What do you mean by an external compiled hlsl file?


Title: Re: GPU FractalScreensaver
Post by: cKleinhuis on July 17, 2008, 11:46:31 AM
hi, i thought the hlsl effect you execute, for rendering the fractal could be an external hlsl file, compiled at runtime, so that i could try some things out, to show you some things...


Title: Re: GPU FractalScreensaver
Post by: cKleinhuis on July 18, 2008, 03:49:48 PM
hi there, a few notes and wishes:

1. let the user choose a screen resolution, right now you take the current desktop resolution, i have a 1650x1028 pixels display, which slows down the calculation a lot
2. a timer for switching the current fractal

 O0 O0 O0


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 20, 2008, 11:57:52 AM
The HLSL file (actually, several files) is embedded into the executable as a resource.  I choose to do it this way because screensavers are traditionally installed into the Windows/system32 folder, and I thought people might object to a half dozen random files being scattered in there with the saver!  Besides, trying to access files (from a screensaver - I wouldn't be surprised if those implicitly had limited permissions) into there is just asking for problems with user account permissions, so self containment was certainly the way to go.

In any case, the HLSL is pretty heavily integrated with the native code, and won't even compile without the native side passing along the appropriate defines so it can resolve which functions to iterate.  You'll want to download the entire source if you want to fiddle with things, so that you can add your functions to the settings dropdown list, for one thing. ;)

http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/ (http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/)

For your compiler, I'd recommend that you grab Visual C++ Express.  It's easy to use, and is the same program that I've been using, so you'll be able to just open the project up and compile/run it, rather than dealing with makefiles or command line nonsense.  Also, and most importantly, it's free. O0

http://www.microsoft.com/express/download/#webInstall (http://www.microsoft.com/express/download/#webInstall)

Finally, you'll need the DirectX SDK.

http://www.microsoft.com/downloads/details.aspx?FamilyID=519aae99-b701-4ca1-8495-39ddde9d7030&DisplayLang=en (http://www.microsoft.com/downloads/details.aspx?FamilyID=519aae99-b701-4ca1-8495-39ddde9d7030&DisplayLang=en)

Those last two are rather large (VC++ is about 150MB, DX SDK is close to 500MB!), so we'll have to figure something out if you don't have a fast internet connection.

You probably should install VC++ before you install the SDK, since when you install the SDK, I believe that it will automatically add in the appropriate directories for VC++ to know where the directX include files and such are.  If it doesn't, tell me, and I'll help you get those set up.

A final note is that there's some sort of bizarre bug where VC++ won't exit when it has this particular project open (my other projects don't have this problem...).  You'll have to force quit the thing - so make sure you save first.  Actually, it'll ask you if you want to save when you try to quit (if you haven't saved your changes), and it'll save just fine.  It just won't quit.  The oddest thing is that this bug has persisted through two different versions of VC++, which includes the conversion to the newer project format.  In any case, you don't have to worry about this bug, since the data will remain just fine.  I'm just telling you about it so you don't freak out when it hangs on save and exit. ;D


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 24, 2008, 09:14:33 AM
In any case, after you've gotten the compiler set up, here are instructions for adding in a new iteration function.

First, we need to decide what function to add.  In this case, let's do a simple composite function, z -> (z*z+c)*(z*z+c)+d.  This is simple f(f(z)) where f(z)=z^2+c, only with the c parameter different each time.

Let's name the function.  We'll call it "(z^2+c)^2+d".

Next, we add that into the iterations listbox.  Open up "Config Dialogue.h" and click on the listbox under the Iteration Function heading in the form designer.  It should now be selected.  Click on the little arrow that just appeared on top of the listbox.  Select edit items.  This should bring up a window with a field full of functions.  Type in "(z^2+c)^2+d" (without quotes) on its own line and hit ok.

Now it will display our new function when we compile and run the settings for the screensaver, but we still have to link it together in the program so that it can translate the string from the listbox into a #define for the shader.

Next thing to do is open "ModeList.h".  This is the header where we define names and values for functions.  The format is like this:
#define <Function Handle Name> <Value>
where <Function Handle Name> is a valid variable name in C++ (i.e. no spaces or symbols) and <Value> is some integer that's unique to the given handle.

Since the name of the handle can't have symbols in it, we can't just use the same plaintext name we have in the listbox.  Instead, I've been using a sort of shorthand that uses only letters to "spell out" the function (The name can be whatever you want, though I recommend you use some sort of shorthand to help keep the names straight!).  In this case, I would pick the name "iterateLZpow2pCRpow2pD".  Let's break this down so you can see how I'm naming it.

iterate refers to the fact that we're defining an iteration function.  Next we have "L" which is a Left parenthesis '('.  Next is Z which stands for 'z'.  Then pow, which is short for Power, and represents the exponentiation operator '^'.  Then we have the number 2, which represents 2 (note that numeric charecters are valid INSIDE the name, but NOT BEGINNING the name, hence x2 is fine but 2x is not.).  Next we have 'p' which stands for Plus, or '+'.  Then C which is 'c'.  Then R for ')', pow for '^'. 2, and pD for '+d'.  Hopefully you get the general idea.  Anyway, the line we're going to add to the bottom of the file is:
Code:
#define iterateLZpow2pCRpow2pD 48
followed by a blank line since the compiler likes to complain if the last line of the file isn't a carriage return.  We choose the number 48 since the previous line had 47.

Now we have to link these together in the code proper.  Open "Config Dialogue.cpp"

Scroll down until you reach the System::String^ encodeFunctionIndex(int functionIndex) line.  Here is where we put the function for converting from handle to string name.  Add the 2 lines:
Code:
case iterateLZpow2pCRpow2pD:
    return ("(z^2+c)^2+d");
on a new line inserted right before the comment //coloration functions.  All the functions use the same function to convert their names, so I have them broken into sections by type.  Thus we have the //iteration functions block, the //coloration functions block and the //palette functions block.

Now, scroll down some more until you get to int decodeFunctionName(System::String^ str).  At the end of the //iteration functions block, just like before, add in the lines:
Code:
if (str == "(z^2+c)^2+d")
     return iterateLZpow2pCRpow2pD;
This converts the string into the handle.

Next, open up ModeSelecter.cpp.

You'll see it's broken up into sections just like the other functions were.  Add the lines:
Code:
else if (modeName == iterateLZpow2pCRpow2pD)
{
defineSlot[0].Name = "iterateLZpow2pCRpow2pD";
defineSlot[0].Definition = "";
viewCenterR = 0.0;
viewCenterI = 0.0;
viewRadius = 1.5;
}
at the end of the Iteration functions block.  This provides the string name for the HLSL define, as well as parameters for the window size and variable ranges to use.  Since we only entered parameters for the window and the function name, our c and d parameters will simply assume default ranges.

Now we finally get to the shader code itself.  Open Iterate.fx.

Scroll down to right before the first #ifdef bailout***** line.  The iteration code is broken into two sections - one section has the defines for the actual code for each iteration, and the second section has bailout functions.  Since our function has typical bailout behavior, we can just use bailoutDefault.  Thus let's add the skeleton for the function as follows:
Code:
#ifdef iterateLZpow2pCRpow2pD
#define bailoutDefault
#define ITERATE_FUNCTION\

#endif
Notice the backslash after ITERATE_FUNCTION.  This is how you tell the preprocesser that the define goes on to the next line.  Thus, we can write our iteration function over several lines instead of cramming it all into a single line.

The last thing to do is to add in the actual code.  Note:  The code must define the variables x, y, and r, where x is the real component of the next value of z, y is the imaginary, and r is the radius squared, or x*x+y*y.  The current values of parameters are stored in cr, ci, dr, di, ect. where cr is the real part of c, ci is the imaginary part, dr is the real part of d, and so forth.  Let's write the code now.
Code:
#ifdef iterateLZpow2pCRpow2pD
#define bailoutDefault
#define ITERATE_FUNCTION\
float2 z = float2(x,y);\
float2 c = float2(cr,ci);\
float2 d = float2(dr,di);\
z = cSqr(cSqr(z)+c)+d;\
x = z.x;\
y = z.y;\
r = x*x+y*y;
#endif
First, notice the float2.  float2 is one of the base types provided by HLSL.  It is basically a vector of two floats, where the operators +-*/ are defined component wise, that is, a*b = float2(a.x*b.x,a.y*b.y).  Hence, we can use + and - straight as is, since they work the same as complex numbers would, but for anything else, we have to write our own functions... or use the functions provided in library.fx!  The names of the functions in the library are things like cSin(z) or cTan(z) or cAcoth(z), where the c in the beginning designates the functions as working on complex numbers (and, more importantly, differentiates them from built in functions like Sin and Cos).  The most important ones are cMul(z1,z2) and cDiv(z1,z2) where cMul returns z1*z2, and cDiv returns z1/z2.  All functions in the library operate on inputs of type float2.  In our case, we're only using cSqr(z) which returns z*z.

Finally, rebuild the project, and your new function should be good to go!


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 24, 2008, 09:32:49 AM
(http://i4.photobucket.com/albums/y136/Keldor314/Julia2.jpg)

I was going to post some links to the SVN where it will show you changes, so you can see exactly what I added to add the new function, but the SVN seems to be having issues at the moment.


Title: Re: GPU FractalScreensaver
Post by: keldor314 on July 25, 2008, 10:42:53 PM
Here's links for viewing the relevant changes.  <3 SVN  O0

http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/ModeList.h?r1=25&r2=26 (http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/ModeList.h?r1=25&r2=26)
http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Config%20Dialogue.h?r1=25&r2=26 (http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Config%20Dialogue.h?r1=25&r2=26)
http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Config%20Dialogue.cpp?r1=24&r2=26 (http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Config%20Dialogue.cpp?r1=24&r2=26)
http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/ModeSelecter.cpp?r1=25&r2=26 (http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/ModeSelecter.cpp?r1=25&r2=26)
http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Iterate.fx?r1=25&r2=26 (http://gpujuliascreens.svn.sourceforge.net/viewvc/gpujuliascreens/Julia%20ScreenSaver/Iterate.fx?r1=25&r2=26)