Mercurial > games > semicongine
comparison tests/test_rendering.nim @ 1212:518a952eccbf compiletime-tests
did: increase texture format compatability
author | sam <sam@basx.dev> |
---|---|
date | Wed, 17 Jul 2024 12:03:02 +0700 |
parents | d9799f74f5a7 |
children | f9919ea98e5b |
comparison
equal
deleted
inserted
replaced
1211:d9799f74f5a7 | 1212:518a952eccbf |
---|---|
126 Material = object | 126 Material = object |
127 baseColor: Vec3f | 127 baseColor: Vec3f |
128 | 128 |
129 Uniforms = object | 129 Uniforms = object |
130 material: GPUValue[Material, UniformBuffer] | 130 material: GPUValue[Material, UniformBuffer] |
131 texture1: Texture[TVec3[uint8]] | 131 texture1: Texture[TVec4[uint8]] |
132 | 132 |
133 QuadShader = object | 133 QuadShader = object |
134 position {.VertexAttribute.}: Vec3f | 134 position {.VertexAttribute.}: Vec3f |
135 fragmentColor {.Pass.}: Vec3f | 135 fragmentColor {.Pass.}: Vec3f |
136 uv {.Pass.}: Vec2f | 136 uv {.Pass.}: Vec2f |
147 outColor = vec4(fragmentColor, 1) * texture(texture1, uv);}""" | 147 outColor = vec4(fragmentColor, 1) * texture(texture1, uv);}""" |
148 QuadMesh = object | 148 QuadMesh = object |
149 position: GPUArray[Vec3f, VertexBuffer] | 149 position: GPUArray[Vec3f, VertexBuffer] |
150 indices: GPUArray[uint16, IndexBuffer] | 150 indices: GPUArray[uint16, IndexBuffer] |
151 | 151 |
152 let R = TVec3[uint8]([255'u8, 0'u8, 0'u8]) | 152 let R = TVec4[uint8]([255'u8, 0'u8, 0'u8, 255'u8]) |
153 let G = TVec3[uint8]([0'u8, 255'u8, 0'u8]) | 153 let G = TVec4[uint8]([0'u8, 255'u8, 0'u8, 255'u8]) |
154 let B = TVec3[uint8]([0'u8, 0'u8, 255'u8]) | 154 let B = TVec4[uint8]([0'u8, 0'u8, 255'u8, 255'u8]) |
155 let W = TVec3[uint8]([255'u8, 255'u8, 255'u8]) | 155 let W = TVec4[uint8]([255'u8, 255'u8, 255'u8, 255'u8]) |
156 var | 156 var |
157 quad = QuadMesh( | 157 quad = QuadMesh( |
158 position: asGPUArray([NewVec3f(-0.5, -0.5), NewVec3f(-0.5, 0.5), NewVec3f(0.5, 0.5), NewVec3f(0.5, -0.5)], VertexBuffer), | 158 position: asGPUArray([NewVec3f(-0.5, -0.5), NewVec3f(-0.5, 0.5), NewVec3f(0.5, 0.5), NewVec3f(0.5, -0.5)], VertexBuffer), |
159 indices: asGPUArray([0'u16, 1'u16, 2'u16, 2'u16, 3'u16, 0'u16], IndexBuffer), | 159 indices: asGPUArray([0'u16, 1'u16, 2'u16, 2'u16, 3'u16, 0'u16], IndexBuffer), |
160 ) | 160 ) |
161 uniforms1 = asDescriptorSet( | 161 uniforms1 = asDescriptorSet( |
162 Uniforms( | 162 Uniforms( |
163 material: asGPUValue(Material(baseColor: NewVec3f(1, 1, 1)), UniformBuffer), | 163 material: asGPUValue(Material(baseColor: NewVec3f(1, 1, 1)), UniformBuffer), |
164 texture1: Texture[TVec3[uint8]](width: 3, height: 3, data: @[R, G, B, G, B, R, B, R, G], interpolation: VK_FILTER_NEAREST), | 164 texture1: Texture[TVec4[uint8]](width: 3, height: 3, data: @[R, G, B, G, B, R, B, R, G], interpolation: VK_FILTER_NEAREST), |
165 ) | 165 ) |
166 ) | 166 ) |
167 uniforms2 = asDescriptorSet( | 167 uniforms2 = asDescriptorSet( |
168 Uniforms( | 168 Uniforms( |
169 material: asGPUValue(Material(baseColor: NewVec3f(0.5, 0.5, 0.5)), UniformBuffer), | 169 material: asGPUValue(Material(baseColor: NewVec3f(0.5, 0.5, 0.5)), UniformBuffer), |
170 texture1: Texture[TVec3[uint8]](width: 2, height: 2, data: @[R, G, B, W]), | 170 texture1: Texture[TVec4[uint8]](width: 2, height: 2, data: @[R, G, B, W]), |
171 ) | 171 ) |
172 ) | 172 ) |
173 | 173 |
174 AssignBuffers(renderdata, quad) | 174 AssignBuffers(renderdata, quad) |
175 AssignBuffers(renderdata, uniforms1) | 175 AssignBuffers(renderdata, uniforms1) |
176 AssignBuffers(renderdata, uniforms2) | 176 AssignBuffers(renderdata, uniforms2) |
342 # test MSAA | 342 # test MSAA |
343 block: | 343 block: |
344 mainRenderpass = CreatePresentationRenderPass(samples = VK_SAMPLE_COUNT_4_BIT) | 344 mainRenderpass = CreatePresentationRenderPass(samples = VK_SAMPLE_COUNT_4_BIT) |
345 swapchain = InitSwapchain(renderpass = mainRenderpass, samples = VK_SAMPLE_COUNT_4_BIT).get() | 345 swapchain = InitSwapchain(renderpass = mainRenderpass, samples = VK_SAMPLE_COUNT_4_BIT).get() |
346 | 346 |
347 test_01_triangle(99999999) | 347 # test_01_triangle(99999999) |
348 | 348 |
349 checkVkResult vkDeviceWaitIdle(vulkan.device) | 349 checkVkResult vkDeviceWaitIdle(vulkan.device) |
350 vkDestroyRenderPass(vulkan.device, mainRenderpass, nil) | 350 vkDestroyRenderPass(vulkan.device, mainRenderpass, nil) |
351 DestroySwapchain(swapchain) | 351 DestroySwapchain(swapchain) |
352 | 352 |