change shader container architecture

This commit is contained in:
nek0 2022-12-02 20:02:01 +01:00
parent 2219355483
commit 00e14ab6ea
3 changed files with 24 additions and 11 deletions

View file

@ -170,13 +170,26 @@ createGraphicsPipelines
= do
let pipelineStagesCreateInfos =
V.fromList $ map Vk.SomeStruct
[ createShaderStageCreateInfo
Vk.SHADER_STAGE_VERTEX_BIT
( maybe
[]
(\shader ->
[ createShaderStageCreateInfo
Vk.SHADER_STAGE_VERTEX_BIT
shader
]
)
(containedVertexShader shaderContainer)
, createShaderStageCreateInfo
Vk.SHADER_STAGE_FRAGMENT_BIT
++
maybe
[]
(\shader ->
[ createShaderStageCreateInfo
Vk.SHADER_STAGE_FRAGMENT_BIT
shader
]
)
(containedFragmentShader shaderContainer)
]
)
dynamicStates =
V.fromList
[ Vk.DYNAMIC_STATE_VIEWPORT
@ -231,7 +244,7 @@ createGraphicsPipelines
Just $ createVertexInputAssemblyStateCreateInfo VK.PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
, Vk.viewportState = Just $ Vk.SomeStruct pipelineViewportStateCreateInfo
, Vk.rasterizationState = Just $ createRasterizationStateCreateInfo Vk.POLYGON_MODE_FILL
, Vk.multisampleState = Just $ createMultisampleStateCreateInfo
, Vk.multisampleState = Just createMultisampleStateCreateInfo
, Vk.colorBlendState = Just $ Vk.SomeStruct pipelineColorBlendStateCreateInfo
, Vk.dynamicState = Just pipelineDynamicStateCreateInfo
, Vk.layout = pipelineLayout
@ -249,7 +262,7 @@ createGraphicsPipelines
(V.replicate number (Vk.SomeStruct pipelineCreateInfo))
Nothing
unless (result == Vk.SUCCESS) $
error "createGraphicsPiepelines: Failed creating pipelines"
error "createGraphicsPipelines: Failed creating pipelines"
return pipelines
)
(\pipelines -> do

View file

@ -90,8 +90,8 @@ initVulkan window = do
rainbowFragmentShader <- loadShader vulkanLogicalDevice "shadersrc/rainbow.frag" "frag"
renderPass <- createRenderPass vulkanLogicalDevice (Khr.format surfaceFormat)
pipelineLayout <- createPipelineLayout vulkanLogicalDevice
let redContainer = ShaderContainer redVertexShader redFragmentShader
let rainbowContainer = ShaderContainer rainbowVertexShader rainbowFragmentShader
let redContainer = ShaderContainer (Just redVertexShader) (Just redFragmentShader)
let rainbowContainer = ShaderContainer (Just rainbowVertexShader) (Just rainbowFragmentShader)
redPipelines <-
createGraphicsPipelines
vulkanLogicalDevice

View file

@ -10,8 +10,8 @@ import qualified Vulkan as Vk
import qualified VulkanMemoryAllocator as VMA
data ShaderContainer = ShaderContainer
{ containedVertexShader :: Vk.ShaderModule
, containedFragmentShader :: Vk.ShaderModule
{ containedVertexShader :: Maybe Vk.ShaderModule
, containedFragmentShader :: Maybe Vk.ShaderModule
}
deriving (Show)