我正在使用https://vulkan-tutorial.com/深度缓冲代码作为基础。进行了一些更改以每帧更新命令缓冲区。
我正在使用一种粗略的方法来检查 fps。不确定它到底有多准确,但我正在对 fps 使用此检查。
static auto startTime = std::chrono::high_resolution_clock::now();
auto currentTime = std::chrono::high_resolution_clock::now();
float time = std::chrono::duration<float, std::chrono::seconds::period>(currentTime - startTime).count();
if (time < 1)
{
counter++;
}
else
{
int a = 34; //breakpoint put here to check the counter fps.
}
Run Code Online (Sandbox Code Playgroud)
任何没有每帧纹理的方式(命令缓冲区仍在每帧更新。) fps 约为 3500 fps。如果我尝试更新每帧的纹理,fps 会下降到 350 fps。
这只是带有空白纹理的测试代码,但这是我第一次使用上传纹理并更新它的过程。
void createTextureImage()
{
int Width = 1024;
int Height = 1024;
VkDeviceSize imageSize = Width * Height * sizeof(Pixel);
PixelImage.resize(Width * Height, Pixel(0xFF, 0x00, 0x00));
VkBuffer …
Run Code Online (Sandbox Code Playgroud)