Mercurial > games > semicongine
diff tests/test_vulkan_wrapper.nim @ 572:9f1de117aaca
did: allow runtime shader-input definitions
author | Sam <sam@basx.dev> |
---|---|
date | Fri, 31 Mar 2023 16:00:16 +0700 |
parents | 1cf928eb0a10 |
children | 0c5a74885796 |
line wrap: on
line diff
--- a/tests/test_vulkan_wrapper.nim Thu Mar 30 00:00:54 2023 +0700 +++ b/tests/test_vulkan_wrapper.nim Fri Mar 31 16:00:16 2023 +0700 @@ -1,3 +1,4 @@ +import std/os import std/options import semicongine/vulkan @@ -5,6 +6,7 @@ import semicongine/math import semicongine/entity import semicongine/scene +import semicongine/gpu_data type Vertex = object @@ -66,22 +68,27 @@ selectedPhysicalDevice.filterForGraphicsPresentationQueues() ) - const vertexBinary = shaderCode[Vertex, Uniforms, FragmentInput](stage=VK_SHADER_STAGE_VERTEX_BIT, version=450, entrypoint="main", "fragpos = pos;") - const fragmentBinary = shaderCode[FragmentInput, void, Pixel](stage=VK_SHADER_STAGE_FRAGMENT_BIT, version=450, entrypoint="main", "color = vec4(1, 1, 1, 0);") + const inputs = AttributeGroup(attributes: @[attr(name="pos", thetype=Float32, components=3)]) + const uniforms = AttributeGroup() + const outputs = AttributeGroup(attributes: @[attr(name="fragpos", thetype=Float32, components=3)]) + const fragOutput = AttributeGroup(attributes: @[attr(name="color", thetype=Float32, components=4)]) + const vertexBinary = shaderCode(inputs=inputs, uniforms=uniforms, outputs=outputs, stage=VK_SHADER_STAGE_VERTEX_BIT, version=450, entrypoint="main", "fragpos = pos;") + const fragmentBinary = shaderCode(inputs=outputs, uniforms=uniforms, outputs=fragOutput, stage=VK_SHADER_STAGE_FRAGMENT_BIT, version=450, entrypoint="main", "color = vec4(1, 1, 1, 0);") var - vertexshader = createShader[Vertex, Uniforms, FragmentInput](device, VK_SHADER_STAGE_VERTEX_BIT, "main", vertexBinary) - fragmentshader = createShader[FragmentInput, void, Pixel](device, VK_SHADER_STAGE_FRAGMENT_BIT, "main", fragmentBinary) + vertexshader = device.createShader(inputs, uniforms, outputs, VK_SHADER_STAGE_VERTEX_BIT, "main", vertexBinary) + fragmentshader = device.createShader(inputs, uniforms, outputs, VK_SHADER_STAGE_FRAGMENT_BIT, "main", fragmentBinary) surfaceFormat = device.physicalDevice.getSurfaceFormats().filterSurfaceFormat() - renderpass = device.simpleForwardRenderPass(surfaceFormat.format, vertexshader, fragmentshader, 2) - var (swapchain, res) = device.createSwapchain(renderpass, surfaceFormat, device.firstGraphicsQueue().get().family, 2) + renderPass = device.simpleForwardRenderPass(surfaceFormat.format, vertexshader, fragmentshader, 2) + var (swapchain, res) = device.createSwapchain(renderPass, surfaceFormat, device.firstGraphicsQueue().get().family, 2) if res != VK_SUCCESS: raise newException(Exception, "Unable to create swapchain") var thescene = Scene(root: newEntity("scene")) + thescene.setupDrawables(renderPass) - echo "All successfull" - for i in 0 ..< 2: - discard swapchain.drawNextFrame(thescene) + echo "Setup successfull, start rendering" + for i in 0 ..< 10: + discard swapchain.drawScene(thescene) echo "Rendered ", swapchain.framesRendered, " frames" echo "Start cleanup" @@ -90,7 +97,7 @@ checkVkResult device.vk.vkDeviceWaitIdle() vertexshader.destroy() fragmentshader.destroy() - renderpass.destroy() + renderPass.destroy() swapchain.destroy() device.destroy()