Ejemplo n.º 1
0
 internal static void Destroy(ref StructuredBufferId id)
 {
     if (id != StructuredBufferId.NULL)
     {
         Destroy(id); id = StructuredBufferId.NULL;
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 6
0
 internal static BufferDescription GetBufferDesc(StructuredBufferId id)
 {
     return(SBuffers.Data[id.Index].Description);
 }
Ejemplo n.º 7
0
 internal static ShaderResourceView GetView(StructuredBufferId id)
 {
     return(id != StructuredBufferId.NULL ? SBuffersData[id.Index].Srv : null);
 }
Ejemplo n.º 8
0
 internal static Buffer GetBuffer(StructuredBufferId id)
 {
     return(SBuffersData[id.Index].Buffer);
 }