comparison tests/test_vulkan_wrapper.nim @ 102:c782d7e52b25

did: update to use new shader concept
author Sam <sam@basx.dev>
date Fri, 17 Mar 2023 01:11:58 +0700
parents 4deffc94484a
children 1e2027dfc642
comparison
equal deleted inserted replaced
101:f0ceb8c17d2c 102:c782d7e52b25
5 import semicongine/math 5 import semicongine/math
6 6
7 type 7 type
8 Vertex = object 8 Vertex = object
9 pos: Vec3 9 pos: Vec3
10 Uniforms = object
11 time: float32
10 12
11 13
12 when isMainModule: 14 when isMainModule:
13 # print basic driver infos 15 # print basic driver infos
14 echo "Layers" 16 echo "Layers"
72 commandPool = device.createCommandPool(family=device.firstGraphicsQueue().get().family, nBuffers=1) 74 commandPool = device.createCommandPool(family=device.firstGraphicsQueue().get().family, nBuffers=1)
73 imageAvailable = device.createSemaphore() 75 imageAvailable = device.createSemaphore()
74 renderFinished = device.createSemaphore() 76 renderFinished = device.createSemaphore()
75 inflight = device.createFence() 77 inflight = device.createFence()
76 78
77 var vertexshader = device.createVertexShader("#version 450\nvoid main() {}", Vertex()) 79 var vertexshader = shader(Vertex, Uniforms, device):
78 var fragmentshader = device.createFragmentShader("#version 450\nvoid main() {}") 80 shadertype: VK_SHADER_STAGE_VERTEX_BIT
79 var pipeline = renderpass.createPipeline(vertexshader, fragmentshader) 81 entrypoint: "main"
82 version: 450
83 code: """"""
84 var fragmentshader = shader(Vertex, Uniforms, device):
85 shadertype: VK_SHADER_STAGE_FRAGMENT_BIT
86 entrypoint: "main"
87 version: 450
88 code: ""
89
90 #var vertexshader = loadShaderCode[Vertex, Uniforms](device, vertexshadercode)
91 #var fragmentshader = loadShaderCode[Vertex, Uniforms](device, fragmentshadercode)
92 #var pipeline = renderpass.createPipeline(vertexshaderhandle, fragmentshaderhandle)
80 93
81 echo "All successfull" 94 echo "All successfull"
82 echo "Start cleanup" 95 echo "Start cleanup"
83 96
84 # cleanup 97 # cleanup
85 pipeline.destroy() 98 #pipeline.destroy()
86 vertexshader.destroy() 99 #vertexshader.destroy()
87 fragmentshader.destroy() 100 #fragmentshader.destroy()
88 inflight.destroy() 101 inflight.destroy()
89 imageAvailable.destroy() 102 imageAvailable.destroy()
90 renderFinished.destroy() 103 renderFinished.destroy()
91 commandPool.destroy() 104 commandPool.destroy()
92 for fb in framebuffers.mitems: 105 for fb in framebuffers.mitems: