VL - Custom Dynamic Buffer

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

2 Likes

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

Hi,
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.

works fine now, thanks.
as a side note I discovered, that one could use “row_major” https://msdn.microsoft.com/en-us/library/windows/desktop/bb509706(v=vs.85).aspx as a type modifier in the struct, which eliminates the need for transposing altogether. I still have to test, if this does anything to matrix math performance or has other issues, but could be a nice alternative.

ah nice, that goes into the docu post then. how does the syntax for the struct look then?

The example struct would look like this. So just put “row_major” in front of the relevant matrix.

struct CustomVertex
{
float3 Position;
float pad0;
float4 Color;
row_major float4x4 rot;
};

3 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.