summaryrefslogtreecommitdiff
path: root/chickadee/graphics/pass.scm
blob: 889d28ddcb21ca1560a5447552f6ce073cef6f9d (plain)
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
;;; Chickadee Game Toolkit
;;; Copyright © 2023 David Thompson <dthompson2@worcester.edu>
;;;
;;; Licensed under the Apache License, Version 2.0 (the "License");
;;; you may not use this file except in compliance with the License.
;;; You may obtain a copy of the License at
;;;
;;;    http://www.apache.org/licenses/LICENSE-2.0
;;;
;;; Unless required by applicable law or agreed to in writing, software
;;; distributed under the License is distributed on an "AS IS" BASIS,
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;; See the License for the specific language governing permissions and
;;; limitations under the License.

;;; Commentary:
;;
;; GPU render passes.
;;
;;; Code:

(define-module (chickadee graphics pass)
  #:use-module (chickadee graphics color)
  #:use-module (chickadee graphics depth-stencil)
  #:use-module (srfi srfi-9)
  #:export (<color-attachment>
            make-color-attachment
            color-attachment?
            color-attachment-view
            color-attachment-resolve-target
            color-attachment-clear-color
            color-attachment-load-op
            color-attachment-store-op

            <depth+stencil-attachment>
            make-depth+stencil-attachment
            depth+stencil-attachment?
            depth+stencil-attachment-view
            depth+stencil-attachment-depth-clear-value
            depth+stencil-attachment-depth-load-op
            depth+stencil-attachment-depth-store-op
            depth+stencil-attachment-depth-read-only?
            depth+stencil-attachment-stencil-clear-value
            depth+stencil-attachment-stencil-load-op
            depth+stencil-attachment-stencil-store-op
            depth+stencil-attachment-stencil-read-only?

            <render-pass>
            make-render-pass
            render-pass?
            render-pass-color-attachments
            render-pass-depth+stencil-attachment))

(define-record-type <color-attachment>
  (%make-color-attachment view resolve-target operation)
  color-attachment?
  (view color-attachment-view)
  (resolve-target color-attachment-resolve-target)
  (operation color-attachment-operation))

(define* (make-color-attachment #:key view resolve-target
                                (operation (make-color-operation)))
  (%make-color-attachment view resolve-target operation))

(define-record-type <depth+stencil-attachment>
  (%make-depth+stencil-attachment view depth-operation stencil-operation)
  depth+stencil-attachment?
  (view depth+stencil-attachment-view)
  (depth-operation depth+stencil-attachment-depth-operation)
  (stencil-operation depth+stencil-attachment-stencil-operation))

(define* (make-depth+stencil-attachment #:key view
                                        (depth-operation (make-depth-operation))
                                        (stencil-operation (make-stencil-operation)))
  (%make-depth+stencil-attachment view depth-operation stencil-operation))

(define-record-type <render-pass>
  (%make-render-pass color-attachments depth+stencil-attachment)
  render-pass?
  (color-attachments render-pass-color-attachments)
  (depth+stencil-attachment render-pass-depth+stencil-attachment))

(define* (make-render-pass #:key (color-attachments #())
                           depth+stencil-attachment)
  (%make-render-pass color-attachments depth+stencil-attachment))