vertexes are vertexing
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
layout(location = 0) in vec3 vPosition;
|
||||
layout(location = 1) in vec3 vColor;
|
||||
layout(location = 2) in vec2 vUV;
|
||||
|
||||
layout(location = 0) out vec3 fFragColour;
|
||||
|
||||
|
||||
Binary file not shown.
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "scene/mesh.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
#include "yolo/yolo.hpp"
|
||||
@@ -20,16 +21,25 @@ Pipeline* pipeline_create(GraphicsDevice* device)
|
||||
pipeline->Device = device;
|
||||
pipeline->Swap = swapchain_create(device, device->SurfaceSize);
|
||||
|
||||
auto bindingDescription = scene::get_vert_binding_description();
|
||||
auto attributeDescriptions = scene::get_vert_attribute_descriptions();
|
||||
auto bindingDescription = new VkVertexInputBindingDescription(scene::get_vert_binding_description());
|
||||
auto attributeDescriptions = new std::array<VkVertexInputAttributeDescription, 2>(scene::get_vert_attribute_descriptions());
|
||||
|
||||
yolo::debug("All Binding Description: {} stride: {}", bindingDescription->binding,
|
||||
bindingDescription->stride);
|
||||
// yolo::debug("All Attribute Description0: {} location: {} format: {} offset: {}",
|
||||
// attributeDescriptions[0].binding, attributeDescriptions[0].location,
|
||||
// attributeDescriptions[0].format, attributeDescriptions[0].offset);
|
||||
// yolo::debug("All Attribute Description1: {} location: {} format: {} offset: {}",
|
||||
// attributeDescriptions[1].binding, attributeDescriptions[1].location,
|
||||
// attributeDescriptions[1].format, attributeDescriptions[1].offset);
|
||||
|
||||
pipeline->VertexInputInfo.sType
|
||||
= VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||
pipeline->VertexInputInfo.vertexBindingDescriptionCount = 1;
|
||||
pipeline->VertexInputInfo.vertexAttributeDescriptionCount
|
||||
= static_cast<uint32_t>(attributeDescriptions.size());
|
||||
pipeline->VertexInputInfo.pVertexBindingDescriptions = &bindingDescription;
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions = attributeDescriptions.data();
|
||||
= static_cast<uint32_t>(attributeDescriptions->size());
|
||||
pipeline->VertexInputInfo.pVertexBindingDescriptions = bindingDescription;
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions = attributeDescriptions->data();
|
||||
|
||||
pipeline->InputAssembly.sType
|
||||
= VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||
@@ -100,6 +110,8 @@ Pipeline* pipeline_create(GraphicsDevice* device)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
yolo::info("Created pipeline layout");
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -138,6 +150,20 @@ void pipeline_configure_to_renderpass(
|
||||
pipelineInfo.subpass = 0;
|
||||
pipelineInfo.basePipelineHandle = VK_NULL_HANDLE; // Optional
|
||||
|
||||
yolo::debug("All Binding Description: {} stride: {}",
|
||||
pipeline->VertexInputInfo.pVertexBindingDescriptions->binding,
|
||||
pipeline->VertexInputInfo.pVertexBindingDescriptions->stride);
|
||||
yolo::debug("All Attribute Description0: {} location: {} format: {} offset: {}",
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions[0].binding,
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions[0].location,
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions[0].format,
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions[0].offset);
|
||||
yolo::debug("All Attribute Description1: {} location: {} format: {} offset: {}",
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions[1].binding,
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions[1].location,
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions[1].format,
|
||||
pipeline->VertexInputInfo.pVertexAttributeDescriptions[1].offset);
|
||||
|
||||
if (vkCreateGraphicsPipelines(pipeline->Device->VulkanDevice, VK_NULL_HANDLE, 1,
|
||||
&pipelineInfo, nullptr, &pipeline->GraphicsPipeline)
|
||||
!= VK_SUCCESS) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// #include "gui/layout.hpp"
|
||||
// #include "renderer/renderer.hpp"
|
||||
// #include "scene/scene.hpp"
|
||||
#include "graphics/buffer.hpp"
|
||||
#include "graphics/device.hpp"
|
||||
#include "graphics/pipeline.hpp"
|
||||
#include "graphics/renderpass.hpp"
|
||||
@@ -18,7 +19,7 @@
|
||||
// #include "preview_renderer/shader.hpp"
|
||||
// #include "scene/camera.hpp"
|
||||
// #include "scene/material.hpp"
|
||||
// #include "scene/mesh.hpp"
|
||||
#include "scene/mesh.hpp"
|
||||
// #include "scene/scene.hpp"
|
||||
|
||||
#include <yolo/yolo.hpp>
|
||||
@@ -101,6 +102,14 @@ InfernoApp* inferno_create()
|
||||
= graphics::renderer_create(app->Device, app->RenderPass->RenderPipeline->Swap);
|
||||
graphics::renderer_configure_command_buffer(app->Renderer);
|
||||
|
||||
std::vector<scene::Vert> verticies
|
||||
= { { { 0.0f, -0.5f, 0.0f }, { 1.0f, 0.0f, 0.0f } },
|
||||
{ { 0.5f, 0.5f, 0.0f }, { 0.0f, 1.0f, 0.0f } },
|
||||
{ { -0.5f, 0.5f, 0.0f }, { 0.0f, 0.0f, 1.0f } } };
|
||||
|
||||
app->VBuffer
|
||||
= graphics::vertex_buffer_create(app->Device, verticies.data(), verticies.size());
|
||||
|
||||
// // setup the scene
|
||||
// scene::Material* basicMaterial = new scene::Material("basic");
|
||||
// graphics::Shader* basicShader = graphics::shader_create();
|
||||
@@ -269,7 +278,10 @@ int inferno_run(InfernoApp* app)
|
||||
vkCmdSetScissor(
|
||||
app->Renderer->CommandBuffers[app->Renderer->CurrentFrame], 0, 1, &scissor);
|
||||
|
||||
vkCmdDraw(app->Renderer->CommandBuffers[app->Renderer->CurrentFrame], 3, 1, 0, 0);
|
||||
graphics::vertex_buffer_bind(
|
||||
app->VBuffer, app->Renderer->CommandBuffers[app->Renderer->CurrentFrame]);
|
||||
|
||||
vkCmdDraw(app->Renderer->CommandBuffers[app->Renderer->CurrentFrame], app->VBuffer->Size, 1, 0, 0);
|
||||
|
||||
graphics::renderer_draw_frame(app->Renderer, app->RenderPass);
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
#include "graphics.hpp"
|
||||
#include "graphics/device.hpp"
|
||||
#include "scene/scene.hpp"
|
||||
#include "scene/camera.hpp"
|
||||
#include "scene/mesh.hpp"
|
||||
// #include "scene/camera.hpp"
|
||||
#include "renderer/renderer.hpp"
|
||||
#include "preview_renderer/renderer.hpp"
|
||||
|
||||
@@ -16,10 +17,12 @@ namespace graphics {
|
||||
struct GraphicsDevice;
|
||||
struct RenderPass;
|
||||
struct VulkanRenderer;
|
||||
struct VertexBuffer;
|
||||
}
|
||||
|
||||
namespace scene {
|
||||
struct Scene;
|
||||
struct Vert;
|
||||
}
|
||||
|
||||
typedef struct InfernoTimer {
|
||||
@@ -51,6 +54,8 @@ typedef struct InfernoInput {
|
||||
typedef struct InfernoApp {
|
||||
InfernoInput* Input;
|
||||
scene::Scene* Scene;
|
||||
graphics::VertexBuffer* VBuffer;
|
||||
|
||||
// graphics::PreviewRenderer* PreviewRenderer;
|
||||
graphics::RayRenderer* RayRenderer;
|
||||
|
||||
|
||||
@@ -16,37 +16,27 @@ VkVertexInputBindingDescription get_vert_binding_description()
|
||||
VkVertexInputBindingDescription bindingDescription = {};
|
||||
bindingDescription.binding = 0;
|
||||
bindingDescription.stride = sizeof(Vert);
|
||||
bindingDescription.inputRate
|
||||
= VK_VERTEX_INPUT_RATE_VERTEX; // VK_VERTEX_INPUT_RATE_INSTANCE
|
||||
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
|
||||
|
||||
return bindingDescription;
|
||||
}
|
||||
|
||||
std::array<VkVertexInputAttributeDescription, 3> get_vert_attribute_descriptions()
|
||||
std::array<VkVertexInputAttributeDescription, 2> get_vert_attribute_descriptions()
|
||||
{
|
||||
std::array<VkVertexInputAttributeDescription, 3> attributeDescriptions = {};
|
||||
std::array<VkVertexInputAttributeDescription, 2> attributeDescriptions = {};
|
||||
|
||||
// Position
|
||||
attributeDescriptions[0].binding = 0;
|
||||
attributeDescriptions[0].location = 0;
|
||||
attributeDescriptions[0].format
|
||||
= VK_FORMAT_R32G32B32_SFLOAT; // VK_FORMAT_R32G32B32A32_SFLOAT
|
||||
attributeDescriptions[0].format = VK_FORMAT_R32G32B32_SFLOAT;
|
||||
attributeDescriptions[0].offset = offsetof(Vert, Position);
|
||||
|
||||
// Normal
|
||||
attributeDescriptions[1].binding = 0;
|
||||
attributeDescriptions[1].location = 1;
|
||||
attributeDescriptions[1].format
|
||||
= VK_FORMAT_R32G32B32_SFLOAT; // VK_FORMAT_R32G32B32A32_SFLOAT
|
||||
attributeDescriptions[1].format = VK_FORMAT_R32G32B32_SFLOAT;
|
||||
attributeDescriptions[1].offset = offsetof(Vert, Normal);
|
||||
|
||||
// UV
|
||||
attributeDescriptions[2].binding = 0;
|
||||
attributeDescriptions[2].location = 2;
|
||||
attributeDescriptions[2].format
|
||||
= VK_FORMAT_R32G32_SFLOAT; // VK_FORMAT_R32G32B32A32_SFLOAT
|
||||
attributeDescriptions[2].offset = offsetof(Vert, UV);
|
||||
|
||||
return attributeDescriptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,13 @@ namespace inferno::scene {
|
||||
class ObjLoader;
|
||||
|
||||
// TODO: This should be procedural like everything else
|
||||
typedef struct Vert {
|
||||
struct Vert {
|
||||
glm::vec3 Position;
|
||||
glm::vec3 Normal;
|
||||
glm::vec2 UV;
|
||||
} Vert;
|
||||
};
|
||||
|
||||
VkVertexInputBindingDescription get_vert_binding_description();
|
||||
std::array<VkVertexInputAttributeDescription, 3> get_vert_attribute_descriptions();
|
||||
std::array<VkVertexInputAttributeDescription, 2> get_vert_attribute_descriptions();
|
||||
|
||||
typedef struct Mesh {
|
||||
graphics::GraphicsDevice* Device;
|
||||
|
||||
Reference in New Issue
Block a user