pick queueFamily programmatically

This commit is contained in:
nek0 2022-07-12 16:58:25 +02:00
parent 53c2fa9c92
commit 8fef9a4830

View file

@ -7,6 +7,8 @@ import Control.Monad
import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Resource
import qualified Data.Vector as V
import Data.Maybe (fromMaybe)
import Data.Bits
import Foreign.C.Types (CInt)
import Linear
import qualified Vulkan as Vk
@ -64,10 +66,22 @@ createLogicalDevice physDevice surface = do
putStrLn "There are currently following queue families available"
print queueFamiliyProperties
let graphicsQueueFamilies = V.foldl
(\acc (index, queueFamily) ->
if Vk.queueFlags queueFamily .&. Vk.QUEUE_GRAPHICS_BIT /= zeroBits
then Just index
else acc
)
Nothing
(V.zip (V.fromList [0..]) queueFamiliyProperties)
let priorities = V.singleton 1
extensionNames = V.singleton Vk.KHR_SWAPCHAIN_EXTENSION_NAME
queueCreateInfo = Vk.zero
{ Vk.queueFamilyIndex = 0
{ Vk.queueFamilyIndex =
fromMaybe
(error "createLogicalDevice: No suitable queu for graphics usage")
graphicsQueueFamilies
, Vk.queuePriorities = priorities
}
deviceCreateInfo = Vk.zero
@ -84,7 +98,7 @@ createLogicalDevice physDevice surface = do
(result, formats) <- Vk.getPhysicalDeviceSurfaceFormatsKHR physDevice surface
unless (result == Vk.SUCCESS) $
error "Failed retrieving surface image formats"
error "createLogicalDevice: Failed retrieving surface image formats"
return (logDevice, formats)