|
|
@ -111,16 +111,6 @@ struct Vertex { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
namespace std { |
|
|
|
template<> struct hash<Vertex> { |
|
|
|
size_t operator()(Vertex const& vertex) const { |
|
|
|
return ((hash<glm::vec3>()(vertex.pos) ^ |
|
|
|
(hash<glm::vec3>()(vertex.color) << 1)) >> 1) ^ |
|
|
|
(hash<glm::vec2>()(vertex.texCoord) << 1); |
|
|
|
} |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
struct UniformBufferObject { |
|
|
|
alignas(16) glm::mat4 model; |
|
|
|
alignas(16) glm::mat4 view; |
|
|
@ -221,8 +211,6 @@ private: |
|
|
|
VkFormat findDepthFormat(); |
|
|
|
bool hasStencilComponent(VkFormat format); |
|
|
|
|
|
|
|
void loadModel(); |
|
|
|
|
|
|
|
void createShaderStorageBuffers(); |
|
|
|
void createComputePipeline(); |
|
|
|
void createComputeCommandBuffers(); |
|
|
@ -277,8 +265,6 @@ private: |
|
|
|
|
|
|
|
VkBufferImageCopy createBufferImageCopyInfo(uint32_t width, uint32_t height); |
|
|
|
|
|
|
|
Vertex createLoadModelVertex(tinyobj::attrib_t attrib, tinyobj::index_t index); |
|
|
|
|
|
|
|
void copyVerticesToStagingBuffer(VkBuffer& stagingBuffer, VkDeviceMemory& stagingBufferMemory); |
|
|
|
void copyIndicesToStagingBuffer(VkBuffer& stagingBuffer, VkDeviceMemory& stagingBufferMemory); |
|
|
|
|
|
|
@ -317,33 +303,27 @@ private: |
|
|
|
const int32_t WIDTH = 800; |
|
|
|
const int32_t HEIGHT = 600; |
|
|
|
|
|
|
|
const std::string MODEL_PATH = "/home/ali-mehrabani/Qt_projects/VkTest/models/viking_room.obj"; |
|
|
|
const std::string TEXTURE_PATH = "/home/ali-mehrabani/Qt_projects/VkTest/textures/viking_room.png"; |
|
|
|
|
|
|
|
const std::vector<const char*> validationLayers = { |
|
|
|
"VK_LAYER_KHRONOS_validation" |
|
|
|
}; |
|
|
|
const std::vector<const char*> deviceExtensions = { |
|
|
|
VK_KHR_SWAPCHAIN_EXTENSION_NAME |
|
|
|
}; |
|
|
|
// const std::vector<Vertex> _vertices = {
|
|
|
|
// {{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f}, {1.0f, 0.0f}},
|
|
|
|
// {{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f}},
|
|
|
|
// {{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 1.0f}},
|
|
|
|
// {{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}},
|
|
|
|
const std::vector<Vertex> _vertices = { |
|
|
|
{{-0.5f, -0.5f, 0.0f}, {1.0f, 0.0f, 0.0f}, {1.0f, 0.0f}}, |
|
|
|
{{0.5f, -0.5f, 0.0f}, {0.0f, 1.0f, 0.0f}, {0.0f, 0.0f}}, |
|
|
|
{{0.5f, 0.5f, 0.0f}, {0.0f, 0.0f, 1.0f}, {0.0f, 1.0f}}, |
|
|
|
{{-0.5f, 0.5f, 0.0f}, {1.0f, 1.0f, 1.0f}, {1.0f, 1.0f}}, |
|
|
|
|
|
|
|
// {{-0.5f, -0.5f, -0.5f}, {1.0f, 0.0f, 0.0f}, {0.0f, 0.0f}},
|
|
|
|
// {{0.5f, -0.5f, -0.5f}, {0.0f, 1.0f, 0.0f}, {1.0f, 0.0f}},
|
|
|
|
// {{0.5f, 0.5f, -0.5f}, {0.0f, 0.0f, 1.0f}, {1.0f, 1.0f}},
|
|
|
|
// {{-0.5f, 0.5f, -0.5f}, {1.0f, 1.0f, 1.0f}, {0.0f, 1.0f}}
|
|
|
|
// };
|
|
|
|
// const std::vector<uint16_t> _indices = {
|
|
|
|
// 0, 1, 2, 2, 3, 0,
|
|
|
|
}; |
|
|
|
const std::vector<uint32_t> _indices = { |
|
|
|
0, 1, 2, 2, 3, 0, |
|
|
|
// 4, 5, 6, 6, 7, 4
|
|
|
|
// };
|
|
|
|
|
|
|
|
std::vector<Vertex> _vertices; |
|
|
|
std::vector<uint32_t> _indices; |
|
|
|
}; |
|
|
|
|
|
|
|
uint32_t currentFrame = 0; |
|
|
|
bool framebufferResized = false; |
|
|
|