Skip to content

Commit

Permalink
Reverted Away from UniformBuffers, Gonna try again
Browse files Browse the repository at this point in the history
  • Loading branch information
tomheeleynz committed Aug 14, 2021
1 parent 24461c0 commit b7968e3
Show file tree
Hide file tree
Showing 14 changed files with 3 additions and 265 deletions.
1 change: 0 additions & 1 deletion Arcane/src/Arcane.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@
#include "Arcane/Renderer/RenderPass.h"
#include "Arcane/Renderer/VertexDescriptor.h"
#include "Arcane/Renderer/Buffer.h"
#include "Arcane/Renderer/UniformBuffer.h"

#include "Arcane/ImGui/ImGuiLayer.h"
6 changes: 0 additions & 6 deletions Arcane/src/Arcane/Platform/Vulkan/VulkanPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
#include "VulkanContext.h"
#include "VulkanRenderPass.h"
#include "VulkanVertexDescriptor.h"
#include "VulkanUniformBuffer.h"

namespace Arcane {
VulkanPipeline::VulkanPipeline(PipelineSpecification& spec)
{
VulkanShader* shader = static_cast<VulkanShader*>(spec.shader);

VulkanUniformBuffer* vulkanUniformBuffer = static_cast<VulkanUniformBuffer*>(spec.uniformBuffer);
VkDescriptorSetLayout vulkanDescriptorLayout = vulkanUniformBuffer->GetLayout();

// Get Vulkan Context to be able to get the devices
Application& app = Application::Get();
Window& window = app.GetWindow();
Expand Down Expand Up @@ -110,8 +106,6 @@ namespace Arcane {

VkPipelineLayoutCreateInfo pipelineLayoutInfo{};
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipelineLayoutInfo.setLayoutCount = 1;
pipelineLayoutInfo.pSetLayouts = &vulkanDescriptorLayout;

if (vkCreatePipelineLayout(logicalDevice, &pipelineLayoutInfo, nullptr, &m_PipelineLayout) != VK_SUCCESS) {
printf("Pipeline Layout Not Created");
Expand Down
5 changes: 2 additions & 3 deletions Arcane/src/Arcane/Platform/Vulkan/VulkanRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "VulkanPipeline.h"
#include "VulkanBuffer.h"
#include "VulkanRenderPass.h"

#include "Arcane/Core/Application.h"

namespace Arcane {
Expand Down Expand Up @@ -122,7 +121,7 @@ namespace Arcane {
VulkanSwapChain& swapChain = _context->GetSwapChain();

// Bind Pipeline for triangle to use
VkPipeline vulkanPipeline = static_cast<VulkanPipeline*>(pipeline)->GetPipeline();
VulkanPipeline* vulkanPipeline = static_cast<VulkanPipeline*>(pipeline);
VkBuffer vulkanVertexBuffer = static_cast<VulkanVertexBuffer*>(buffer)->GetVertexBuffer();

// Get Index Buffer and count from vertex buffer
Expand All @@ -134,7 +133,7 @@ namespace Arcane {

for (size_t i = 0; i < swapChainBuffers.size(); i++) {
// Bind Pipeline
vkCmdBindPipeline(swapChainBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanPipeline);
vkCmdBindPipeline(swapChainBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanPipeline->GetPipeline());

// Bind Vertex Buffer
VkBuffer vertexBuffers[] = { vulkanVertexBuffer };
Expand Down
1 change: 0 additions & 1 deletion Arcane/src/Arcane/Platform/Vulkan/VulkanRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace Arcane {
// Render Quad Functions
// -- Without Uniform Buffer
void RenderQuad(VertexBuffer* buffer, Pipeline* pipeline) override;
// -- With Uniform Buffer

private:

Expand Down
155 changes: 0 additions & 155 deletions Arcane/src/Arcane/Platform/Vulkan/VulkanUniformBuffer.cpp

This file was deleted.

41 changes: 0 additions & 41 deletions Arcane/src/Arcane/Platform/Vulkan/VulkanUniformBuffer.h

This file was deleted.

2 changes: 0 additions & 2 deletions Arcane/src/Arcane/Renderer/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
#include "Shader.h"
#include "RenderPass.h"
#include "VertexDescriptor.h"
#include "UniformBuffer.h"

namespace Arcane {
struct PipelineSpecification
{
Shader* shader;
RenderPass* renderPass;
VertexDescriptor* descriptor;
UniformBuffer* uniformBuffer;
};

class Pipeline
Expand Down
18 changes: 0 additions & 18 deletions Arcane/src/Arcane/Renderer/UniformBuffer.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions Arcane/src/Arcane/Renderer/UniformBuffer.h

This file was deleted.

1 change: 0 additions & 1 deletion EnchantingTable/src/Assets/Shaders/Basic.frag
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#version 450

layout(location = 0) in vec3 fragColor;

layout(location = 0) out vec4 outColor;

void main() {
Expand Down
7 changes: 1 addition & 6 deletions EnchantingTable/src/Assets/Shaders/Basic.vert
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
#version 450

layout (binding = 0) uniform UniformBufferObject {
mat4 model;
mat4 view;
mat4 proj;
} ubo;

layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aColor;

layout(location = 0) out vec3 fragColor;

void main() {
gl_Position = ubo.proj * ubo.view * ubo.model * vec4(aPos, 1.0);
gl_Position = vec4(aPos, 1.0);
fragColor = aColor;
}
Binary file modified EnchantingTable/src/Assets/Shaders/vert.spv
Binary file not shown.
16 changes: 0 additions & 16 deletions EnchantingTable/src/EditorLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ void EditorLayer::OnAttach()
Arcane::VertexType::float3
});

m_UniformBuffer = Arcane::UniformBuffer::Create(sizeof(UniformBufferObject));

// Test Pipeline
Arcane::PipelineSpecification spec;
spec.descriptor = m_VertexDescriptor;
spec.renderPass = m_RenderPass;
spec.shader = m_Shader;
spec.uniformBuffer = m_UniformBuffer;

m_Pipeline = Arcane::Pipeline::Create(spec);

Expand All @@ -62,15 +60,6 @@ void EditorLayer::OnAttach()
m_VertexBuffer = Arcane::VertexBuffer::Create(vertices.data(), sizeof(TestVertex) * vertices.size());
Arcane::IndexBuffer* indexBuffer = Arcane::IndexBuffer::Create(indices.data(), indices.size());
m_VertexBuffer->AddIndexBuffer(indexBuffer);

UniformBufferObject ubo{};
ubo.model = glm::rotate(glm::mat4(1.0f), glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f));
ubo.proj = glm::perspective(glm::radians(45.0f), 1600.0f / 1200.0f, 0.1f, 10.0f);
ubo.proj[1][1] *= -1;

m_UniformBuffer->WriteData(&ubo);

}

void EditorLayer::OnDetach()
Expand All @@ -80,11 +69,6 @@ void EditorLayer::OnDetach()

void EditorLayer::OnUpdate(float deltaTime)
{
// printf("%.2f\n", deltaTime);


// m_UniformBuffer->WriteData(&ubo);

// Begin a Render pass
Arcane::Renderer::BeginRenderPass(m_RenderPass);

Expand Down
1 change: 0 additions & 1 deletion EnchantingTable/src/EditorLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@ class EditorLayer : public Arcane::Layer
Arcane::VertexDescriptor* m_VertexDescriptor;
Arcane::VertexBuffer* m_VertexBuffer;
Arcane::Pipeline* m_Pipeline;
Arcane::UniformBuffer* m_UniformBuffer;

};

0 comments on commit b7968e3

Please sign in to comment.