@@ -166,6 +166,8 @@ public:
|
||||
|
||||
// Binds the shared per-view constant buffer at slot 1 (see ViewData in MaterialCommon.hlsl)
|
||||
void BindViewData();
|
||||
// Binds the shared per-draw constant buffer at slot 2 (see DrawData in MaterialCommon.hlsl)
|
||||
void BindDrawData();
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -84,6 +84,27 @@ void IMaterial::BindParameters::BindViewData()
|
||||
GPUContext->BindCB(1, PerViewConstants);
|
||||
}
|
||||
|
||||
void IMaterial::BindParameters::BindDrawData()
|
||||
{
|
||||
// Write draw call to the object buffer
|
||||
auto& objectBuffer = RenderContext.List->TempObjectBuffer;
|
||||
objectBuffer.Clear();
|
||||
ShaderObjectData objData;
|
||||
objData.Store(*DrawCall);
|
||||
objectBuffer.Write(objData);
|
||||
objectBuffer.Flush(GPUContext);
|
||||
ObjectBuffer = objectBuffer.GetBuffer()->View();
|
||||
|
||||
// Setup data
|
||||
MaterialShaderDataPerDraw perDraw;
|
||||
perDraw.DrawPadding = Float3::Zero;
|
||||
perDraw.DrawObjectIndex = 0;
|
||||
|
||||
// Update constants
|
||||
GPUContext->UpdateCB(PerDrawConstants, &perDraw);
|
||||
GPUContext->BindCB(2, PerDrawConstants);
|
||||
}
|
||||
|
||||
GPUPipelineState* MaterialShader::PipelineStateCache::InitPS(CullMode mode, bool wireframe)
|
||||
{
|
||||
Desc.CullMode = mode;
|
||||
|
||||
Reference in New Issue
Block a user