예제 #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);
 }