Pipeline Changes

This commit is contained in:
Chewico 2026-03-24 12:49:09 +01:00
parent 73fcd0be6b
commit 338c2f1bde
5 changed files with 95 additions and 0 deletions

View File

@ -0,0 +1,9 @@
#version 450
layout(location = 0) in vec3 fragColor;
layout(location = 0) out vec4 outColor;
void main() {
outColor = vec4(fragColor, 1.0);
}

View File

@ -0,0 +1,20 @@
#version 450
layout(location = 0) out vec3 fragColor;
vec2 positions[3] = vec2[](
vec2(0.0, -0.5),
vec2(0.5, 0.5),
vec2(-0.5, 0.5)
);
vec3 colors[3] = vec3[](
vec3(1.0, 0.0, 0.0),
vec3(0.0, 1.0, 0.0),
vec3(0.0, 0.0, 1.0)
);
void main() {
gl_Position = vec4(positions[gl_VertexIndex], 0.0, 1.0);
fragColor = colors[gl_VertexIndex];
}

View File

@ -0,0 +1,21 @@
#pragma once
#include <deerith/core/types.h>
#include <glm/glm.hpp>
#include <vulkan/vulkan.h>
namespace derith {
namespace graphics {
struct StaticMeshVertex {
glm::vec3 position;
glm::vec3 normal;
};
enum class VertexLayout : uint8_t {
StaticMesh = 0
};
extern VkPipelineVertexInputStateCreateInfo static_mesh_vertex_input_state;
void create_vulkan_vertex_inputs();
} // namespace graphics
} // namespace derith

View File

@ -1,4 +1,5 @@
#include "detail/graphics.h"
#include "detail/vertex_layout.h"
#include <fstream>

View File

@ -0,0 +1,44 @@
#include "detail/vertex_layout.h"
#include <array>
namespace derith {
namespace graphics {
void create_vulkan_static_mesh_vertex_input_state();
VkPipelineVertexInputStateCreateInfo static_mesh_vertex_input_state;
VkVertexInputBindingDescription static_mesh_binding_description;
std::array<VkVertexInputAttributeDescription, 2> static_mesh_attribute_descriptors;
} // namespace graphics
void graphics::create_vulkan_vertex_inputs() {
create_vulkan_static_mesh_vertex_input_state();
}
void graphics::create_vulkan_static_mesh_vertex_input_state() {
VkVertexInputBindingDescription bindingDescription{};
bindingDescription.binding = 0;
bindingDescription.stride = sizeof(StaticMeshVertex);
bindingDescription.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
static_mesh_attribute_descriptors[0] = {};
static_mesh_attribute_descriptors[0].binding = 0;
static_mesh_attribute_descriptors[0].location = 0;
static_mesh_attribute_descriptors[0].format = VK_FORMAT_R32G32B32_SFLOAT;
static_mesh_attribute_descriptors[0].offset = offsetof(StaticMeshVertex, position);
static_mesh_attribute_descriptors[1] = {};
static_mesh_attribute_descriptors[1].binding = 0;
static_mesh_attribute_descriptors[1].location = 1;
static_mesh_attribute_descriptors[1].format = VK_FORMAT_R32G32B32_SFLOAT;
static_mesh_attribute_descriptors[1].offset = offsetof(StaticMeshVertex, normal);
static_mesh_vertex_input_state = {};
static_mesh_vertex_input_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
static_mesh_vertex_input_state.vertexBindingDescriptionCount = 1;
static_mesh_vertex_input_state.pVertexBindingDescriptions = &static_mesh_binding_description;
static_mesh_vertex_input_state.vertexAttributeDescriptionCount = static_cast<uint32_t>(static_mesh_attribute_descriptors.size());
static_mesh_vertex_input_state.pVertexAttributeDescriptions = static_mesh_attribute_descriptors.data();
}
} // namespace derith