本文整理汇总了C++中GraphicsContext::GetComputeContext方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::GetComputeContext方法的具体用法?C++ GraphicsContext::GetComputeContext怎么用?C++ GraphicsContext::GetComputeContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext::GetComputeContext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FillLightGrid
void Lighting::FillLightGrid(GraphicsContext& gfxContext, const Camera& camera)
{
ScopedTimer _prof(L"FillLightGrid", gfxContext);
ComputeContext& Context = gfxContext.GetComputeContext();
Context.SetRootSignature(m_FillLightRootSig);
switch ((int)LightGridDim)
{
case 8: Context.SetPipelineState(m_FillLightGridCS_8 ); break;
case 16: Context.SetPipelineState(m_FillLightGridCS_16); break;
case 24: Context.SetPipelineState(m_FillLightGridCS_24); break;
case 32: Context.SetPipelineState(m_FillLightGridCS_32); break;
default: ASSERT(false); break;
}
Context.TransitionResource(m_LightBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
Context.TransitionResource(g_LinearDepth, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
Context.TransitionResource(g_SceneDepthBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
Context.TransitionResource(m_LightGrid, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
Context.TransitionResource(m_LightGridBitMask, D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
Context.SetDynamicDescriptor(1, 0, m_LightBuffer.GetSRV());
Context.SetDynamicDescriptor(1, 1, g_LinearDepth.GetSRV());
//Context.SetDynamicDescriptor(1, 1, g_SceneDepthBuffer.GetDepthSRV());
Context.SetDynamicDescriptor(2, 0, m_LightGrid.GetUAV());
Context.SetDynamicDescriptor(2, 1, m_LightGridBitMask.GetUAV());
// todo: assumes 1920x1080 resolution
uint32_t tileCountX = Math::DivideByMultiple(g_SceneColorBuffer.GetWidth(), LightGridDim);
uint32_t tileCountY = Math::DivideByMultiple(g_SceneColorBuffer.GetHeight(), LightGridDim);
float FarClipDist = camera.GetFarClip();
float NearClipDist = camera.GetNearClip();
const float RcpZMagic = NearClipDist / (FarClipDist - NearClipDist);
struct CSConstants
{
uint32_t ViewportWidth, ViewportHeight;
float InvTileDim;
float RcpZMagic;
uint32_t TileCount;
Matrix4 ViewProjMatrix;
} csConstants;
// todo: assumes 1920x1080 resolution
csConstants.ViewportWidth = g_SceneColorBuffer.GetWidth();
csConstants.ViewportHeight = g_SceneColorBuffer.GetHeight();
csConstants.InvTileDim = 1.0f / LightGridDim;
csConstants.RcpZMagic = RcpZMagic;
csConstants.TileCount = tileCountX;
csConstants.ViewProjMatrix = camera.GetViewProjMatrix();
Context.SetDynamicConstantBufferView(0, sizeof(CSConstants), &csConstants);
Context.Dispatch(tileCountX, tileCountY, 1);
Context.TransitionResource(m_LightGrid, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
Context.TransitionResource(m_LightGridBitMask, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
}