@@ -14,49 +14,16 @@ export import :utilities;
1414export namespace vk {
1515 inline namespace v1 {
1616
17- // VkPipelineInputAssemblyStateCreateInfo input_assembly = {
18- // .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
19- // .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
20- // .primitiveRestartEnable = VK_FALSE,
21- // };
2217 struct input_assembly_state {
2318 const enum primitive_topology topology = primitive_topology::triangle_list;
2419 bool primitive_restart_enable = false ;
2520 };
2621
27- // VkPipelineViewportStateCreateInfo viewport_state = {
28- // .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
29- // .viewportCount = 1,
30- // .scissorCount = 1,
31- // };
3222 struct viewport_state {
3323 uint8_t viewport_count= 1 ;
3424 uint8_t scissor_count = 1 ;
3525 };
3626
37- // VkPipelineRasterizationStateCreateInfo rasterizer_ci = {
38- // .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
39- // .depthClampEnable = false,
40- // .rasterizerDiscardEnable =
41- // false, // set to true make fragmenta that are beyond near/far
42- // // planes clamped to them as opposed to discarding them
43- // .polygonMode =
44- // VK_POLYGON_MODE_FILL, // if set to true then geometry never passes
45- // // through rasterizer stage. This basically
46- // // disables output to frame_buffer
47- // .cullMode = VK_CULL_MODE_NONE, // determines what culling to use.
48- // // Can also be disabled, culls
49- // // front-face, back-face or both
50- // .frontFace =
51- // VK_FRONT_FACE_COUNTER_CLOCKWISE, // specifies vertex order of
52- // // fdaces considered front-face
53- // // or clockwise/counter-clockwise
54- // .depthBiasEnable = false,
55- // .depthBiasConstantFactor = 0.0f, // Optional
56- // .depthBiasClamp = 0.0f, // Optional
57- // .depthBiasSlopeFactor = 0.0f, // Optional
58- // .lineWidth = 1.f
59- // };
6027 struct rasterization_state {
6128 bool depth_clamp_enabled = false ;
6229 bool rasterizer_discard_enabled = false ;
@@ -70,16 +37,6 @@ export namespace vk {
7037 float line_width = 1 .f;
7138 };
7239
73- // VkPipelineMultisampleStateCreateInfo multisampling_ci = {
74- // .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
75- // .rasterizationSamples = VK_SAMPLE_COUNT_1_BIT,
76- // .sampleShadingEnable = false,
77- // // .minSampleShading = 1.0f, // Optional
78- // // .pSampleMask = nullptr, // Optional
79- // // .alphaToCoverageEnable = VK_FALSE, // Optional
80- // // .alphaToOneEnable = VK_FALSE, // Optional
81- // };
82-
8340 struct multisample_state {
8441 sample_bit rasterization_samples=sample_bit::count_1;
8542 bool shading_enabled=false ;
@@ -89,17 +46,6 @@ export namespace vk {
8946 bool alpha_to_one_enable=false ; // optional
9047 };
9148
92- // VkPipelineColorBlendAttachmentState color_blend_attachment = {
93- // .blendEnable = true,
94- // .srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA, // Enabled: alpha blending
95- // .dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, // Enabled: alpha blending
96- // .colorBlendOp = VK_BLEND_OP_ADD, // Enabled: alpha blending
97- // .srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE, // Enabled: alpha blending
98- // .dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO, // Enabled: alpha blending
99- // .alphaBlendOp = VK_BLEND_OP_ADD, // Enabled: alpha blending
100- // .colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
101- // };
102-
10349 struct color_blend_attachment_state {
10450 bool blend_enabled = true ;
10551 blend_factor src_color_blend_factor=blend_factor::src_alpha;
@@ -111,31 +57,13 @@ export namespace vk {
11157 uint32_t color_write_mask = color_component::red | color_component::green | color_component::blue | color_component::alpha;
11258 };
11359
114- // VkPipelineColorBlendStateCreateInfo color_blending_ci = {
115- // .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
116- // .logicOpEnable = VK_FALSE,
117- // .logicOp = VK_LOGIC_OP_COPY, // Optional
118- // .attachmentCount = 1,
119- // .pAttachments = &color_blend_attachment,
120- // // these are optional
121- // .blendConstants = { 0.f, 0.f, 0.f, 0.f } // optional
122- // };
123-
12460 struct color_blend_state {
12561 bool logic_op_enable=false ;
12662 logical_op logical_op = logical_op::copy;
12763 std::span<const color_blend_attachment_state> attachments;
12864 std::span<float > blend_constants;
12965 };
13066
131- // VkPipelineDepthStencilStateCreateInfo pipeline_deth_stencil_state_ci = {
132- // .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
133- // .depthTestEnable = true,
134- // .depthWriteEnable = true,
135- // .depthCompareOp = VK_COMPARE_OP_LESS,
136- // .depthBoundsTestEnable = false,
137- // .stencilTestEnable = false,
138- // };
13967 struct depth_stencil_state {
14068 bool depth_test_enable = true ;
14169 bool depth_write_enable = true ;
@@ -145,23 +73,6 @@ export namespace vk {
14573 };
14674
14775
148- // ! @note Dynamic State
149- // ! @note -- pipeline states needs to be baked into the pipeline state
150- // std::array<VkDynamicState, 2> dynamic_states = {
151- // VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR
152- // };
153-
154- // VkPipelineDynamicStateCreateInfo dynamic_state_ci = {
155- // .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
156- // .dynamicStateCount = static_cast<uint32_t>(dynamic_states.size()),
157- // .pDynamicStates = dynamic_states.data()
158- // };
159-
160- // struct dynamic_state_configure {
161- // std::span<dynamic_state> dynamic_states = {};
162- // };
163-
164-
16576 /* *
16677 * @param renderpass is required for a VkPipeline to know up front
16778 * @param shader_modules is a std::span<VkShaderModule> of the loaded shader
@@ -265,57 +176,20 @@ export namespace vk {
265176 .pVertexAttributeDescriptions = attributes.data ()
266177 };
267178
268- // VkPipelineInputAssemblyStateCreateInfo input_assembly = {
269- // .sType =
270- // VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
271- // .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST,
272- // .primitiveRestartEnable = VK_FALSE,
273- // };
274179 VkPipelineInputAssemblyStateCreateInfo input_assembly = {
275180 .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
276181 .topology = static_cast <VkPrimitiveTopology>(p_info.input_assembly .topology ),
277182 .primitiveRestartEnable = p_info.input_assembly .primitive_restart_enable ,
278183 };
279184
280- // VkPipelineViewportStateCreateInfo viewport_state = {
281- // .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
282- // .viewportCount = 1,
283- // .scissorCount = 1,
284- // };
285-
286185 VkPipelineViewportStateCreateInfo viewport_state = {
287186 .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
288187 .viewportCount = p_info.viewport .viewport_count ,
289188 .scissorCount = p_info.viewport .scissor_count ,
290189 };
291190
292-
293- // ! @note Rasterization
294- // Keep in mind: if lineWidth is zero, validation layers will occur
191+ // if lineWidth is zero, validation layers will occur
295192 // because cant be zero. Must be set to 1.0f
296- // VkPipelineRasterizationStateCreateInfo rasterizer_ci = {
297- // .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
298- // .depthClampEnable = false,
299- // .rasterizerDiscardEnable =
300- // false, // set to true make fragmenta that are beyond near/far
301- // // planes clamped to them as opposed to discarding them
302- // .polygonMode =
303- // VK_POLYGON_MODE_FILL, // if set to true then geometry never passes
304- // // through rasterizer stage. This basically
305- // // disables output to frame_buffer
306- // .cullMode = VK_CULL_MODE_NONE, // determines what culling to use.
307- // // Can also be disabled, culls
308- // // front-face, back-face or both
309- // .frontFace =
310- // VK_FRONT_FACE_COUNTER_CLOCKWISE, // specifies vertex order of
311- // // fdaces considered front-face
312- // // or clockwise/counter-clockwise
313- // .depthBiasEnable = false,
314- // .depthBiasConstantFactor = 0.0f, // Optional
315- // .depthBiasClamp = 0.0f, // Optional
316- // .depthBiasSlopeFactor = 0.0f, // Optional
317- // .lineWidth = 1.f
318- // };
319193 VkPipelineRasterizationStateCreateInfo rasterizer_ci = {
320194 .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
321195 .depthClampEnable = p_info.rasterization .depth_clamp_enabled ,
@@ -330,19 +204,6 @@ export namespace vk {
330204 .lineWidth = p_info.rasterization .line_width
331205 };
332206
333-
334- // ! @note Multi-sampling
335- // p_info.rasterization
336- // VkPipelineMultisampleStateCreateInfo multisampling_ci = {
337- // .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
338- // .rasterizationSamples = VK_SAMPLE_COUNT_1_BIT,
339- // .sampleShadingEnable = false,
340- // // .minSampleShading = 1.0f, // Optional
341- // // .pSampleMask = nullptr, // Optional
342- // // .alphaToCoverageEnable = VK_FALSE, // Optional
343- // // .alphaToOneEnable = VK_FALSE, // Optional
344- // };
345-
346207 VkPipelineMultisampleStateCreateInfo multisampling_ci = {
347208 .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
348209 .rasterizationSamples = static_cast <VkSampleCountFlagBits>(p_info.multisample .rasterization_samples ),
@@ -353,26 +214,6 @@ export namespace vk {
353214 .alphaToOneEnable = p_info.multisample .alpha_to_one_enable ,
354215 };
355216
356- // Color blending Attachment -- blending color when the fragment returns
357- // the color
358- // VkPipelineColorBlendAttachmentState color_blend_attachment = {
359- // .blendEnable = true,
360- // .srcColorBlendFactor =
361- // VK_BLEND_FACTOR_SRC_ALPHA, // Enabled: alpha blending
362- // .dstColorBlendFactor =
363- // VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA, // Enabled: alpha blending
364- // .colorBlendOp = VK_BLEND_OP_ADD, // Enabled: alpha blending
365- // .srcAlphaBlendFactor =
366- // VK_BLEND_FACTOR_ONE, // Enabled: alpha blending
367- // .dstAlphaBlendFactor =
368- // VK_BLEND_FACTOR_ZERO, // Enabled: alpha blending
369- // .alphaBlendOp = VK_BLEND_OP_ADD, // Enabled: alpha blending
370- // .colorWriteMask =
371- // VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
372- // VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT,
373- // };
374-
375- // std::array<VkPipelineColorBlendAttachmentState, p_info.color_blend.attachments.size()> color_blend_attachments{};
376217 std::vector<VkPipelineColorBlendAttachmentState> color_blend_attachments (p_info.color_blend .attachments .size ());
377218
378219 for (size_t i = 0 ; i < color_blend_attachments.size (); i++) {
@@ -388,20 +229,6 @@ export namespace vk {
388229 };
389230 }
390231
391- // VkPipelineColorBlendStateCreateInfo color_blending_ci = {
392- // .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
393- // .logicOpEnable = VK_FALSE,
394- // .logicOp = VK_LOGIC_OP_COPY, // Optional
395- // .attachmentCount = static_cast<uint32_t>(color_blend_attachments.size()),
396- // .pAttachments = color_blend_attachments.data(),
397- // // these are optional
398- // .blendConstants = { 0.f, 0.f, 0.f, 0.f } // optional
399- // };
400-
401- // Get the first 4 elements in the span as those are
402- // the data we are to set the .blendConstants to.
403-
404- // As .blendConstants only take up to 4 elements in the array.
405232
406233 VkPipelineColorBlendStateCreateInfo color_blending_ci = {
407234 .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
@@ -415,19 +242,13 @@ export namespace vk {
415242
416243 // Using ranges to load in the floats from an arbitrary array into this. Though it should only be valid to accept only 4 floats rather then N arbitrary floats in this buffer.
417244 if (!p_info.color_blend .blend_constants .empty ()) {
245+ // Get the first 4 elements in the span as those are
246+ // the data we are to set the .blendConstants to.
247+ // As .blendConstants only take up to 4 elements in the array.
418248 std::span<float , 4 > color_blend_constants = p_info.color_blend .blend_constants .first <4 >();
419249 std::ranges::copy (color_blend_constants.begin (), color_blend_constants.end (), color_blending_ci.blendConstants );
420250 }
421251
422- // Enable depth-stencil state
423- // VkPipelineDepthStencilStateCreateInfo pipeline_deth_stencil_state_ci = {
424- // .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
425- // .depthTestEnable = true,
426- // .depthWriteEnable = true,
427- // .depthCompareOp = VK_COMPARE_OP_LESS,
428- // .depthBoundsTestEnable = false,
429- // .stencilTestEnable = false,
430- // };
431252 VkPipelineDepthStencilStateCreateInfo pipeline_deth_stencil_state_ci = {
432253 .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
433254 .depthTestEnable = p_info.depth_stencil .depth_test_enable ,
@@ -437,18 +258,14 @@ export namespace vk {
437258 .stencilTestEnable = p_info.depth_stencil .stencil_test_enable ,
438259 };
439260
440- // ! @note Dynamic State
441261 // ! @note -- pipeline states needs to be baked into the pipeline state
442- // std::array<VkDynamicState, 2> dynamic_states = {
443- // VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR
444- // };
445-
446262 VkPipelineDynamicStateCreateInfo dynamic_state_ci = {
447263 .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
448264 .dynamicStateCount = static_cast <uint32_t >(p_info.dynamic_states .size ()),
449265 .pDynamicStates = reinterpret_cast <const VkDynamicState*>(p_info.dynamic_states .data ())
450266 };
451267
268+ // Specifies layout of the uniforms (data resources) to be used by this specified graphics pipeline
452269 VkPipelineLayoutCreateInfo pipeline_layout_ci = {
453270 .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
454271 .setLayoutCount = static_cast <uint32_t >(p_info.descriptor_layouts .size ()),
@@ -470,7 +287,6 @@ export namespace vk {
470287 .pViewportState = &viewport_state,
471288 .pRasterizationState = &rasterizer_ci,
472289 .pMultisampleState = &multisampling_ci,
473- // .pDepthStencilState = nullptr, // Optional
474290 .pDepthStencilState = &pipeline_deth_stencil_state_ci,
475291 .pColorBlendState = &color_blending_ci,
476292 .pDynamicState = &dynamic_state_ci,
0 commit comments