- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我刚买了一台使用 nvidia 显卡 (gtx 1060) 的新电脑,当我尝试运行我的程序(之前可以运行)时,我遇到了一堆错误,但大部分都已修复。我留下的一个问题是,vkWaitForFences() 和 vkDeviceWaitIdle 返回 VK_ERROR_DEVICE_LOST。我的旧计算机使用 amd 显卡,但确实很旧,我使用的是旧版本的 vulkan sdk,但我认为这不是问题所在。
当然,我用谷歌搜索了这个错误,这对我帮助不大,因为没有多少人遇到过这个问题。我发现这可能是驱动程序的问题,所以按照建议,我更新了 windows 和 nvidia 驱动程序。那并没有多大帮助。我还追踪了问题发生的位置,它总是在我第二次提交命令缓冲区时发生。设备丢失也是第二次发生。
我的提交命令功能,任何人都想知道为什么结果是大声笑,因为那是我总是为了快速调试而写的第一件事,并不是什么严重的事情。
if (m_OldAllocCount == 0 || m_RecordCmdBuffers){
recordPrimaryCmdBuffer();
}
VkResult lol = vkWaitForFences(m_ContextPtr->device, 1, &inFlightFences[current_frame], VK_TRUE, std::numeric_limits<uint64_t>::max());
if (lol == VK_ERROR_DEVICE_LOST)
std::cout << "device lost" << std::endl;
uint32_t imageIndex = 0;
VkResult result = vkAcquireNextImageKHR(m_ContextPtr->device, m_CurrentWindow->m_SwapChain.swapChain, std::numeric_limits<uint64_t>::max(),
imageAvailableSemaphore[current_frame], VK_NULL_HANDLE, &imageIndex);
m_RecordCmdBuffers = false;
// If swapchain needs recreation
if (result == VK_ERROR_OUT_OF_DATE_KHR)
{
recreateSwapChain(m_CurrentWindow->getWindowSize());
viewport(Vector2i(0), m_CurrentWindow->getWindowSize());
}
else if(result != VK_SUCCESS && result != VK_SUBOPTIMAL_KHR)
throw std::runtime_error("failed to acquire swap chain image!");
// Set the correct index to image, for the uniform buffers to send data to correct block
for (auto& shader : m_CurrentShaders)
{
shader->m_UniformBuffers[(int)ShaderStage::VertexBit].m_CurrentImage = imageIndex;
shader->m_UniformBuffers[(int)ShaderStage::FragmentBit].m_CurrentImage = imageIndex;
shader->m_UniformBuffers[(int)ShaderStage::GeometryBit].m_CurrentImage = imageIndex;
}
VkSubmitInfo submitInfo = {};
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
VkSemaphore waitSemaphores[] = { imageAvailableSemaphore[current_frame] };
VkPipelineStageFlags waitStages[] = { VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT };
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = waitSemaphores;
submitInfo.pWaitDstStageMask = waitStages;
submitInfo.commandBufferCount = m_PrimaryCommandBuffer.size();
submitInfo.pCommandBuffers = m_PrimaryCommandBuffer.data();
VkSemaphore signalSemaphores[] = { renderFinishedSemaphore[current_frame] };
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = signalSemaphores;
// Reset the fences
vkResetFences(m_ContextPtr->device, 1, &inFlightFences[current_frame]);
// Submit the graphics queue
if (vkQueueSubmit(m_ContextPtr->graphicsQueue, 1, &submitInfo, inFlightFences[current_frame]) != VK_SUCCESS)
std::cout << "failed to submit command buffer" << std::endl;
VkPresentInfoKHR presentInfo = {};
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = signalSemaphores;
VkSwapchainKHR swapChains[] = { m_CurrentWindow->m_SwapChain.swapChain };
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = swapChains;
presentInfo.pImageIndices = &imageIndex;
presentInfo.pResults = nullptr;
result = vkQueuePresentKHR(m_ContextPtr->presentQueue, &presentInfo);
// If swapchain needs recreation
if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR || m_CurrentWindow->windowResized()) {
vkWaitForFences(m_ContextPtr->device, 1, &inFlightFences[current_frame], VK_TRUE, std::numeric_limits<uint64_t>::max());
recreateSwapChain(m_CurrentWindow->getWindowSize());
viewport(Vector2i(0), m_CurrentWindow->getWindowSize());
}
else if (result != VK_SUCCESS)
throw std::runtime_error("failed to present swap chain image!");
current_frame = (current_frame + 1) % MAX_FRAMES_IN_FLIGHT;
if (m_AllocCount > 0)
{
m_CurrentCmdBuf = 0;
m_OldAllocCount = m_AllocCount;
}
这是我的输出
[Run time : 0.00032s][Application]Info: application version: 4194304
[Run time : 0.00495s][Application]Info: engine version: 4194304
[Run time : 0.00641s][Application]Info: api version: 4194304
[Run time : 0.02141s][Validation Layers]Debug: Validation layers available
[Run time : 1.69485s][Extensions]Info: VK_KHR_surface
[Run time : 1.69698s][Extensions]Info: VK_KHR_win32_surface
[Run time : 1.69893s][Extensions]Info: VK_EXT_debug_utils
[Run time : 3.35121s][Vulkan Instance]Trace: Succesfully created instance
[Run time : 3.35314s][Vk Validation]Debug: Added messenger
[Run time : 0.00004s][Application]Info: application version: 4194304
[Run time : 0.00079s][Application]Info: engine version: 4194304
[Run time : 0.00144s][Application]Info: api version: 4194304
[Run time : 0.01320s][Validation Layers]Debug: Validation layers available
[Run time : 0.01410s][Extensions]Info: VK_KHR_surface
[Run time : 0.01502s][Extensions]Info: VK_KHR_win32_surface
[Run time : 0.01580s][Extensions]Info: VK_EXT_debug_utils
[Run time : 0.06975s][Vulkan Instance]Trace: Succesfully created instance
[Run time : 0.07116s][Window]Trace: Succesfully created window surface
[Run time : 0.07216s][GPU]Info: Found atleast one GPU with vulkan support
[Run time : 0.07302s][GPU]Debug: [GeForce GTX 1060]
[Run time : 0.07366s][GPU]Debug: score: 82920
[Run time : 0.07434s][GPU]Debug: device type: discrete
[Run time : 0.07496s][GPU]Debug: driver version: 1749598208
[Run time : 0.07558s][GPU]Debug: vulkan version: 4198484
[Run time : 0.07620s][GPU]Debug: max viewports: 16
[Run time : 0.07680s][GPU]Debug: max tesselation level: 64
[Run time : 0.07743s][GPU]Debug: memory heap count: 2
[Run time : 0.07808s][GPU]Debug: vendor id: 4318
[Run time : 0.08448s][GPU]Debug: [Intel(R) UHD Graphics 630]
[Run time : 0.08767s][GPU]Debug: score: 34816
[Run time : 0.08877s][GPU]Debug: device type: integrated
[Run time : 0.09002s][GPU]Debug: driver version: 1644692
[Run time : 0.09115s][GPU]Debug: vulkan version: 4198482
[Run time : 0.09233s][GPU]Debug: max viewports: 16
[Run time : 0.09377s][GPU]Debug: max tesselation level: 64
[Run time : 0.09493s][GPU]Debug: memory heap count: 1
[Run time : 0.09597s][GPU]Debug: vendor id: 32902
[Run time : 0.09977s][GPU]Info: Using discrete graphics [GeForce GTX 1060]
[Run time : 0.67138s][Logical Device]Trace: Succesfully created logical device
[Run time : 0.95405s][Swap Chain]Trace: Succesfully created swap chain
[Run time : 0.95670s][Swap Chain]Trace: Succesfully created image views for swap chain
found obj file(resources/3d-models/common/cube.obj)
size of obj file resources/3d-models/common/cube.obj: 829
found obj file(resources/3d-models/sponza/sponza.obj)
size of obj file resources/3d-models/sponza/sponza.obj: 21109956
found obj file(resources/3d-models/common/example.obj)
size of obj file resources/3d-models/common/example.obj: 51671
[Run time : 28.05996s][Rendering]Trace: Succesfully created renderpass for swap chain
[Run time : 28.06264s][Rendering]Trace: Allocated command buffers
[Run time : 28.06549s][Rendering]Trace: Allocated command buffers
[Run time : 28.06832s][Rendering]Trace: Allocated command buffers
[Run time : 28.13745s][Uniform Buffer]Debug: success!, created descriptor set layout for uniform buffer
[Run time : 28.14002s][Uniform Buffer]Debug: success!, created descriptor pool
[Run time : 28.14322s][Uniform Buffer]Debug: allocated descriptor sets
[Run time : 28.15548s][Vk Validation]Error: Shader uses descriptor slot 0.1 but descriptor not accessible from stage VK_SHADER_STAGE_FRAGMENT_BIT
[Run time : 28.16189s][Rendering]Trace: Succesfully created graphics pipeline
[Run time : 28.16439s][Rendering]Trace: Allocated command buffers
[Run time : 28.16829s][Uniform Buffer]Debug: success!, created descriptor set layout for uniform buffer
[Run time : 28.17082s][Uniform Buffer]Debug: success!, created descriptor pool
[Run time : 28.17548s][Uniform Buffer]Debug: allocated descriptor sets
[Run time : 28.18030s][Rendering]Trace: Succesfully created graphics pipeline
[Run time : 28.18263s][Rendering]Trace: Allocated command buffers
[Run time : 28.18724s][Uniform Buffer]Debug: success!, created descriptor set layout for uniform buffer
[Run time : 28.18990s][Uniform Buffer]Debug: success!, created descriptor pool
[Run time : 28.19598s][Uniform Buffer]Debug: allocated descriptor sets
[Run time : 28.20237s][Rendering]Trace: Succesfully created graphics pipeline
[Run time : 28.20461s][Rendering]Trace: Allocated command buffers
submited command buffer
submited command buffer
device lost
[Run time : 28.50525s][Vk Validation]Error: Cannot call vkDestroyFramebuffer on VkFramebuffer 0x34[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to framebuffer must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyFramebuffer-framebuffer-00892)
[Run time : 28.50789s][Vk Validation]Error: Cannot call vkDestroyFramebuffer on VkFramebuffer 0x35[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to framebuffer must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyFramebuffer-framebuffer-00892)
[Run time : 28.51032s][Vk Validation]Error: Cannot call vkDestroyFramebuffer on VkFramebuffer 0x36[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to framebuffer must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyFramebuffer-framebuffer-00892)
[Run time : 28.51312s][Vk Validation]Error: Cannot call vkDestroyImageView on VkImageView 0x9[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to imageView must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyImageView-imageView-01026)
[Run time : 28.51778s][Vk Validation]Error: Cannot call vkDestroyImageView on VkImageView 0xa[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to imageView must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyImageView-imageView-01026)
[Run time : 28.52056s][Vk Validation]Error: Cannot call vkDestroyImageView on VkImageView 0xb[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to imageView must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyImageView-imageView-01026)
[Run time : 28.55500s][Vk Validation]Error: Attempt to reset VkCommandBuffer 0x2048fbb6340[] which is in use. The Vulkan spec states: commandBuffer must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkResetCommandBuffer-commandBuffer-00045)
[Run time : 28.55764s][Vk Validation]Error: Attempt to reset VkCommandBuffer 0x2048fb963b0[] which is in use. The Vulkan spec states: commandBuffer must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkResetCommandBuffer-commandBuffer-00045)
[Run time : 28.56087s][Vk Validation]Error: Attempt to reset VkCommandBuffer 0x2048fb97b10[] which is in use. The Vulkan spec states: commandBuffer must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkResetCommandBuffer-commandBuffer-00045)
[Run time : 28.56487s][Vk Validation]Error: Attempt to reset VkCommandBuffer 0x2048fb96fd0[] which is in use. The Vulkan spec states: commandBuffer must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkResetCommandBuffer-commandBuffer-00045)
[Run time : 28.57102s][Vk Validation]Error: Attempt to reset VkCommandBuffer 0x2048fbae220[] which is in use. The Vulkan spec states: commandBuffer must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkResetCommandBuffer-commandBuffer-00045)
[Run time : 28.57564s][Vk Validation]Error: Attempt to reset VkCommandBuffer 0x2048fbbf4a0[] which is in use. The Vulkan spec states: commandBuffer must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkResetCommandBuffer-commandBuffer-00045)
[Run time : 28.58219s][Vk Validation]Error: Cannot call vkDestroyRenderPass on VkRenderPass 0x33[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to renderPass must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyRenderPass-renderPass-00873)
[Run time : 28.58625s][Vk Validation]Error: Cannot call vkDestroyImageView on VkImageView 0x32[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to imageView must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyImageView-imageView-01026)
[Run time : 28.59076s][Vk Validation]Error: Cannot call vkDestroyImage on VkImage 0x30[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to image, either directly or via a VkImageView, must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyImage-image-01000)
[Run time : 28.59819s][Vk Validation]Error: Cannot call vkDestroyDescriptorPool on VkDescriptorPool 0x44[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to descriptorPool (via any allocated descriptor sets) must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyDescriptorPool-descriptorPool-00303)
[Run time : 28.60357s][Vk Validation]Error: Cannot call vkDestroyDescriptorPool on VkDescriptorPool 0x5d[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to descriptorPool (via any allocated descriptor sets) must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyDescriptorPool-descriptorPool-00303)
[Run time : 28.61071s][Vk Validation]Error: Cannot call vkDestroyDescriptorPool on VkDescriptorPool 0x76[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to descriptorPool (via any allocated descriptor sets) must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkDestroyDescriptorPool-descriptorPool-00303)
[Run time : 28.61863s][Vk Validation]Error: Attempt to free VkCommandBuffer 0x2048fb6d740[] which is in use. The Vulkan spec states: All elements of pCommandBuffers must not be in the pending state (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkFreeCommandBuffers-pCommandBuffers-00047)
[Run time : 28.62422s][Rendering]Trace: Succesfully created renderpass for swap chain
[Run time : 28.64659s][Swap Chain]Trace: Succesfully created swap chain
[Run time : 28.64906s][Swap Chain]Trace: Succesfully created image views for swap chain
[Run time : 28.65212s][Uniform Buffer]Debug: success!, created descriptor pool
[Run time : 28.65492s][Uniform Buffer]Debug: allocated descriptor sets
[Run time : 28.65860s][Uniform Buffer]Debug: success!, created descriptor pool
[Run time : 28.66277s][Uniform Buffer]Debug: allocated descriptor sets
[Run time : 28.66672s][Uniform Buffer]Debug: success!, created descriptor pool
[Run time : 28.66859s][Uniform Buffer]Debug: allocated descriptor sets
[Run time : 28.67708s][Vk Validation]Error: VkFence 0x2c[] is in use. The Vulkan spec states: Each element of pFences must not be currently associated with any queue command that has not yet completed execution on that queue (https://www.khronos.org/registry/vulkan/specs/1.1-extensions/html/vkspec.html#VUID-vkResetFences-pFences-01123)
failed to submit command buffer
最佳答案
所以我解决了它,显然设备丢失是由于我的输出中的描述符插槽 0.1 而发生的,我认为这不是问题的原因是因为它在我的旧计算机上工作,即使那个错误弹出。我想这对于不同的 GPU 是不同的。它现在按预期工作,感谢任何试图提供帮助的人。
关于c++ - vkWaitForFences 和 vkDeviceWaitIdle 不等待,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57748654/
我试图让脚本暂停大约 1 秒,然后继续执行脚本,但我似乎无法弄清楚如何做。这是我的代码: function hello() { alert("Hi!") //I need about a 1
wait() 和 wait(timeout) 之间有什么区别。无论如何 wait() 需要等待通知调用,但为什么我们有 wait(timeout)? 那么 sleep(timeout) 和 wait(
我需要做什么: 我有一个带有文件输入和隐藏文本输入的上传表单。用户上传图像,图像被操作,然后发送到远程服务器进行处理,这需要几秒钟,然后远程服务器将最终的图像发送回家庭服务器,并保存在新文件夹中。 J
大家好,我正在使用 Visual C++ 2010,尝试使用 Winsock 编写服务器/客户端应用程序...我不确定为什么,但有时服务器会在 listen() 函数处等待,有时会在 accept 处
任务描述 我为我的 Angular 应用程序实现了 CRSF 保护。服务器检查 crsf token 是否位于请求的 header “X-CSRF-TOKEN”中。如果不是,它会发送一个 HTTP 响
我想做这个例子https://stackoverflow.com/a/33585993/1973680同步。 这是正确的实现方式吗? let times= async (n,f)=>{
我如何将 while 循环延迟到 1 秒间隔,而不会将其运行的整个代码/计算机的速度减慢到一秒延迟(只是一个小循环)。 最佳答案 Thread.sleep(1000); // do nothing f
我知道这是一个重复的问题。但是我无法通过解释来理解。我想用一个很好的例子来清楚地理解它。任何人都可以帮忙吗。 “为什么我们从同步上下文中调用 wait()、notify() 方法”。 最佳答案 当我们
我有一个 click 事件,该事件是第一次从另一个地方自动触发的。我的问题是它运行得太快,因为所需的变量仍在由 Flash 和 Web 服务定义。所以现在我有: (function ($) {
我有如下功能 function async populateInventories(custID){ this.inventories = await this.inventoryServic
我一直对“然后”不被等待的行为感到困扰,我明白其原因。然而,我仍然需要绕过它。这是我的用例。 doWork(family) { return doWork1(family)
我想我理解异步背后的想法,返回一个Future,但是我不清楚异步在一个非常基本的层面上如何表现。据我了解,它不会自动在程序中创建异步行为。例如: import 'dart:async'; main()
我正在制作一个使用异步的Flutter应用程序,但它的工作方式不像我对它的了解。所以我对异步和在 Dart 中等待有一些疑问。这是一个例子: Future someFunction() async {
我在 main.tf 中创建资源组和 vNet,并在同一文件中引用模块。问题是,模块无法从模块访问这些资源。相关代码(删除了大部分代码,只留下相关部分): main.tf: module "worke
我的代码的问题是,当代码第一次运行时,我试图获取的 dom 元素并不总是存在,如果它不存在,那么永远不会做出 promise 。 我是否可以等到 promise 做出后再尝试实现它? 我希望我的最后一
所以,过去几天我一直在研究这段代码,并尝试实现回调/等待/任何需要的东西,但没有成功。 问题是,我如何等待响应,直到我得到两个函数的回调? (以及我将如何实现) 简而言之,我想做的是: POST 发生
谁能帮我理解这一点吗? 如果我们有一个类: public class Sample{ public synchronized method1(){ //Line1 .... wait();
这是我编写的代码,用于测试 wait() 和 notify() 的工作。现在我有很多疑问。 class A extends Thread { public void run() { try
我有以下代码由于语法错误而无法运行(在异步函数外等待) 如何使用 await 定义变量并将其导出? 当我这样定义一个变量并从其他文件导入它时,该变量是只创建一次(第一次读取文件时?)还是每次导入时都创
一个简单的线程程序,其中写入器将内容放入堆栈,读取器从堆栈中弹出。 java.util.Stack; import java.util.concurrent.ExecutorService; impo
我是一名优秀的程序员,十分优秀!