本文整理汇总了C++中Sampler::GetSamplerHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ Sampler::GetSamplerHandle方法的具体用法?C++ Sampler::GetSamplerHandle怎么用?C++ Sampler::GetSamplerHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sampler
的用法示例。
在下文中一共展示了Sampler::GetSamplerHandle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: GenerateMipsForShadowMap
void SDSMShadowManager::GenerateMipsForShadowMap(uint32 partitionIndex, RenderPassContext *renderPassContext)
{
Direct3DManager *direct3DManager = mGraphicsManager->GetDirect3DManager();
GraphicsContext *graphicsContext = direct3DManager->GetContextManager()->GetGraphicsContext();
graphicsContext->TransitionResourceExplicit(mShadowEVSMTextures[partitionIndex], D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, 0, false, true);
graphicsContext->SetPipelineState(mGenerateMipShader);
graphicsContext->SetRootSignature(NULL, mGenerateMipShader->GetRootSignature());
DescriptorHeapHandle evsmTargetHandle = renderPassContext->GetCBVSRVHeap()->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, evsmTargetHandle.GetCPUHandle(), mShadowEVSMTextures[partitionIndex]->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
Sampler *mipSampler = mGraphicsManager->GetSamplerManager()->GetSampler(SAMPLER_DEFAULT_LINEAR_CLAMP);
DescriptorHeapHandle samplerHandle = renderPassContext->GetSamplerHeap()->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, samplerHandle.GetCPUHandle(), mipSampler->GetSamplerHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
graphicsContext->SetComputeDescriptorTable(2, samplerHandle.GetGPUHandle());
graphicsContext->SetComputeDescriptorTable(3, evsmTargetHandle.GetGPUHandle());
uint32 mipTextureSize = mShadowPreferences.ShadowTextureSize;
for (uint32 i = 1; i < mShadowPreferences.ShadowTextureMipLevels; i++)
{
graphicsContext->TransitionResourceExplicit(mShadowEVSMTextures[partitionIndex], D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, i, false, true);
DescriptorHeapHandle mipTargetHandle = renderPassContext->GetCBVSRVHeap()->GetHeapHandleBlock(1);
direct3DManager->GetDevice()->CopyDescriptorsSimple(1, mipTargetHandle.GetCPUHandle(), mShadowEVSMTextures[partitionIndex]->GetUnorderedAccessViewHandle(i).GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
mipTextureSize = mipTextureSize >> 1;
float mipTexelSize = 1.0f / (float)mipTextureSize;
Vector3 mipConstants = Vector3(mipTexelSize, mipTexelSize, (float)(i - 1));
graphicsContext->SetComputeDescriptorTable(0, mipTargetHandle.GetGPUHandle());
graphicsContext->SetComputeConstants(1, 3, &mipConstants);
graphicsContext->Dispatch2D(mipTextureSize, mipTextureSize, 8, 8);
graphicsContext->InsertUAVBarrier(mShadowEVSMTextures[partitionIndex], false);
graphicsContext->TransitionResourceExplicit(mShadowEVSMTextures[partitionIndex], D3D12_RESOURCE_STATE_UNORDERED_ACCESS, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, i, false, true);
}
for (uint32 i = 1; i < mShadowPreferences.ShadowTextureMipLevels; i++)
{
graphicsContext->TransitionResourceExplicit(mShadowEVSMTextures[partitionIndex], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, i, false, false);
}
graphicsContext->TransitionResourceExplicit(mShadowEVSMTextures[partitionIndex], D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE, 0, true, true);
}