Mercurial > games > semicongine
diff semiconginev2/rendering.nim @ 1229:5dcb503ef0c0
did: refactor renderpass a bit, enable depth buffering and msaa on offscreen-rendering
author | sam <sam@basx.dev> |
---|---|
date | Thu, 18 Jul 2024 21:32:41 +0700 |
parents | 4e465583ea32 |
children | 70f6c1cfe005 |
line wrap: on
line diff
--- a/semiconginev2/rendering.nim Thu Jul 18 16:33:24 2024 +0700 +++ b/semiconginev2/rendering.nim Thu Jul 18 21:32:41 2024 +0700 @@ -12,6 +12,8 @@ const MEMORY_BLOCK_ALLOCATION_SIZE = 100_000_000'u64 # ca. 100mb per block, seems reasonable const BUFFER_ALLOCATION_SIZE = 9_000_000'u64 # ca. 9mb per block, seems reasonable, can put 10 buffers into one memory block const MAX_DESCRIPTORSETS = 4 +const SURFACE_FORMAT* = VK_FORMAT_B8G8R8A8_SRGB +const DEPTH_FORMAT* = VK_FORMAT_D32_SFLOAT # custom pragmas to classify shader attributes template VertexAttribute* {.pragma.} @@ -42,29 +44,37 @@ debugMessenger: VkDebugUtilsMessengerEXT # unclear as of yet anisotropy*: float32 = 0 # needs to be enable during device creation - Swapchain* = object + Renderpass* = ref object + vk*: VkRenderPass + samples*: VkSampleCountFlagBits + depthBuffer*: bool + Swapchain* = ref object # parameters to InitSwapchain, required for swapchain recreation - renderPass: VkRenderPass + renderPass*: RenderPass vSync: bool - samples*: VkSampleCountFlagBits # populated through InitSwapchain proc vk: VkSwapchainKHR width*: uint32 height*: uint32 - msaaImage: VkImage - msaaMemory: VkDeviceMemory - msaaImageView: VkImageView framebuffers: seq[VkFramebuffer] framebufferViews: seq[VkImageView] currentFramebufferIndex: uint32 commandBufferPool: VkCommandPool + # depth buffer stuff, if enabled + depthImage: VkImage + depthImageView*: VkImageView + depthMemory: VkDeviceMemory + # MSAA stuff, if enabled + msaaImage: VkImage + msaaImageView*: VkImageView + msaaMemory: VkDeviceMemory # frame-in-flight handling currentFiF: range[0 .. (INFLIGHTFRAMES - 1).int] queueFinishedFence*: array[INFLIGHTFRAMES.int, VkFence] imageAvailableSemaphore*: array[INFLIGHTFRAMES.int, VkSemaphore] renderFinishedSemaphore*: array[INFLIGHTFRAMES.int, VkSemaphore] commandBuffers: array[INFLIGHTFRAMES.int, VkCommandBuffer] - oldSwapchain: ref Swapchain + oldSwapchain: Swapchain oldSwapchainCounter: int # swaps until old swapchain will be destroyed var vulkan*: VulkanGlobals @@ -115,6 +125,7 @@ imageview*: VkImageView sampler*: VkSampler isRenderTarget*: bool = false + samples*: VkSampleCountFlagBits = VK_SAMPLE_COUNT_1_BIT GPUArray*[T: SupportedGPUType, TBuffer: static BufferType] = object data*: seq[T] buffer*: Buffer