From 9c0188c3898020cc8f4e8714ec88b4868284f91e Mon Sep 17 00:00:00 2001 From: Niklas Birk Date: Tue, 31 Mar 2020 18:38:58 +0200 Subject: [PATCH] minor changes --- initVulkan.c | 2 +- initVulkan.h | 6 ++++-- openglMain.c | 12 ++++++------ shaders/opengl/FragmentShader.glsl | 3 +++ shaders/opengl/VertexShader.glsl | 4 +++- vulkanMain.c | 4 ++-- 6 files changed, 19 insertions(+), 12 deletions(-) diff --git a/initVulkan.c b/initVulkan.c index 12b23d3..927e990 100644 --- a/initVulkan.c +++ b/initVulkan.c @@ -10,7 +10,7 @@ void shutdownGLFW(GLFWwindow *window) void createInstance(Compute *compute, Graphics *graphics) { GLuint enabledLayerSize = 0; - const char **enabledLayer; + const char **enabledLayer = NULL; GLuint extensionsSize; const char **glfwExtensions = glfwGetRequiredInstanceExtensions(&extensionsSize); diff --git a/initVulkan.h b/initVulkan.h index 0adaca5..5acff37 100644 --- a/initVulkan.h +++ b/initVulkan.h @@ -14,7 +14,7 @@ #define ENGINE_NAME "rwu_particles" #define ENGINE_VERSION VK_MAKE_VERSION(0, 0, 0) -#define PARTICLE_AMOUNT 1000000 +#define PARTICLE_AMOUNT 10000000 #define PARTICLE_SIZE (3 * sizeof(vector3f) + sizeof(float)) #define WORKGROUP_SIZE_Y 1 #define WORKGROUP_SIZE_Z 1 @@ -141,6 +141,8 @@ void createGraphicsPipeline(Graphics *graphics); void createFramebuffer(Graphics *graphics); void createGraphicsCommandBuffers(Graphics *graphics); -// ELse +// Else void mapBufferMemory(Compute *compute, VkDeviceMemory memory, void *inputData, uint32_t dataSize); void createSemaphore(VkDevice device, VkSemaphore *semaphore); + + diff --git a/openglMain.c b/openglMain.c index 50dd67a..16f8fdb 100644 --- a/openglMain.c +++ b/openglMain.c @@ -84,12 +84,6 @@ int main() tFrame = time - tLast; tLast = time; - /*** UPDATE ***/ - glUseProgram(computeShaderProgram); - glUniform1f(dtUniformLocation, tFrame); - glDispatchCompute(PARTICLE_AMOUNT / WORKGROUP_SIZE_X, 1, 1); - glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT); - /*** RENDER ***/ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glfwGetFramebufferSize(window, &width, &height); @@ -98,6 +92,12 @@ int main() glDrawArrays(GL_POINTS, 0, PARTICLE_AMOUNT); glBindVertexArray(0); + /*** UPDATE ***/ + glUseProgram(computeShaderProgram); + glUniform1f(dtUniformLocation, tFrame); + glDispatchCompute(PARTICLE_AMOUNT / WORKGROUP_SIZE_X, 1, 1); + glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT); + glfwSwapBuffers(window); glfwPollEvents(); } diff --git a/shaders/opengl/FragmentShader.glsl b/shaders/opengl/FragmentShader.glsl index b007fd9..f843c5d 100644 --- a/shaders/opengl/FragmentShader.glsl +++ b/shaders/opengl/FragmentShader.glsl @@ -7,3 +7,6 @@ void main(void) { colOut = vec4(colV, 1); } + + + diff --git a/shaders/opengl/VertexShader.glsl b/shaders/opengl/VertexShader.glsl index 2c66e6a..8e60f0e 100644 --- a/shaders/opengl/VertexShader.glsl +++ b/shaders/opengl/VertexShader.glsl @@ -9,4 +9,6 @@ void main(void) { colV = colIn; gl_Position = vec4(pos, 1); -} \ No newline at end of file +} + + diff --git a/vulkanMain.c b/vulkanMain.c index 88cd1f3..39d78b3 100644 --- a/vulkanMain.c +++ b/vulkanMain.c @@ -96,7 +96,6 @@ int main() graphicsPresentInfo.swapchainCount = 1; graphicsPresentInfo.pSwapchains = &(graphics.swapChain); - // Compute preparation VkPipelineStageFlags computeWaitStageMask = VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; @@ -121,7 +120,8 @@ int main() tLast = time; /*** RENDER ***/ - ASSERT_VK(vkAcquireNextImageKHR(graphics.device, graphics.swapChain, UINT64_MAX, graphics.presentComplete, VK_NULL_HANDLE, &imageIndex)) + ASSERT_VK(vkAcquireNextImageKHR(graphics.device, graphics.swapChain, UINT64_MAX, + graphics.presentComplete, VK_NULL_HANDLE, &imageIndex)) graphicsSubmitInfo.pCommandBuffers = &(graphics.commandBuffers[imageIndex]); ASSERT_VK(vkQueueSubmit(graphics.queue, 1, &graphicsSubmitInfo, VK_NULL_HANDLE))