diff --git a/newVulkan/initVulkan.c b/newVulkan/initVulkan.c index 2479c9f..0ee5c5f 100644 --- a/newVulkan/initVulkan.c +++ b/newVulkan/initVulkan.c @@ -366,10 +366,18 @@ void createComputePipeline(Compute *compute) compute->dtUniformBufferDescriptorSetLayout, compute->staticInUniformBufferDescriptorSetLayout }; + + VkPushConstantRange dtPushConstantRange = {}; + dtPushConstantRange.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT; + dtPushConstantRange.offset = 0; + dtPushConstantRange.size = sizeof(Dt); + VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo = {}; pipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; pipelineLayoutCreateInfo.setLayoutCount = 3; pipelineLayoutCreateInfo.pSetLayouts = descriptorSetLayouts; + pipelineLayoutCreateInfo.pushConstantRangeCount = 1; + pipelineLayoutCreateInfo.pPushConstantRanges = &dtPushConstantRange; ASSERT_VK(vkCreatePipelineLayout(compute->device, &pipelineLayoutCreateInfo, NULL, &(compute->pipelineLayout))) @@ -461,7 +469,7 @@ void fillComputeBuffers(Compute *compute, float *particles, Dt *dtData, StaticIn fillComputeBuffer(compute, compute->staticInUniformBuffer, staticInData, compute->staticInUniformBufferSize); } -void createComputeCommandBuffer(Compute *compute, Graphics *graphics) +void createComputeCommandBuffer(Compute *compute) { VkCommandPoolCreateInfo commandPoolCreateInfo = {}; commandPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; @@ -488,7 +496,7 @@ void createComputeCommandBuffer(Compute *compute, Graphics *graphics) VkDescriptorSet descriptorSets[] = { compute->particleBufferDescriptorSet, compute->dtUniformBufferDescriptorSet, - compute->staticInUniformBufferDescriptorSet, + compute->staticInUniformBufferDescriptorSet }; vkCmdBindDescriptorSets(compute->commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, compute->pipelineLayout, 0, 3, descriptorSets, 0, NULL); @@ -624,13 +632,13 @@ void createGraphicsPipeline(Graphics *graphics) VkVertexInputAttributeDescription positionVertexInputAttributeDescription; positionVertexInputAttributeDescription.binding = 0; positionVertexInputAttributeDescription.location = 0; - positionVertexInputAttributeDescription.format = VK_FORMAT_R32G32_SFLOAT; + positionVertexInputAttributeDescription.format = VK_FORMAT_R32G32B32_SFLOAT; positionVertexInputAttributeDescription.offset = 0; VkVertexInputAttributeDescription colInVertexInputAttributeDescription; colInVertexInputAttributeDescription.binding = 0; colInVertexInputAttributeDescription.location = 1; - colInVertexInputAttributeDescription.format = VK_FORMAT_R32G32_SFLOAT; + colInVertexInputAttributeDescription.format = VK_FORMAT_R32G32B32_SFLOAT; colInVertexInputAttributeDescription.offset = 24; VkVertexInputAttributeDescription vertexInputAttributeDescription[2] = { diff --git a/newVulkan/initVulkan.h b/newVulkan/initVulkan.h index 3b42506..f1455b4 100644 --- a/newVulkan/initVulkan.h +++ b/newVulkan/initVulkan.h @@ -31,6 +31,17 @@ } #define ASSERT_GLFW_SUCCESS(res) { if (res != GLFW_TRUE) { printf("Error-Code: %d", res); return FAILURE; } } +typedef struct dt { + float dt; +} Dt; + +typedef struct staticIn { + float x; + float y; + float z; + unsigned int maxParticles; +} StaticIn; + typedef struct compute { VkInstance instance; @@ -105,17 +116,6 @@ typedef struct graphics { VkSemaphore semaphore; } Graphics; -typedef struct dt { - float dt; -} Dt; - -typedef struct staticIn { - float x; - float y; - float z; - unsigned int maxParticles; -} StaticIn; - // Shutdown void shutdownGLFW(GLFWwindow *window); void shutdownComputeVulkan(Compute *compute); @@ -133,7 +133,7 @@ void createComputeDescriptorSetLayouts(Compute *compute); void createComputeDescriptorSets(Compute *compute); void createComputePipeline(Compute *compute); void fillComputeBuffers(Compute *compute, float *particles, Dt *dtData, StaticIn *staticInData); -void createComputeCommandBuffer(Compute *compute, Graphics *graphics); +void createComputeCommandBuffer(Compute *compute); // Graphics void createGraphicsSurface(Graphics *graphics, GLFWwindow *window); diff --git a/newVulkan/vulkanMain.c b/newVulkan/vulkanMain.c index 3318378..88cd1f3 100644 --- a/newVulkan/vulkanMain.c +++ b/newVulkan/vulkanMain.c @@ -57,7 +57,7 @@ int main() ASSERT_VK(vkQueueSubmit(compute.queue, 1, &submitInfo, VK_NULL_HANDLE)); ASSERT_VK(vkQueueWaitIdle(compute.queue)); - createComputeCommandBuffer(&compute, &graphics); + createComputeCommandBuffer(&compute); // Graphics graphics.particleBuffer = compute.particleBuffer;