Harden Vulkan setup for discrete GPUs
This commit is contained in:
@@ -266,6 +266,22 @@ void V210ComputeDecoder::createFeedResources(
|
|||||||
<< " flags=0x" << std::hex << feed.v210MemoryProperties
|
<< " flags=0x" << std::hex << feed.v210MemoryProperties
|
||||||
<< std::dec << std::endl;
|
<< std::dec << std::endl;
|
||||||
|
|
||||||
|
VkFormatProperties outputFormatProperties{};
|
||||||
|
vkGetPhysicalDeviceFormatProperties(
|
||||||
|
physicalDevice,
|
||||||
|
VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
|
&outputFormatProperties);
|
||||||
|
const VkFormatFeatureFlags requiredOutputFeatures =
|
||||||
|
VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT |
|
||||||
|
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||||
|
if ((outputFormatProperties.optimalTilingFeatures &
|
||||||
|
requiredOutputFeatures) != requiredOutputFeatures)
|
||||||
|
{
|
||||||
|
throw std::runtime_error(
|
||||||
|
"VK_FORMAT_R8G8B8A8_UNORM does not support sampled "
|
||||||
|
"storage images on this GPU");
|
||||||
|
}
|
||||||
|
|
||||||
createImage(
|
createImage(
|
||||||
m_device,
|
m_device,
|
||||||
physicalDevice,
|
physicalDevice,
|
||||||
|
|||||||
+4
-2
@@ -30,8 +30,10 @@ QueueFamilyIndices findQueueFamilies(
|
|||||||
|
|
||||||
for (uint32_t i = 0; i < queueFamilyCount; ++i)
|
for (uint32_t i = 0; i < queueFamilyCount; ++i)
|
||||||
{
|
{
|
||||||
if (queueFamilies[i].queueFlags &
|
if ((queueFamilies[i].queueFlags &
|
||||||
VK_QUEUE_GRAPHICS_BIT)
|
VK_QUEUE_GRAPHICS_BIT) &&
|
||||||
|
(queueFamilies[i].queueFlags &
|
||||||
|
VK_QUEUE_COMPUTE_BIT))
|
||||||
{
|
{
|
||||||
indices.graphicsFamily = i;
|
indices.graphicsFamily = i;
|
||||||
}
|
}
|
||||||
|
|||||||
+29
-6
@@ -117,7 +117,10 @@ void createBuffer(
|
|||||||
throw std::runtime_error("Failed to allocate buffer memory");
|
throw std::runtime_error("Failed to allocate buffer memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
vkBindBufferMemory(device, buffer, bufferMemory, 0);
|
if (vkBindBufferMemory(device, buffer, bufferMemory, 0) != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to bind buffer memory");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void createBufferWithPreferredMemory(
|
void createBufferWithPreferredMemory(
|
||||||
@@ -161,7 +164,10 @@ void createBufferWithPreferredMemory(
|
|||||||
throw std::runtime_error("Failed to allocate buffer memory");
|
throw std::runtime_error("Failed to allocate buffer memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
vkBindBufferMemory(device, buffer, bufferMemory, 0);
|
if (vkBindBufferMemory(device, buffer, bufferMemory, 0) != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to bind buffer memory");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VkCommandBuffer beginSingleTimeCommands(
|
VkCommandBuffer beginSingleTimeCommands(
|
||||||
@@ -192,15 +198,29 @@ void endSingleTimeCommands(
|
|||||||
VkQueue graphicsQueue,
|
VkQueue graphicsQueue,
|
||||||
VkCommandBuffer commandBuffer)
|
VkCommandBuffer commandBuffer)
|
||||||
{
|
{
|
||||||
vkEndCommandBuffer(commandBuffer);
|
if (vkEndCommandBuffer(commandBuffer) != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to end one-time command buffer");
|
||||||
|
}
|
||||||
|
|
||||||
VkSubmitInfo submitInfo{};
|
VkSubmitInfo submitInfo{};
|
||||||
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||||
submitInfo.commandBufferCount = 1;
|
submitInfo.commandBufferCount = 1;
|
||||||
submitInfo.pCommandBuffers = &commandBuffer;
|
submitInfo.pCommandBuffers = &commandBuffer;
|
||||||
|
|
||||||
vkQueueSubmit(graphicsQueue, 1, &submitInfo, VK_NULL_HANDLE);
|
if (vkQueueSubmit(
|
||||||
vkQueueWaitIdle(graphicsQueue);
|
graphicsQueue,
|
||||||
|
1,
|
||||||
|
&submitInfo,
|
||||||
|
VK_NULL_HANDLE) != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to submit one-time command buffer");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vkQueueWaitIdle(graphicsQueue) != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to wait for one-time command buffer");
|
||||||
|
}
|
||||||
|
|
||||||
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
vkFreeCommandBuffers(device, commandPool, 1, &commandBuffer);
|
||||||
}
|
}
|
||||||
@@ -254,7 +274,10 @@ void createImage(
|
|||||||
throw std::runtime_error("Failed to allocate image memory");
|
throw std::runtime_error("Failed to allocate image memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
vkBindImageMemory(device, image, imageMemory, 0);
|
if (vkBindImageMemory(device, image, imageMemory, 0) != VK_SUCCESS)
|
||||||
|
{
|
||||||
|
throw std::runtime_error("Failed to bind image memory");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void recordImageLayoutTransition(
|
void recordImageLayoutTransition(
|
||||||
|
|||||||
Reference in New Issue
Block a user