-
Notifications
You must be signed in to change notification settings - Fork 0
/
vk.scm
executable file
·143 lines (98 loc) · 3.3 KB
/
vk.scm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/scheme
;; (load "vulkan/instance.scm")
;; (load "vulkan/structure-types.scm")
;; (load "ffi.scm")
(library-directories '("./thunderchez" "."))
(import (prelude)
(ffi)
(assimp)
(glfw)
(shaderc)
(camera)
(image)
;; (renderdoc)
(srfi s43 vectors)
(vulkan structure-types)
(matchable))
(begin (glfw-init)
(define v (load-shared-object "libvulkan.so.1"))
(load "vulkan/enums.scm")
(load "vulkan/ftype.scm")
(load "vulkan/instance.scm")
(load "vulkan/surface.scm")
(load "vulkan/queues.scm")
(load "vulkan/devices.scm")
(load "vulkan/swapchain.scm"))
(define-record-type vulkan-state
(fields window surface physical-device queue-index device queues swapchain))
(define setup-vulkan
(lambda ()
(let* ((instance (init-vulkan))
(_ (glfw-init))
(window (setup-window instance 3840 2160))
(surface (window-details-surface window))
(physical-device (array-pointer-raw-ptr (get-physical-devices instance)))
(queue-index (find-queue-family physical-device surface))
(device (create-logical-device physical-device queue-index))
(queues (create-queue-handles device))
(swapchain-details (create-swapchain physical-device device surface queue-index)))
(make-vulkan-state window surface physical-device queue-index device queues
swapchain-details))))
(define vs (setup-vulkan))
(load "vulkan/images.scm")
(load "vulkan/pipeline.scm")
(load "vulkan/texture.scm")
(load "vulkan/buffers.scm")
;; ;; (start-frame-capture)
;; (load "vulkan/sync.scm")
(define window (window-details-window (vulkan-state-window vs)))
(start-loop)
#!eof
> (load "vk.scm")
> (load "ffi.scm")
> (import (ffi))
> (load "vulkan/ftype.scm")
> (define vs (setup-vulkan))
;; (define validation? #t)
;; (trace make-vulkan-instance)
;; (define instance (make-vulkan-instance #t))
;; (ftype-pointer-ftype instance)
;; (create-debug-utils-messenger instance)
;; (ptr->strings (get-required-extensions))
;; (get-procedure-address instance "vkEnumeratePhysicalDevices")
;; (define count (make-foreign-object int))
;; (define strs (make-foreign-object uptr))
;; (define layers (make-ftype-pointer uptr (17 * )))
;; (define c (make-foreign-object int))
;; ((foreign-procedure "vkEnumeratePhysicalDevices" ((& vk-instance) (* int) uptr) int)
;; instance c 0)
;; (ftype-pointer->sexpr c)
;; (_enumerate-physical-devices instance
;; count
;; 0)
;; (get-physical-devices instance)
;; (trace-define-syntax define-enum-library
;; (lambda (stx)
;; (define (identifiers e*)
;; (let lp ((e* e*)
;; (ids '()))
;; (cond
;; ((null? e*) ids)
;; (else
;; (syntax-case (car e*) ()
;; ((e _) (lp (cdr e*)
;; (cons #'e ids)))
;; (e (lp (cdr e*)
;; (cons #'e ids))))))))
;; (syntax-case stx ()
;; ((_ library-name enum-name e* ...)
;; (with-syntax (((e ...) (identifiers #'(e* ...))))
;; (syntax (library library-name
;; (export e ...)
;; (import (ffi))
;; (define-enum-ftype enum-name e* ...))))))))
;; (trace-define-syntax define-vulkan-enum
;; (syntax-rules ()
;; ((_ enum-name e* ...)
;; (define-enum-library (vulkan enum-name) enum-name e* ...))))
;; (define-vulkan-enum vk-result vk-false vk-true)