change shader container architecture
This commit is contained in:
parent
2219355483
commit
00e14ab6ea
3 changed files with 24 additions and 11 deletions
|
@ -170,13 +170,26 @@ createGraphicsPipelines
|
||||||
= do
|
= do
|
||||||
let pipelineStagesCreateInfos =
|
let pipelineStagesCreateInfos =
|
||||||
V.fromList $ map Vk.SomeStruct
|
V.fromList $ map Vk.SomeStruct
|
||||||
[ createShaderStageCreateInfo
|
( maybe
|
||||||
Vk.SHADER_STAGE_VERTEX_BIT
|
[]
|
||||||
|
(\shader ->
|
||||||
|
[ createShaderStageCreateInfo
|
||||||
|
Vk.SHADER_STAGE_VERTEX_BIT
|
||||||
|
shader
|
||||||
|
]
|
||||||
|
)
|
||||||
(containedVertexShader shaderContainer)
|
(containedVertexShader shaderContainer)
|
||||||
, createShaderStageCreateInfo
|
++
|
||||||
Vk.SHADER_STAGE_FRAGMENT_BIT
|
maybe
|
||||||
|
[]
|
||||||
|
(\shader ->
|
||||||
|
[ createShaderStageCreateInfo
|
||||||
|
Vk.SHADER_STAGE_FRAGMENT_BIT
|
||||||
|
shader
|
||||||
|
]
|
||||||
|
)
|
||||||
(containedFragmentShader shaderContainer)
|
(containedFragmentShader shaderContainer)
|
||||||
]
|
)
|
||||||
dynamicStates =
|
dynamicStates =
|
||||||
V.fromList
|
V.fromList
|
||||||
[ Vk.DYNAMIC_STATE_VIEWPORT
|
[ Vk.DYNAMIC_STATE_VIEWPORT
|
||||||
|
@ -231,7 +244,7 @@ createGraphicsPipelines
|
||||||
Just $ createVertexInputAssemblyStateCreateInfo VK.PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
|
Just $ createVertexInputAssemblyStateCreateInfo VK.PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
|
||||||
, Vk.viewportState = Just $ Vk.SomeStruct pipelineViewportStateCreateInfo
|
, Vk.viewportState = Just $ Vk.SomeStruct pipelineViewportStateCreateInfo
|
||||||
, Vk.rasterizationState = Just $ createRasterizationStateCreateInfo Vk.POLYGON_MODE_FILL
|
, Vk.rasterizationState = Just $ createRasterizationStateCreateInfo Vk.POLYGON_MODE_FILL
|
||||||
, Vk.multisampleState = Just $ createMultisampleStateCreateInfo
|
, Vk.multisampleState = Just createMultisampleStateCreateInfo
|
||||||
, Vk.colorBlendState = Just $ Vk.SomeStruct pipelineColorBlendStateCreateInfo
|
, Vk.colorBlendState = Just $ Vk.SomeStruct pipelineColorBlendStateCreateInfo
|
||||||
, Vk.dynamicState = Just pipelineDynamicStateCreateInfo
|
, Vk.dynamicState = Just pipelineDynamicStateCreateInfo
|
||||||
, Vk.layout = pipelineLayout
|
, Vk.layout = pipelineLayout
|
||||||
|
@ -249,7 +262,7 @@ createGraphicsPipelines
|
||||||
(V.replicate number (Vk.SomeStruct pipelineCreateInfo))
|
(V.replicate number (Vk.SomeStruct pipelineCreateInfo))
|
||||||
Nothing
|
Nothing
|
||||||
unless (result == Vk.SUCCESS) $
|
unless (result == Vk.SUCCESS) $
|
||||||
error "createGraphicsPiepelines: Failed creating pipelines"
|
error "createGraphicsPipelines: Failed creating pipelines"
|
||||||
return pipelines
|
return pipelines
|
||||||
)
|
)
|
||||||
(\pipelines -> do
|
(\pipelines -> do
|
||||||
|
|
|
@ -90,8 +90,8 @@ initVulkan window = do
|
||||||
rainbowFragmentShader <- loadShader vulkanLogicalDevice "shadersrc/rainbow.frag" "frag"
|
rainbowFragmentShader <- loadShader vulkanLogicalDevice "shadersrc/rainbow.frag" "frag"
|
||||||
renderPass <- createRenderPass vulkanLogicalDevice (Khr.format surfaceFormat)
|
renderPass <- createRenderPass vulkanLogicalDevice (Khr.format surfaceFormat)
|
||||||
pipelineLayout <- createPipelineLayout vulkanLogicalDevice
|
pipelineLayout <- createPipelineLayout vulkanLogicalDevice
|
||||||
let redContainer = ShaderContainer redVertexShader redFragmentShader
|
let redContainer = ShaderContainer (Just redVertexShader) (Just redFragmentShader)
|
||||||
let rainbowContainer = ShaderContainer rainbowVertexShader rainbowFragmentShader
|
let rainbowContainer = ShaderContainer (Just rainbowVertexShader) (Just rainbowFragmentShader)
|
||||||
redPipelines <-
|
redPipelines <-
|
||||||
createGraphicsPipelines
|
createGraphicsPipelines
|
||||||
vulkanLogicalDevice
|
vulkanLogicalDevice
|
||||||
|
|
|
@ -10,8 +10,8 @@ import qualified Vulkan as Vk
|
||||||
import qualified VulkanMemoryAllocator as VMA
|
import qualified VulkanMemoryAllocator as VMA
|
||||||
|
|
||||||
data ShaderContainer = ShaderContainer
|
data ShaderContainer = ShaderContainer
|
||||||
{ containedVertexShader :: Vk.ShaderModule
|
{ containedVertexShader :: Maybe Vk.ShaderModule
|
||||||
, containedFragmentShader :: Vk.ShaderModule
|
, containedFragmentShader :: Maybe Vk.ShaderModule
|
||||||
}
|
}
|
||||||
deriving (Show)
|
deriving (Show)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue