Hello.
I would like to use a Buffer for delivering an array of floats from cpu into a shader.
I have no idea how to initialize it with the cpu data array.
Here is the code I did up to now:
shader side:
Buffer<float> myArray;
cpp side:
BEGIN_SHADER_PARAMETER_STRUCT(MyParamateres, )
:
SHADER_PARAMETER_RDG_BUFFER_SRV(Buffer<float>, myArray)
:
END_SHADER_PARAMETER_STRUCT()
static void prepare_data_for_rendering(TArray<float>& data)
{
// create GPU buffer
FRDGBufferDesc TestBufferDesc = FRDGBufferDesc::CreateBufferDesc(sizeof(float), data.Num());
FRDGBuffer* pBuffer = GraphBuilder.CreateBuffer(TestBufferDesc, TEXT("MyParamateres.myArray"));
// create Shader Resource View (read) for the buffer for reading it within the shader stage
MyParamateres.myArray= GraphBuilder.CreateSRV(pBuffer , PF_R32_FLOAT);
// ??? how to initialize pBuffer with data ???
}