add some clarification to the command buffer section
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
2da50bbf18
commit
63f507dbce
|
@ -6,7 +6,7 @@ weight: 4
|
||||||
|
|
||||||
Now that we have our rendering state set up, we can talk about issuing commands.
|
Now that we have our rendering state set up, we can talk about issuing commands.
|
||||||
|
|
||||||
There are three kinds of overarching operations that we perform using the command buffer: applying render state, uploading uniform data, and binding resources. Let's go through each of these and then tie it all together.
|
There are three kinds of overarching operations that we perform using the command buffer: applying render state, binding resources, and issuing draw commands. Let's go through each of these and then tie it all together.
|
||||||
|
|
||||||
First, we need to acquire a command buffer.
|
First, we need to acquire a command buffer.
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ All bindings and draw calls must be made within a render pass. You should think
|
||||||
|
|
||||||
Beginning a render pass requires a minimum of three parameters: a render pass object, a framebuffer object, a rectangle representing the area of the framebuffer that will be rendered to. You may also optionally provide clear colors per color target, and a depth/stencil clear value for the depth/stencil target.
|
Beginning a render pass requires a minimum of three parameters: a render pass object, a framebuffer object, a rectangle representing the area of the framebuffer that will be rendered to. You may also optionally provide clear colors per color target, and a depth/stencil clear value for the depth/stencil target.
|
||||||
|
|
||||||
There can only be one active render pass at a time.
|
There can only be one active render pass at a time per command buffer.
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
myCommandBuffer.BeginRenderPass(
|
myCommandBuffer.BeginRenderPass(
|
||||||
|
@ -35,7 +35,7 @@ myCommandBuffer.BeginRenderPass(
|
||||||
|
|
||||||
This example assumes there is one color target in the framebuffer, and we will clear it to the cornflower blue color.
|
This example assumes there is one color target in the framebuffer, and we will clear it to the cornflower blue color.
|
||||||
|
|
||||||
You can also clear the framebuffer by calling `CommandBuffer.Clear`. It's strongly recommended to clear when beginning a render pass whenever possible, but it is possible to clear mid-pass if you wish.
|
You can also clear the framebuffer by calling `CommandBuffer.Clear`. It's strongly recommended to clear when beginning a render pass if you need the render target cleared, but it is possible to clear mid-pass if you wish.
|
||||||
|
|
||||||
### Binding the graphics pipeline
|
### Binding the graphics pipeline
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ When we wish to use a graphics pipeline, we "bind" it, meaning that we make it a
|
||||||
myCommandBuffer.BindGraphicsPipeline(myGraphicsPipeline);
|
myCommandBuffer.BindGraphicsPipeline(myGraphicsPipeline);
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that if you need to use multiple graphics pipelines that all share a render pass, you can call this method again and it will bind a new graphics pipeline without needing to end the render pass.
|
Note that if you use multiple graphics pipelines that all share a render pass, you can call this method again and it will bind a new graphics pipeline without needing to end the render pass.
|
||||||
|
|
||||||
## Binding Buffers
|
## Binding Buffers
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ myCommandBuffer.BindIndexBuffer(myIndexBuffer);
|
||||||
|
|
||||||
"Binding" a buffer makes it available to be used by draw calls. If you are doing instanced rendering, you will bind multiple vertex buffers, otherwise you will just bind one. You will need to bind an index buffer if you are doing indexed or instanced rendering, otherwise you will not bind one.
|
"Binding" a buffer makes it available to be used by draw calls. If you are doing instanced rendering, you will bind multiple vertex buffers, otherwise you will just bind one. You will need to bind an index buffer if you are doing indexed or instanced rendering, otherwise you will not bind one.
|
||||||
|
|
||||||
You may also bind buffers while providing an offset value.
|
You may also bind buffers while providing an offset value in the case where you put lots of different vertex data into large buffers.
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
myCommandBuffer.BindVertexBuffers(new BufferBinding(myVertexBuffer, myOffsetValue));
|
myCommandBuffer.BindVertexBuffers(new BufferBinding(myVertexBuffer, myOffsetValue));
|
||||||
|
@ -142,7 +142,6 @@ myCommandBuffer.CopyTextureToBuffer(
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that it is an error to provide too small of a buffer to contain the image data.
|
|
||||||
|
|
||||||
Remember that you have to call `GraphicsDevice.Submit` and `GraphicsDevice.Wait` before the contents of the buffer are guaranteed to be filled. Then you can call `myBuffer.GetData` to get the image data.
|
Remember that you have to call `GraphicsDevice.Submit` and `GraphicsDevice.Wait` before the contents of the buffer are guaranteed to be filled. Then you can call `myBuffer.GetData` to get the image data.
|
||||||
|
|
||||||
|
Note that it is an error to provide too small of a buffer to contain the image data.
|
||||||
|
|
Loading…
Reference in New Issue