Mercurial > games > semicongine
diff src/semicongine/renderer.nim @ 321:30117d8f0052
did next step in renderpipeline-refactoring, using shaderconfiguration objects instead for less ambigious shader-pipeline configuration
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 15 Aug 2023 23:51:37 +0700 |
parents | 9efc258df208 |
children | 6dab370d1758 |
line wrap: on
line diff
--- a/src/semicongine/renderer.nim Sun Aug 13 19:00:11 2023 +0700 +++ b/src/semicongine/renderer.nim Tue Aug 15 23:51:37 2023 +0700 @@ -56,31 +56,31 @@ raise newException(Exception, "Unable to create swapchain") result.swapchain = swapchain.get() -proc setupDrawableBuffers*(renderer: var Renderer, scene: Scene, inputs: seq[ShaderAttribute], samplers: seq[ShaderAttribute], transformAttribute="transform", materialIndexAttribute="materialIndex") = +proc setupDrawableBuffers*(renderer: var Renderer, scene: Scene, inputs: seq[ShaderAttribute], samplers: seq[ShaderAttribute]) = assert not (scene in renderer.scenedata) const VERTEX_ATTRIB_ALIGNMENT = 4 # used for buffer alignment var scenedata = SceneData() # if mesh transformation are handled through the scenegraph-transformation, set it up here - if transformattribute != "": + if scene.transformAttribute != "": var hasTransformAttribute = false for input in inputs: - if input.name == transformattribute: + if input.name == scene.transformAttribute: assert input.perInstance == true, $input assert getDataType[Mat4]() == input.thetype hasTransformAttribute = true assert hasTransformAttribute - scenedata.transformAttribute = transformAttribute + scenedata.transformAttribute = scene.transformAttribute # check if we have support for material indices, if required - if materialIndexAttribute != "": + if scene.materialIndexAttribute != "": var hasMaterialIndexAttribute = false for input in inputs: - if input.name == materialIndexAttribute: + if input.name == scene.materialIndexAttribute: assert getDataType[uint16]() == input.thetype hasMaterialIndexAttribute = true assert hasMaterialIndexAttribute - scenedata.materialIndexAttribute = materialIndexAttribute + scenedata.materialIndexAttribute = scene.materialIndexAttribute # find all meshes, populate missing attribute values for shader var allMeshes: seq[Mesh] @@ -312,7 +312,7 @@ debug " Index buffer: ", renderer.scenedata[scene].indexBuffer for drawable in renderer.scenedata[scene].drawables.values: - commandBuffer.draw(drawable, vertexBuffers=renderer.scenedata[scene].vertexBuffers, indexBuffer=renderer.scenedata[scene].indexBuffer) + drawable.draw(commandBuffer, vertexBuffers=renderer.scenedata[scene].vertexBuffers, indexBuffer=renderer.scenedata[scene].indexBuffer) if i < renderer.renderPass.subpasses.len - 1: commandBuffer.vkCmdNextSubpass(VK_SUBPASS_CONTENTS_INLINE)