From 2da50bbf1800dd2465edbb3d5abcb2a3bebeaaa4 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Sun, 4 Apr 2021 14:27:34 -0700 Subject: [PATCH] update shader uniform documentation --- content/Graphics/CommandBuffer/_index.md | 11 ----------- content/Graphics/Resources/ComputePipeline.md | 6 ++++++ .../Resources/GraphicsPipeline/GraphicsPipeline.md | 7 +++++++ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/content/Graphics/CommandBuffer/_index.md b/content/Graphics/CommandBuffer/_index.md index 0e0695a..6bec7fc 100644 --- a/content/Graphics/CommandBuffer/_index.md +++ b/content/Graphics/CommandBuffer/_index.md @@ -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. -## 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 ```cs diff --git a/content/Graphics/Resources/ComputePipeline.md b/content/Graphics/Resources/ComputePipeline.md index e2f5318..a14c336 100644 --- a/content/Graphics/Resources/ComputePipeline.md +++ b/content/Graphics/Resources/ComputePipeline.md @@ -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. + +Similar to graphics pipelines, uniforms can also be pushed to compute pipelines. + +```cs +var myComputeUniformOffset = myComputePipeline.PushComputeShaderUniforms(myComputeUniforms); +``` diff --git a/content/Graphics/Resources/GraphicsPipeline/GraphicsPipeline.md b/content/Graphics/Resources/GraphicsPipeline/GraphicsPipeline.md index d597053..a46c45e 100644 --- a/content/Graphics/Resources/GraphicsPipeline/GraphicsPipeline.md +++ b/content/Graphics/Resources/GraphicsPipeline/GraphicsPipeline.md @@ -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. + +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); +```