Skip to content

Commit

Permalink
Merge pull request #207 from expipiplus1/joe-rays
Browse files Browse the repository at this point in the history
Initial working version of ray tracing,
  • Loading branch information
expipiplus1 authored Nov 30, 2020
2 parents 7c06931 + 1c7584a commit 9093e15
Show file tree
Hide file tree
Showing 63 changed files with 7,496 additions and 351 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ jobs:

- run: |
if command -v glslc &> /dev/null; then
cabal configure -fgeneric-instances -fhave-shaderc
cabal configure -fgeneric-instances -f-raytracing -fhave-shaderc
else
echo "glslc could not be found"
cabal configure -fgeneric-instances -f-have-shaderc
cabal configure -fgeneric-instances -f-raytracing -f-have-shaderc
fi
shell: bash
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-20.04, macOS-latest, windows-latest]
stack-args: ['--flag vulkan:generic-instances --flag VulkanMemoryAllocator:generic-instances --flag vulkan-examples:-have-shaderc --system-ghc']
stack-args: ['--flag vulkan:generic-instances --flag VulkanMemoryAllocator:generic-instances --flag vulkan-examples:-raytracing --flag vulkan-examples:-have-shaderc --system-ghc']
exclude:
# https://github.com/actions/setup-haskell/issues/49
- os: windows-latest
Expand Down
6 changes: 2 additions & 4 deletions VulkanMemoryAllocator/VulkanMemoryAllocator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ cabal-version: 2.2
-- This file has been generated from package.yaml by hpack version 0.34.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: fcf45270da7fe44091b7dee466087cd52abed25e68532b85a04a30915dd1da94

name: VulkanMemoryAllocator
version: 0.3.10
version: 0.3.11
synopsis: Bindings to the VulkanMemoryAllocator library
category: Graphics
homepage: https://github.com/expipiplus1/vulkan#readme
Expand Down Expand Up @@ -65,7 +63,7 @@ library
, bytestring
, transformers
, vector
, vulkan >=3.6 && <3.8
, vulkan >=3.6 && <3.9
if flag(safe-foreign-calls)
cpp-options: -DSAFE_FOREIGN_CALLS
if flag(vma-ndebug)
Expand Down
4 changes: 4 additions & 0 deletions VulkanMemoryAllocator/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## WIP

## [0.3.11] - 2020-11-30

- Raise upper bound on `vulkan`

## [0.3.10] - 2020-11-24

- Documentation fixes
Expand Down
4 changes: 2 additions & 2 deletions VulkanMemoryAllocator/package.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: VulkanMemoryAllocator
version: "0.3.10"
version: "0.3.11"
synopsis: Bindings to the VulkanMemoryAllocator library
category: Graphics
maintainer: Joe Hermaszewski <[email protected]>
Expand All @@ -20,7 +20,7 @@ library:
src/lib.cpp
dependencies:
- base <5
- vulkan >= 3.6 && < 3.8
- vulkan >= 3.6 && < 3.9
- bytestring
- transformers
- vector
Expand Down
5 changes: 5 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ source-repository-package
location: https://github.com/expipiplus1/brittany.git
tag: b80f77c36bda563665c616abbdb1eaaf35b1da1c

source-repository-package
type: git
location: https://github.com/expipiplus1/derive-storable-plugin.git
tag: e98e5835913e50a10cf8545af9a1f29f84a9d15a

allow-newer: strict
10 changes: 9 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Change Log

## WIP
- Bump API version to v1.2.163

## [3.8] - 2020-11-30

- Bump API version to v1.2.163
- Add `Vulkan.Requirement`, a module for specifying requirements for `Device`s
and `Instance`s
- Expose SPIR-V Extensions and Capabilities in `Vulkan.SPIRVRequirements`
- Expose extension dependencies in `Vulkan.Extensions.Dependencies`
- Squash some warnings

Thanks to @sheaf for their help with this release!

