Example #1
0
 internal static void ResizeAndUpdateStaticStructuredBuffer(ref StructuredBufferId id, int capacity, int stride, IntPtr data, string debugName, MyRenderContext rc = null)
 {
     if (id == StructuredBufferId.NULL)
     {
         id = CreateStructuredBuffer(capacity, stride, false, data, debugName);
     }
     else
     {
         Debug.Assert(stride == id.Stride);
         Debug.Assert(false == id.Dynamic);
         if (id.Capacity < capacity)
         {
             SBuffersData[id.Index].Buffer.Dispose();
             SBuffers.Data[id.Index].Description.SizeInBytes = stride * capacity;
             InitStructuredBuffer(id, data);
         }
         else
         {
             if (rc == null)
                 rc = MyRender11.RC;
             rc.UpdateSubresource(new DataBox(data, stride * capacity, 0), id.Buffer);
         }
     }
 }