本文整理汇总了C++中GraphicsDevice::BindRenderTargets方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsDevice::BindRenderTargets方法的具体用法?C++ GraphicsDevice::BindRenderTargets怎么用?C++ GraphicsDevice::BindRenderTargets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsDevice
的用法示例。
在下文中一共展示了GraphicsDevice::BindRenderTargets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDepthStencil
void RenderPath2D::Render() const
{
GraphicsDevice* device = wiRenderer::GetDevice();
const Texture2D* dsv = GetDepthStencil();
// Special care for internal resolution, because stencil buffer is of internal resolution,
// so we might need to render stencil sprites to separate render target that matches internal resolution!
if (GetDepthStencil() != nullptr && wiRenderer::GetResolutionScale() != 1.0f)
{
const Texture2D* rts[] = { &rtStenciled };
device->BindRenderTargets(ARRAYSIZE(rts), rts, dsv, GRAPHICSTHREAD_IMMEDIATE);
float clear[] = { 0,0,0,0 };
device->ClearRenderTarget(rts[0], clear, GRAPHICSTHREAD_IMMEDIATE);
ViewPort vp;
vp.Width = (float)rtStenciled.GetDesc().Width;
vp.Height = (float)rtStenciled.GetDesc().Height;
device->BindViewports(1, &vp, GRAPHICSTHREAD_IMMEDIATE);
wiRenderer::GetDevice()->EventBegin("STENCIL Sprite Layers", GRAPHICSTHREAD_IMMEDIATE);
for (auto& x : layers)
{
for (auto& y : x.items)
{
if (y.sprite != nullptr && y.sprite->params.stencilComp != STENCILMODE_DISABLED)
{
y.sprite->Draw(GRAPHICSTHREAD_IMMEDIATE);
}
}
}
wiRenderer::GetDevice()->EventEnd(GRAPHICSTHREAD_IMMEDIATE);
dsv = nullptr;
}
const Texture2D* rts[] = { &rtFinal };
device->BindRenderTargets(ARRAYSIZE(rts), rts, dsv, GRAPHICSTHREAD_IMMEDIATE);
float clear[] = { 0,0,0,0 };
device->ClearRenderTarget(rts[0], clear, GRAPHICSTHREAD_IMMEDIATE);
ViewPort vp;
vp.Width = (float)rtFinal.GetDesc().Width;
vp.Height = (float)rtFinal.GetDesc().Height;
device->BindViewports(1, &vp, GRAPHICSTHREAD_IMMEDIATE);
if (GetDepthStencil() != nullptr)
{
if (wiRenderer::GetResolutionScale() != 1.0f)
{
wiRenderer::GetDevice()->EventBegin("Copy STENCIL Sprite Layers", GRAPHICSTHREAD_IMMEDIATE);
wiImageParams fx;
fx.enableFullScreen();
wiImage::Draw(&rtStenciled, fx, GRAPHICSTHREAD_IMMEDIATE);
wiRenderer::GetDevice()->EventEnd(GRAPHICSTHREAD_IMMEDIATE);
}
else
{
wiRenderer::GetDevice()->EventBegin("STENCIL Sprite Layers", GRAPHICSTHREAD_IMMEDIATE);
for (auto& x : layers)
{
for (auto& y : x.items)
{
if (y.sprite != nullptr && y.sprite->params.stencilComp != STENCILMODE_DISABLED)
{
y.sprite->Draw(GRAPHICSTHREAD_IMMEDIATE);
}
}
}
wiRenderer::GetDevice()->EventEnd(GRAPHICSTHREAD_IMMEDIATE);
}
}
wiRenderer::GetDevice()->EventBegin("Sprite Layers", GRAPHICSTHREAD_IMMEDIATE);
for (auto& x : layers)
{
for (auto& y : x.items)
{
if (y.sprite != nullptr && y.sprite->params.stencilComp == STENCILMODE_DISABLED)
{
y.sprite->Draw(GRAPHICSTHREAD_IMMEDIATE);
}
if (y.font != nullptr)
{
y.font->Draw(GRAPHICSTHREAD_IMMEDIATE);
}
}
}
wiRenderer::GetDevice()->EventEnd(GRAPHICSTHREAD_IMMEDIATE);
GetGUI().Render();
RenderPath::Render();
}
示例2: ARRAYSIZE
void RenderPath3D_TiledDeferred::Render() const
{
RenderFrameSetUp(GRAPHICSTHREAD_IMMEDIATE);
RenderShadows(GRAPHICSTHREAD_IMMEDIATE);
RenderReflections(GRAPHICSTHREAD_IMMEDIATE);
// Main scene:
{
GRAPHICSTHREAD threadID = GRAPHICSTHREAD_IMMEDIATE;
GraphicsDevice* device = wiRenderer::GetDevice();
wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), threadID);
const GPUResource* dsv[] = { &depthBuffer };
device->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_READ, RESOURCE_STATE_DEPTH_WRITE, threadID);
{
wiProfiler::BeginRange("Opaque Scene", wiProfiler::DOMAIN_GPU, threadID);
const Texture2D* rts[] = {
&rtGBuffer[0],
&rtGBuffer[1],
&rtGBuffer[2],
&lightbuffer_diffuse,
&lightbuffer_specular,
};
device->BindRenderTargets(ARRAYSIZE(rts), rts, &depthBuffer, threadID);
float clear[] = { 0,0,0,0 };
device->ClearRenderTarget(&rtGBuffer[1], clear, threadID);
device->ClearDepthStencil(&depthBuffer, CLEAR_DEPTH | CLEAR_STENCIL, 0, 0, threadID);
ViewPort vp;
vp.Width = (float)rts[0]->GetDesc().Width;
vp.Height = (float)rts[0]->GetDesc().Height;
device->BindViewports(1, &vp, threadID);
device->BindResource(PS, getReflectionsEnabled() ? &rtReflection : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_REFLECTION, threadID);
device->BindResource(PS, getSSAOEnabled() ? &rtSSAO[0] : wiTextureHelper::getWhite(), TEXSLOT_RENDERPATH_SSAO, threadID);
wiRenderer::DrawScene(wiRenderer::GetCamera(), getTessellationEnabled(), threadID, RENDERPASS_DEFERRED, getHairParticlesEnabled(), true, getLayerMask());
wiProfiler::EndRange(threadID); // Opaque Scene
}
device->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_DEPTH_WRITE, RESOURCE_STATE_COPY_SOURCE, threadID);
device->CopyTexture2D(&depthBuffer_Copy, &depthBuffer, threadID);
device->TransitionBarrier(dsv, ARRAYSIZE(dsv), RESOURCE_STATE_COPY_SOURCE, RESOURCE_STATE_DEPTH_READ, threadID);
RenderLinearDepth(threadID);
device->UnbindResources(TEXSLOT_ONDEMAND0, TEXSLOT_ONDEMAND_COUNT, threadID);
wiRenderer::BindDepthTextures(&depthBuffer_Copy, &rtLinearDepth, threadID);
RenderDecals(threadID);
wiRenderer::BindGBufferTextures(&rtGBuffer[0], &rtGBuffer[1], &rtGBuffer[2], threadID);
device->BindResource(CS, getSSAOEnabled() ? &rtSSAO[0] : wiTextureHelper::getWhite(), TEXSLOT_RENDERPATH_SSAO, threadID);
device->BindResource(CS, getSSREnabled() ? &rtSSR : wiTextureHelper::getTransparent(), TEXSLOT_RENDERPATH_SSR, threadID);
wiRenderer::ComputeTiledLightCulling(threadID, &lightbuffer_diffuse, &lightbuffer_specular);
RenderSSAO(threadID);
RenderSSS(threadID);
RenderDeferredComposition(threadID);
RenderSSR(rtDeferred, threadID);
}
DownsampleDepthBuffer(GRAPHICSTHREAD_IMMEDIATE);
wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), GRAPHICSTHREAD_IMMEDIATE);
RenderOutline(rtDeferred, GRAPHICSTHREAD_IMMEDIATE);
RenderLightShafts(GRAPHICSTHREAD_IMMEDIATE);
RenderVolumetrics(GRAPHICSTHREAD_IMMEDIATE);
RenderParticles(false, GRAPHICSTHREAD_IMMEDIATE);
RenderRefractionSource(rtDeferred, GRAPHICSTHREAD_IMMEDIATE);
RenderTransparents(rtDeferred, RENDERPASS_TILEDFORWARD, GRAPHICSTHREAD_IMMEDIATE);
RenderParticles(true, GRAPHICSTHREAD_IMMEDIATE);
TemporalAAResolve(rtDeferred, rtGBuffer[1], GRAPHICSTHREAD_IMMEDIATE);
RenderBloom(rtDeferred, GRAPHICSTHREAD_IMMEDIATE);
RenderPostprocessChain(rtDeferred, rtGBuffer[1], GRAPHICSTHREAD_IMMEDIATE);
RenderPath2D::Render();
}