I'm just getting started in DX12 after a bit of time in Vulkan, I am trying to update a part of a dynamically indexed buffer I'm using to hold mesh transforms.

I'm using the MSFT MiniEngine examples which include wrappers for upload buffers, and am not sure if I can use them to update an existing buffer, or if they're supposed to be the main resource used in place of the "GpuBuffer" in the same engine.

Any specific insight into the use of those classes would be really useful, but more generally, is it possible to update part of a buffer, or will I have to upload a copy of the whole thing?

Obviously a simple example would be brilliant if anyone has one..


Right so the answer is very easy it turns out: Using the MiniEngine examples, create a DynamicUploadBuffer, map it, copy the data to be transferred into it, then use WriteBuffer to update the portion of gpu buffer:

    float * buffer = (float*)m_TransformUploadBuffer.Map();
    memcpy(buffer, &trans_mat, 16 * sizeof(float));
    auto index = 1;
    ComputeContext& Ctx = ComputeContext::Begin(L"UploadTest");

    Ctx.WriteBuffer(m_TransformBuffer, index * sizeof(float) * 16, buffer, 16*sizeof(float));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.