update docs for upload ABI break
continuous-integration/drone/push Build is passing Details

main
cosmonaut 2022-01-13 15:04:18 -08:00
parent cb61b849fe
commit b1aef3198d
3 changed files with 15 additions and 4 deletions

View File

@ -16,6 +16,15 @@ var myCommandBuffer = GraphicsDevice.AcquireCommandBuffer();
Note that it is an **error** to use the same command buffer on multiple threads. If you want to do multithreaded draw calls, acquire one command buffer per thread. Note that it is an **error** to use the same command buffer on multiple threads. If you want to do multithreaded draw calls, acquire one command buffer per thread.
## Uploading data
You can upload data to buffers and textures using a command buffer. Uploads are guaranteed to be thread-safe. Note that it is an **error** to upload data in the middle of a render pass.
```cs
myCommandBuffer.SetTextureData(myTexture, myPixels);
myCommandBuffer.SetBufferData(myBuffer, myData);
```
## Beginning the render pass ## Beginning the render pass
All bindings and draw calls must be made within a render pass. You should think of a render pass as being a set of draw calls made to the same group of render targets. All bindings and draw calls must be made within a render pass. You should think of a render pass as being a set of draw calls made to the same group of render targets.

View File

@ -19,18 +19,20 @@ To create a buffer, you do this:
This creates a 64-byte buffer intended for use as an [index buffer](https://vulkan-tutorial.com/Vertex_buffers/Index_buffer). Index buffers allow the renderer to reuse vertices when drawing in 3D so you don't need to put a bunch of redundant data in your vertex buffer. Every 3D model format and exporter will give you index data along with vertex data. This creates a 64-byte buffer intended for use as an [index buffer](https://vulkan-tutorial.com/Vertex_buffers/Index_buffer). Index buffers allow the renderer to reuse vertices when drawing in 3D so you don't need to put a bunch of redundant data in your vertex buffer. Every 3D model format and exporter will give you index data along with vertex data.
To upload data to a buffer, you use the `SetData` method. To upload data to a buffer, you must use the `SetBufferData` method on a command buffer. We'll get to command buffers later, just know that you must upload data via command buffer so that you can safely use multithreading.
```cs ```cs
var myVertices = new VertexPositionNormalTexture[128]; var myVertices = new VertexPositionNormalTexture[128];
var vertexSizeInBytes = Marshal.SizeOf<VertexPositionNormalTexture>(); var vertexSizeInBytes = Marshal.SizeOf<VertexPositionNormalTexture>();
// set vertex data here // set your vertex data here!
var myVertexBuffer = new Buffer(GraphicsDevice, BufferUsageFlags.Vertex, 128 * vertexSizeInBytes); var myVertexBuffer = new Buffer(GraphicsDevice, BufferUsageFlags.Vertex, 128 * vertexSizeInBytes);
myVertexBuffer.SetData(myVertices);
myCommandBuffer.SetBufferData(myVertexBuffer, myVertices);
``` ```
To get data from a buffer, you use the `GetData` method. To get data from a buffer, you use the `GetData` method.
```cs ```cs

View File

@ -37,7 +37,7 @@ var pixels = new Color[width * height];
myCommandBuffer.SetTextureData(myTexture, pixels); myCommandBuffer.SetTextureData(myTexture, pixels);
``` ```
We'll get to command buffers later, just know that you must upload data via command buffer so that you safely use multithreading. This can speed up load times greatly. We'll get to command buffers later, just know that you must upload data via command buffer so that you can safely use multithreading. This can speed up load times greatly.
Of course, having to fill in all this data every time is kind of cumbersome, so we have some shortcut methods for common texture usages. Of course, having to fill in all this data every time is kind of cumbersome, so we have some shortcut methods for common texture usages.