update shader uniform documentation
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
40f07ec30f
commit
2da50bbf18
|
@ -47,17 +47,6 @@ 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 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.
|
||||||
|
|
||||||
## Pushing shader uniforms
|
|
||||||
|
|
||||||
Remember when we talked about shader uniforms earlier? This is where we apply them.
|
|
||||||
|
|
||||||
```cs
|
|
||||||
var myVertexUniformOffset = myCommandBuffer.PushVertexShaderUniforms(myVertexShaderUniforms);
|
|
||||||
var myFragmentUniformOffset = myCommandBuffer.PushFragmentShaderUniforms(myFragmentShaderUniforms);
|
|
||||||
```
|
|
||||||
|
|
||||||
Note that these offset values are later accepted by the draw calls, and also note that you can pass multiple shader uniform structs at once. Remember that sending data between the CPU and GPU is expensive and we want to do that as infrequently as possible. Batching your uniform updates minimizes data transfer.
|
|
||||||
|
|
||||||
## Binding Buffers
|
## Binding Buffers
|
||||||
|
|
||||||
```cs
|
```cs
|
||||||
|
|
|
@ -32,3 +32,9 @@ var myComputePipeline = new ComputePipeline(
|
||||||
```
|
```
|
||||||
|
|
||||||
This example creates a compute pipeline with no uniform input, one buffer binding, and no image bindings.
|
This example creates a compute pipeline with no uniform input, one buffer binding, and no image bindings.
|
||||||
|
|
||||||
|
Similar to graphics pipelines, uniforms can also be pushed to compute pipelines.
|
||||||
|
|
||||||
|
```cs
|
||||||
|
var myComputeUniformOffset = myComputePipeline.PushComputeShaderUniforms(myComputeUniforms);
|
||||||
|
```
|
||||||
|
|
|
@ -29,3 +29,10 @@ var myGraphicsPipeline = new GraphicsPipeline(
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally! That's it! You might have noticed that a lot of this structure can be reused across pipelines. I strongly recommend creating individual container objects for the various states your renderer uses so you don't have to repeat yourself a whole bunch.
|
Finally! That's it! You might have noticed that a lot of this structure can be reused across pipelines. I strongly recommend creating individual container objects for the various states your renderer uses so you don't have to repeat yourself a whole bunch.
|
||||||
|
|
||||||
|
Graphics pipelines are unique from our other resources so far because they have two methods that are used to push uniforms. These methods return offset values that are used with draw commands.
|
||||||
|
|
||||||
|
```cs
|
||||||
|
var vertUniformOffset = myGraphicsPipeline.PushVertexShaderUniforms(myVertUniforms);
|
||||||
|
var fragUniformOffset = myGraphicsPipeline.PushFragmentShaderUniforms(myFragUniforms);
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue