detach some create info creation
This commit is contained in:
parent
68645fc5de
commit
d8eba446a1
2 changed files with 57 additions and 39 deletions
|
@ -19,6 +19,8 @@ import qualified Vulkan.Utils.ShaderQQ.GLSL.Shaderc as Vk
|
||||||
|
|
||||||
-- internal imports
|
-- internal imports
|
||||||
import Types
|
import Types
|
||||||
|
import qualified Vulkan as VK
|
||||||
|
import qualified Vulkan.CStruct.Extends as VK
|
||||||
|
|
||||||
loadShader
|
loadShader
|
||||||
:: (MonadResource m)
|
:: (MonadResource m)
|
||||||
|
@ -104,13 +106,56 @@ createRenderPass
|
||||||
Vk.destroyRenderPass logicalDevice renderPass Nothing
|
Vk.destroyRenderPass logicalDevice renderPass Nothing
|
||||||
)
|
)
|
||||||
|
|
||||||
|
createShaderStageCreateInfo
|
||||||
|
:: Vk.ShaderStageFlagBits
|
||||||
|
-> Vk.ShaderModule
|
||||||
|
-> Vk.PipelineShaderStageCreateInfo '[]
|
||||||
|
createShaderStageCreateInfo stageBit shaderModule =
|
||||||
|
Vk.zero
|
||||||
|
{ Vk.stage = stageBit
|
||||||
|
, Vk.module' = shaderModule
|
||||||
|
, Vk.name = "main"
|
||||||
|
}
|
||||||
|
|
||||||
|
createVertexInputAssemblyStateCreateInfo
|
||||||
|
:: Vk.PrimitiveTopology
|
||||||
|
-> Vk.PipelineInputAssemblyStateCreateInfo
|
||||||
|
createVertexInputAssemblyStateCreateInfo topology =
|
||||||
|
Vk.zero
|
||||||
|
{ Vk.topology = topology
|
||||||
|
, Vk.primitiveRestartEnable = False
|
||||||
|
}
|
||||||
|
|
||||||
|
createRasterizationStateCreateInfo
|
||||||
|
:: Vk.PolygonMode
|
||||||
|
-> VK.SomeStruct Vk.PipelineRasterizationStateCreateInfo
|
||||||
|
createRasterizationStateCreateInfo mode =
|
||||||
|
Vk.SomeStruct $ Vk.zero
|
||||||
|
{ Vk.depthClampEnable = False
|
||||||
|
, Vk.rasterizerDiscardEnable = False
|
||||||
|
, Vk.polygonMode = mode
|
||||||
|
, Vk.lineWidth = 1
|
||||||
|
, Vk.cullMode = Vk.CULL_MODE_NONE
|
||||||
|
, Vk.frontFace = Vk.FRONT_FACE_CLOCKWISE
|
||||||
|
, Vk.depthBiasEnable = False
|
||||||
|
, Vk.depthBiasConstantFactor = 0
|
||||||
|
, Vk.depthBiasClamp = 0
|
||||||
|
, Vk.depthBiasSlopeFactor = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
createMultisampleStateCreateInfo
|
||||||
|
:: Vk.SomeStruct Vk.PipelineMultisampleStateCreateInfo
|
||||||
|
createMultisampleStateCreateInfo =
|
||||||
|
Vk.SomeStruct $ Vk.zero
|
||||||
|
{ Vk.sampleShadingEnable = False
|
||||||
|
, Vk.rasterizationSamples = Vk.SAMPLE_COUNT_1_BIT
|
||||||
|
}
|
||||||
|
|
||||||
createGraphicsPipelines
|
createGraphicsPipelines
|
||||||
:: (MonadResource m)
|
:: (MonadResource m)
|
||||||
=> Vk.Device
|
=> Vk.Device
|
||||||
-> Vk.RenderPass
|
-> Vk.RenderPass
|
||||||
-> ShaderContainer
|
-> ShaderContainer
|
||||||
-> BS.ByteString
|
|
||||||
-> V2 CInt
|
-> V2 CInt
|
||||||
-> Int
|
-> Int
|
||||||
-> Vk.PipelineLayout
|
-> Vk.PipelineLayout
|
||||||
|
@ -119,25 +164,18 @@ createGraphicsPipelines
|
||||||
logicalDevice
|
logicalDevice
|
||||||
renderPass
|
renderPass
|
||||||
shaderContainer
|
shaderContainer
|
||||||
stageName
|
|
||||||
(V2 width height)
|
(V2 width height)
|
||||||
number
|
number
|
||||||
pipelineLayout
|
pipelineLayout
|
||||||
= do
|
= do
|
||||||
let vertexShaderStageCreateInfo = Vk.zero
|
let pipelineStagesCreateInfos =
|
||||||
{ Vk.stage = Vk.SHADER_STAGE_VERTEX_BIT
|
|
||||||
, Vk.module' = containedVertexShader shaderContainer
|
|
||||||
, Vk.name = stageName
|
|
||||||
}
|
|
||||||
fragmentShaderStageCreateInfo = Vk.zero
|
|
||||||
{ Vk.stage = Vk.SHADER_STAGE_FRAGMENT_BIT
|
|
||||||
, Vk.module' = containedFragmentShader shaderContainer
|
|
||||||
, Vk.name = stageName
|
|
||||||
}
|
|
||||||
pipelineStagesCreateInfos =
|
|
||||||
V.fromList $ map Vk.SomeStruct
|
V.fromList $ map Vk.SomeStruct
|
||||||
[ vertexShaderStageCreateInfo
|
[ createShaderStageCreateInfo
|
||||||
, fragmentShaderStageCreateInfo
|
Vk.SHADER_STAGE_VERTEX_BIT
|
||||||
|
(containedVertexShader shaderContainer)
|
||||||
|
, createShaderStageCreateInfo
|
||||||
|
Vk.SHADER_STAGE_FRAGMENT_BIT
|
||||||
|
(containedFragmentShader shaderContainer)
|
||||||
]
|
]
|
||||||
dynamicStates =
|
dynamicStates =
|
||||||
V.fromList
|
V.fromList
|
||||||
|
@ -151,10 +189,6 @@ createGraphicsPipelines
|
||||||
{ Vk.vertexBindingDescriptions = V.empty -- Fill me?
|
{ Vk.vertexBindingDescriptions = V.empty -- Fill me?
|
||||||
, Vk.vertexAttributeDescriptions = V.empty -- Fill me?
|
, Vk.vertexAttributeDescriptions = V.empty -- Fill me?
|
||||||
}
|
}
|
||||||
pipelineInputAssemblyStateCreateInfo = Vk.zero
|
|
||||||
{ Vk.topology = Vk.PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
|
|
||||||
, Vk.primitiveRestartEnable = False
|
|
||||||
}
|
|
||||||
viewport = Vk.Viewport
|
viewport = Vk.Viewport
|
||||||
{ Vk.x = 0
|
{ Vk.x = 0
|
||||||
, Vk.y = 0
|
, Vk.y = 0
|
||||||
|
@ -171,22 +205,6 @@ createGraphicsPipelines
|
||||||
{ Vk.viewports = V.singleton viewport
|
{ Vk.viewports = V.singleton viewport
|
||||||
, Vk.scissors = V.singleton scissor
|
, Vk.scissors = V.singleton scissor
|
||||||
}
|
}
|
||||||
pipelineRasterizationStateCreateInfo = Vk.zero
|
|
||||||
{ Vk.depthClampEnable = False
|
|
||||||
, Vk.rasterizerDiscardEnable = False
|
|
||||||
, Vk.polygonMode = Vk.POLYGON_MODE_FILL
|
|
||||||
, Vk.lineWidth = 1
|
|
||||||
, Vk.cullMode = Vk.CULL_MODE_BACK_BIT
|
|
||||||
, Vk.frontFace = Vk.FRONT_FACE_CLOCKWISE
|
|
||||||
, Vk.depthBiasEnable = False
|
|
||||||
, Vk.depthBiasConstantFactor = 0
|
|
||||||
, Vk.depthBiasClamp = 0
|
|
||||||
, Vk.depthBiasSlopeFactor = 0
|
|
||||||
}
|
|
||||||
pipelineMultisamplingCreateInfo = Vk.zero
|
|
||||||
{ Vk.sampleShadingEnable = False
|
|
||||||
, Vk.rasterizationSamples = Vk.SAMPLE_COUNT_1_BIT
|
|
||||||
}
|
|
||||||
colorBlendAttachment = Vk.zero
|
colorBlendAttachment = Vk.zero
|
||||||
{ Vk.colorWriteMask =
|
{ Vk.colorWriteMask =
|
||||||
Vk.COLOR_COMPONENT_R_BIT .|.
|
Vk.COLOR_COMPONENT_R_BIT .|.
|
||||||
|
@ -209,10 +227,11 @@ createGraphicsPipelines
|
||||||
{ Vk.stageCount = 2
|
{ Vk.stageCount = 2
|
||||||
, Vk.stages = pipelineStagesCreateInfos
|
, Vk.stages = pipelineStagesCreateInfos
|
||||||
, Vk.vertexInputState = Just $ Vk.SomeStruct pipelineVertexInputCreateInfo
|
, Vk.vertexInputState = Just $ Vk.SomeStruct pipelineVertexInputCreateInfo
|
||||||
, Vk.inputAssemblyState = Just pipelineInputAssemblyStateCreateInfo
|
, Vk.inputAssemblyState =
|
||||||
|
Just $ createVertexInputAssemblyStateCreateInfo VK.PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
|
||||||
, Vk.viewportState = Just $ Vk.SomeStruct pipelineViewportStateCreateInfo
|
, Vk.viewportState = Just $ Vk.SomeStruct pipelineViewportStateCreateInfo
|
||||||
, Vk.rasterizationState = Just $ Vk.SomeStruct pipelineRasterizationStateCreateInfo
|
, Vk.rasterizationState = Just $ createRasterizationStateCreateInfo Vk.POLYGON_MODE_FILL
|
||||||
, Vk.multisampleState = Just $ Vk.SomeStruct pipelineMultisamplingCreateInfo
|
, 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
|
||||||
|
|
|
@ -88,7 +88,6 @@ initVulkan window = do
|
||||||
vulkanLogicalDevice
|
vulkanLogicalDevice
|
||||||
renderPass
|
renderPass
|
||||||
shaderContainer
|
shaderContainer
|
||||||
"main"
|
|
||||||
dimensions
|
dimensions
|
||||||
(length imageViews)
|
(length imageViews)
|
||||||
pipelineLayout
|
pipelineLayout
|
||||||
|
|
Loading…
Reference in a new issue