Types
Buffer = object
BufferType = enum VertexBuffer, VertexBufferMapped, IndexBuffer, IndexBufferMapped, UniformBuffer, UniformBufferMapped
DescriptorSetData[T] = object data*: T
MemoryBlock = object
NativeWindow = object display*: ptr xlib.Display window*: x11.Window
Pipeline[TShader] = object descriptorSetLayouts*: array[MAX_DESCRIPTORSETS, VkDescriptorSetLayout]
RenderData = ref RenderDataObject
RenderPass = ref object vk*: VkRenderPass samples*: VkSampleCountFlagBits depthBuffer*: bool
Swapchain = ref object renderPass*: RenderPass vSync*: bool tripleBuffering*: bool width*: uint32 height*: uint32 depthImageView*: VkImageView msaaImageView*: VkImageView queueFinishedFence*: array[2'u32.int, VkFence] imageAvailableSemaphore*: array[2'u32.int, VkSemaphore] renderFinishedSemaphore*: array[2'u32.int, VkSemaphore]
VulkanGlobals = object instance*: VkInstance device*: VkDevice physicalDevice*: VkPhysicalDevice window*: NativeWindow graphicsQueueFamily*: uint32 graphicsQueue*: VkQueue swapchain*: Swapchain anisotropy*: float32 = 0.0
Vars
vulkan = VulkanGlobals(anisotropy: 0.0)
Consts
DEPTH_FORMAT = VK_FORMAT_D32_SFLOAT
INFLIGHTFRAMES = 2'u32
SURFACE_FORMAT = VK_FORMAT_B8G8R8A8_SRGB
Procs
proc asDescriptorSetData[T](data: sink T): auto
proc asGPUArray[T](data: sink openArray[T]; bufferType: static BufferType): auto
proc asGPUValue[T](data: sink T; bufferType: static BufferType): auto
proc assignBuffers(renderdata: var RenderData; descriptorSet: var DescriptorSetData; uploadData = true)
proc assignBuffers[T](renderdata: var RenderData; data: var T; uploadData = true)
proc bestMemory(mappable: bool; filter: seq[uint32] = @[]): uint32 {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc bindDescriptorSet[TDescriptorSet, TShader](commandBuffer: VkCommandBuffer; descriptorSet: DescriptorSetData[TDescriptorSet]; index: static DescriptorSetIndex; pipeline: Pipeline[TShader])
proc bindDescriptorSet[TDescriptorSet](commandBuffer: VkCommandBuffer; descriptorSet: DescriptorSetData[TDescriptorSet]; index: static DescriptorSetIndex; layout: VkPipelineLayout)
proc clearSwapchain() {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc createDirectPresentationRenderPass(depthBuffer: bool; samples = VK_SAMPLE_COUNT_1_BIT): RenderPass {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc createIndirectPresentationRenderPass(depthBuffer: bool; samples = VK_SAMPLE_COUNT_1_BIT): (RenderPass, RenderPass) {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc createPipeline[TShader](renderPass: RenderPass; topology: VkPrimitiveTopology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; polygonMode: VkPolygonMode = VK_POLYGON_MODE_FILL; cullMode: openArray[VkCullModeFlagBits] = [VK_CULL_MODE_BACK_BIT]; frontFace: VkFrontFace = VK_FRONT_FACE_CLOCKWISE; lineWidth = 1.0'f32; depthClampEnable = false): Pipeline[ TShader]
proc createWindow(title: string): NativeWindow {....raises: [Exception], tags: [], forbids: [].}
proc currentFiF(): int {....raises: [], tags: [], forbids: [].}
proc destroy(window: NativeWindow) {....raises: [Exception], tags: [], forbids: [].}
proc destroyPipeline(pipeline: Pipeline)
proc destroyRenderData(renderData: RenderData) {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc destroyRenderPass(renderPass: RenderPass) {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc destroySwapchain(swapchain: Swapchain) {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc destroyVulkan() {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc flushAllMemory(renderData: RenderData) {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc flushBuffer(buffer: Buffer) {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc fullscreen(): bool {....raises: [], tags: [], forbids: [].}
proc getAspectRatio(): float32 {....raises: [], tags: [], forbids: [].}
proc getMousePosition(window: NativeWindow): Vec2i {....raises: [], tags: [], forbids: [].}
proc hasValidationLayer(): bool {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc initDescriptorSet(renderData: RenderData; layout: VkDescriptorSetLayout; descriptorSet: DescriptorSetData)
proc initRenderData(descriptorPoolLimit = 1024'u32): RenderData {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc initVulkan(appName: string = "semicongine app") {. ...raises: [Exception, OSError, KeyError], tags: [RootEffect, WriteEnvEffect], forbids: [].}
func layout(pipeline: Pipeline; level: int): VkDescriptorSetLayout
proc maxFramebufferSampleCount(maxSamples = VK_SAMPLE_COUNT_8_BIT): VkSampleCountFlagBits {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc pendingEvents(window: NativeWindow): seq[Event] {....raises: [], tags: [], forbids: [].}
proc recreateSwapchain() {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc recreateSwapchain(vSync: bool; tripleBuffering: bool) {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc render[TShader, TMesh, TInstance](commandBuffer: VkCommandBuffer; pipeline: Pipeline[TShader]; mesh: TMesh; instances: TInstance; fixedVertexCount = -1; fixedInstanceCount = -1)
proc render[TShader, TMesh](commandBuffer: VkCommandBuffer; pipeline: Pipeline[TShader]; mesh: TMesh; fixedVertexCount = -1; fixedInstanceCount = -1)
proc renderWithPushConstant[TShader, TMesh, TInstance, TPushConstant]( commandBuffer: VkCommandBuffer; pipeline: Pipeline[TShader]; mesh: TMesh; instances: TInstance; pushConstant: TPushConstant; fixedVertexCount = -1; fixedInstanceCount = -1)
proc renderWithPushConstant[TShader, TMesh, TPushConstant]( commandBuffer: VkCommandBuffer; pipeline: Pipeline[TShader]; mesh: TMesh; pushConstant: TPushConstant; fixedVertexCount = -1; fixedInstanceCount = -1)
proc setFullscreen(enable: bool) {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc setFullscreen(window: var NativeWindow; enable: bool) {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc setMousePosition(window: NativeWindow; pos: Vec2i) {....raises: [], tags: [], forbids: [].}
proc setTitle(window: NativeWindow; title: string) {....raises: [], tags: [], forbids: [].}
proc setupSwapchain(renderPass: RenderPass; vSync: bool = false) {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc showSystemCursor(value: bool) {....raises: [Exception], tags: [], forbids: [].}
proc showSystemCursor(window: NativeWindow; value: bool) {....raises: [Exception], tags: [], forbids: [].}
proc size(window: NativeWindow): Vec2i {....raises: [], tags: [], forbids: [].}
proc svkAllocateMemory(size: uint64; typeIndex: uint32): VkDeviceMemory {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkCreate2DImage(width, height: uint32; format: VkFormat; usage: openArray[VkImageUsageFlagBits]; samples = VK_SAMPLE_COUNT_1_BIT; nLayers = 1'u32): VkImage {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkCreate2DImageView(image: VkImage; format: VkFormat; aspect = VK_IMAGE_ASPECT_COLOR_BIT; nLayers = 1'u32; isArray = false): VkImageView {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkCreateBuffer(size: uint64; usage: openArray[VkBufferUsageFlagBits]): VkBuffer {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkCreateFence(signaled = false): VkFence {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkCreateFramebuffer(renderpass: VkRenderPass; width, height: uint32; attachments: openArray[VkImageView]): VkFramebuffer {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkCreateSemaphore(): VkSemaphore {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkGetBufferMemoryRequirements(buffer: VkBuffer): tuple[size: uint64, alignment: uint64, memoryTypes: seq[uint32]] {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkGetDeviceQueue(device: VkDevice; queueFamilyIndex: uint32; qType: VkQueueFlagBits): VkQueue {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkGetImageMemoryRequirements(image: VkImage): tuple[size: uint64, alignment: uint64, memoryTypes: seq[uint32]] {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkGetPhysicalDeviceProperties(): VkPhysicalDeviceProperties {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkGetPhysicalDeviceSurfacePresentModesKHR(): seq[VkPresentModeKHR] {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkGetPhysicalDeviceSurfaceSupportKHR(queueFamily: uint32): bool {. ...raises: [Exception], tags: [RootEffect], forbids: [].}
proc svkResetFences(fence: VkFence) {....raises: [Exception], tags: [RootEffect], forbids: [].}
proc updateAllGPUBuffers[T](value: T; flush = false)
proc updateGPUBuffer(gpuData: GPUData; count = 0'u64; flush = false)
proc uploadImages(renderdata: var RenderData; descriptorSet: var DescriptorSetData)
Templates
template DescriptorSet(index: DescriptorSetIndex) {.pragma.}
template InstanceAttribute() {.pragma.}
template Pass() {.pragma.}
template PassFlat() {.pragma.}
template PushConstant() {.pragma.}
template ShaderOutput() {.pragma.}
template VertexAttribute() {.pragma.}
template withNextFrame(framebufferName, commandBufferName, body: untyped): untyped
template withPipeline(commandbuffer: VkCommandBuffer; pipeline: Pipeline; body: untyped): untyped
template withRenderPass(theRenderPass: RenderPass; theFramebuffer: VkFramebuffer; commandbuffer: VkCommandBuffer; renderWidth: uint32; renderHeight: uint32; clearColor: Vec4f; body: untyped): untyped
template withSingleUseCommandBuffer(cmd, body: untyped): untyped
template withStagingBuffer[T: (VkBuffer, uint64) | (VkImage, uint32, uint32, uint32)](target: T; bufferSize: uint64; dataPointer, body: untyped): untyped