Mercurial > games > semicongine
comparison semicongine/renderer.nim @ 408:848a6845a588
did: overhaul dynamic array-api in a few places
author | Sam <sam@basx.dev> |
---|---|
date | Thu, 04 Jan 2024 21:13:11 +0700 |
parents | ffc265916415 |
children | a430b5febe22 |
comparison
equal
deleted
inserted
replaced
407:ffc265916415 | 408:848a6845a588 |
---|---|
260 # gather textures | 260 # gather textures |
261 scenedata.textures[shaderPipeline.vk] = initTable[string, seq[VulkanTexture]]() | 261 scenedata.textures[shaderPipeline.vk] = initTable[string, seq[VulkanTexture]]() |
262 for texture in shaderPipeline.samplers: | 262 for texture in shaderPipeline.samplers: |
263 scenedata.textures[shaderPipeline.vk][texture.name] = newSeq[VulkanTexture]() | 263 scenedata.textures[shaderPipeline.vk][texture.name] = newSeq[VulkanTexture]() |
264 if scene.shaderGlobals.contains(texture.name): | 264 if scene.shaderGlobals.contains(texture.name): |
265 for textureValue in getValues[Texture](scene.shaderGlobals[texture.name])[]: | 265 for textureValue in scene.shaderGlobals[texture.name][Texture][]: |
266 if not uploadedTextures.contains(textureValue): | 266 if not uploadedTextures.contains(textureValue): |
267 uploadedTextures[textureValue] = renderer.device.uploadTexture(textureValue) | 267 uploadedTextures[textureValue] = renderer.device.uploadTexture(textureValue) |
268 scenedata.textures[shaderPipeline.vk][texture.name].add uploadedTextures[textureValue] | 268 scenedata.textures[shaderPipeline.vk][texture.name].add uploadedTextures[textureValue] |
269 else: | 269 else: |
270 var foundTexture = false | 270 var foundTexture = false |
271 for material in scene.getMaterials(materialType): | 271 for material in scene.getMaterials(materialType): |
272 if material.hasMatchingAttribute(texture): | 272 if material.hasMatchingAttribute(texture): |
273 foundTexture = true | 273 foundTexture = true |
274 let value = get[Texture](material, texture.name) | 274 let value = material[texture.name, Texture][] |
275 assert value.len == 1, &"Mesh material attribute '{texture.name}' has texture-array, but only single textures are allowed" | 275 assert value.len == 1, &"Mesh material attribute '{texture.name}' has texture-array, but only single textures are allowed" |
276 if not uploadedTextures.contains(value[0]): | 276 if not uploadedTextures.contains(value[0]): |
277 uploadedTextures[value[0]] = renderer.device.uploadTexture(value[0]) | 277 uploadedTextures[value[0]] = renderer.device.uploadTexture(value[0]) |
278 scenedata.textures[shaderPipeline.vk][texture.name].add uploadedTextures[value[0]] | 278 scenedata.textures[shaderPipeline.vk][texture.name].add uploadedTextures[value[0]] |
279 assert foundTexture, &"No texture found in shaderGlobals or materials for '{texture.name}'" | 279 assert foundTexture, &"No texture found in shaderGlobals or materials for '{texture.name}'" |
376 value = scene.shaderGlobals[uniform.name] | 376 value = scene.shaderGlobals[uniform.name] |
377 else: | 377 else: |
378 var foundValue = false | 378 var foundValue = false |
379 for material in renderer.scenedata[scene].materials[materialType]: | 379 for material in renderer.scenedata[scene].materials[materialType]: |
380 if material.hasMatchingAttribute(uniform): | 380 if material.hasMatchingAttribute(uniform): |
381 value.appendValues(material.getDataList(uniform.name)) | 381 value.appendValues(material[uniform.name]) |
382 foundValue = true | 382 foundValue = true |
383 assert foundValue, &"Uniform '{uniform.name}' not found in scene shaderGlobals or materials" | 383 assert foundValue, &"Uniform '{uniform.name}' not found in scene shaderGlobals or materials" |
384 assert (uniform.arrayCount == 0 and value.len == 1) or value.len == uniform.arrayCount, &"Uniform '{uniform.name}' found has wrong length (shader declares {uniform.arrayCount} but shaderGlobals and materials provide {value.len})" | 384 assert (uniform.arrayCount == 0 and value.len == 1) or value.len == uniform.arrayCount, &"Uniform '{uniform.name}' found has wrong length (shader declares {uniform.arrayCount} but shaderGlobals and materials provide {value.len})" |
385 let (pdata, size) = value.getRawData() | 385 let (pdata, size) = value.getRawData() |
386 assert size == uniform.size, "During uniform update: gathered value has size {size} but uniform expects size {uniform.size}" | 386 assert size == uniform.size, "During uniform update: gathered value has size {size} but uniform expects size {uniform.size}" |