• Advertisement
Sign in to follow this  

Data oriented design and rendering

This topic is 986 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to apply data oriented design to my engine's main systems, including the renderer. This is easily done for things like particle systems and agent simulation, but I'm having a hard time applying it to mesh rendering.

 

Before DOD, I had a "Mesh" class with its vertices, normals, texcoords, etc. My renderer also had arrays of vertex and index buffers. This was your typical "Array of Structures" pattern. 

 

Now, I'm trying to convert this to "Structure of Arrays" but I'm hitting a wall when it comes to sending mesh data to the shaders. My vertex shader uses a StructuredBuffer for all the vertices. Here's how it looks like:

struct Vertex
{
    float3 position;
    float3 normal;
    float2 texcoord;
};

StructuredBuffer<Vertex> vertexBuffer : register(t0);

This encourages the "AoS" pattern. Before issuing a draw call, it forces me to upload a buffer of "Vertex" on the CPU, which is the opposite of what I want. Would shader performance be the same if I split the buffer in the shader into 3 StructuredBuffers, one for each vertex attribute? Am I doing all this for nothing in the end?

Edited by jesta

Share this post


Link to post
Share on other sites
Advertisement
+1 to everything been said.
Meshes are dealt mostly by the GPU, not the CPU. The GPU often prefers data in AoS style, not SoA.

DOD isn't about blindly decomposing things to their basest elements, its about understanding what elements are used strictly (or almost-so) together.

Cheers to that!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement