当前位置: 首页>>代码示例>>C++>>正文


C++ GraphicsContext::InsertPixEndEvent方法代码示例

本文整理汇总了C++中GraphicsContext::InsertPixEndEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::InsertPixEndEvent方法的具体用法?C++ GraphicsContext::InsertPixEndEvent怎么用?C++ GraphicsContext::InsertPixEndEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsContext的用法示例。


在下文中一共展示了GraphicsContext::InsertPixEndEvent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
}
开发者ID:Edenspuzzle,项目名称:EdensEngine,代码行数:65,代码来源:SDSMShadowManager.cpp

示例2: ComputeShadowPartitions


//.........这里部分代码省略.........
    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());

    graphicsContext->Dispatch2D((uint32)direct3DManager->GetScreenSize().X, (uint32)direct3DManager->GetScreenSize().Y, mCurrentSDSMBuffer.reduceTileDim, mCurrentSDSMBuffer.reduceTileDim);

    ////// Get Partitions From Depth Bounds
    graphicsContext->TransitionResource(mShadowPartitionBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, true);

    shadowPartitionUAVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionUAVHandle.GetCPUHandle(), mShadowPartitionBuffer->GetUnorderedAccessViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

    shadowPartitionCBVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionCBVHandle.GetCPUHandle(), mSDSMBuffers[direct3DManager->GetFrameIndex()]->GetConstantBufferViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

    graphicsContext->SetPipelineState(mCalculateLogPartitionsFromDepthBoundsShader);
    graphicsContext->SetRootSignature(NULL, mCalculateLogPartitionsFromDepthBoundsShader->GetRootSignature());
    graphicsContext->SetComputeDescriptorTable(0, shadowPartitionUAVHandle.GetGPUHandle());
    graphicsContext->SetComputeDescriptorTable(1, shadowPartitionCBVHandle.GetGPUHandle());

    graphicsContext->Dispatch(1, 1, 1);

    ////// Get Partition Bounds Range From Partitions
    graphicsContext->TransitionResource(mShadowPartitionBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, true);

    shadowPartitionBoundsUAVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionBoundsUAVHandle.GetCPUHandle(), mShadowPartitionBoundsBuffer->GetUnorderedAccessViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

    shadowPartitionSRVHandle = shadowSRVDescHeap->GetHeapHandleBlock(2);
    D3D12_CPU_DESCRIPTOR_HANDLE currentTextureHandle = shadowPartitionSRVHandle.GetCPUHandle();

    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, currentTextureHandle, depthStencil->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
    currentTextureHandle.ptr += shadowSRVDescHeap->GetDescriptorSize();
    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, currentTextureHandle, mShadowPartitionBuffer->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

    shadowPartitionCBVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionCBVHandle.GetCPUHandle(), mSDSMBuffers[direct3DManager->GetFrameIndex()]->GetConstantBufferViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

    graphicsContext->SetPipelineState(mCalculatePartitionBoundsShader);
    graphicsContext->SetRootSignature(NULL, mCalculatePartitionBoundsShader->GetRootSignature());
    graphicsContext->SetComputeDescriptorTable(0, shadowPartitionBoundsUAVHandle.GetGPUHandle());
    graphicsContext->SetComputeDescriptorTable(1, shadowPartitionSRVHandle.GetGPUHandle());
    graphicsContext->SetComputeDescriptorTable(2, shadowPartitionCBVHandle.GetGPUHandle());

    graphicsContext->Dispatch2D((uint32)direct3DManager->GetScreenSize().X, (uint32)direct3DManager->GetScreenSize().Y, mCurrentSDSMBuffer.reduceTileDim, mCurrentSDSMBuffer.reduceTileDim);

    ////// Finalize Partition Bounds
    graphicsContext->TransitionResource(mShadowPartitionBuffer, D3D12_RESOURCE_STATE_UNORDERED_ACCESS, false);
    graphicsContext->TransitionResource(mShadowPartitionBoundsBuffer, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE, true);

    shadowPartitionUAVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionUAVHandle.GetCPUHandle(), mShadowPartitionBuffer->GetUnorderedAccessViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

    shadowPartitionSRVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionSRVHandle.GetCPUHandle(), mShadowPartitionBoundsBuffer->GetShaderResourceViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

    shadowPartitionCBVHandle = shadowSRVDescHeap->GetHeapHandleBlock(1);
    direct3DManager->GetDevice()->CopyDescriptorsSimple(1, shadowPartitionCBVHandle.GetCPUHandle(), mSDSMBuffers[direct3DManager->GetFrameIndex()]->GetConstantBufferViewHandle().GetCPUHandle(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);

    graphicsContext->SetPipelineState(mFinalizePartitionsShader);
    graphicsContext->SetRootSignature(NULL, mFinalizePartitionsShader->GetRootSignature());
    graphicsContext->SetComputeDescriptorTable(0, shadowPartitionUAVHandle.GetGPUHandle());
    graphicsContext->SetComputeDescriptorTable(1, shadowPartitionSRVHandle.GetGPUHandle());
    graphicsContext->SetComputeDescriptorTable(2, shadowPartitionCBVHandle.GetGPUHandle());

    graphicsContext->Dispatch(1, 1, 1);

    graphicsContext->InsertPixEndEvent();
}
开发者ID:Edenspuzzle,项目名称:EdensEngine,代码行数:101,代码来源:SDSMShadowManager.cpp


注:本文中的GraphicsContext::InsertPixEndEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。