Add Pipeline abstraction
This commit is contained in:
+18
-1
@@ -125,6 +125,13 @@
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)ext/lib/;C:/VulkanSDK/1.3.236.0/Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Command>glslc res/shaders/shader.vert -o res/shaders/vert.spv && glslc res/shaders/shader.frag -o res/shaders/frag.spv</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
@@ -145,6 +152,13 @@
|
||||
<AdditionalLibraryDirectories>$(ProjectDir)ext/lib/;C:/VulkanSDK/1.3.236.0/Lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<AdditionalDependencies>vulkan-1.lib;glfw3.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<PreBuildEvent>
|
||||
<Command>
|
||||
</Command>
|
||||
</PreBuildEvent>
|
||||
<PostBuildEvent>
|
||||
<Command>glslc res/shaders/shader.vert -o res/shaders/vert.spv && glslc res/shaders/shader.frag -o res/shaders/frag.spv</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\main.cpp" />
|
||||
@@ -155,6 +169,7 @@
|
||||
<ClInclude Include="src\Common.h" />
|
||||
<ClInclude Include="src\DebugMessenger.h" />
|
||||
<ClInclude Include="src\FileSystem.h" />
|
||||
<ClInclude Include="src\Framebuffer.h" />
|
||||
<ClInclude Include="src\IndexBuffer.h" />
|
||||
<ClInclude Include="src\Pipeline.h" />
|
||||
<ClInclude Include="src\PipelineCreator.h" />
|
||||
@@ -170,9 +185,11 @@
|
||||
<ClInclude Include="src\Window.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\shaders\compile.bat" />
|
||||
<None Include="compile.bat" />
|
||||
<None Include="res\shaders\frag.spv" />
|
||||
<None Include="res\shaders\shader.frag" />
|
||||
<None Include="res\shaders\shader.vert" />
|
||||
<None Include="res\shaders\vert.spv" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
|
||||
@@ -74,12 +74,17 @@
|
||||
<ClInclude Include="src\VertexDescriptor.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Framebuffer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="res\shaders\shader.frag" />
|
||||
<None Include="res\shaders\shader.vert" />
|
||||
<None Include="res\shaders\compile.bat">
|
||||
<None Include="compile.bat">
|
||||
<Filter>Source Files</Filter>
|
||||
</None>
|
||||
<None Include="res\shaders\frag.spv" />
|
||||
<None Include="res\shaders\vert.spv" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +0,0 @@
|
||||
glslc shader.vert -o vert.spv
|
||||
glslc shader.frag -o frag.spv
|
||||
pause
|
||||
@@ -1,10 +1,11 @@
|
||||
#version 450
|
||||
|
||||
layout(binding = 0) uniform UniformBufferObject
|
||||
layout(set = 0, binding = 0) uniform SceneUniformBufferObject
|
||||
{
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
mat4 view;
|
||||
mat4 model;
|
||||
vec3 lightPos;
|
||||
} ubo;
|
||||
|
||||
layout(location = 0) in vec2 inPosition;
|
||||
@@ -13,6 +14,6 @@ layout(location = 1) in vec3 inColor;
|
||||
layout(location = 0) out vec3 fragColor;
|
||||
|
||||
void main() {
|
||||
gl_Position = ubo.projection * ubo.view * ubo.model * vec4(inPosition, 0.0, 1.0);
|
||||
gl_Position = ubo.projection * ubo.view * ubo.model * vec4(inPosition.x, 0.0, inPosition.y, 1.0);
|
||||
fragColor = inColor;
|
||||
}
|
||||
Binary file not shown.
+34
-47
@@ -15,8 +15,8 @@ class Pipeline
|
||||
private:
|
||||
Instance& instance;
|
||||
|
||||
std::map<uint32_t, VkDescriptorSetLayout> vertexDescriptorSetLayouts;
|
||||
std::map<uint32_t, VkDescriptorSetLayout> fragmentDescriptorSetLayouts;
|
||||
VkDescriptorSetLayout vertexDescriptorSetLayout;
|
||||
VkDescriptorSetLayout fragmentDescriptorSetLayout;
|
||||
VkPipelineLayout pipelineLayout;
|
||||
VkPipeline graphicsPipeline;
|
||||
|
||||
@@ -32,14 +32,8 @@ public:
|
||||
{
|
||||
vkDestroyPipeline(instance.GetDevice(), graphicsPipeline, nullptr);
|
||||
vkDestroyPipelineLayout(instance.GetDevice(), pipelineLayout, nullptr);
|
||||
for (auto&& descriptorSetLayout : vertexDescriptorSetLayouts)
|
||||
{
|
||||
vkDestroyDescriptorSetLayout(instance.GetDevice(), descriptorSetLayout.second, nullptr);
|
||||
}
|
||||
for (auto&& descriptorSetLayout : fragmentDescriptorSetLayouts)
|
||||
{
|
||||
vkDestroyDescriptorSetLayout(instance.GetDevice(), descriptorSetLayout.second, nullptr);
|
||||
}
|
||||
vkDestroyDescriptorSetLayout(instance.GetDevice(), vertexDescriptorSetLayout, nullptr);
|
||||
vkDestroyDescriptorSetLayout(instance.GetDevice(), fragmentDescriptorSetLayout, nullptr);
|
||||
}
|
||||
|
||||
void Bind(VkCommandBuffer commandBuffer)
|
||||
@@ -65,35 +59,21 @@ public:
|
||||
return pipelineLayout;
|
||||
}
|
||||
|
||||
VkDescriptorSetLayout GetVertexDescriptorSetLayout(uint32_t binding)
|
||||
VkDescriptorSetLayout GetVertexDescriptorSetLayout()
|
||||
{
|
||||
return vertexDescriptorSetLayouts.at(binding);
|
||||
return vertexDescriptorSetLayout;
|
||||
}
|
||||
|
||||
VkDescriptorSetLayout GetFragmentDescriptorSetLayout(uint32_t binding)
|
||||
VkDescriptorSetLayout GetFragmentDescriptorSetLayout()
|
||||
{
|
||||
return fragmentDescriptorSetLayouts.at(binding);
|
||||
return fragmentDescriptorSetLayout;
|
||||
}
|
||||
|
||||
private:
|
||||
void InitializeDescriptorSetLayouts(const PipelineCreator& creator)
|
||||
{
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& binding : creator.vertexDescriptorSetLayouts)
|
||||
{
|
||||
vertexDescriptorSetLayouts.emplace(binding, InitializeDescriptorSetLayout(binding, VK_SHADER_STAGE_VERTEX_BIT));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
{
|
||||
int i = 0;
|
||||
for (auto& binding : creator.fragmentDescriptorSetLayouts)
|
||||
{
|
||||
fragmentDescriptorSetLayouts.emplace(binding, InitializeDescriptorSetLayout(binding, VK_SHADER_STAGE_FRAGMENT_BIT));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
vertexDescriptorSetLayout = InitializeDescriptorSetLayouts(creator.vertexDescriptorSetLayouts, VK_SHADER_STAGE_VERTEX_BIT);
|
||||
fragmentDescriptorSetLayout = InitializeDescriptorSetLayouts(creator.fragmentDescriptorSetLayouts, VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
}
|
||||
|
||||
void InitializePipeline(const PipelineCreator& creator)
|
||||
@@ -119,10 +99,10 @@ private:
|
||||
|
||||
VkPipelineVertexInputStateCreateInfo vertexInputCreateInfo{};
|
||||
vertexInputCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
||||
vertexInputCreateInfo.vertexBindingDescriptionCount = 1;
|
||||
vertexInputCreateInfo.pVertexBindingDescriptions = &creator.vertexInputBindingDescription;
|
||||
vertexInputCreateInfo.vertexAttributeDescriptionCount = creator.vertexInputAttributeDescriptions.size();
|
||||
vertexInputCreateInfo.pVertexAttributeDescriptions = creator.vertexInputAttributeDescriptions.data();
|
||||
vertexInputCreateInfo.vertexBindingDescriptionCount = creator.vertexDescriptor.GetBindings().size();
|
||||
vertexInputCreateInfo.pVertexBindingDescriptions = creator.vertexDescriptor.GetBindings().data();
|
||||
vertexInputCreateInfo.vertexAttributeDescriptionCount = creator.vertexDescriptor.GetAttributes().size();
|
||||
vertexInputCreateInfo.pVertexAttributeDescriptions = creator.vertexDescriptor.GetAttributes().data();
|
||||
|
||||
VkPipelineInputAssemblyStateCreateInfo inputAssemblyCreateInfo{};
|
||||
inputAssemblyCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
||||
@@ -205,16 +185,9 @@ private:
|
||||
colorBlendCreateInfo.blendConstants[2] = 0.0f;
|
||||
colorBlendCreateInfo.blendConstants[3] = 0.0f;
|
||||
|
||||
std::vector<VkDescriptorSetLayout> layouts{vertexDescriptorSetLayouts.size() + fragmentDescriptorSetLayouts.size()};
|
||||
int i = 0;
|
||||
for (auto&& descriptorSetLayout : vertexDescriptorSetLayouts)
|
||||
{
|
||||
layouts[i++] = descriptorSetLayout.second;
|
||||
}
|
||||
for (auto&& descriptorSetLayout : fragmentDescriptorSetLayouts)
|
||||
{
|
||||
layouts[i++] = descriptorSetLayout.second;
|
||||
}
|
||||
std::vector<VkDescriptorSetLayout> layouts{};
|
||||
if (vertexDescriptorSetLayout != VK_NULL_HANDLE) layouts.emplace_back(vertexDescriptorSetLayout);
|
||||
if (fragmentDescriptorSetLayout != VK_NULL_HANDLE) layouts.emplace_back(fragmentDescriptorSetLayout );
|
||||
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo{};
|
||||
pipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
||||
pipelineLayoutCreateInfo.setLayoutCount = layouts.size();
|
||||
@@ -261,23 +234,37 @@ private:
|
||||
return shaderModule;
|
||||
}
|
||||
|
||||
VkDescriptorSetLayout InitializeDescriptorSetLayout(uint32_t binding, VkShaderStageFlags flags)
|
||||
VkDescriptorSetLayout InitializeDescriptorSetLayouts(const std::set<uint32_t>& bindings, VkShaderStageFlags flags)
|
||||
{
|
||||
VkDescriptorSetLayout descriptorSetLayout;
|
||||
std::vector<VkDescriptorSetLayoutBinding> descriptorSetLayoutBindings{bindings.size()};
|
||||
|
||||
int i = 0;
|
||||
for (auto&& binding : bindings)
|
||||
{
|
||||
VkDescriptorSetLayoutBinding layoutBinding{};
|
||||
layoutBinding.binding = binding;
|
||||
layoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
layoutBinding.descriptorCount = 1;
|
||||
layoutBinding.stageFlags = flags;
|
||||
layoutBinding.pImmutableSamplers = nullptr;
|
||||
descriptorSetLayoutBindings[i++] = layoutBinding;
|
||||
}
|
||||
|
||||
if (!descriptorSetLayoutBindings.empty())
|
||||
{
|
||||
VkDescriptorSetLayoutCreateInfo createInfo{};
|
||||
createInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||
createInfo.bindingCount = 1;
|
||||
createInfo.pBindings = &layoutBinding;
|
||||
createInfo.bindingCount = descriptorSetLayoutBindings.size();
|
||||
createInfo.pBindings = descriptorSetLayoutBindings.data();
|
||||
|
||||
CP_VK_ASSERT(vkCreateDescriptorSetLayout(instance.GetDevice(), &createInfo, nullptr, &descriptorSetLayout), "Failed to initialize descriptor set layout");
|
||||
|
||||
return descriptorSetLayout;
|
||||
}
|
||||
else
|
||||
{
|
||||
return VK_NULL_HANDLE;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -13,8 +13,7 @@ private:
|
||||
|
||||
std::string vertexShader;
|
||||
std::string fragmentShader;
|
||||
VkVertexInputBindingDescription vertexInputBindingDescription;
|
||||
std::vector<VkVertexInputAttributeDescription> vertexInputAttributeDescriptions{};
|
||||
VertexDescriptor vertexDescriptor{};
|
||||
VkPrimitiveTopology topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
|
||||
VkCullModeFlags cullMode = VK_CULL_MODE_BACK_BIT;
|
||||
VkFrontFace frontFace = VK_FRONT_FACE_CLOCKWISE;
|
||||
@@ -25,18 +24,14 @@ public:
|
||||
: vertexShader{vertexShader}, fragmentShader{fragmentShader}
|
||||
{}
|
||||
|
||||
void SetVertexInputBindingDescription(VkVertexInputBindingDescription description)
|
||||
void SetVertexDescriptor(const VertexDescriptor& descriptor)
|
||||
{
|
||||
vertexInputBindingDescription = description;
|
||||
}
|
||||
|
||||
void SetVertexInputAttributeDescription(const std::vector<VkVertexInputAttributeDescription>& descriptions)
|
||||
{
|
||||
vertexInputAttributeDescriptions = descriptions;
|
||||
vertexDescriptor = descriptor;
|
||||
}
|
||||
|
||||
void AddVertexDescriptorSetLayoutBinding(uint32_t binding)
|
||||
{
|
||||
CP_ASSERT(binding == 0, "Currently only support uniforms with binding = 0");
|
||||
vertexDescriptorSetLayouts.emplace(binding);
|
||||
}
|
||||
|
||||
|
||||
@@ -278,6 +278,7 @@ VkSurfaceFormatKHR SwapChain::SelectSwapSurfaceFormat(const std::vector<VkSurfac
|
||||
|
||||
VkPresentModeKHR SwapChain::SelectSwapPresentMode(const std::vector<VkPresentModeKHR>& availablePresentModes)
|
||||
{
|
||||
return VK_PRESENT_MODE_FIFO_KHR;
|
||||
for (auto&& availablePresentMode : availablePresentModes)
|
||||
{
|
||||
if (availablePresentMode == VK_PRESENT_MODE_MAILBOX_KHR)
|
||||
|
||||
@@ -6,21 +6,26 @@
|
||||
class VertexBuffer : public Buffer
|
||||
{
|
||||
CP_DELETE_COPY_AND_MOVE_CTOR(VertexBuffer);
|
||||
std::map<uint32_t, VkDeviceSize> bindingOffsets;
|
||||
std::map<uint32_t, VkDeviceSize> bindingSizes;
|
||||
private:
|
||||
std::vector<VkDeviceSize> bindingOffsets;
|
||||
std::vector<VkDeviceSize> bindingSizes;
|
||||
public:
|
||||
VertexBuffer(Instance& instance, VkDeviceSize size)
|
||||
: Buffer{instance, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, size, 1}
|
||||
{}
|
||||
|
||||
VertexBuffer(Instance& instance, const VertexDescriptor& descriptor, int vertexCount)
|
||||
: Buffer{instance, VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, descriptor.GetVertexSize() * vertexCount, 1}
|
||||
{}
|
||||
{
|
||||
VkDeviceSize offset = 0;
|
||||
for (auto&& binding : descriptor.GetBindings())
|
||||
{
|
||||
bindingOffsets.emplace_back(offset);
|
||||
bindingSizes.emplace_back(binding.stride * vertexCount);
|
||||
offset += binding.stride * vertexCount;
|
||||
}
|
||||
}
|
||||
|
||||
void Bind(VkCommandBuffer commandBuffer) override
|
||||
{
|
||||
VkDeviceSize offset = 0;
|
||||
vkCmdBindVertexBuffers(commandBuffer, 0, 1, &handle, &offset);
|
||||
std::vector<VkBuffer> buffers{bindingOffsets.size(), handle};
|
||||
vkCmdBindVertexBuffers(commandBuffer, 0, bindingOffsets.size(), buffers.data(), bindingOffsets.data());
|
||||
}
|
||||
|
||||
void Update(uint32_t binding, void* data)
|
||||
|
||||
@@ -14,8 +14,9 @@ public:
|
||||
template <typename T>
|
||||
void AddAttribute(uint32_t binding, uint32_t location, VkFormat format, uint32_t offset)
|
||||
{
|
||||
auto it = std::find_if(bindings.begin(), bindings.end(), [&binding](const VkVertexInputBindingDescription& description) { return description.binding == binding; });
|
||||
if (it == bindings.end())
|
||||
CP_ASSERT(binding <= bindings.size(), "Attribute binding must less than or be equal to the amount of current bindings");
|
||||
|
||||
if (binding == bindings.size())
|
||||
AddLayout(binding, sizeof(T));
|
||||
|
||||
VkVertexInputAttributeDescription description{};
|
||||
@@ -36,6 +37,16 @@ public:
|
||||
return bufferSize;
|
||||
}
|
||||
|
||||
const std::vector<VkVertexInputAttributeDescription>& GetAttributes() const
|
||||
{
|
||||
return attributes;
|
||||
}
|
||||
|
||||
const std::vector<VkVertexInputBindingDescription>& GetBindings() const
|
||||
{
|
||||
return bindings;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t AddLayout(uint32_t binding, uint32_t size)
|
||||
{
|
||||
|
||||
+30
-15
@@ -14,6 +14,7 @@
|
||||
#include <optional>
|
||||
#include <set>
|
||||
#include <glm/glm.hpp>
|
||||
#include <stb/stb_image.h>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <chrono>
|
||||
|
||||
@@ -24,15 +25,30 @@ const std::vector<Vertex> vertices = {
|
||||
Vertex{{-0.5f, 0.5f}, {1.0f, 1.0f, 1.0f}}
|
||||
};
|
||||
|
||||
const std::vector<glm::vec2> positions = {
|
||||
{-0.5f, -0.5f},
|
||||
{0.5f, -0.5f},
|
||||
{0.5f, 0.5f},
|
||||
{-0.5f, 0.5f}
|
||||
};
|
||||
|
||||
const std::vector<glm::vec3> colors = {
|
||||
glm::vec3{1.0f, 0.0f, 0.0f},
|
||||
glm::vec3{0.0f, 1.0f, 0.0f},
|
||||
glm::vec3{0.0f, 0.0f, 1.0f},
|
||||
glm::vec3{1.0f, 1.0f, 1.0f}
|
||||
};
|
||||
|
||||
const std::vector<uint16_t> indices = {
|
||||
0, 1, 2, 2, 3, 0
|
||||
};
|
||||
|
||||
struct ShaderUniform
|
||||
struct alignas(64) ShaderUniform
|
||||
{
|
||||
glm::mat4 model;
|
||||
glm::mat4 view;
|
||||
glm::mat4 projection;
|
||||
alignas(16) glm::mat4 projection;
|
||||
alignas(16) glm::mat4 view;
|
||||
alignas(16) glm::mat4 model;
|
||||
alignas(16) glm::vec3 lightPos;
|
||||
};
|
||||
|
||||
class Application final
|
||||
@@ -42,7 +58,7 @@ private:
|
||||
std::unique_ptr<Pipeline> graphicsPipeline;
|
||||
std::unique_ptr<VertexBuffer> vertexBuffer;
|
||||
std::unique_ptr<IndexBuffer> indexBuffer;
|
||||
std::unique_ptr<UniformBuffer<ShaderUniform>> uniformBuffer;
|
||||
std::unique_ptr<UniformBuffer<ShaderUniform>> shaderUniformBuffer;
|
||||
std::vector<VkCommandBuffer> commandBuffers;
|
||||
|
||||
public:
|
||||
@@ -86,23 +102,22 @@ private:
|
||||
|
||||
void InitializeUniformBuffer()
|
||||
{
|
||||
uniformBuffer = std::make_unique<UniformBuffer<ShaderUniform>>(*instance, *graphicsPipeline, 0, graphicsPipeline->GetVertexDescriptorSetLayout(0));
|
||||
shaderUniformBuffer = std::make_unique<UniformBuffer<ShaderUniform>>(*instance, *graphicsPipeline, 0, graphicsPipeline->GetVertexDescriptorSetLayout());
|
||||
}
|
||||
|
||||
void InitializeGraphicsPipeline()
|
||||
{
|
||||
PipelineCreator creator{"res/shaders/vert.spv", "res/shaders/frag.spv"};
|
||||
creator.AddVertexDescriptorSetLayoutBinding(0);
|
||||
creator.SetVertexInputBindingDescription(Vertex::GetBindingDescription());
|
||||
creator.SetVertexInputAttributeDescription(Vertex::GetAttributeDescriptions());
|
||||
creator.SetVertexDescriptor(Vertex::GetDescriptor());
|
||||
creator.SetCullMode(VK_CULL_MODE_NONE);
|
||||
graphicsPipeline = std::make_unique<Pipeline>(*instance, creator);
|
||||
}
|
||||
|
||||
void InitializeVertexBuffer()
|
||||
{
|
||||
VkDeviceSize bufferSize = sizeof(Vertex) * vertices.size();
|
||||
vertexBuffer = std::make_unique<VertexBuffer>(*instance, bufferSize);
|
||||
vertexBuffer->UpdateStaging((void*)vertices.data());
|
||||
vertexBuffer = std::make_unique<VertexBuffer>(*instance, Vertex::GetDescriptor(), vertices.size());
|
||||
vertexBuffer->Update(0, (void*)vertices.data());
|
||||
}
|
||||
|
||||
void InitializeIndexBuffer()
|
||||
@@ -154,7 +169,7 @@ private:
|
||||
|
||||
vertexBuffer->Bind(commandBuffer);
|
||||
indexBuffer->Bind(commandBuffer);
|
||||
uniformBuffer->Bind(commandBuffer);
|
||||
shaderUniformBuffer->Bind(commandBuffer);
|
||||
|
||||
indexBuffer->Draw(commandBuffer);
|
||||
|
||||
@@ -168,12 +183,12 @@ private:
|
||||
|
||||
float time = startTimer.Elapsed();
|
||||
ShaderUniform shaderUniform;
|
||||
shaderUniform.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f));
|
||||
shaderUniform.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));
|
||||
shaderUniform.view = glm::lookAt(glm::vec3(2.0f, 2.0f, 2.0f), glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
shaderUniform.projection = glm::perspective(glm::radians(45.0f), instance->GetSwapChain().GetExtent().width / (float) instance->GetSwapChain().GetExtent().height, 0.1f, 10.0f);
|
||||
shaderUniform.model = glm::rotate(glm::mat4(1.0f), time * glm::radians(90.0f), glm::vec3(0.0f, 1.0f, 0.0f));
|
||||
shaderUniform.projection[1][1] *= -1;
|
||||
|
||||
uniformBuffer->Update(shaderUniform);
|
||||
shaderUniformBuffer->Update(shaderUniform);
|
||||
}
|
||||
|
||||
VkShaderModule InitializeShaderModule(const std::vector<char>& code)
|
||||
|
||||
Reference in New Issue
Block a user