# HG changeset patch # User sam # Date 1718763444 -25200 # Node ID 836dc1eda5e350144294fe467786045caee25b4b # Parent e7cbb13999e4859f2d7a2932a13d3083379bcf0d did: some stuff diff -r e7cbb13999e4 -r 836dc1eda5e3 static_utils.nim --- a/static_utils.nim Mon Jun 17 22:21:59 2024 +0700 +++ b/static_utils.nim Wed Jun 19 09:17:24 2024 +0700 @@ -106,18 +106,18 @@ else: return 1 - type - Renderable[IndexType: static VkIndexType] = object + Renderable = object buffers: seq[VkBuffer] offsets: seq[VkDeviceSize] instanceCount: uint32 - when IndexType == VK_INDEX_TYPE_NONE_KHR: - vertexCount: uint32 - else: - indexBuffer: VkBuffer - indexCount: uint32 - indexBufferOffset: VkDeviceSize + case indexType: VkIndexType + of VK_INDEX_TYPE_NONE_KHR: + vertexCount: uint32 + of VK_INDEX_TYPE_UINT8_EXT, VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32: + indexBuffer: VkBuffer + indexCount: uint32 + indexBufferOffset: VkDeviceSize Pipeline = object pipeline: VkPipeline layout: VkPipelineLayout @@ -271,7 +271,7 @@ ) -proc Render*[IndexType: static VkIndexType](renderable: Renderable[IndexType], commandBuffer: VkCommandBuffer, pipeline: Pipeline, frameInFlight: int) = +proc Render*(renderable: Renderable, commandBuffer: VkCommandBuffer, pipeline: Pipeline, frameInFlight: int) = assert 0 <= frameInFlight and frameInFlight < 2 commandBuffer.vkCmdBindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline.pipeline) commandBuffer.vkCmdBindDescriptorSets( @@ -289,7 +289,7 @@ pBuffers = renderable.buffers.ToCPointer(), pOffsets = renderable.offsets.ToCPointer() ) - when IndexType != VK_INDEX_TYPE_NONE_KHR: + if renderable.indexType != VK_INDEX_TYPE_NONE_KHR: commandBuffer.vkCmdBindIndexBuffer( renderable.indexBuffer, renderable.indexBufferOffset, diff -r e7cbb13999e4 -r 836dc1eda5e3 test2.nim --- a/test2.nim Mon Jun 17 22:21:59 2024 +0700 +++ b/test2.nim Wed Jun 19 09:17:24 2024 +0700 @@ -1,10 +1,41 @@ +import std/os + +import semicongine/platform/window +import semicongine/core/vulkanapi +import semicongine/vulkan/instance +import semicongine/vulkan/device +import semicongine/vulkan/physicaldevice +# import ./vulkan/shader + +import semicongine/core/vector +import semicongine/core/matrix + type - ShaderInputA = object - positions {.VertexAttribute.}: seq[Vec3f] - colors {.VertexAttribute.}: seq[Vec3f] - transforms {.InstanceAttribute.}: seq[Vec3f] - other: bool + MeshA = object + positions: seq[Vec3f] + colors: seq[Vec3f] + transparency: float32 + ArrayData = object + transforms: seq[Vec3f] + Enemy = object - shaderData: ShaderInputA + mesh: MeshA + enemies: ArrayData + +let e = Enemy() +echo e -proc initEnemy() +let w = CreateWindow("test2") +putEnv("VK_LAYER_ENABLES", "VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_AMD,VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_NVIDIA,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXTVK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT") +let i = w.CreateInstance( + vulkanVersion = VK_MAKE_API_VERSION(0, 1, 3, 0), + instanceExtensions = @[], + layers = @["VK_LAYER_KHRONOS_validation"], +) + +let selectedPhysicalDevice = i.GetPhysicalDevices().FilterBestGraphics() +let d = i.CreateDevice( + selectedPhysicalDevice, + enabledExtensions = @[], + selectedPhysicalDevice.FilterForGraphicsPresentationQueues() +)