Brainstorming: Noise optimization
#21
I have no idea how vector instructions work and how you want to use that language, can you provide a simple end-to-end example?
Reply
Thanks given by:
#22
So instead of something like:
Code:
for (int i = 0; i < ArrayCount; i++)
{
a_Array[i] *= Amplitude;
}
you would have:

Code:
@StartVectorCalc(ArrayCount,i,a_Array)
a_Array *= $Amplitude;
@EndVectorCalc

The actual calculation being done with c++ operators. Results var and iteration var may be unnecessary but width is essential. The $ in front of Amplitude indicates its a scalar to avoid needing to do to much c++ parsing.
Reply
Thanks given by:
#23
I'm still not too convinced about Lua parsing, it is a big chunk of work to make Lua parse something, it's much easier to let it generate something out of data it already has. Is there any way we could represent the vector code as a Lua table, for example, and let Lua generate the C++ code out of that into a "vec_doThisThat.inc" file, then in the hand-maintained cpp file we would use #include "vec_doThisThat.inc" in places where we wanted the actual code to be inserted.

So, to sum up:
vector_input.lua:
GenerateCode =
{
  vec_ThisThat =
  {
    -- Describe the calculation in a Lua table here
  },
  ...
}

cNoise.cpp:
void cCubicNoise::Generate1D(...)
{
  // Prepare the data
  #include "vec_ThisThat.h"
  // Do some post-processing
}

As for Lua under Windows, there's still the possibility to abuse tolua++ when generating the bindings to execute this additional script as well.
Reply
Thanks given by:
#24
Sort of a lisp-style language. Why not just use lisp syntax because a lisp parser is easy and lisp syntax is slightly easier to read then lua object syntax when it comes to code.
Reply
Thanks given by:
#25
Because we don't want to bring yet another dependency to the code? Is there even a decent lisp interpreter for windows?Tongue
Reply
Thanks given by:
#26
Not actually in lisp, just lisp syntax. I can code a lisp parser reasonably quickly and then a lisp-like DSL on top of that as quickly as I can on lua tables.
Reply
Thanks given by:
#27
I fail to see the point of making an extra parser when you can represent the data reasonably well directly.
Reply
Thanks given by: bearbin
#28
Just written one, probably full of bugs but should be easy to use. I'll push it to a branch if you want to see it. As for another reading the table syntax will be confusing:
Code:
VectorFunction = {
    "add" = {
         "multiply" = {
               Array,
               4
         },
         5
    }
}

For most people writing lisp is hard enough, writing lisp in a DDL is even harder.
Reply
Thanks given by:
#29
At the moment
Code:
a = b + c
is written as
Code:
(= a (+ b c))
Reply
Thanks given by:
#30
Why not just write the actual code, in C++, and use #if/#else for other platform specific code. Seems much easier to me.
Reply
Thanks given by:




Users browsing this thread: 3 Guest(s)