Ejemplo n.º 1
0
	void BackBuffer::CreateReductionTargets(ID3D11Device* device)
	{
		// Create the staging textures for reading back the reduced depth buffer
		for (uint32 i = 0; i < MaxReadbackLatency; ++i)
			m_ReductionStagingTextures[i].Initialize(device, 1, 1, DXGI_FORMAT_R16G16_UNORM);

		m_DepthReductionTargets.clear();

		uint32 w = m_SurfaceDesc.Width;
		uint32 h = m_SurfaceDesc.Height;

		auto DispatchSize = [](uint32 tgSize, uint32 numElements)
		{
			uint32 dispatchSize = numElements / tgSize;
			dispatchSize += numElements % tgSize > 0 ? 1 : 0;
			return dispatchSize;
		};

		while (w > 1 || h > 1)
		{
			w = DispatchSize(ReductionTGSize, w);
			h = DispatchSize(ReductionTGSize, h);

			RenderTarget2D rt;
			rt.Initialize(device, w, h, DXGI_FORMAT_R16G16_UNORM, 1, 1, 0, FALSE, TRUE);
			m_DepthReductionTargets.push_back(rt);
		}
	}
Ejemplo n.º 2
0
void MeshRenderer::OnResize(uint32 width, uint32 height)
{
    depthReductionTargets.clear();

    uint32 w = width;
    uint32 h = height;

    while(w > 1 || h > 1)
    {
        w = DispatchSize(ReductionTGSize, w);
        h = DispatchSize(ReductionTGSize, h);

        RenderTarget2D rt;
        rt.Initialize(device, w, h, DXGI_FORMAT_R16G16_UNORM, 1, 1, 0, false, true);
        depthReductionTargets.push_back(rt);
    }
}