module Render.Unlit.Colored.Pipeline ( Pipeline , allocate , allocateWireframe , Config , config , configWireframe , stageCode , stageSpirv ) where import RIO import Control.Monad.Trans.Resource (ResourceT) import Data.Tagged (Tagged(..)) import Vulkan.Core10 qualified as Vk import Engine.Vulkan.Pipeline.Graphics qualified as Graphics import Engine.Vulkan.Types (HasVulkan, HasRenderPass(..), DsBindings) import Render.Code (compileVert, compileFrag) import Render.DescSets.Set0 (Scene, vertexPos, instanceTransform) import Render.Unlit.Colored.Code qualified as Code import Render.Unlit.Colored.Model qualified as Model type Pipeline = Graphics.Pipeline '[Scene] Model.VertexAttrs Model.InstanceAttrs type Config = Graphics.Configure Pipeline type instance Graphics.Specialization Pipeline = () allocate :: ( HasVulkan env , HasRenderPass renderpass ) => Bool -> Vk.SampleCountFlagBits -> Tagged Scene DsBindings -> renderpass -> ResourceT (RIO env) Pipeline allocate :: forall env renderpass. (HasVulkan env, HasRenderPass renderpass) => Bool -> SampleCountFlagBits -> Tagged Scene DsBindings -> renderpass -> ResourceT (RIO env) Pipeline allocate Bool useDepth SampleCountFlagBits multisample Tagged Scene DsBindings tset0 renderpass rp = do (ReleaseKey _, Pipeline p) <- Maybe Extent2D -> SampleCountFlagBits -> Config '[Scene] Vec4 Transform () -> renderpass -> ResourceT (RIO env) (ReleaseKey, Pipeline) forall config pipeline (dsl :: [*]) vertices instances spec env (m :: * -> *) renderpass. (config ~ Configure pipeline, pipeline ~ Pipeline dsl vertices instances, spec ~ Specialization pipeline, Specialization spec, HasCallStack, MonadVulkan env m, MonadResource m, HasRenderPass renderpass) => Maybe Extent2D -> SampleCountFlagBits -> Config dsl vertices instances spec -> renderpass -> m (ReleaseKey, pipeline) Graphics.allocate Maybe Extent2D forall a. Maybe a Nothing SampleCountFlagBits multisample (Bool -> Tagged Scene DsBindings -> Configure Pipeline config Bool useDepth Tagged Scene DsBindings tset0) renderpass rp Pipeline -> ResourceT (RIO env) Pipeline forall (f :: * -> *) a. Applicative f => a -> f a pure Pipeline p allocateWireframe :: ( HasVulkan env , HasRenderPass renderpass ) => Bool -> Vk.SampleCountFlagBits -> Tagged Scene DsBindings -> renderpass -> ResourceT (RIO env) Pipeline allocateWireframe :: forall env renderpass. (HasVulkan env, HasRenderPass renderpass) => Bool -> SampleCountFlagBits -> Tagged Scene DsBindings -> renderpass -> ResourceT (RIO env) Pipeline allocateWireframe Bool useDepth SampleCountFlagBits multisample Tagged Scene DsBindings tset0 renderpass rp = do (ReleaseKey _, Pipeline p) <- Maybe Extent2D -> SampleCountFlagBits -> Config '[Scene] Vec4 Transform () -> renderpass -> ResourceT (RIO env) (ReleaseKey, Pipeline) forall config pipeline (dsl :: [*]) vertices instances spec env (m :: * -> *) renderpass. (config ~ Configure pipeline, pipeline ~ Pipeline dsl vertices instances, spec ~ Specialization pipeline, Specialization spec, HasCallStack, MonadVulkan env m, MonadResource m, HasRenderPass renderpass) => Maybe Extent2D -> SampleCountFlagBits -> Config dsl vertices instances spec -> renderpass -> m (ReleaseKey, pipeline) Graphics.allocate Maybe Extent2D forall a. Maybe a Nothing SampleCountFlagBits multisample (Bool -> Tagged Scene DsBindings -> Configure Pipeline configWireframe Bool useDepth Tagged Scene DsBindings tset0) renderpass rp Pipeline -> ResourceT (RIO env) Pipeline forall (f :: * -> *) a. Applicative f => a -> f a pure Pipeline p config :: Bool -> Tagged Scene DsBindings -> Config config :: Bool -> Tagged Scene DsBindings -> Configure Pipeline config Bool useDepth (Tagged DsBindings set0) = Config '[] Any Any () forall vertices instances. Config '[] vertices instances () Graphics.baseConfig { $sel:cDescLayouts:Config :: Tagged '[Scene] [DsBindings] Graphics.cDescLayouts = forall {s :: [*]} {b}. b -> Tagged s b forall {k} (s :: k) b. b -> Tagged s b Tagged @'[Scene] [DsBindings set0] , $sel:cStages:Config :: StageSpirv Graphics.cStages = StageSpirv stageSpirv , $sel:cVertexInput:Config :: SomeStruct PipelineVertexInputStateCreateInfo Graphics.cVertexInput = SomeStruct PipelineVertexInputStateCreateInfo vertexInput , $sel:cBlend:Config :: Bool Graphics.cBlend = Bool True , $sel:cDepthTest:Config :: Bool Graphics.cDepthTest = Bool useDepth , $sel:cDepthWrite:Config :: Bool Graphics.cDepthWrite = Bool useDepth } where vertexInput :: SomeStruct PipelineVertexInputStateCreateInfo vertexInput = [(VertexInputRate, [Format])] -> SomeStruct PipelineVertexInputStateCreateInfo Graphics.vertexInput [ (VertexInputRate, [Format]) vertexPos , (VertexInputRate Vk.VERTEX_INPUT_RATE_VERTEX, [Format] Model.vkVertexAttrs) , (VertexInputRate, [Format]) instanceTransform ] stageCode :: Graphics.StageCode stageCode :: StageCode stageCode = ("vert" ::: Code) -> ("vert" ::: Code) -> StageCode forall a. ("vert" ::: a) -> ("vert" ::: a) -> Stages (Maybe ("vert" ::: a)) Graphics.basicStages "vert" ::: Code Code.vert "vert" ::: Code Code.frag stageSpirv :: Graphics.StageSpirv stageSpirv :: StageSpirv stageSpirv = ("vert" ::: ByteString) -> ("vert" ::: ByteString) -> StageSpirv forall a. ("vert" ::: a) -> ("vert" ::: a) -> Stages (Maybe ("vert" ::: a)) Graphics.basicStages "vert" ::: ByteString vertSpirv "vert" ::: ByteString fragSpirv vertSpirv :: ByteString vertSpirv :: "vert" ::: ByteString vertSpirv = $(compileVert Code.vert) fragSpirv :: ByteString fragSpirv :: "vert" ::: ByteString fragSpirv = $(compileFrag Code.frag) configWireframe :: Bool -> Tagged Scene DsBindings -> Config configWireframe :: Bool -> Tagged Scene DsBindings -> Configure Pipeline configWireframe Bool useDepth Tagged Scene DsBindings tset0 = (Bool -> Tagged Scene DsBindings -> Configure Pipeline config Bool useDepth Tagged Scene DsBindings tset0) { $sel:cTopology:Config :: PrimitiveTopology Graphics.cTopology = PrimitiveTopology Vk.PRIMITIVE_TOPOLOGY_LINE_LIST }