KrOoze, somehow I didn’t get notified about your message, so I put together my own version. Looks about the same as yours. I notice in your code there are no VkImageMemoryBarrier calls to change the format of the frame buffer. Are those optional?
Anyway, I still have the same problem. Works fine on NVidia, and performance is terrible on Radeon. Any idea what the problem can be?
Here’s my latest loop and the command buffer.
// Get the index of the next available swapchain image:
err = AcquireNextImageKHR(m_device, m_swapChain, UINT64_MAX, m_acquireComplete,
(VkFence) VK_NULL_HANDLE,
&m_currentBuffer);
VkSubmitInfo submitInfo;
memset(&submitInfo, 0, sizeof(submitInfo));
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
submitInfo.pNext = NULL;
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = &m_acquireComplete;
VkPipelineStageFlags waitFlags = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
submitInfo.pWaitDstStageMask = &waitFlags;
submitInfo.signalSemaphoreCount = 1;
submitInfo.pSignalSemaphores = &m_submitComplete;
submitInfo.commandBufferCount = 1;
submitInfo.pCommandBuffers = &m_buffers[m_currentBuffer].cmd;
err = vkQueueSubmit(m_queue, 1, &submitInfo, (VkFence) VK_NULL_HANDLE);
assert(!err);
VkPresentInfoKHR presentInfo;
memset(&presentInfo, 0, sizeof(presentInfo));
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.pNext = NULL;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = &m_submitComplete;
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = &m_swapChain;
presentInfo.pImageIndices = &m_currentBuffer;
err = QueuePresentKHR(m_queue, &presentInfo);
The command buffer looks like this: I’ve removed some of the structure elements for brevity.
VkImageMemoryBarrier barrier;
barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
barrier.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
0, 0, NULL, 0, NULL, 1, &barrier);
// begin render pass
vkCmdBeginRenderPass(cmdBuf, &passBegin, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS, m_pipeline);
vkCmdBindDescriptorSets(cmdBuf, VK_PIPELINE_BIND_POINT_GRAPHICS,
m_pipelineLayout, 0, 1, &m_descSet, 0, NULL);
// set viewport and scissor
vkCmdSetViewport(cmdBuf, 0, 1, &viewport);
vkCmdSetScissor(cmdBuf, 0, 1, &scissor);
VkDeviceSize offsets[1] = {0};
vkCmdBindVertexBuffers(cmdBuf, VERTEX_BUFFER_BIND_ID, 1, &m_vertices.buf, offsets);
vkCmdBindVertexBuffers(cmdBuf, INSTANCE_BUFFER_BIND_ID, 1, &m_instances.buf, offsets);
vkCmdBindIndexBuffer(cmdBuf, m_indexes.buf, 0, VK_INDEX_TYPE_UINT32);
vkCmdDrawIndexed(cmdBuf, 6 * 6, m_cubeCountm_cubeCountm_cubeCount, 0, 0, 0);
vkCmdEndRenderPass(cmdBuf);
VkImageMemoryBarrier barrier;
barrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
barrier.image = m_buffers[m_currentBuffer].image;
vkCmdPipelineBarrier(cmdBuf, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0,
NULL, 1, &barrier);
So what is wrong with this??