• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 Google, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MESHES_H
18 #define MESHES_H
19 
20 #include <vulkan/vulkan.h>
21 #include <vector>
22 
23 class Meshes {
24 public:
25     Meshes(VkDevice dev, const std::vector<VkMemoryPropertyFlags> &mem_flags);
26     ~Meshes();
27 
vertex_input_state()28     const VkPipelineVertexInputStateCreateInfo &vertex_input_state() const { return vertex_input_state_; }
input_assembly_state()29     const VkPipelineInputAssemblyStateCreateInfo &input_assembly_state() const { return input_assembly_state_; }
30 
31     enum Type {
32         MESH_PYRAMID,
33         MESH_ICOSPHERE,
34         MESH_TEAPOT,
35 
36         MESH_COUNT,
37     };
38 
39     void cmd_bind_buffers(VkCommandBuffer cmd) const;
40     void cmd_draw(VkCommandBuffer cmd, Type type) const;
41 
42 private:
43     void allocate_resources(VkDeviceSize vb_size, VkDeviceSize ib_size, const std::vector<VkMemoryPropertyFlags> &mem_flags);
44 
45     VkDevice dev_;
46 
47     VkVertexInputBindingDescription vertex_input_binding_;
48     std::vector<VkVertexInputAttributeDescription> vertex_input_attrs_;
49     VkPipelineVertexInputStateCreateInfo vertex_input_state_;
50     VkPipelineInputAssemblyStateCreateInfo input_assembly_state_;
51     VkIndexType index_type_;
52 
53     std::vector<VkDrawIndexedIndirectCommand> draw_commands_;
54 
55     VkBuffer vb_;
56     VkBuffer ib_;
57     VkDeviceMemory mem_;
58     VkDeviceSize ib_mem_offset_;
59 };
60 
61 #endif // MESHES_H
62