Mercurial > games > semicongine
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 1228:4e465583ea32 | 1229:5dcb503ef0c0 |
|---|---|
| 10 const INFLIGHTFRAMES* = 2'u32 | 10 const INFLIGHTFRAMES* = 2'u32 |
| 11 const BUFFER_ALIGNMENT = 64'u64 # align offsets inside buffers along this alignment | 11 const BUFFER_ALIGNMENT = 64'u64 # align offsets inside buffers along this alignment |
| 12 const MEMORY_BLOCK_ALLOCATION_SIZE = 100_000_000'u64 # ca. 100mb per block, seems reasonable | 12 const MEMORY_BLOCK_ALLOCATION_SIZE = 100_000_000'u64 # ca. 100mb per block, seems reasonable |
| 13 const BUFFER_ALLOCATION_SIZE = 9_000_000'u64 # ca. 9mb per block, seems reasonable, can put 10 buffers into one memory block | 13 const BUFFER_ALLOCATION_SIZE = 9_000_000'u64 # ca. 9mb per block, seems reasonable, can put 10 buffers into one memory block |
| 14 const MAX_DESCRIPTORSETS = 4 | 14 const MAX_DESCRIPTORSETS = 4 |
| 15 const SURFACE_FORMAT* = VK_FORMAT_B8G8R8A8_SRGB | |
| 16 const DEPTH_FORMAT* = VK_FORMAT_D32_SFLOAT | |
| 15 | 17 |
| 16 # custom pragmas to classify shader attributes | 18 # custom pragmas to classify shader attributes |
| 17 template VertexAttribute* {.pragma.} | 19 template VertexAttribute* {.pragma.} |
| 18 template InstanceAttribute* {.pragma.} | 20 template InstanceAttribute* {.pragma.} |
| 19 template Pass* {.pragma.} | 21 template Pass* {.pragma.} |
| 40 graphicsQueueFamily*: uint32 | 42 graphicsQueueFamily*: uint32 |
| 41 graphicsQueue*: VkQueue | 43 graphicsQueue*: VkQueue |
| 42 debugMessenger: VkDebugUtilsMessengerEXT | 44 debugMessenger: VkDebugUtilsMessengerEXT |
| 43 # unclear as of yet | 45 # unclear as of yet |
| 44 anisotropy*: float32 = 0 # needs to be enable during device creation | 46 anisotropy*: float32 = 0 # needs to be enable during device creation |
| 45 Swapchain* = object | 47 Renderpass* = ref object |
| 48 vk*: VkRenderPass | |
| 49 samples*: VkSampleCountFlagBits | |
| 50 depthBuffer*: bool | |
| 51 Swapchain* = ref object | |
| 46 # parameters to InitSwapchain, required for swapchain recreation | 52 # parameters to InitSwapchain, required for swapchain recreation |
| 47 renderPass: VkRenderPass | 53 renderPass*: RenderPass |
| 48 vSync: bool | 54 vSync: bool |
| 49 samples*: VkSampleCountFlagBits | |
| 50 # populated through InitSwapchain proc | 55 # populated through InitSwapchain proc |
| 51 vk: VkSwapchainKHR | 56 vk: VkSwapchainKHR |
| 52 width*: uint32 | 57 width*: uint32 |
| 53 height*: uint32 | 58 height*: uint32 |
| 54 msaaImage: VkImage | |
| 55 msaaMemory: VkDeviceMemory | |
| 56 msaaImageView: VkImageView | |
| 57 framebuffers: seq[VkFramebuffer] | 59 framebuffers: seq[VkFramebuffer] |
| 58 framebufferViews: seq[VkImageView] | 60 framebufferViews: seq[VkImageView] |
| 59 currentFramebufferIndex: uint32 | 61 currentFramebufferIndex: uint32 |
| 60 commandBufferPool: VkCommandPool | 62 commandBufferPool: VkCommandPool |
| 63 # depth buffer stuff, if enabled | |
| 64 depthImage: VkImage | |
| 65 depthImageView*: VkImageView | |
| 66 depthMemory: VkDeviceMemory | |
| 67 # MSAA stuff, if enabled | |
| 68 msaaImage: VkImage | |
| 69 msaaImageView*: VkImageView | |
| 70 msaaMemory: VkDeviceMemory | |
| 61 # frame-in-flight handling | 71 # frame-in-flight handling |
| 62 currentFiF: range[0 .. (INFLIGHTFRAMES - 1).int] | 72 currentFiF: range[0 .. (INFLIGHTFRAMES - 1).int] |
| 63 queueFinishedFence*: array[INFLIGHTFRAMES.int, VkFence] | 73 queueFinishedFence*: array[INFLIGHTFRAMES.int, VkFence] |
| 64 imageAvailableSemaphore*: array[INFLIGHTFRAMES.int, VkSemaphore] | 74 imageAvailableSemaphore*: array[INFLIGHTFRAMES.int, VkSemaphore] |
| 65 renderFinishedSemaphore*: array[INFLIGHTFRAMES.int, VkSemaphore] | 75 renderFinishedSemaphore*: array[INFLIGHTFRAMES.int, VkSemaphore] |
| 66 commandBuffers: array[INFLIGHTFRAMES.int, VkCommandBuffer] | 76 commandBuffers: array[INFLIGHTFRAMES.int, VkCommandBuffer] |
| 67 oldSwapchain: ref Swapchain | 77 oldSwapchain: Swapchain |
| 68 oldSwapchainCounter: int # swaps until old swapchain will be destroyed | 78 oldSwapchainCounter: int # swaps until old swapchain will be destroyed |
| 69 | 79 |
| 70 var vulkan*: VulkanGlobals | 80 var vulkan*: VulkanGlobals |
| 71 var fullscreen: bool | 81 var fullscreen: bool |
| 72 | 82 |
| 113 data*: seq[T] | 123 data*: seq[T] |
| 114 vk*: VkImage | 124 vk*: VkImage |
| 115 imageview*: VkImageView | 125 imageview*: VkImageView |
| 116 sampler*: VkSampler | 126 sampler*: VkSampler |
| 117 isRenderTarget*: bool = false | 127 isRenderTarget*: bool = false |
| 128 samples*: VkSampleCountFlagBits = VK_SAMPLE_COUNT_1_BIT | |
| 118 GPUArray*[T: SupportedGPUType, TBuffer: static BufferType] = object | 129 GPUArray*[T: SupportedGPUType, TBuffer: static BufferType] = object |
| 119 data*: seq[T] | 130 data*: seq[T] |
| 120 buffer*: Buffer | 131 buffer*: Buffer |
| 121 offset*: uint64 | 132 offset*: uint64 |
| 122 GPUValue*[T: object, TBuffer: static BufferType] = object | 133 GPUValue*[T: object, TBuffer: static BufferType] = object |
