本文整理汇总了C++中GraphicsContext::TransitionResource方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::TransitionResource方法的具体用法?C++ GraphicsContext::TransitionResource怎么用?C++ GraphicsContext::TransitionResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext::TransitionResource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertToEVSM
void SDSMShadowManager::ConvertToEVSM(uint32 partitionIndex)
{
GraphicsContext *graphicsContext = mGraphicsManager->GetDirect3DManager()->GetContextManager()->GetGraphicsContext();
graphicsContext->TransitionResource(mShadowDepthTarget, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, false);
graphicsContext->TransitionResource(mShadowEVSMTextures[partitionIndex], D3D12_RESOURCE_STATE_RENDER_TARGET, true);
graphicsContext->SetRenderTarget(mShadowEVSMTextures[partitionIndex]->GetRenderTargetViewHandle().GetCPUHandle());
graphicsContext->DrawFullScreenTriangle();
}
示例2: RenderAccumulatedShadowMap
void SDSMShadowManager::RenderAccumulatedShadowMap(RenderPassContext *renderPassContext, DepthStencilTarget *gbufferDepth, RenderTarget *gbufferNormals)
{
Direct3DManager *direct3DManager = mGraphicsManager->GetDirect3DManager();
GraphicsContext *graphicsContext = direct3DManager->GetContextManager()->GetGraphicsContext();
Direct3DHeapManager *heapManager = direct3DManager->GetContextManager()->GetHeapManager();
Vector2 screenSize = direct3DManager->GetScreenSize();
graphicsContext->TransitionResource(gbufferNormals, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, false);
graphicsContext->TransitionResource(gbufferNormals, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, false);
graphicsContext->TransitionResource(mShadowAccumulationTexture, D3D12_RESOURCE_STATE_RENDER_TARGET, true);
graphicsContext->SetViewport(direct3DManager->GetScreenViewport());
graphicsContext->SetScissorRect(0, 0, (uint32)screenSize.X, (uint32)screenSize.Y);
DescriptorHeapHandle shadowSRVHandle = renderPassContext->GetCBVSRVHeap()->GetHeapHandleBlock(7);
DescriptorHeapHandle shadowSamplersHandle = renderPassContext->GetSamplerHeap()->GetHeapHandleBlock(1);
DescriptorHeapHandle shadowCBVHandle = renderPassContext->GetCBVSRVHeap()->GetHeapHandleBlock(1);
D3D12_CPU_DESCRIPTOR_HANDLE shadowSRVHandleOffset = shadowSRVHandle.GetCPUHandle();
uint32 srvHandleOffsetIncrement = renderPassContext->GetCBVSRVHeap()->GetDescriptorSize();
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowSRVHandleOffset, gbufferNormals->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
shadowSRVHandleOffset.ptr += srvHandleOffsetIncrement;
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowSRVHandleOffset, gbufferDepth->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
shadowSRVHandleOffset.ptr += srvHandleOffsetIncrement;
for (uint32 i = 0; i < SDSM_SHADOW_PARTITION_COUNT; i++)
{
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowSRVHandleOffset, mShadowEVSMTextures[i]->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
shadowSRVHandleOffset.ptr += srvHandleOffsetIncrement;
}
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowSRVHandleOffset, mShadowPartitionBuffer->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
Sampler *shadowSampler = mGraphicsManager->GetSamplerManager()->GetSampler(SAMPLER_DEFAULT_ANISO_16_CLAMP);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowSamplersHandle.GetCPUHandle(), shadowSampler->GetSamplerHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowCBVHandle.GetCPUHandle(), mSDSMAccumulationBuffers[direct3DManager->GetFrameIndex()]->GetConstantBufferViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
graphicsContext->SetRenderTarget(mShadowAccumulationTexture->GetRenderTargetViewHandle().GetCPUHandle());
graphicsContext->SetPipelineState(mSDSMAccumulationShader);
graphicsContext->SetRootSignature(mSDSMAccumulationShader->GetRootSignature(), NULL);
graphicsContext->SetGraphicsDescriptorTable(0, shadowSRVHandle.GetGPUHandle());
graphicsContext->SetGraphicsDescriptorTable(1, shadowSamplersHandle.GetGPUHandle());
graphicsContext->SetGraphicsDescriptorTable(2, shadowCBVHandle.GetGPUHandle());
graphicsContext->DrawFullScreenTriangle();
}
示例3: BeginRendering
void ShadowBuffer::BeginRendering( GraphicsContext& Context )
{
Context.TransitionResource(*this, D3D12_RESOURCE_STATE_DEPTH_WRITE, true);
Context.ClearDepth(*this);
Context.SetDepthStencilTarget(GetDSV());
Context.SetViewportAndScissor(m_Viewport, m_Scissor);
}
示例4: RenderShadowDepth
void SDSMShadowManager::RenderShadowDepth(uint32 partitionIndex, RenderPassContext *renderPassContext, const D3DXMATRIX &lightViewProjMatrix, DynamicArray<SceneEntity*> &shadowEntities)
{
GraphicsContext *graphicsContext = mGraphicsManager->GetDirect3DManager()->GetContextManager()->GetGraphicsContext();
graphicsContext->TransitionResource(mShadowDepthTarget, D3D12_RESOURCE_STATE_DEPTH_WRITE, true);
graphicsContext->ClearDepthStencilTarget(mShadowDepthTarget->GetDepthStencilViewHandle().GetCPUHandle(), 1.0f, 0);
graphicsContext->SetDepthStencilTarget(mShadowDepthTarget->GetDepthStencilViewHandle().GetCPUHandle());
for (uint32 i = 0; i < shadowEntities.CurrentSize(); i++)
{
shadowEntities[i]->RenderShadows(renderPassContext, lightViewProjMatrix);
}
}
示例5: Render
void DeferredRenderer::Render()
{
Direct3DManager *direct3DManager = mGraphicsManager->GetDirect3DManager();
GraphicsContext *graphicsContext = direct3DManager->GetContextManager()->GetGraphicsContext();
graphicsContext->SetViewport(direct3DManager->GetScreenViewport());
BackBufferTarget *backBuffer = direct3DManager->GetBackBufferTarget();
graphicsContext->TransitionResource((*backBuffer), D3D12_RESOURCE_STATE_RENDER_TARGET, true);
static float blueSub = 0.0f;
if (blueSub < 0.9f)
{
blueSub += 0.0001f;
}
// Record drawing commands.
float color[4] = {0.392156899f, 0.584313750f, 0.929411829f - blueSub, 1.000000000f};
graphicsContext->ClearRenderTarget(direct3DManager->GetRenderTargetView(), color);
graphicsContext->TransitionResource((*backBuffer), D3D12_RESOURCE_STATE_PRESENT, true);
graphicsContext->Flush(direct3DManager->GetContextManager()->GetQueueManager(), true);
}
示例6: RenderShadowMapPartitions
void SDSMShadowManager::RenderShadowMapPartitions(const D3DXMATRIX &lightViewProjMatrix, DynamicArray<SceneEntity*> &shadowEntities, DepthStencilTarget *gbufferDepth, RenderTarget *gbufferNormals)
{
Direct3DManager *direct3DManager = mGraphicsManager->GetDirect3DManager();
GraphicsContext *graphicsContext = direct3DManager->GetContextManager()->GetGraphicsContext();
Direct3DHeapManager *heapManager = direct3DManager->GetContextManager()->GetHeapManager();
Direct3DQueueManager *queueManager = direct3DManager->GetContextManager()->GetQueueManager();
//TDA: * mShadowPreferences.PartitionCount <--- is only for testing. Can just fill those cbv descs on the first partition and then reuse them
uint32 numCBVSRVDescsShadowMap = shadowEntities.CurrentSize() * mShadowPreferences.PartitionCount + mShadowPreferences.PartitionCount + 1; //1 cbv per entity + X partition cbvs + 1 partition srv
uint32 numCBVSRVDescsEVSM = 1;
uint32 numCBVSRVDescsMips = 1 + mShadowPreferences.ShadowTextureMipLevels;
RenderPassDescriptorHeap *shadowSRVDescHeap = heapManager->GetRenderPassDescriptorHeapFor(RenderPassDescriptorHeapType_ShadowRender, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, direct3DManager->GetFrameIndex(), numCBVSRVDescsShadowMap + numCBVSRVDescsEVSM + numCBVSRVDescsMips);
RenderPassDescriptorHeap *shadowSamplerDescHeap = heapManager->GetRenderPassDescriptorHeapFor(RenderPassDescriptorHeapType_ShadowRender, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, direct3DManager->GetFrameIndex(), 1);
graphicsContext->InsertPixBeginEvent(0xFF00FF00, "Shadow Render");
graphicsContext->TransitionResource(mShadowPartitionBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE | D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, true);
graphicsContext->SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, shadowSRVDescHeap->GetHeap());
graphicsContext->SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, shadowSamplerDescHeap->GetHeap());
graphicsContext->SetViewport(mShadowMapViewport);
graphicsContext->SetScissorRect(0, 0, mShadowPreferences.ShadowTextureSize, mShadowPreferences.ShadowTextureSize);
DescriptorHeapHandle shadowParitionReadBuffer = shadowSRVDescHeap->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowParitionReadBuffer.GetCPUHandle(), mShadowPartitionBuffer->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
DescriptorHeapHandle shadowMapDepthHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowMapDepthHandle.GetCPUHandle(), mShadowDepthTarget->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
DynamicArray<MaterialTextureType> noTexturesForThisPass;
RenderPassContext shadowPassContext(graphicsContext, shadowSRVDescHeap, shadowSamplerDescHeap, noTexturesForThisPass, direct3DManager->GetFrameIndex());
for (uint32 i = 0; i < SDSM_SHADOW_PARTITION_COUNT; i++)
{
DescriptorHeapHandle perPassParitionBuffer = shadowSRVDescHeap->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, perPassParitionBuffer.GetCPUHandle(), mPartitionIndexBuffers[i]->GetConstantBufferViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
graphicsContext->SetPipelineState(mShadowMapShader);
graphicsContext->SetRootSignature(mShadowMapShader->GetRootSignature(), NULL);
graphicsContext->SetGraphicsDescriptorTable(1, perPassParitionBuffer.GetGPUHandle());
graphicsContext->SetGraphicsDescriptorTable(2, shadowParitionReadBuffer.GetGPUHandle());
RenderShadowDepth(i, &shadowPassContext, lightViewProjMatrix, shadowEntities);
graphicsContext->SetPipelineState(mShadowMapEVSMShader);
graphicsContext->SetRootSignature(mShadowMapEVSMShader->GetRootSignature(), NULL);
graphicsContext->SetGraphicsDescriptorTable(0, perPassParitionBuffer.GetGPUHandle());
graphicsContext->SetGraphicsDescriptorTable(1, shadowMapDepthHandle.GetGPUHandle());
graphicsContext->SetGraphicsDescriptorTable(2, shadowParitionReadBuffer.GetGPUHandle());
ConvertToEVSM(i);
if (mShadowPreferences.UseSoftShadows)
{
ApplyBlur();
}
GenerateMipsForShadowMap(i, &shadowPassContext);
graphicsContext->TransitionResource(mShadowEVSMTextures[i], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, true);
}
RenderAccumulatedShadowMap(&shadowPassContext, gbufferDepth, gbufferNormals);
graphicsContext->InsertPixEndEvent();
}
示例7: ComputeShadowPartitions
void SDSMShadowManager::ComputeShadowPartitions(Camera *camera, D3DXMATRIX &lightViewMatrix, D3DXMATRIX &lightProjectionMatrix, DepthStencilTarget *depthStencil)
{
Direct3DManager *direct3DManager = mGraphicsManager->GetDirect3DManager();
Camera::CameraScreenSettings cameraSettings = camera->GetScreenSettings();
const float maxFloat = FLT_MAX;
Vector3 maxPartitionScale(maxFloat, maxFloat, maxFloat);
mBlurSizeInLightSpace = Vector2(0.0f, 0.0f);
if (mShadowPreferences.UseSoftShadows)
{
mBlurSizeInLightSpace.X = mShadowPreferences.SofteningAmount * 0.5f * lightProjectionMatrix._11;
mBlurSizeInLightSpace.Y = mShadowPreferences.SofteningAmount * 0.5f * lightProjectionMatrix._22;
float maxBlurLightSpace = mShadowPreferences.MaxSofteningFilter / ((float)mShadowPreferences.ShadowTextureSize);
maxPartitionScale.X = maxBlurLightSpace / mBlurSizeInLightSpace.X;
maxPartitionScale.Y = maxBlurLightSpace / mBlurSizeInLightSpace.Y;
}
Vector3 partitionBorderLightSpace(mBlurSizeInLightSpace.X, mBlurSizeInLightSpace.Y, 1.0f);
partitionBorderLightSpace.Z *= lightProjectionMatrix._33;
D3DXMATRIX cameraViewInvMatrix;
D3DXMATRIX cameraViewMatrix = camera->GetViewMatrix();
D3DXMatrixInverse(&cameraViewInvMatrix, NULL, &cameraViewMatrix);
D3DXMATRIX lightViewProjMatrix = lightViewMatrix * lightProjectionMatrix;
mCurrentSDSMBuffer.cameraProjMatrix = camera->GetReverseProjectionMatrix();
mCurrentSDSMBuffer.cameraViewToLightProjMatrix = cameraViewInvMatrix * lightViewProjMatrix;
mCurrentSDSMBuffer.lightSpaceBorder = Vector4(partitionBorderLightSpace.X, partitionBorderLightSpace.Y, partitionBorderLightSpace.Z, 0.0f);
mCurrentSDSMBuffer.maxScale = Vector4(maxPartitionScale.X, maxPartitionScale.Y, maxPartitionScale.Z, 0.0f);
mCurrentSDSMBuffer.bufferDimensions = direct3DManager->GetScreenSize();
mCurrentSDSMBuffer.cameraNearFar = Vector2(cameraSettings.Near, cameraSettings.Far);
mCurrentSDSMBuffer.dilationFactor = 0.01f;
mCurrentSDSMBuffer.reduceTileDim = 64;
D3DXMatrixTranspose(&mCurrentSDSMBuffer.cameraProjMatrix, &mCurrentSDSMBuffer.cameraProjMatrix);
D3DXMatrixTranspose(&mCurrentSDSMBuffer.cameraViewToLightProjMatrix, &mCurrentSDSMBuffer.cameraViewToLightProjMatrix);
mCurrentAccumulationBuffer.projectionMatrix = mCurrentSDSMBuffer.cameraProjMatrix;
mCurrentAccumulationBuffer.viewToLightProjMatrix = mCurrentSDSMBuffer.cameraViewToLightProjMatrix;
mCurrentAccumulationBuffer.bufferDimensions = direct3DManager->GetScreenSize();
mSDSMBuffers[direct3DManager->GetFrameIndex()]->SetConstantBufferData(&mCurrentSDSMBuffer, sizeof(SDSMBuffer));
mSDSMAccumulationBuffers[direct3DManager->GetFrameIndex()]->SetConstantBufferData(&mCurrentAccumulationBuffer, sizeof(SDSMAccumulationBuffer));
uint32 shadowNumSRVDescs = 1;
Direct3DHeapManager *heapManager = direct3DManager->GetContextManager()->GetHeapManager();
RenderPassDescriptorHeap *shadowSRVDescHeap = heapManager->GetRenderPassDescriptorHeapFor(RenderPassDescriptorHeapType_ShadowCompute, D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, direct3DManager->GetFrameIndex(), shadowNumSRVDescs);
GraphicsContext *graphicsContext = direct3DManager->GetContextManager()->GetGraphicsContext();
graphicsContext->InsertPixBeginEvent(0xFF00FF00, "Shadow Compute");
graphicsContext->SetDescriptorHeap(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, shadowSRVDescHeap->GetHeap());
////// Clear partitions
graphicsContext->TransitionResource(mShadowPartitionBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, false);
graphicsContext->TransitionResource(mShadowPartitionBoundsBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, true);
DescriptorHeapHandle shadowPartitionUAVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionUAVHandle.GetCPUHandle(), mShadowPartitionBuffer->GetUnorderedAccessViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
graphicsContext->SetPipelineState(mClearShadowPartitionsShader);
graphicsContext->SetRootSignature(NULL, mClearShadowPartitionsShader->GetRootSignature());
graphicsContext->SetComputeDescriptorTable(0, shadowPartitionUAVHandle.GetGPUHandle());
graphicsContext->Dispatch(1, 1, 1);
////// Clear Partition Bounds
DescriptorHeapHandle shadowPartitionBoundsUAVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionBoundsUAVHandle.GetCPUHandle(), mShadowPartitionBoundsBuffer->GetUnorderedAccessViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
graphicsContext->SetPipelineState(mClearShadowPartitionBoundsShader);
graphicsContext->SetRootSignature(NULL, mClearShadowPartitionBoundsShader->GetRootSignature());
graphicsContext->SetComputeDescriptorTable(0, shadowPartitionBoundsUAVHandle.GetGPUHandle());
graphicsContext->Dispatch(1, 1, 1);
graphicsContext->TransitionResource(mShadowPartitionBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, false); //force UAV barrier
graphicsContext->TransitionResource(mShadowPartitionBoundsBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, true);
/////// Calculate depth buffer bounds
shadowPartitionUAVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionUAVHandle.GetCPUHandle(), mShadowPartitionBuffer->GetUnorderedAccessViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
DescriptorHeapHandle shadowPartitionSRVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionSRVHandle.GetCPUHandle(), depthStencil->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
DescriptorHeapHandle shadowPartitionCBVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionCBVHandle.GetCPUHandle(), mSDSMBuffers[direct3DManager->GetFrameIndex()]->GetConstantBufferViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
graphicsContext->SetPipelineState(mCalculateDepthBufferBoundsShader);
graphicsContext->SetRootSignature(NULL, mCalculateDepthBufferBoundsShader->GetRootSignature());
graphicsContext->SetComputeDescriptorTable(0, shadowPartitionUAVHandle.GetGPUHandle());
graphicsContext->SetComputeDescriptorTable(1, shadowPartitionSRVHandle.GetGPUHandle());
graphicsContext->SetComputeDescriptorTable(2, shadowPartitionCBVHandle.GetGPUHandle());
//.........这里部分代码省略.........
示例8: EndRendering
void ShadowBuffer::EndRendering( GraphicsContext& Context )
{
Context.TransitionResource(*this, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
}