VL - Custom Dynamic Buffer

textures coming up next…

1 Like

now with dynamic texture nodes, please test again with new alpha and this update:

download below

hey, thanks for these nodes. I tested it a bit with @sebl and it works fine!
But my use case is a bit more for custom dynamic buffer types.
I’m working on an update for SuperPhysical, where all logic is done in VL. I already created some custom data types for material and light setup, which works fine and allows for a very slim and patching friendly setup.
Now I would like to send the data from VL directly to the shader, thats what I need the custom dynamic buffers for.
Since I don’t wand to have dozens of connections and buffers, I’m bundeling them in custom structs.
Now if I want to use the current craftLie contribution, a custom struct has to be compiled, if I am not mistaken.
I’m not sure if this is a feasible workflow, since it adds complexity to the development process and depenencies to my contribution. Do you see a possibillity to create the struct dynamically ? I would need some kind of “dynamic buffer cons” to bundle different types, What are your thoughts on this?

gald you tested it already and it works so far. unfortunately this is currently the best way of dong it… VL cannot build native C# structs, but we can make a general byte buffer that only gets the size in bytes and uploads the data, similar to the dynamic texture nodes in VL. this would ‘only’ need a custom serializer for your VL data types that outputs your data as a byte array with correct order.

A byte buffer seems to be a good alternative. would be great, if it you could add it.

yes, this follows now the pattern of the dynamic texture, there is FromSpread, FromArray and FromIntPtr. all expect the data as bytes:

download below

not that you need Buffer to read from raw buffers instead of StructuredBuffer in the shader code.

also it is best for performance to have structs that have a data alignment of 32 byte (128-bit). if your struct does not fit exactly you can pad with unused data to fill up to the next 32 byte.

struct Foo
    float4 Position;
    float  Radius;
    float pad0;
    float pad1;
    float pad2;

Buffer <Foo> FooBuf;

from: https://developer.nvidia.com/content/understanding-structured-buffer-performance


i get an error when testing your latest version:
Could not load type 'VL.Core.TypeAttribute' from assembly 'VL.Core

is there a thing missing in latest alphas?i used b6a92831a2

1 Like

here is a rebuild against VL.Core.dll of latest alpha, hope that works:

download below

Now with UploadTexture for DX9 as well and all VL nodes have a “Set” pin:

download below

1 Like

this now has options to load pixel data from streams and from image data (jpg, png, dds, …) in memory or streams:

download below


do you have some help- or test-patches for the new nodes? didn’t get the new rawbuffer thing to work…

sure, i’ll upload one…

found some issues with the raw buffer, “Set” was not working (my bad) but in the shader you can only read 32-byte chunks, means a max of 4 floats. that’s not what you want probably.

so now i am thinking of adding a structured buffer description where you can set the “Stride Size” so you can input a bunch of floats or Vector4 but set the stride size of the struct you have in the shader. then you can read bigger chunks that are already typed to your custom struct. might even be faster…

1 Like

the structured buffers now also follow the same pattern. FromSpread/Array/IntPtr/Stream except that the array and spread nodes are generic, so you can input any struct. this makes it easier, you now only have to convert your custom types into a sequence of Vector4 for example. in the shader you can then make a StructuredBuffer and read the vectors back as your custom type. Please test with the attached CraftLie and test patch:

Dynamic Raw Buffer Test.zip (14.6 KB)

download below


was able to find a way to get rid of all the specialized UploadBuffer nodes in vvvv, there is now only one for structured buffers and one for raw buffers. quite nice solution now:

CraftLie.1.1.0.zip (2.7 MB)

i also moved this thread to ‘wip’. the system is so essential that it will move from CraftLie into a VL pack that we ship together with upcoming beta36.

1 Like

this new type of UploadBuffer seems great so far.
I tried to extend the custom vertex with a matrix that is split into vector4s.
I think it almost worked, but not quite. How would you approach this?

Dynamic Raw Buffer Test Matrix.zip (15.9 KB)

that is the only shortcoming of the new upload buffer node, you need to transpose the matrix yourself before you upload it… does this work?

EDIT: checking… seems to be another problem…

oh well, was more simple but not obvious. you only put 3 instances of the struct into the buffer from VL but the quad has 4 vertices. so when the SV_VertexID gives 3 you read only zeroes into the CustomVertex which gives the weird behavior.

but still the problem of transposing the matrix exists. I’ve now put it in the shader code, but you can also do that when serializing the struct in VL. this is up to you and depends on whether GPU or CPU has more resources to spare. or when you have the same matrix for all do it once before you put it into the struct in VL. in the case of this test patch once in vvvv.

Dynamic Raw Buffer Test Matrix.zip (15.4 KB)

1 Like

Yeah. there is something fishy…but maybe I didn’t convert the matrix correctly?

see post above.