示例#1
0
 internal static void Destroy(ref StructuredBufferId id)
 {
     if (id != StructuredBufferId.NULL)
     {
         Destroy(id); id = StructuredBufferId.NULL;
     }
 }
示例#2
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);
         }
     }
 }
示例#3
0
        internal static StructuredBufferId CreateStructuredBuffer(BufferDescription description, IntPtr?data, string debugName)
        {
            var id = new StructuredBufferId {
                Index = SBuffers.Allocate()
            };

            MyArrayHelpers.Reserve(ref SBuffersData, id.Index + 1);
            SBuffers.Data[id.Index] = new MyHwBufferDesc {
                Description = description, DebugName = debugName
            };
            SBuffersData[id.Index] = new MyStructuredBufferData {
            };

            SbIndices.Add(id);

            if (!data.HasValue)
            {
                InitStructuredBuffer(id);
            }
            else
            {
                InitStructuredBuffer(id, data.Value);
            }

            return(id);
        }
示例#4
0
 internal static void InitStructuredBuffer(StructuredBufferId id, IntPtr data)
 {
     SBuffersData[id.Index].Buffer = new Buffer(MyRender11.Device, data, SBuffers.Data[id.Index].Description);
     SBuffersData[id.Index].Srv    = new ShaderResourceView(MyRender11.Device, SBuffersData[id.Index].Buffer);
     if (SBuffers.Data[id.Index].DebugName != null)
     {
         SBuffersData[id.Index].Buffer.DebugName = SBuffers.Data[id.Index].DebugName;
         SBuffersData[id.Index].Srv.DebugName    = SBuffers.Data[id.Index].DebugName;
     }
 }
示例#5
0
 internal static void Destroy(StructuredBufferId id)
 {
     SbIndices.Remove(id);
     if (SBuffersData[id.Index].Buffer != null)
     {
         SBuffersData[id.Index].Buffer.Dispose();
         SBuffersData[id.Index].Buffer = null;
     }
     if (SBuffersData[id.Index].Srv != null)
     {
         SBuffersData[id.Index].Srv.Dispose();
         SBuffersData[id.Index].Srv = null;
     }
     SBuffers.Free(id.Index);
 }
示例#6
0
 internal static BufferDescription GetBufferDesc(StructuredBufferId id)
 {
     return(SBuffers.Data[id.Index].Description);
 }
示例#7
0
 internal static ShaderResourceView GetView(StructuredBufferId id)
 {
     return(id != StructuredBufferId.NULL ? SBuffersData[id.Index].Srv : null);
 }
示例#8
0
 internal static Buffer GetBuffer(StructuredBufferId id)
 {
     return(SBuffersData[id.Index].Buffer);
 }