mirror of
https://github.com/Drezil/dear-imgui.hs.git
synced 2024-11-22 08:56:59 +00:00
Fix GHC-9.2 build (#145)
This commit is contained in:
parent
7d4f3a8b93
commit
08d4b423ad
@ -190,9 +190,9 @@ initialiseVulkanContext instanceType appName ( VulkanRequirements { instanceRequ
|
|||||||
device <- logDebug "Creating logical device" *>
|
device <- logDebug "Creating logical device" *>
|
||||||
Vulkan.Utils.createDeviceFromRequirements swapchainDeviceRequirements [] physicalDevice deviceCreateInfo
|
Vulkan.Utils.createDeviceFromRequirements swapchainDeviceRequirements [] physicalDevice deviceCreateInfo
|
||||||
queue <- Vulkan.getDeviceQueue device ( fromIntegral queueFamily ) 0
|
queue <- Vulkan.getDeviceQueue device ( fromIntegral queueFamily ) 0
|
||||||
|
|
||||||
pure ( VulkanContext { .. } )
|
pure ( VulkanContext { .. } )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vulkanInstanceInfo
|
vulkanInstanceInfo
|
||||||
@ -206,7 +206,7 @@ vulkanInstanceInfo appName = do
|
|||||||
let
|
let
|
||||||
validationLayer :: Maybe ValidationLayerName
|
validationLayer :: Maybe ValidationLayerName
|
||||||
validationLayer
|
validationLayer
|
||||||
= coerce
|
= coerce
|
||||||
. foldMap
|
. foldMap
|
||||||
( ( Vulkan.layerName :: Vulkan.LayerProperties -> ByteString )
|
( ( Vulkan.layerName :: Vulkan.LayerProperties -> ByteString )
|
||||||
>>> \case
|
>>> \case
|
||||||
@ -374,11 +374,10 @@ chooseSwapchainFormat
|
|||||||
|
|
||||||
case sortOn ( Down . score ) ( Boxed.Vector.toList surfaceFormats ) of
|
case sortOn ( Down . score ) ( Boxed.Vector.toList surfaceFormats ) of
|
||||||
[] -> error "No formats found."
|
[] -> error "No formats found."
|
||||||
( best : _ )
|
Vulkan.SurfaceFormatKHR{format=Vulkan.FORMAT_UNDEFINED} : _rest ->
|
||||||
| Vulkan.FORMAT_UNDEFINED <- ( Vulkan.format :: Vulkan.SurfaceFormatKHR -> Vulkan.Format ) best
|
pure preferredFormat
|
||||||
-> pure preferredFormat
|
best : _rest
|
||||||
| otherwise
|
-> pure best
|
||||||
-> pure best
|
|
||||||
|
|
||||||
where
|
where
|
||||||
match :: Eq a => a -> a -> Int
|
match :: Eq a => a -> a -> Int
|
||||||
@ -406,20 +405,17 @@ createSwapchain physicalDevice device surface surfaceFormat imageUsage imageCoun
|
|||||||
surfaceCapabilities <- Vulkan.getPhysicalDeviceSurfaceCapabilitiesKHR physicalDevice ( Vulkan.SurfaceKHR surface )
|
surfaceCapabilities <- Vulkan.getPhysicalDeviceSurfaceCapabilitiesKHR physicalDevice ( Vulkan.SurfaceKHR surface )
|
||||||
|
|
||||||
( _, presentModes ) <- Vulkan.getPhysicalDeviceSurfacePresentModesKHR physicalDevice ( Vulkan.SurfaceKHR surface )
|
( _, presentModes ) <- Vulkan.getPhysicalDeviceSurfacePresentModesKHR physicalDevice ( Vulkan.SurfaceKHR surface )
|
||||||
|
|
||||||
let
|
let
|
||||||
presentMode :: Vulkan.PresentModeKHR
|
presentMode :: Vulkan.PresentModeKHR
|
||||||
presentMode
|
presentMode
|
||||||
| Vulkan.PRESENT_MODE_MAILBOX_KHR `elem` presentModes
|
| Vulkan.PRESENT_MODE_MAILBOX_KHR `elem` presentModes
|
||||||
= Vulkan.PRESENT_MODE_MAILBOX_KHR
|
= Vulkan.PRESENT_MODE_MAILBOX_KHR
|
||||||
| otherwise
|
| otherwise
|
||||||
= Vulkan.PRESENT_MODE_FIFO_KHR
|
= Vulkan.PRESENT_MODE_FIFO_KHR
|
||||||
|
|
||||||
currentExtent :: Vulkan.Extent2D
|
Vulkan.SurfaceCapabilitiesKHR{currentExtent, currentTransform} = surfaceCapabilities
|
||||||
currentExtent = ( Vulkan.currentExtent :: Vulkan.SurfaceCapabilitiesKHR -> Vulkan.Extent2D ) surfaceCapabilities
|
Vulkan.SurfaceFormatKHR{format=fmt, colorSpace=csp} = surfaceFormat
|
||||||
|
|
||||||
currentTransform :: Vulkan.SurfaceTransformFlagBitsKHR
|
|
||||||
currentTransform = ( Vulkan.currentTransform :: Vulkan.SurfaceCapabilitiesKHR -> Vulkan.SurfaceTransformFlagBitsKHR ) surfaceCapabilities
|
|
||||||
|
|
||||||
swapchainCreateInfo :: Vulkan.SwapchainCreateInfoKHR '[]
|
swapchainCreateInfo :: Vulkan.SwapchainCreateInfoKHR '[]
|
||||||
swapchainCreateInfo =
|
swapchainCreateInfo =
|
||||||
@ -428,8 +424,8 @@ createSwapchain physicalDevice device surface surfaceFormat imageUsage imageCoun
|
|||||||
, Vulkan.flags = Vulkan.zero
|
, Vulkan.flags = Vulkan.zero
|
||||||
, Vulkan.surface = Vulkan.SurfaceKHR surface
|
, Vulkan.surface = Vulkan.SurfaceKHR surface
|
||||||
, Vulkan.minImageCount = imageCount
|
, Vulkan.minImageCount = imageCount
|
||||||
, Vulkan.imageFormat = ( Vulkan.format :: Vulkan.SurfaceFormatKHR -> Vulkan.Format ) surfaceFormat
|
, Vulkan.imageFormat = fmt
|
||||||
, Vulkan.imageColorSpace = ( Vulkan.colorSpace :: Vulkan.SurfaceFormatKHR -> Vulkan.ColorSpaceKHR ) surfaceFormat
|
, Vulkan.imageColorSpace = csp
|
||||||
, Vulkan.imageExtent = currentExtent
|
, Vulkan.imageExtent = currentExtent
|
||||||
, Vulkan.imageArrayLayers = 1
|
, Vulkan.imageArrayLayers = 1
|
||||||
, Vulkan.imageUsage = imageUsage
|
, Vulkan.imageUsage = imageUsage
|
||||||
@ -494,7 +490,7 @@ simpleRenderPass dev attachments = Vulkan.withRenderPass dev createInfo Nothing
|
|||||||
{ Vulkan.next = ()
|
{ Vulkan.next = ()
|
||||||
, Vulkan.flags = Vulkan.zero
|
, Vulkan.flags = Vulkan.zero
|
||||||
, Vulkan.attachments = Boxed.Vector.fromList attachmentDescriptions
|
, Vulkan.attachments = Boxed.Vector.fromList attachmentDescriptions
|
||||||
, Vulkan.subpasses = Boxed.Vector.singleton subpass
|
, Vulkan.subpasses = Boxed.Vector.singleton subpass
|
||||||
, Vulkan.dependencies = Boxed.Vector.fromList [ dependency1, dependency2 ]
|
, Vulkan.dependencies = Boxed.Vector.fromList [ dependency1, dependency2 ]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,7 +587,7 @@ createFramebuffer
|
|||||||
-> Vulkan.Extent2D
|
-> Vulkan.Extent2D
|
||||||
-> f Vulkan.ImageView
|
-> f Vulkan.ImageView
|
||||||
-> m ( ResourceT.ReleaseKey, Vulkan.Framebuffer )
|
-> m ( ResourceT.ReleaseKey, Vulkan.Framebuffer )
|
||||||
createFramebuffer dev renderPass extent attachments = Vulkan.withFramebuffer dev createInfo Nothing ResourceT.allocate
|
createFramebuffer dev renderPass Vulkan.Extent2D{width, height} attachments = Vulkan.withFramebuffer dev createInfo Nothing ResourceT.allocate
|
||||||
where
|
where
|
||||||
createInfo :: Vulkan.FramebufferCreateInfo '[]
|
createInfo :: Vulkan.FramebufferCreateInfo '[]
|
||||||
createInfo =
|
createInfo =
|
||||||
@ -600,8 +596,8 @@ createFramebuffer dev renderPass extent attachments = Vulkan.withFramebuffer dev
|
|||||||
, Vulkan.flags = Vulkan.zero
|
, Vulkan.flags = Vulkan.zero
|
||||||
, Vulkan.renderPass = renderPass
|
, Vulkan.renderPass = renderPass
|
||||||
, Vulkan.attachments = Boxed.Vector.fromList . toList $ attachments
|
, Vulkan.attachments = Boxed.Vector.fromList . toList $ attachments
|
||||||
, Vulkan.width = ( Vulkan.width :: Vulkan.Extent2D -> Word32 ) extent
|
, Vulkan.width = width
|
||||||
, Vulkan.height = ( Vulkan.height :: Vulkan.Extent2D -> Word32 ) extent
|
, Vulkan.height = height
|
||||||
, Vulkan.layers = 1
|
, Vulkan.layers = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,9 +201,7 @@ app = do
|
|||||||
surfaceCapabilities <- Vulkan.getPhysicalDeviceSurfaceCapabilitiesKHR physicalDevice ( Vulkan.SurfaceKHR surface )
|
surfaceCapabilities <- Vulkan.getPhysicalDeviceSurfaceCapabilitiesKHR physicalDevice ( Vulkan.SurfaceKHR surface )
|
||||||
|
|
||||||
let
|
let
|
||||||
minImageCount, maxImageCount, imageCount :: Word32
|
Vulkan.SurfaceCapabilitiesKHR{minImageCount, maxImageCount} = surfaceCapabilities
|
||||||
minImageCount = ( Vulkan.minImageCount :: Vulkan.SurfaceCapabilitiesKHR -> Word32 ) surfaceCapabilities
|
|
||||||
maxImageCount = ( Vulkan.maxImageCount :: Vulkan.SurfaceCapabilitiesKHR -> Word32 ) surfaceCapabilities
|
|
||||||
imageCount
|
imageCount
|
||||||
| maxImageCount == 0 = minImageCount + 1
|
| maxImageCount == 0 = minImageCount + 1
|
||||||
| otherwise = ( minImageCount + 1 ) `min` maxImageCount
|
| otherwise = ( minImageCount + 1 ) `min` maxImageCount
|
||||||
@ -213,31 +211,30 @@ app = do
|
|||||||
|
|
||||||
swapchainResources :: Maybe SwapchainResources -> m ( m (), SwapchainResources )
|
swapchainResources :: Maybe SwapchainResources -> m ( m (), SwapchainResources )
|
||||||
swapchainResources mbOldResources = do
|
swapchainResources mbOldResources = do
|
||||||
( surfaceFormat, imGuiRenderPass ) <- case mbOldResources of
|
( colFmt, surfaceFormat, imGuiRenderPass ) <- case mbOldResources of
|
||||||
Nothing -> do
|
Nothing -> do
|
||||||
logDebug "Choosing swapchain format & color space"
|
logDebug "Choosing swapchain format & color space"
|
||||||
surfaceFormat <- chooseSwapchainFormat preferredFormat physicalDevice surface
|
surfaceFormat <- chooseSwapchainFormat preferredFormat physicalDevice surface
|
||||||
let
|
let Vulkan.SurfaceFormatKHR{format=colFmt} = surfaceFormat
|
||||||
colFmt :: Vulkan.Format
|
|
||||||
colFmt = ( Vulkan.format :: Vulkan.SurfaceFormatKHR -> Vulkan.Format ) surfaceFormat
|
|
||||||
logDebug "Creating Dear ImGui render pass"
|
logDebug "Creating Dear ImGui render pass"
|
||||||
( _, imGuiRenderPass ) <-
|
( _, imGuiRenderPass ) <-
|
||||||
simpleRenderPass device
|
simpleRenderPass device
|
||||||
( noAttachments
|
( noAttachments
|
||||||
{ colorAttachments = Boxed.Vector.singleton $ presentableColorAttachmentDescription colFmt }
|
{ colorAttachments = Boxed.Vector.singleton $ presentableColorAttachmentDescription colFmt }
|
||||||
)
|
)
|
||||||
pure ( surfaceFormat, imGuiRenderPass )
|
pure ( colFmt, surfaceFormat, imGuiRenderPass )
|
||||||
Just oldResources -> pure ( surfaceFormat oldResources, imGuiRenderPass oldResources )
|
Just oldResources -> do
|
||||||
|
let surFmt = surfaceFormat oldResources
|
||||||
let
|
let Vulkan.SurfaceFormatKHR{format=colFmt} = surFmt
|
||||||
colFmt :: Vulkan.Format
|
pure ( colFmt, surFmt, imGuiRenderPass oldResources )
|
||||||
colFmt = ( Vulkan.format :: Vulkan.SurfaceFormatKHR -> Vulkan.Format ) surfaceFormat
|
|
||||||
|
|
||||||
logDebug "Creating swapchain"
|
logDebug "Creating swapchain"
|
||||||
( swapchainKey, swapchain, swapchainExtent ) <-
|
( swapchainKey, swapchain, swapchainExtent ) <-
|
||||||
createSwapchain
|
createSwapchain
|
||||||
physicalDevice device
|
physicalDevice
|
||||||
surface surfaceFormat
|
device
|
||||||
|
surface
|
||||||
|
surfaceFormat
|
||||||
surfaceUsage
|
surfaceUsage
|
||||||
imageCount
|
imageCount
|
||||||
( swapchain <$> mbOldResources )
|
( swapchain <$> mbOldResources )
|
||||||
|
@ -24,6 +24,10 @@ import Data.Traversable
|
|||||||
( for )
|
( for )
|
||||||
import Foreign.Storable
|
import Foreign.Storable
|
||||||
( Storable )
|
( Storable )
|
||||||
|
#if MIN_VERSION_template_haskell(2,18,0)
|
||||||
|
import Data.Coerce
|
||||||
|
( coerce )
|
||||||
|
#endif
|
||||||
|
|
||||||
-- containers
|
-- containers
|
||||||
import Data.Map.Strict
|
import Data.Map.Strict
|
||||||
@ -171,7 +175,7 @@ declareEnumeration finiteEnumName countName ( Enumeration {..} ) = do
|
|||||||
else
|
else
|
||||||
\ nm args dir pat ->
|
\ nm args dir pat ->
|
||||||
TH.patSynD_doc nm args dir pat
|
TH.patSynD_doc nm args dir pat
|
||||||
( Just $ Text.unpack patDoc ) []
|
( Just $ Text.unpack _patDoc ) []
|
||||||
)
|
)
|
||||||
#else
|
#else
|
||||||
TH.patSynD
|
TH.patSynD
|
||||||
|
Loading…
Reference in New Issue
Block a user