Data oriented design and rendering

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

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 on other sites
+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!

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• Forum Statistics

• Total Topics
631785
• Total Posts
3002347
×