How to transition resource state using barriers for subresources in DX12

Started by
0 comments, last by hbr3ehreg 9 months ago

Hello,

I'm trying to combine my vertex buffer and index buffer into one buffer, then copy it to the VRAM.

After that I want to use barriers to synchronize Resource States.

Something like this:

vertices = {.…}
Indices = {….}

Resource* meshBuffer;
Resource* uploadBuffer;

CreateCommitedResource(verticesSize + indicesSize, &meshBuffer);
CreateCommitedResource(verticesSize + indicesSize, &uploadBuffer);

// Can I update both vertices and indices all at once?
UpdateSubresource();

// Maybe I should use 2 transitions?
// One for RESOURCE_STATE_VERTEX
// The other for RESOURCE_STATE_INDEX
ResourceBarrier(Transition( RESOURCE_STATE_BEFORE, RESOURCE_STATE_AFTER ));
  • UpdateSubresources() has offset for intermediate buffer but not destination buffer, does that mean I have to put vertices and indices into one data structure first before I can updating resource?
  • What resource state is appropriate and how do I transition to it?
  • I would need a offset to keep track of my indices, do I need to worry about memory alignment (for Vertex maybe)?

Thanks for any responses.

Follow up the question:
I dig into this topic and it seems like one of the solution is using in placed resource.
Haven't tried this approach though.
Then another question pops out, why put vertices and indices into one buffer.
Streaming is one of the reasons, although streaming introduces fragmentation.
Another reason might has some thing to do with mem accessing pattern of the renderer?

This topic is closed to new replies.

Advertisement