tinker around to hopefully get all layers needed

This commit is contained in:
nek0 2023-01-26 06:46:55 +01:00
parent 79a4fea655
commit dce40ecf08
3 changed files with 16 additions and 50 deletions

View file

@ -35,8 +35,13 @@
cabal-install cabal-install
]) ++ (with pkgs; [ ]) ++ (with pkgs; [
shaderc shaderc
vulkan-loader
vulkan-validation-layers
]); ]);
SDL_VULKAN_LIBRARY = "${pkgs.vulkan-loader}/lib/libvulkan.so"; shellHook = ''
export VK_LAYER_PATH="${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
export SDL_VULKAN_LIBRARY="${pkgs.vulkan-loader}/lib/libvulkan.so";
'';
}; };
#devShell = pkgs.mkShell { #devShell = pkgs.mkShell {
# buildInputs = with haskellPackages; [ # buildInputs = with haskellPackages; [

View file

@ -38,7 +38,7 @@ initEngine
initEngine = do initEngine = do
-- initialize SDL2 with all subsystems -- initialize SDL2 with all subsystems
void $ allocate_ void $ allocate_
(SDL.initialize [ SDL.InitVideo ]) SDL.initializeAll
(do (do
putStrLn "This is the end!" putStrLn "This is the end!"
SDL.quit SDL.quit

View file

@ -10,67 +10,28 @@ import qualified Data.Vector as V
import qualified SDL hiding (V2) import qualified SDL hiding (V2)
import qualified SDL.Video.Vulkan as SDL import qualified SDL.Video.Vulkan as SDL
import qualified Vulkan as Vk import qualified Vulkan as Vk
import qualified Vulkan.Requirement as Vk
import qualified Vulkan.Zero as Vk import qualified Vulkan.Zero as Vk
import qualified Vulkan.Utils.Initialization as VkU
createInstance :: MonadResource m => SDL.Window -> m Vk.Instance createInstance :: MonadResource m => SDL.Window -> m Vk.Instance
createInstance window = do createInstance window = do
windowExtensions <- windowExtensions <- liftIO $ fmap (
(++)
-- [ Vk.KHR_PUSH_DESCRIPTOR_EXTENSION_NAME
-- , Vk.EXT_DEBUG_UTILS_EXTENSION_NAME
-- ]
[ Vk.EXT_DEBUG_UTILS_EXTENSION_NAME [ Vk.EXT_DEBUG_UTILS_EXTENSION_NAME
] ] ++) $
<$> traverse BS.packCString =<< SDL.vkGetInstanceExtensions window
((liftIO . mapM BS.packCString) =<< SDL.vkGetInstanceExtensions window) liftIO $ do
-- liftIO $ do putStrLn "activating following extensions:"
-- putStrLn "activating followinfg extensions:" print windowExtensions
-- print windowExtensions
let createInfo = Vk.zero let createInfo = Vk.zero
{ Vk.applicationInfo = Just Vk.zero { Vk.applicationInfo = Just Vk.zero
{ Vk.applicationName = Just "Haskell ❤️ Vulkan" { Vk.applicationName = Just "Haskell ❤️ Vulkan"
, Vk.apiVersion = Vk.API_VERSION_1_2 , Vk.apiVersion = Vk.API_VERSION_1_3
} }
-- enable debug util extension for debugging purposes -- enable debug util extension for debugging purposes
, Vk.enabledExtensionNames = V.fromList windowExtensions , Vk.enabledExtensionNames = V.fromList windowExtensions
-- enable validation layer for debugging purposes -- enable validation layer for debugging purposes
, Vk.enabledLayerNames = V.fromList , Vk.enabledLayerNames = V.singleton "VK_LAYER_KHRONOS_validation"
[ "VK_LAYER_KHRONOS_validation"
]
} }
requirements =
[ Vk.RequireInstanceExtension
{ Vk.instanceExtensionLayerName = Nothing
, Vk.instanceExtensionName = Vk.KHR_GET_DISPLAY_PROPERTIES_2_EXTENSION_NAME
, Vk.instanceExtensionMinVersion = Vk.KHR_GET_DISPLAY_PROPERTIES_2_SPEC_VERSION
}
, Vk.RequireInstanceExtension
{ Vk.instanceExtensionLayerName = Nothing
, Vk.instanceExtensionName = Vk.KHR_XLIB_SURFACE_EXTENSION_NAME
, Vk.instanceExtensionMinVersion = Vk.KHR_XLIB_SURFACE_SPEC_VERSION
}
, Vk.RequireInstanceExtension
{ Vk.instanceExtensionLayerName = Nothing
, Vk.instanceExtensionName = Vk.KHR_DISPLAY_EXTENSION_NAME
, Vk.instanceExtensionMinVersion = Vk.KHR_DISPLAY_SPEC_VERSION
}
, Vk.RequireInstanceExtension
{ Vk.instanceExtensionLayerName = Nothing
, Vk.instanceExtensionName = Vk.KHR_SURFACE_EXTENSION_NAME
, Vk.instanceExtensionMinVersion = Vk.KHR_SURFACE_SPEC_VERSION
}
, Vk.RequireInstanceExtension
{ Vk.instanceExtensionLayerName = Nothing
, Vk.instanceExtensionName = Vk.KHR_PUSH_DESCRIPTOR_EXTENSION_NAME
, Vk.instanceExtensionMinVersion = Vk.KHR_PUSH_DESCRIPTOR_SPEC_VERSION
}
]
SDL.vkLoadLibrary Nothing
-- VkU.createDebugInstanceFromRequirements requirements [] createInfo
(_, inst) <- allocate (_, inst) <- allocate
(Vk.createInstance createInfo Nothing) (Vk.createInstance createInfo Nothing)
(\inst -> do (\inst -> do