Mercurial > games > semicongine
diff tests/test_rendering.nim @ 1499:1f58458b7ef7 default tip
did: fix a few issues with tests
author | sam <sam@basx.dev> |
---|---|
date | Tue, 14 Oct 2025 00:27:28 +0700 |
parents | d3d667bbdda4 |
children |
line wrap: on
line diff
--- a/tests/test_rendering.nim Thu Sep 25 23:53:41 2025 +0700 +++ b/tests/test_rendering.nim Tue Oct 14 00:27:28 2025 +0700 @@ -827,11 +827,8 @@ destroyPipeline(pipeline) destroyRenderData(renderdata) -proc test_09_triangle_2pass( - time: float32, depthBuffer: bool, samples: VkSampleCountFlagBits -) = - var (offscreenRP, presentRP) = - createIndirectPresentationRenderPass(depthBuffer = depthBuffer, samples = samples) +proc test_09_triangle_2pass(time: float32, depthBuffer: bool, samples: VkSampleCountFlagBits) = + var (offscreenRP, presentRP) = createIndirectPresentationRenderPass(depthBuffer = depthBuffer, samples = samples) setupSwapchain(renderpass = presentRP, vSync = false, tripleBuffering = false) @@ -916,6 +913,7 @@ depthImage: VkImage depthImageView: VkImageView depthMemory: VkDeviceMemory + if offscreenRP.depthBuffer: depthImage = svkCreate2DImage( width = frameWidth(), @@ -938,6 +936,7 @@ msaaImage: VkImage msaaImageView: VkImageView msaaMemory: VkDeviceMemory + if offscreenRP.samples != VK_SAMPLE_COUNT_1_BIT: msaaImage = svkCreate2DImage( width = frameWidth(), @@ -952,45 +951,49 @@ msaaImageView = svkCreate2DImageView(image = msaaImage, format = SURFACE_FORMAT) var attachments: seq[VkImageView] - if offscreenRP.samples == VK_SAMPLE_COUNT_1_BIT: - if offscreenRP.depthBuffer: - attachments = @[uniforms1.data[currentFiF()].frameTexture.imageview, depthImageView] + for j in 0 ..< INFLIGHTFRAMES: + if offscreenRP.samples == VK_SAMPLE_COUNT_1_BIT: + if offscreenRP.depthBuffer: + attachments = @[uniforms1.data[j].frameTexture.imageview, depthImageView] + else: + attachments = @[uniforms1.data[j].frameTexture.imageview] else: - attachments = @[uniforms1.data[currentFiF()].frameTexture.imageview] - else: - if offscreenRP.depthBuffer: - attachments = @[msaaImageView, depthImageView, uniforms1.data[currentFiF()].frameTexture.imageview] - else: - attachments = @[msaaImageView, uniforms1.data[currentFiF()].frameTexture.imageview] + if offscreenRP.depthBuffer: + attachments = @[msaaImageView, depthImageView, uniforms1.data[j].frameTexture.imageview] + else: + attachments = @[msaaImageView, uniforms1.data[j].frameTexture.imageview] + var offscreenFB = svkCreateFramebuffer(offscreenRP.vk, frameWidth(), frameHeight(), attachments) renderdata.flushAllMemory() var start = getMonoTime() while ((getMonoTime() - start).inMilliseconds().int / 1000) < time: - withNextFrame(framebuffer, commandbuffer): - withRenderPass( - offscreenRP, - offscreenFB, - commandbuffer, - frameWidth(), - frameHeight(), - vec4(0, 0, 0, 0), - ): - withPipeline(commandbuffer, drawPipeline): - render(commandbuffer = commandbuffer, pipeline = drawPipeline, mesh = mesh) - - withRenderPass( - presentRP, - framebuffer, - commandbuffer, - frameWidth(), - frameHeight(), - vec4(0, 0, 0, 0), - ): - withPipeline(commandbuffer, presentPipeline): - bindDescriptorSet(commandbuffer, uniforms1, 0, presentPipeline) - render(commandbuffer = commandbuffer, pipeline = presentPipeline, mesh = quad) + discard updateInputs() + if keyWasPressed(Space): + withNextFrame(framebuffer, commandbuffer): + withRenderPass( + offscreenRP, + offscreenFB, + commandbuffer, + frameWidth(), + frameHeight(), + vec4(0.5, 0.5, 0.5, 1), + ): + withPipeline(commandbuffer, drawPipeline): + render(commandbuffer = commandbuffer, pipeline = drawPipeline, mesh = mesh) + + withRenderPass( + presentRP, + framebuffer, + commandbuffer, + frameWidth(), + frameHeight(), + vec4(1, 0, 1, 1), + ): + withPipeline(commandbuffer, presentPipeline): + bindDescriptorSet(commandbuffer, uniforms1, 0, presentPipeline) + render(commandbuffer = commandbuffer, pipeline = presentPipeline, mesh = quad) # cleanup checkVkResult vkDeviceWaitIdle(engine().vulkan.device) @@ -1056,7 +1059,8 @@ ]# # test multiple render passes - for i, (depthBuffer, samples) in renderPasses: - test_09_triangle_2pass(time, depthBuffer, samples) + test_09_triangle_2pass(1000'f, true, VK_SAMPLE_COUNT_1_BIT) + # for i, (depthBuffer, samples) in renderPasses: + # test_09_triangle_2pass(time, depthBuffer, samples) destroyVulkan()