-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple #- SOURCE -# Annotation Fixes
- Loading branch information
Showing
8 changed files
with
155 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
ghengin-vulkan/ghengin-vulkan/Ghengin/Vulkan/Renderer/Buffer.hs-boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
-- | This module currently duplicates Buffer.hsig in ghengin-core, so it can be used in ghengin-vulkan | ||
module Ghengin.Vulkan.Renderer.Buffer where | ||
|
||
import Data.Word (Word, Word32) | ||
import Data.Int (Int32) | ||
import qualified Data.Vector.Storable as SV | ||
-- TODO:Exchange Vk specific types to renderer agnostic enumerations | ||
import qualified Vulkan as Vk (DescriptorType, BufferUsageFlags, Buffer, DeviceMemory) | ||
|
||
import {-# SOURCE #-} Ghengin.Vulkan.Renderer.Kernel | ||
import Ghengin.Core.Mesh.Vertex | ||
|
||
import Data.Linear.Alias (Aliasable) | ||
|
||
{- | ||
Note [Mapped vs Device-local Buffers] | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Mapped buffers are buffers of usage 'UNIFORM' (as in uniform buffer) which are | ||
mapped to a device-local buffer. Writing to a mapped buffer writes host-local | ||
memory which is synchronized automatically to the device-local memory. | ||
It is (probably?) faster to use a mapped buffer if you are writing it a lot. | ||
The alternative is a DeviceLocalBuffer such as a VertexBuffer, which is | ||
allocated on the device without being mapped to host-local memory. To write such | ||
a device-local buffer one needs to allocate a separate mapped buffer called a | ||
staging buffer and then issue a copy command from the staging buffer to the | ||
device-local buffer. Device-local buffers are more performant often, but writing | ||
to them seems much slower. | ||
In Vulkan at least. For some renderers this distinction might not exist... | ||
-} | ||
|
||
-------- Specific buffers -------------- | ||
|
||
data Index32Buffer where | ||
Index32Buffer :: !DeviceLocalBuffer | ||
⊸ Word32 -- ^ N indices | ||
-> Index32Buffer | ||
|
||
createIndex32Buffer :: SV.Vector Int32 -- ^ Indices | ||
-> Renderer Index32Buffer | ||
|
||
data VertexBuffer where | ||
VertexBuffer :: !DeviceLocalBuffer | ||
⊸ Word32 -- ^ N vertices | ||
-> VertexBuffer | ||
|
||
createVertexBuffer :: ∀ αs. SV.Storable (Vertex αs) | ||
=> SV.Vector (Vertex αs) -- ^ Vertices | ||
-> Renderer VertexBuffer | ||
|
||
-------- Device-local buffer ----------- | ||
|
||
data DeviceLocalBuffer where | ||
DeviceLocalBuffer :: {-# UNPACK #-} !Vk.Buffer | ||
⊸ {-# UNPACK #-} !Vk.DeviceMemory | ||
-- ⊸ Word -- Size | ||
⊸ DeviceLocalBuffer | ||
|
||
createDeviceLocalBuffer :: ∀ α. SV.Storable α => Vk.BufferUsageFlags -> SV.Vector α -> Renderer DeviceLocalBuffer | ||
|
||
destroyDeviceLocalBuffer :: DeviceLocalBuffer ⊸ Renderer () | ||
|
||
-------- Mapped Buffer ----------------- | ||
|
||
-- | A mapped (uniform) buffer. See Note [Mapped vs Device-local Buffers] | ||
data MappedBuffer | ||
instance Aliasable MappedBuffer | ||
|
||
-- | TODO: Drop dependency on Vulkan and make DescriptorType a data type renderer agnostic | ||
createMappedBuffer :: Word -> Vk.DescriptorType -> Renderer (Alias MappedBuffer) | ||
writeMappedBuffer :: ∀ α. SV.Storable α => Alias MappedBuffer ⊸ α -> Renderer (Alias MappedBuffer) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
ghengin-vulkan/ghengin-vulkan/Ghengin/Vulkan/Renderer/Kernel.hs-boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Ghengin.Vulkan.Renderer.Kernel where | ||
|
||
import Ghengin.Core.Prelude | ||
import Ghengin.Core.Log | ||
import Ghengin.Vulkan.Renderer.Device | ||
import qualified Prelude | ||
import qualified Vulkan as Vk | ||
import qualified Data.Linear.Alias as Alias | ||
|
||
type Alias = Alias.Alias Renderer | ||
data Renderer a | ||
instance Functor Renderer | ||
instance Applicative Renderer | ||
instance Monad Renderer | ||
instance MonadIO Renderer | ||
instance HasLogger Renderer | ||
|
||
copyBuffer :: Vk.Buffer ⊸ Vk.Buffer ⊸ Vk.DeviceSize -> Renderer (Vk.Buffer, Vk.Buffer) | ||
unsafeUseVulkanDevice :: (VulkanDevice -> Prelude.IO b) -> Renderer b | ||
unsafeUseDevice :: (Vk.Device -> Prelude.IO b) -> Renderer b |
12 changes: 12 additions & 0 deletions
12
ghengin-vulkan/ghengin-vulkan/Ghengin/Vulkan/Renderer/Pipeline.hs-boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module Ghengin.Vulkan.Renderer.Pipeline where | ||
|
||
import qualified Vulkan as Vk | ||
|
||
data RendererPipeline (t :: PipelineType) | ||
= VulkanPipeline { _pipeline :: Vk.Pipeline | ||
, _pipelineLayout :: Vk.PipelineLayout | ||
} | ||
|
||
-- ROMES:TODO: Type data | ||
data PipelineType = Graphics | Compute | ||
|
17 changes: 17 additions & 0 deletions
17
ghengin-vulkan/ghengin-vulkan/Ghengin/Vulkan/Renderer/RenderPass.hs-boot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Ghengin.Vulkan.Renderer.RenderPass where | ||
|
||
import qualified Vulkan as Vk | ||
import qualified Data.Vector as Vector | ||
|
||
data RenderPass = VulkanRenderPass { _renderPass :: Vk.RenderPass | ||
-- | We bundle framebuffer with the | ||
-- RenderPass because in rendering we have | ||
-- a fixed SwapChain so the Framebuffer is | ||
-- differentiated just from the rendering pass. | ||
-- That means that we have to create a | ||
-- framebuffer for all of the images | ||
-- in the swap chain and use the one | ||
-- that corresponds to the retrieved | ||
-- image at drawing time. | ||
, _framebuffers :: Vector.Vector Vk.Framebuffer | ||
} |