pick queueFamily programmatically
This commit is contained in:
parent
53c2fa9c92
commit
8fef9a4830
1 changed files with 16 additions and 2 deletions
|
@ -7,6 +7,8 @@ import Control.Monad
|
||||||
import Control.Monad.IO.Class (liftIO)
|
import Control.Monad.IO.Class (liftIO)
|
||||||
import Control.Monad.Trans.Resource
|
import Control.Monad.Trans.Resource
|
||||||
import qualified Data.Vector as V
|
import qualified Data.Vector as V
|
||||||
|
import Data.Maybe (fromMaybe)
|
||||||
|
import Data.Bits
|
||||||
import Foreign.C.Types (CInt)
|
import Foreign.C.Types (CInt)
|
||||||
import Linear
|
import Linear
|
||||||
import qualified Vulkan as Vk
|
import qualified Vulkan as Vk
|
||||||
|
@ -64,10 +66,22 @@ createLogicalDevice physDevice surface = do
|
||||||
putStrLn "There are currently following queue families available"
|
putStrLn "There are currently following queue families available"
|
||||||
print queueFamiliyProperties
|
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
|
let priorities = V.singleton 1
|
||||||
extensionNames = V.singleton Vk.KHR_SWAPCHAIN_EXTENSION_NAME
|
extensionNames = V.singleton Vk.KHR_SWAPCHAIN_EXTENSION_NAME
|
||||||
queueCreateInfo = Vk.zero
|
queueCreateInfo = Vk.zero
|
||||||
{ Vk.queueFamilyIndex = 0
|
{ Vk.queueFamilyIndex =
|
||||||
|
fromMaybe
|
||||||
|
(error "createLogicalDevice: No suitable queu for graphics usage")
|
||||||
|
graphicsQueueFamilies
|
||||||
, Vk.queuePriorities = priorities
|
, Vk.queuePriorities = priorities
|
||||||
}
|
}
|
||||||
deviceCreateInfo = Vk.zero
|
deviceCreateInfo = Vk.zero
|
||||||
|
@ -84,7 +98,7 @@ createLogicalDevice physDevice surface = do
|
||||||
|
|
||||||
(result, formats) <- Vk.getPhysicalDeviceSurfaceFormatsKHR physDevice surface
|
(result, formats) <- Vk.getPhysicalDeviceSurfaceFormatsKHR physDevice surface
|
||||||
unless (result == Vk.SUCCESS) $
|
unless (result == Vk.SUCCESS) $
|
||||||
error "Failed retrieving surface image formats"
|
error "createLogicalDevice: Failed retrieving surface image formats"
|
||||||
|
|
||||||
return (logDevice, formats)
|
return (logDevice, formats)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue