Mercurial > games > semicongine
comparison tests/test_vulkan_wrapper.nim @ 103:1e2027dfc642
add: finally working initial approach for shader definitions
author | Sam <sam@basx.dev> |
---|---|
date | Mon, 20 Mar 2023 10:25:50 +0700 |
parents | c782d7e52b25 |
children | 9eeb9a44d158 |
comparison
equal
deleted
inserted
replaced
102:c782d7e52b25 | 103:1e2027dfc642 |
---|---|
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 FragmentInput = object | |
11 fragpos: Vec3 | |
10 Uniforms = object | 12 Uniforms = object |
11 time: float32 | 13 time: float32 |
14 Pixel = object | |
15 color: Vec4 | |
12 | 16 |
13 | 17 |
14 when isMainModule: | 18 when isMainModule: |
15 # print basic driver infos | 19 # print basic driver infos |
16 echo "Layers" | 20 echo "Layers" |
74 commandPool = device.createCommandPool(family=device.firstGraphicsQueue().get().family, nBuffers=1) | 78 commandPool = device.createCommandPool(family=device.firstGraphicsQueue().get().family, nBuffers=1) |
75 imageAvailable = device.createSemaphore() | 79 imageAvailable = device.createSemaphore() |
76 renderFinished = device.createSemaphore() | 80 renderFinished = device.createSemaphore() |
77 inflight = device.createFence() | 81 inflight = device.createFence() |
78 | 82 |
79 var vertexshader = shader(Vertex, Uniforms, device): | 83 const vertexBinary = shaderCode[Vertex, Uniforms, FragmentInput](shadertype=VK_SHADER_STAGE_VERTEX_BIT, version=450, entrypoint="main", "fragpos = pos;") |
80 shadertype: VK_SHADER_STAGE_VERTEX_BIT | 84 const fragmentBinary = shaderCode[FragmentInput, void, Pixel](shadertype=VK_SHADER_STAGE_FRAGMENT_BIT, version=450, entrypoint="main", "color = vec4(1, 1, 1, 0);") |
81 entrypoint: "main" | 85 var vertexshader = createShader[Vertex, Uniforms, FragmentInput](device, "main", vertexBinary) |
82 version: 450 | 86 var fragmentshader = createShader[FragmentInput, void, Pixel](device, "main", fragmentBinary) |
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 | 87 |
90 #var vertexshader = loadShaderCode[Vertex, Uniforms](device, vertexshadercode) | 88 var pipeline = renderpass.createPipeline(vertexshader, fragmentshader) |
91 #var fragmentshader = loadShaderCode[Vertex, Uniforms](device, fragmentshadercode) | |
92 #var pipeline = renderpass.createPipeline(vertexshaderhandle, fragmentshaderhandle) | |
93 | 89 |
94 echo "All successfull" | 90 echo "All successfull" |
95 echo "Start cleanup" | 91 echo "Start cleanup" |
96 | 92 |
97 # cleanup | 93 # cleanup |
98 #pipeline.destroy() | 94 #pipeline.destroy() |
99 #vertexshader.destroy() | 95 #vertexshader.destroy() |
100 #fragmentshader.destroy() | 96 #fragmentshader.destroy() |
97 vertexshader.destroy() | |
98 fragmentshader.destroy() | |
101 inflight.destroy() | 99 inflight.destroy() |
102 imageAvailable.destroy() | 100 imageAvailable.destroy() |
103 renderFinished.destroy() | 101 renderFinished.destroy() |
104 commandPool.destroy() | 102 commandPool.destroy() |
105 for fb in framebuffers.mitems: | 103 for fb in framebuffers.mitems: |