Mercurial > games > semicongine
comparison tests/test_vulkan_wrapper.nim @ 791:43432dad4797
did: remove some stuff from the heap, maybe nicer?
| author | Sam <sam@basx.dev> |
|---|---|
| date | Sat, 02 Sep 2023 23:51:02 +0700 |
| parents | a979e5c581de |
| children | 05fb85ba97dd |
comparison
equal
deleted
inserted
replaced
| 790:a979e5c581de | 791:43432dad4797 |
|---|---|
| 11 wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT, | 11 wrapModeT: VK_SAMPLER_ADDRESS_MODE_REPEAT, |
| 12 ) | 12 ) |
| 13 (R, W) = ([255'u8, 0'u8, 0'u8, 255'u8], [255'u8, 255'u8, 255'u8, 255'u8]) | 13 (R, W) = ([255'u8, 0'u8, 0'u8, 255'u8], [255'u8, 255'u8, 255'u8, 255'u8]) |
| 14 mat = Material( | 14 mat = Material( |
| 15 name: "mat", | 15 name: "mat", |
| 16 materialType: "textures_material", | |
| 17 textures: { | 16 textures: { |
| 18 "my_little_texture": Texture(image: Image(width: 5, height: 5, imagedata: @[ | 17 "my_little_texture": Texture(image: Image(width: 5, height: 5, imagedata: @[ |
| 19 R, R, R, R, R, | 18 R, R, R, R, R, |
| 20 R, R, W, R, R, | 19 R, R, W, R, R, |
| 21 R, W, W, W, R, | 20 R, W, W, W, R, |
| 24 ]), sampler: sampler) | 23 ]), sampler: sampler) |
| 25 }.toTable | 24 }.toTable |
| 26 ) | 25 ) |
| 27 mat2 = Material( | 26 mat2 = Material( |
| 28 name: "mat2", | 27 name: "mat2", |
| 29 materialType: "textures_material", | |
| 30 textures: { | 28 textures: { |
| 31 "my_little_texture": Texture(image: Image(width: 5, height: 5, imagedata: @[ | 29 "my_little_texture": Texture(image: Image(width: 5, height: 5, imagedata: @[ |
| 32 R, W, R, W, R, | 30 R, W, R, W, R, |
| 33 W, R, W, R, W, | 31 W, R, W, R, W, |
| 34 R, W, R, W, R, | 32 R, W, R, W, R, |
| 37 ]), sampler: sampler) | 35 ]), sampler: sampler) |
| 38 }.toTable | 36 }.toTable |
| 39 ) | 37 ) |
| 40 mat3 = Material( | 38 mat3 = Material( |
| 41 name: "mat3", | 39 name: "mat3", |
| 42 materialType: "plain", | |
| 43 constants: { | 40 constants: { |
| 44 "color": toGPUValue(newVec4f(0, 1, 0, 1)) | 41 "color": toGPUValue(@[newVec4f(0, 1, 0, 1)]) |
| 45 }.toTable | 42 }.toTable |
| 46 ) | 43 ) |
| 47 | 44 |
| 48 proc scene_different_mesh_types(): seq[Mesh] = | 45 proc scene_different_mesh_types(): seq[Mesh] = |
| 49 @[ | 46 @[ |
| 164 shaderConfiguration1 = createShaderConfiguration( | 161 shaderConfiguration1 = createShaderConfiguration( |
| 165 inputs=[ | 162 inputs=[ |
| 166 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), | 163 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), |
| 167 attr[Vec4f]("color", memoryPerformanceHint=PreferFastWrite), | 164 attr[Vec4f]("color", memoryPerformanceHint=PreferFastWrite), |
| 168 attr[Mat4]("transform", perInstance=true), | 165 attr[Mat4]("transform", perInstance=true), |
| 169 attr[uint16]("materialIndex", perInstance=true), | |
| 170 ], | 166 ], |
| 171 intermediates=[ | 167 intermediates=[ |
| 172 attr[Vec4f]("outcolor"), | 168 attr[Vec4f]("outcolor"), |
| 173 attr[uint16]("materialIndexOut", noInterpolation=true), | |
| 174 ], | 169 ], |
| 175 outputs=[attr[Vec4f]("color")], | 170 outputs=[attr[Vec4f]("color")], |
| 176 uniforms=[attr[float32]("time")], | 171 uniforms=[attr[float32]("time")], |
| 177 samplers=[ | 172 samplers=[ |
| 178 attr[Sampler2DType]("my_little_texture", arrayCount=2) | 173 attr[Sampler2DType]("my_little_texture") |
| 179 ], | 174 ], |
| 180 vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = color; materialIndexOut = materialIndex;""", | 175 vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = color;""", |
| 181 fragmentCode="color = texture(my_little_texture[materialIndexOut], outcolor.xy) * 0.5 + outcolor * 0.5;", | 176 fragmentCode="color = texture(my_little_texture, outcolor.xy) * 0.5 + outcolor * 0.5;", |
| 182 ) | 177 ) |
| 183 shaderConfiguration2 = createShaderConfiguration( | 178 shaderConfiguration2 = createShaderConfiguration( |
| 184 inputs=[ | 179 inputs=[ |
| 185 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), | 180 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), |
| 186 attr[Mat4]("transform", perInstance=true), | 181 attr[Mat4]("transform", perInstance=true), |
| 187 ], | 182 ], |
| 188 intermediates=[attr[Vec4f]("outcolor")], | 183 intermediates=[attr[Vec4f]("outcolor")], |
| 189 outputs=[attr[Vec4f]("color")], | 184 outputs=[attr[Vec4f]("color")], |
| 190 uniforms=[attr[Vec4f]("color")], | 185 uniforms=[attr[Vec4f]("color", arrayCount=1)], |
| 191 vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = Uniforms.color;""", | 186 vertexCode="""gl_Position = vec4(position, 1.0) * transform; outcolor = Uniforms.color[0];""", |
| 192 fragmentCode="color = outcolor;", | 187 fragmentCode="color = outcolor;", |
| 193 ) | 188 ) |
| 194 engine.initRenderer({ | 189 engine.initRenderer({ |
| 195 "textures_material": shaderConfiguration1, | 190 "mat": shaderConfiguration1, |
| 196 "plain": shaderConfiguration2, | 191 "mat2": shaderConfiguration1, |
| 192 "mat3": shaderConfiguration2, | |
| 197 }.toTable) | 193 }.toTable) |
| 198 | 194 |
| 199 # INIT SCENES | 195 # INIT SCENES |
| 200 var scenes = [ | 196 var scenes = [ |
| 201 Scene(name: "simple", meshes: scene_simple()), | 197 Scene(name: "simple", meshes: scene_simple()), |
