Title: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on October 26, 2015, 01:17:01 AM Hi,
this is not for users yet, but for people who enjoy exploring new formulas and want to play with them quickly (without the need to code them in ASM). Please do not spread the link, especially not on dA or Facebook, as it is only a proof of concept. The link below provides the new *.exe and an example-formula In Formulas there is now a new section "[SOURCE]" where you can put your formula as Delphi-code. Each formula should have the signature Code: procedure MyFormula(var x, y, z, w: Double; PIteration3D: TPIteration3D); Any other structures like TPIteration3DExt are not defined yet (each you want to access must be defined for the JIT-compiler, because the compiler can not use the internal structures. ). http://www.andreas-maschke.de/java/tmp/MB3D_JIT.zip (http://www.andreas-maschke.de/java/tmp/MB3D_JIT.zip) About performance: it is known that the JIT-version of a formula is slower than a native or ASM variant. But this one is for exploring and inventing new stuff with ease giving a nice overall performance. Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: Snicker02 on October 26, 2015, 02:21:18 AM I am not finding Source under formulas
(http://orig14.deviantart.net/c37f/f/2015/298/2/b/untitled_by_snicker02-d9eea02.png) Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on October 26, 2015, 02:40:04 AM I am not finding Source under formulas Currently, you must edit them outside of MB3D with a text-editor, e.g. Notepad++Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: DarkBeam on October 26, 2015, 07:56:00 AM :wow: :cantor_dance: great... now we don't need Fragmentarium or stuff like that! Powerrrrr :D
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: m2001 on October 26, 2015, 08:54:45 AM thx! ;D
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: DarkBeam on October 26, 2015, 11:12:07 AM Hum, some questions now:
If I add an user variable to a custom formula how do I access it? Like [OPTIONS] .Version = 2 .DEscale = 1 .SIpower = 2 .Double Scale = 2.0 And difs/3DA/4D/4DA are still unsupported? Thanks infinitely :beer: Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: KRAFTWERK on October 26, 2015, 11:17:39 AM Cool! Great work Thargor! :beer:
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on October 26, 2015, 11:34:26 AM If I add an user variable to a custom formula how do I access it? Not supported yet (but on the TODO-list), you must hardcode all params for nowAnd difs/3DA/4D/4DA are still unsupported? Thanks infinitely :beer: You specify this by setting the .DEoption parameterTitle: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: DarkBeam on October 26, 2015, 11:57:24 AM OK!!! In that mode you need to manually scale the DE, that is found in "w" variable (like in other formulas!!!) :beer: It perfectly works Andreas you are genius!
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: mclarekin on October 26, 2015, 12:41:49 PM @ Thargor
O0 O0 O0 Much greater access to infinity is sooooo cool. This is what explorers want. :) :) :) Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: cKleinhuis on October 26, 2015, 09:10:34 PM @andreas do you plan to include used formulas in the save file? that can get really messy :D
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on October 26, 2015, 10:18:53 PM Thank you all!
@Christian Do not know yet if I want to include the formulas in the file, the format is rather tricky, not sure yet if that is really desired. Any comments? :-) Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: Snicker02 on October 26, 2015, 11:14:00 PM I tried opening it up in Notepad++ and did a search for source.... but not sure which one
(http://orig04.deviantart.net/ddc2/f/2015/299/2/0/1510261811_by_snicker02-d9ehibj.png) Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: cKleinhuis on October 26, 2015, 11:19:07 PM I tried opening it up in Notepad++ and did a search for source.... but not sure which one ??????????????? what did you want to achieve by that? @andreas i think it is just fine to NOT include it, but keeping a record of the exact version of a formula might be needed, since now the available formulas will get spread to infinity, regarding dynamic formula writing i believe an online archive of available formulas is the way to go, similar to what ultrafractal does with automatic downloading and such ;) Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: cKleinhuis on October 26, 2015, 11:20:58 PM what i find a bit tricky is that 2 mandelbulb renderers have completely different formula definition syntax (delphi/glsl) some sort of meta language to be transformed into both output formats would be worth a thought ... just sayin'
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: Snicker02 on October 26, 2015, 11:33:09 PM ??????????????? what did you want to achieve by that? That is what I was told to do@andreas i think it is just fine to NOT include it, but keeping a record of the exact version of a formula might be needed, since now the available formulas will get spread to infinity, regarding dynamic formula writing i believe an online archive of available formulas is the way to go, similar to what ultrafractal does with automatic downloading and such ;) Currently, you must edit them outside of MB3D with a text-editor, e.g. Notepad++ Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on October 27, 2015, 12:25:18 AM That is what I was told to do You can not find them, you must/can create them. This is why I said it is not for users (who just want use a ready software), it is for developers to extend the software, so please ignore it unless you know what to do :DCheers! Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on October 27, 2015, 12:31:01 AM what i find a bit tricky is that 2 mandelbulb renderers have completely different formula definition syntax (delphi/glsl) some sort of meta language to be transformed into both output formats would be worth a thought ... just sayin' Agree, I also had a discussion with Lyc about that. My idea is to have two layers, the lowlevel-layer, which allows anything, even modification of internal state as it is needed/wanted by some formula, and some highlevel layer where you just define a formula in a more abstract way. The current implementation is the lowlevel layer in the hope to simplify the creation of formulas by "wizards". The higher layer is for users (and should not expose MB3D-interna), we spoke about Lua, but it was just an idea.Cheers! Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: DarkBeam on October 27, 2015, 04:30:13 AM Little lazy question. Is there a way to display the compiled assembly to get a m3f without a sweat drop? :D No eh... ;)
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: M Benesi on October 27, 2015, 05:49:34 AM What Luca said! :D Quick compiled assembly... wow.. The last formula I wrote would be the last I had to do lots of hard work on!
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: DarkBeam on November 05, 2015, 06:22:17 PM Would be a too big luxury for us :) :dink:
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: teeanDy on November 30, 2015, 04:27:57 PM Thanks a lot for this version. O0 Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on December 14, 2015, 03:12:28 AM If I add an user variable to a custom formula how do I access it? Like Support for accessing variables and constants is added now, as well as an integrated editor:(http://www.andreas-maschke.de/java/tmp/MB3D_JIT.jpg) Because of performance-reasons you must access the variables/constants the same way as MB3D-code does. The first constant is located at Base+0, the second at Base + <size>, e.g. Base + 8 (see the screenshot for example, Base is called PVar). The variables start Base-16, and increase in the inverse direction, i. e. second variable is at Base-16-<size>, e.g. Base - 24 Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: cKleinhuis on December 14, 2015, 10:36:57 AM +1 for style and functionality
are the constants program globals or code locals? hehe why not call this field "magic constants" :tease: :) Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on December 14, 2015, 11:40:35 AM are the constants program globals or code locals? hehe why not call this field "magic constants" :tease: :) Those constants are maintained on a per-formula-basis. Not all values must be classic "magic constants", you may provide any pre-calculated value in order to speedup the formula-calculation.Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: cKleinhuis on December 14, 2015, 11:59:57 AM Those constants are maintained on a per-formula-basis. Not all values must be classic "magic constants", you may provide any pre-calculated value in order to speedup the formula-calculation. isnt this was magic constanst are? ;) i meant the lack of a name for these constants Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on December 14, 2015, 01:30:53 PM i meant the lack of a name for these constants Unfortunatly, there is no room for a name of constants in the *.m3f-file, so the names could not be saved (unless we would further extend the format, but I do not want to do this in this case)Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: cKleinhuis on December 14, 2015, 01:33:27 PM that is understandable, i wonder how they are referenced then in the program by index? const[1..n] ?
Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on December 14, 2015, 01:48:17 PM i wonder how they are referenced then in the program by index? const[1..n] ? By just navigating from the base pointer (not all must have the same size, so its not even an array). You can see this in the screenshot, where sqrt_1_2, sqrt_1_3 and sqrt_2_3 are populated using the provided 3 constant-valuesTitle: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: cyseal on December 15, 2015, 12:52:46 PM Support for accessing variables and constants is added now, as well as an integrated editor: (http://www.andreas-maschke.de/java/tmp/MB3D_JIT.jpg) Because of performance-reasons you must access the variables/constants the same way as MB3D-code does. The first constant is located at Base+0, the second at Base + <size>, e.g. Base + 8 (see the screenshot for example, Base is called PVar). The variables start Base-16, and increase in the inverse direction, i. e. second variable is at Base-16-<size>, e.g. Base - 24 How to get this editor running ? I can't find it. Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on December 15, 2015, 01:13:16 PM How to get this editor running ? I can't find it. Is not released as binary yet, currently working on improving the performance before releasing itTitle: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: knighty on December 15, 2015, 01:38:20 PM Maybe it's possible to hide parameters and constants access inside the body of the formula and avoid the user to make mistakes:
the user could define the parametrs and constants before the procedure: Parameter double scale = 2; Parameter double offset = 2; Constant double sqrt_2 = 1.41....; ... etc. then the procedure is modified to add access to those paremeters and constants before it is sent to the JIT compiler. Just my 2cts. Great job thargor6! :thumbsup1: Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on December 15, 2015, 03:09:19 PM Maybe it's possible to hide parameters and constants access inside the body of the formula and avoid the user to make mistakes: Hi, thanks for your ideas! I was also thinking about a way to simplify this, but it is not easy whithout actually putting some "magic" into the code (which I dislike). The problem is, that the actual parameters at runtime are "fed" by MB3D's interface. So, the values of 2.0 for scale and offset in this example are only the initial values, but can be changed by the user. Best regards, Andreas Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: knighty on December 15, 2015, 04:08:56 PM Well... this is not exactly what I was suggesting.
Taking for example the BenesiPineTree formula. The user could write: Code: Parameter double scale=2; { the =2 is just to say it's the default value}A preprocessor could detect the code preceding the procedure and parse it. Then transform the user code to something like: Code: procedure BenesiPineTree(var x,y,z,w :double; PIteration3D : TPIteration3D); That is after computing the constants, computing the offsets wrt PIteration3D^.PVar and updating other sections of the formula accordingly. Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on December 15, 2015, 05:05:24 PM Well... this is not exactly what I was suggesting. Thanks again, but what I meant was that this is somewhat "magic" (=not good code), because you had to violate the DRY-principle. In order to have the params to appear in the UI, you have to put them also in the parameter section of the file (together with the default value). Which would be no problem here, but in the constants-section you can't have names. So we would have to mix it (i. e., your suggestion, but only for constants). To be clean, we had to change the file format, which is probably a good option. I.E.: - Programmatically put also named constants in the file - Preprocess the named constants and the named parameters in the way suggested. i. e. generate the code-fragment to define and initialize them What do you think? Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: knighty on December 16, 2015, 11:47:40 AM IIUC, yes.
But wait!... the JIT can handle constants, right? in this case there is no need to manage them at all. :) IMHO, ".Version" could be used to prevent the use of the formula in older versions of MB3D. A clause like ".JIT PaxCompiler" or ".Language ObjectPascal" could also be added to the file format... maybe in the future MB3D could support other JIT compilers... Why not. In order to be "clean" the parameters could still be defined in the [OPTIONS] sections while adding the in-procedure name (and other stuff): Code: .Double Offset 1 = 0 {InProcName = Offset_1} {Comment = Use it to change the shape! is it clear?}There is another opportunity: Hidden parameters that are initialized using the visible ones. For example: getting a rotation matrix from euler angles... Another one: The possiblity to modify some parameters values. For example: barycentric coodinates that should sum to 1... These could be handled by another procedure in another section [INIT]. These are not feature request, only suggestions. There is a long and hard way between the idea and it's implementation. So R.E.S.P.E.C.T. Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on December 17, 2015, 12:29:22 AM In order to be "clean" the parameters could still be defined in the [OPTIONS] sections while adding the in-procedure name (and other stuff): Hi again, I think I have found a very good compromise of all the options discussed, you are most welcome to have an early look at the binary (I will send you a link).I have extended the file-format to support also named constants. One may use named constants in ASM-formulas as well, even when those names will never be refered from code later. Those named constants are supported by the JIT-editor, and now, there is a preprocessor which fills in the the nasty code to read those values. What makes this solution sexy is, that there was nearly no change necessary to the MB3D-core. Example of the final (preprocessed) code (again, the Benesi-tree :D): Code: procedure BenesiPineTree(var x, y, z, w: Double; PIteration3D: TPIteration3D); The *.m3f-file also looks sexy, there are no redundancies in code/definitions: Code: [OPTIONS] Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: knighty on December 17, 2015, 01:50:24 PM :worm:
That's perfect! Does Pax compiler support inline assembler? it seem that the answer is no. Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: chunkygravy on December 17, 2015, 05:03:43 PM excellent work. i can mostly understand this, much better than the hard coded se.
i would love to see this develop into something similar to fractint which allowed you to write your own formulas in a simple text file that required no compiling or spooky code. Mandelbrot(XAXIS) {; Mark Peterson ; Classical fractal showing LastSqr speedup z = Pixel, z = Sqr(z): ; Start with z**2 to initialize LastSqr z = z + Pixel z = Sqr(z) LastSqr <= 4 ; Use LastSqr instead of recalculating } Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: chunkygravy on January 22, 2016, 05:46:06 AM ok so i expanded the trig example that came with the update.
I have 32 functions implimentable on X, Y, and Z. Each axis can have a different function. Must be used as a pretransform. (repeat from here after this formula) I also want to make it where you can turn off the functions and have it not affect the render. I set abc to 0 but it still affects the render. how do i make a pass through like x:=x ? Code: procedure BenesiPineTree(var x, y, z, w: Double; PIteration3D: TPIteration3D); Title: Re: Experimental MB3D-version with integrated formula-compiler (JIT) Post by: thargor6 on January 22, 2016, 12:18:40 PM If you do not actually change x (either by not writing it at all or using x := x), it should not affect the render. If it does, it may be a bug, but sounds strange. |