StepTimer和tripple缓冲

StepTimer和tripple缓冲

本文介绍了D3D12项目模板,StepTimer和tripple缓冲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于创建c ++ directx 12项目的D3D12项目模板,即File> New> Project> Visual C ++> DirectX 12 App(通用Windows)使用旋转立方体创建项目。  使用3 RTV渲染此立方体,将
写入后备缓冲区,并根据当前帧进行呈现。 只要你每秒运行60帧,这就很有效。 如果由于阴影绘制,光照,
反射,我将步进时间改为1/30或30帧,因为很多生产游戏都会运行,立方体开始抖动。我相信这个抖动来自更新,不能快速复制常量缓冲区数据,以便渲染读取它,因此渲染实际上是调用一些以前的常量缓冲区数据。 您可以通过每次更新而不是按帧更新
所有常量缓冲区来轻松修复它。

The D3D12 project template for creating a c++ directx 12 project aka File>New>Project>Visual C++> DirectX 12 App(Universal Windows) creates a project with a spinning cube.   This cube is rendered using 3 RTV, writing to the backbuffer, and presenting based on the current frame.  This works great as long as you are running 60 frames a second.  If I change the steptimer to 1/30, or 30 frames a second as a lot of production games run because of shadow drawing, lighting, reflections, the cube starts to jitter. I believe this jitter comes from the Update not copying the constant buffer data fast enough for render to read it so render is actually calling some previous constant buffer data.  You can fix it easily by updating all the constant buffers every update instead of by frame.

		// Update the constant buffer resource.
		for (size_t i = 0; i < DX::c_frameCount; i++)
		{
			UINT8* destination = m_mappedConstantBuffer + (i * c_alignedConstantBufferSize);
			memcpy(destination, &m_constantBufferData, sizeof(m_constantBufferData));
		}

我的问题是,这是处理此问题的最佳方法吗? 什么是最好的方法?

My question is, is this the best way to handle this?  what is the best way?

推荐答案


这篇关于D3D12项目模板,StepTimer和tripple缓冲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 00:35