-
Notifications
You must be signed in to change notification settings - Fork 1
/
macros.lisp
executable file
·73 lines (67 loc) · 2.97 KB
/
macros.lisp
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
(in-package :krma)
(eval-when (:compile-toplevel :load-toplevel)
(when krma::*debug*
(declaim (optimize (safety 3) (debug 3)))))
(defmacro maybe-defer-debug ((app) &body body)
"Sets up `ignore' restart, and records error message and backtrace in application object."
(let ((app-sym (gensym)))
`(let ((,app-sym ,app))
(restart-bind ((ignore (lambda (&optional c)
(declare (ignorable c))
(throw :ignore nil))))
(catch :ignore
(handler-bind ((error (lambda (c)
(record-error-msg ,app-sym c)
(record-backtrace ,app-sym))))
,@body))))))
(defmacro rm-dispatch-to-render-thread-with-handle ((resource draw-data-var handle-var) &body body)
(let ((dd0-sym (gensym))
(dd1-sym (gensym))
(ddvec-sym (gensym)))
`(let* ((,ddvec-sym (rm-draw-data ,resource)))
(declare (type vector ,ddvec-sym))
(let ((,dd0-sym (svref ,ddvec-sym 0))
(,dd1-sym (svref ,ddvec-sym 1)))
(declare (type retained-mode-draw-data ,dd0-sym ,dd1-sym))
(let ((,handle-var (gen-rm-handle)))
(let ((,draw-data-var ,dd0-sym))
(lparallel.queue:push-queue
#'(lambda () ,@body)
(draw-data-work-queue ,dd0-sym)))
(let ((,draw-data-var ,dd1-sym))
(lparallel.queue:push-queue
#'(lambda () ,@body)
(draw-data-work-queue ,dd1-sym)))
,handle-var)))))
(defmacro rm-dispatch-to-render-thread ((resource draw-data-var) &body body)
(let ((dd0-sym (gensym))
(dd1-sym (gensym))
(ddvec-sym (gensym)))
`(let* ((,ddvec-sym (rm-draw-data ,resource)))
(declare (type vector ,ddvec-sym))
(let ((,dd0-sym (svref ,ddvec-sym 0))
(,dd1-sym (svref ,ddvec-sym 1)))
(declare (type retained-mode-draw-data ,dd0-sym ,dd1-sym))
(let ((,draw-data-var ,dd0-sym))
(lparallel.queue:push-queue
#'(lambda () ,@body)
(draw-data-work-queue ,dd0-sym)))
(let ((,draw-data-var ,dd1-sym))
(lparallel.queue:push-queue
#'(lambda () ,@body)
(draw-data-work-queue ,dd1-sym)))
(values)))))
(defmacro with-graphics-queue-and-command-buffer ((dpy queue-var command-buffer-var) &body body)
(let ((helper-window-sym (gensym))
(device-sym (gensym))
(index-sym (gensym))
(command-pool-sym (gensym))
(dpy-sym (gensym)))
`(let* ((,dpy-sym ,dpy)
(,helper-window-sym (clui::helper-window ,dpy-sym))
(,device-sym (default-logical-device ,dpy-sym))
(,index-sym (queue-family-index (render-surface ,helper-window-sym)))
(,queue-var (find-queue ,device-sym ,index-sym))
(,command-pool-sym (find-command-pool ,device-sym ,index-sym))
(,command-buffer-var (elt (command-buffers ,command-pool-sym) 0)))
,@body)))