コード例 #1
0
 private void WriteToBuffer <T>(DX11Resource <IDX11ReadableStructureBuffer> bufferResource, DX11RenderContext context, T[] bufferToCopy, int elementCount)
     where T : struct
 {
     if (elementCount > 0)
     {
         if (this.FBufferType[0] == DX11BufferUploadType.Dynamic)
         {
             DX11DynamicStructuredVLBuffer <T> b = (DX11DynamicStructuredVLBuffer <T>)bufferResource[context];
             b.WriteData(bufferToCopy, 0, elementCount);
         }
         else if (this.FBufferType[0] == DX11BufferUploadType.Default)
         {
             DX11CopyDestStructuredVLBuffer <T> b = (DX11CopyDestStructuredVLBuffer <T>)bufferResource[context];
             b.WriteData(bufferToCopy, 0, elementCount);
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Creates a buffer.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="bufferResource">The buffer resource</param>
 /// <param name="context">The DX11 context.</param>
 /// <param name="count">The required count. Gets blown up to the next power of 2.</param>
 /// <param name="bufferToCopy">The buffer to copy in case of immutable buffer type</param>
 private void CreateBuffer <T>(DX11Resource <IDX11ReadableStructureBuffer> bufferResource, DX11RenderContext context, int count, T[] bufferToCopy)
     where T : struct
 {
     if (!bufferResource.Contains(context))
     {
         count = NextUpperPow2(count);
         if (this.FBufferType[0] == DX11BufferUploadType.Dynamic)
         {
             bufferResource[context] = new DX11DynamicStructuredVLBuffer <T>(context, count);
         }
         else if (this.FBufferType[0] == DX11BufferUploadType.Default)
         {
             bufferResource[context] = new DX11CopyDestStructuredVLBuffer <T>(context, count);
         }
         else
         {
             bufferResource[context] = new DX11ImmutableStructuredVLBuffer <T>(context.Device, bufferToCopy, count);
         }
     }
 }