Update a buffer.

Apr 17, 2012 at 6:33 PM

I have a constant buffer which I am trying to update with Updatesubresource. However, I have a ResourcePtr but I am not sure how to access the underlying ID3D11Buffer out of it. I couldn't find any function which can update a subresource. Can someone tell me how to do it ?

Apr 17, 2012 at 8:50 PM

I don't believe there is a method in the engine at the moment that uses update subresource.  However, in order to add one you could simply add a method to the pipeline manager class in much the same way as the map method does.  The only difference is that you would use the update subresource device context method.  The map method also shows how to access a resource when all you have is a resource pointer.

I will add a method to this effect in the next commit.

Apr 17, 2012 at 9:03 PM

Thanks so much Jason. I will try that out. I was just doing a round about way of doing it. Basically getting the integer resource id from the ResourcePtr and then use the GetConstantBufferByIndex on that. But a function would definitely be helpful.


Apr 26, 2012 at 7:13 PM

I added the UpdateSubResource method in the latest commit.  It is a fairly light wrapper around the actual API call, but it should be good enough for trying it out.  If you have a chance to get it working, please let me know!

The resource argument should be passed like this: ResourcePtr->m_iResource

If you have any questions, please feel free to post them here!!