Mercurial > games > semicongine
comparison semiconginev2/rendering/renderer.nim @ 1253:c4f98eb4bb05
fix: a few things
author | sam <sam@basx.dev> |
---|---|
date | Fri, 26 Jul 2024 23:39:24 +0700 |
parents | 01e9f41d35b1 |
children | b0f4c8ccd49a |
comparison
equal
deleted
inserted
replaced
1252:01e9f41d35b1 | 1253:c4f98eb4bb05 |
---|---|
668 pipeline: Pipeline[TShader], | 668 pipeline: Pipeline[TShader], |
669 mesh: TMesh, | 669 mesh: TMesh, |
670 ) = | 670 ) = |
671 Render(commandBuffer, pipeline, mesh, EMPTY()) | 671 Render(commandBuffer, pipeline, mesh, EMPTY()) |
672 | 672 |
673 proc assertValidPushConstantType(TShader, TPushConstant: typedesc) = | |
674 assert sizeof(TPushConstant) <= PUSH_CONSTANT_SIZE, "Push constant values must be <= 128 bytes" | |
675 var foundPushConstant = false | |
676 for fieldname, fieldvalue in default(TShader).fieldPairs(): | |
677 when hasCustomPragma(fieldvalue, PushConstantAttribute): | |
678 assert typeof(fieldvalue) is TPushConstant, "Provided push constant has not same type as declared in shader" | |
679 assert foundPushConstant == false, "More than on push constant found in shader" | |
680 foundPushConstant = true | |
681 assert foundPushConstant == true, "No push constant found in shader" | |
682 | |
673 proc RenderWithPushConstant*[TShader, TMesh, TInstance, TPushConstant]( | 683 proc RenderWithPushConstant*[TShader, TMesh, TInstance, TPushConstant]( |
674 commandBuffer: VkCommandBuffer, | 684 commandBuffer: VkCommandBuffer, |
675 pipeline: Pipeline[TShader], | 685 pipeline: Pipeline[TShader], |
676 mesh: TMesh, | 686 mesh: TMesh, |
677 instances: TInstance, | 687 instances: TInstance, |
678 pushConstant: TPushConstant, | 688 pushConstant: TPushConstant, |
679 ) = | 689 ) = |
690 static: assertValidPushConstantType(TShader, TPushConstant) | |
680 vkCmdPushConstants( | 691 vkCmdPushConstants( |
681 commandBuffer = commandBuffer, | 692 commandBuffer = commandBuffer, |
682 layout = pipeline.layout, | 693 layout = pipeline.layout, |
683 stageFlags = VkShaderStageFlags(VK_SHADER_STAGE_ALL_GRAPHICS), | 694 stageFlags = VkShaderStageFlags(VK_SHADER_STAGE_ALL_GRAPHICS), |
684 offset = 0, | 695 offset = 0, |
685 size = 128, | 696 size = PUSH_CONSTANT_SIZE, |
686 pValues = addr(pushConstant) | 697 pValues = addr(pushConstant) |
687 ); | 698 ); |
688 Render(commandBuffer, pipeline, mesh, instances) | 699 Render(commandBuffer, pipeline, mesh, instances) |
689 proc RenderWithPushConstant*[TShader, TMesh, TPushConstant]( | 700 proc RenderWithPushConstant*[TShader, TMesh, TPushConstant]( |
690 commandBuffer: VkCommandBuffer, | 701 commandBuffer: VkCommandBuffer, |
691 pipeline: Pipeline[TShader], | 702 pipeline: Pipeline[TShader], |
692 mesh: TMesh, | 703 mesh: TMesh, |
693 pushConstant: TPushConstant, | 704 pushConstant: TPushConstant, |
694 ) = | 705 ) = |
706 static: assertValidPushConstantType(TShader, TPushConstant) | |
695 vkCmdPushConstants( | 707 vkCmdPushConstants( |
696 commandBuffer = commandBuffer, | 708 commandBuffer = commandBuffer, |
697 layout = pipeline.layout, | 709 layout = pipeline.layout, |
698 stageFlags = VkShaderStageFlags(VK_SHADER_STAGE_ALL_GRAPHICS), | 710 stageFlags = VkShaderStageFlags(VK_SHADER_STAGE_ALL_GRAPHICS), |
699 offset = 0, | 711 offset = 0, |
700 size = 128, | 712 size = PUSH_CONSTANT_SIZE, |
701 pValues = addr(pushConstant) | 713 pValues = addr(pushConstant) |
702 ); | 714 ); |
703 Render(commandBuffer, pipeline, mesh, EMPTY()) | 715 Render(commandBuffer, pipeline, mesh, EMPTY()) |
704 | 716 |
705 proc asGPUArray*[T](data: openArray[T], bufferType: static BufferType): auto = | 717 proc asGPUArray*[T](data: openArray[T], bufferType: static BufferType): auto = |