CMSC23700 Common Code Library
Support code for CS23700 programming projects
Loading...
Searching...
No Matches
cs237-pipeline.hpp
Go to the documentation of this file.
1
11/*
12 * COPYRIGHT (c) 2023 John Reppy (http://cs.uchicago.edu/~jhr)
13 * All rights reserved.
14 */
15
16#ifndef _CS237_PIPELINE_HPP_
17#define _CS237_PIPELINE_HPP_
18
19#ifndef _CS237_HPP_
20#error "cs237-pipeline.hpp should not be included directly"
21#endif
22
23namespace cs237 {
24
31inline
32vk::PipelineVertexInputStateCreateInfo vertexInputInfo (
33 std::vector<vk::VertexInputBindingDescription> const &descs,
34 std::vector<vk::VertexInputAttributeDescription> const &attrs)
35{
36 vk::PipelineVertexInputStateCreateInfo vertexInfo{};
37
38 vertexInfo.vertexBindingDescriptionCount = descs.size();
39 if (descs.size() > 0) {
40 // we copy the data into the heap to ensure that it is still around
41 // when we create the pipeline
42 auto pDescs = new vk::VertexInputBindingDescription[descs.size()];
43 for (int i = 0; i < descs.size(); ++i) {
44 pDescs[i] = descs[i];
45 }
46 vertexInfo.pVertexBindingDescriptions = pDescs;
47 }
48
49 vertexInfo.vertexAttributeDescriptionCount = attrs.size();
50 if (attrs.size() > 0) {
51 auto pAttrs = new vk::VertexInputAttributeDescription[attrs.size()];
52 for (int i = 0; i < attrs.size(); ++i) {
53 pAttrs[i] = attrs[i];
54 }
55 vertexInfo.pVertexAttributeDescriptions = pAttrs;
56 }
57
58 return vertexInfo;
59}
60
62inline
63void destroyVertexInputInfo (vk::PipelineVertexInputStateCreateInfo &info)
64{
65 if (info.pVertexBindingDescriptions != nullptr) {
66 delete info.pVertexBindingDescriptions;
67 info.pVertexBindingDescriptions = nullptr;
68 }
69 if (info.pVertexAttributeDescriptions != nullptr) {
70 delete info.pVertexAttributeDescriptions;
71 info.pVertexAttributeDescriptions = nullptr;
72 }
73}
74
75} // namespace cs237
76
77#endif // !_CS237_PIPELINE_HPP_
Definition cs237-aabb.hpp:22
void destroyVertexInputInfo(vk::PipelineVertexInputStateCreateInfo &info)
release resources allocated by vertexInputInfo
Definition cs237-pipeline.hpp:63
vk::PipelineVertexInputStateCreateInfo vertexInputInfo(std::vector< vk::VertexInputBindingDescription > const &descs, std::vector< vk::VertexInputAttributeDescription > const &attrs)
initialize info for the vertex input stage of the pipeline
Definition cs237-pipeline.hpp:32