## [3.7] - 2020-11-24
- Bump API version to v1.2.162
- This is a breaking change to anyone using VK_KHR_ray_tracing (which no
Expand Down
3 changes: 3 additions & 0 deletions examples/hie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ cradle:

- path: "./hlsl/"
component: "exe:hlsl"

- path: "./rays/"
component: "exe:rays"
27 changes: 16 additions & 11 deletions examples/hlsl/Init.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE QuasiQuotes #-}
module Init
( Init.createInstance
, Init.createDevice
Expand All @@ -14,8 +15,6 @@ import Data.Word
import Say
import UnliftIO.Exception
import Vulkan.Core12.Promoted_From_VK_KHR_timeline_semaphore
( PhysicalDeviceTimelineSemaphoreFeatures(..)
)
import Vulkan.Extensions.VK_KHR_timeline_semaphore

import Control.Applicative
Expand All @@ -39,8 +38,10 @@ import Vulkan.Core10 as Vk
import Vulkan.Extensions.VK_KHR_get_physical_device_properties2
import Vulkan.Extensions.VK_KHR_surface
import Vulkan.Extensions.VK_KHR_swapchain
import Vulkan.Requirement
import Vulkan.Utils.Initialization
import Vulkan.Utils.QueueAssignment
import qualified Vulkan.Utils.Requirements.TH as U
import Vulkan.Zero
import VulkanMemoryAllocator ( Allocator
, AllocatorCreateInfo(..)
Expand All @@ -65,10 +66,12 @@ createInstance win = do
, apiVersion = myApiVersion
}
}
extensions =
[KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME]
<> windowExtensions
createDebugInstanceWithExtensions [] [] extensions [] createInfo
reqs =
(\n -> RequireInstanceExtension Nothing n minBound)
<$> ( KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME
: windowExtensions
)
createDebugInstanceFromRequirements reqs [] createInfo

----------------------------------------------------------------
-- Device creation
Expand All @@ -93,11 +96,13 @@ createDevice inst win = do
sayErr . ("Using device: " <>) =<< physicalDeviceName phys
let deviceCreateInfo =
zero { queueCreateInfos = SomeStruct <$> pdiQueueCreateInfos pdi }
::& PhysicalDeviceTimelineSemaphoreFeatures True
:& ()
extensions =
[KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME, KHR_SWAPCHAIN_EXTENSION_NAME]
dev <- createDeviceWithExtensions phys [] extensions deviceCreateInfo
reqs = [U.reqs|
1.0
VK_KHR_swapchain
VK_KHR_timeline_semaphore
PhysicalDeviceTimelineSemaphoreFeatures.timelineSemaphore
|]
dev <- createDeviceFromRequirements reqs [] phys deviceCreateInfo
requireCommands inst dev
queues <- liftIO $ pdiGetQueues pdi dev
pure (phys, dev, queues, surf)
Expand Down
11 changes: 9 additions & 2 deletions examples/hlsl/MonadFrame.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,15 @@ runFrame f@Frame {..} (F r) = runReaderT r f `finally` do
, values = V.fromList (snd <$> waits)
}
waitSemaphoresSafe' waitInfo oneSecond >>= \case
TIMEOUT ->
timeoutError "Timed out (1s) waiting for frame to finish on Device"
TIMEOUT -> do
-- Give the frame one last chance to complete,
-- It could be that the program was suspended during the preceding
-- wait causing it to timeout, this will check if it actually
-- finished.
waitSemaphores' waitInfo 0 >>= \case
TIMEOUT -> timeoutError
"Timed out (1s) waiting for frame to finish on Device"
_ -> pure ()
_ -> pure ()

-- Free resources wanted elsewhere now, all those in RecycledResources
Expand Down
13 changes: 5 additions & 8 deletions examples/info/Main.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module Main
where
module Main where

import Control.Exception
import Data.Foldable
Expand All @@ -25,11 +24,9 @@ deviceInfo p = do
traverse_ myPrint layers
myPrint =<< getPhysicalDeviceFeatures p
myPrint =<< getPhysicalDeviceProperties p
myPrint =<< getPhysicalDeviceMemoryProperties p

myPrint :: Show a => a -> IO ()
myPrint =
pPrintOpt
CheckColorTty
defaultOutputOptionsDarkBg
{ outputOptionsStringStyle = Literal
}
myPrint = pPrintOpt
CheckColorTty
defaultOutputOptionsDarkBg { outputOptionsStringStyle = Literal }
44 changes: 38 additions & 6 deletions examples/package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,42 @@ executables:
- vector
- vulkan
- vulkan-utils >= 0.3
- file-embed
- extra
- filepath
- temporary
- typed-process
when:
- condition: impl(ghc < 8.10.0)
buildable: false
- condition: '!flag(have-shaderc)'
buildable: false

rays:
main: Main.hs
source-dirs: rays
dependencies:
- VulkanMemoryAllocator
- autoapply >= 0.4
- base <5
- bytestring
- containers
- lens
- linear
- primitive-unlifted
- resourcet >= 1.2.4
- say
- sdl2 >= 2.5.2.0
- template-haskell
- text
- derive-storable >= 0.3
- derive-storable-plugin
- transformers
- unagi-chan
- unliftio
- vector
- vulkan >= 3.7
- vulkan-utils >= 0.3
when:
- condition: impl(ghc < 8.10.0)
buildable: false
- condition: '!flag(raytracing)'
buildable: false

when:
- condition: os(windows)
Expand All @@ -158,7 +183,14 @@ flags:
have-shaderc:
description:
Set this flag if you have shaderc (and the glslc executable) installed.
It enables the examples which use HLSL shaders.
It enables building the examples which use HLSL shaders.
default: yes
manual: yes
raytracing:
description:
Set this flag if you have a version of glslValidator recent enough to
compile ray tracing shaders. It enables building the examples which use
ray tracing.
default: yes
manual: yes

Expand Down
Loading

0 comments on commit 9093e15

Please sign in to comment.