How do you send StructuredBuffers (or array of structs) to shaders in UE4 C++?

StructuredBuffers are DX11 buffers of custom structs that can be sent to a vertex/fragment shader as well as a compute shader.

I’m looking through the UE4 source code, searching for “StructuredBuffer” and the only place I see it used is an example where they send it to a Compute Shader by using this line:



//VplListEntry is the struct for the Structured Buffer in the usf compute shader
mVplListBuffer->Initialize( sizeof( VplListEntry ), VplListBufferSize, 0, true, false );
RHICmdList.SetUAVParameter( FComputeShaderRHIRef(), 7, mVplListBuffer->UAV, 0 );// this parameter FComputeShaderRHIRef -- only for compute shaders?


Does the FComputeShaderRHIParamRef parameter imply this only sends structured buffers to compute shaders?

Alternatively, how else do you send arrays of structs to HLSL shaders in UE4? How is UE4 even sending for ex an array of lights to HLSL? (didn’t find that yet in the source)

I see you can use DECLARE_UNIFORM_BUFFER_STRUCT_MEMBER_ARRAY(FVector, varName, [10]) for the built-in UE4 structs. But I don’t know what makes them eligible and my custom structs not eligible. Or if I’m allowed to have nested structs.


To clarify, there’s two things:

  • sending a buffer to a shader such that the vertex and geometry shaders run on that buffer instead of a classic mesh vertex buffer.
  • sending a general short array to the shader as a shader parameter (and not feed it into the vertex input)

I require both but I want to know about at least the second option