blob: a24feb2dfc50baf37236429b152590b98deae5a7 (
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
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
|
;;; 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 pipelines.
;;
;;; Code:
(define-module (chickadee graphics pipeline)
#:use-module ((chickadee graphics backend) #:prefix gpu:)
#:use-module (chickadee graphics color)
#:use-module (chickadee graphics depth-stencil)
#:use-module (chickadee graphics layout)
#:use-module (chickadee graphics primitive)
#:use-module (ice-9 match)
#:use-module (srfi srfi-9)
#:use-module (srfi srfi-9 gnu)
#:export (make-render-pipeline
destroy-render-pipeline
render-pipeline?
render-pipeline-name
render-pipeline-shader
render-pipeline-primitive
render-pipeline-color-target
render-pipeline-depth+stencil
render-pipeline-vertex-layout
render-pipeline-binding-layout)
#:re-export (make-vertex-attribute
vertex-attribute?
vertex-attribute-format
vertex-attribute-offset
make-vertex-buffer-layout
vertex-buffer-layout?
vertex-buffer-layout-stride
vertex-buffer-layout-step-mode
vertex-buffer-layout-attributes
make-texture-layout
texture-layout?
texture-layout-sample-type
texture-layout-dimension
texture-layout-multisample?
make-sampler-layout
sampler-layout?
sampler-layout-type
make-buffer-layout
buffer-layout?
buffer-layout-type
buffer-layout-min-size))
(define shader-handle (@@ (chickadee graphics shader) shader-handle))
(define-record-type <render-pipeline>
(%make-render-pipeline gpu handle name shader primitive color-target
depth+stencil multisample vertex-layout binding-layout)
render-pipeline?
(gpu render-pipeline-gpu)
(handle render-pipeline-handle)
(name render-pipeline-name)
(destroyed? render-pipeline-destroyed? set-render-pipeline-destroyed!)
(shader render-pipeline-shader)
(primitive render-pipeline-primitive)
(color-target render-pipeline-color-target)
(depth+stencil render-pipeline-depth+stencil)
(multisample render-pipeline-multisample)
(vertex-layout render-pipeline-vertex-layout)
(binding-layout render-pipeline-binding-layout))
(define (print-render-pipeline pipeline port)
(format port "#<render-pipeline name: ~a>"
(render-pipeline-name pipeline)))
(set-record-type-printer! <render-pipeline> print-render-pipeline)
(define* (make-render-pipeline #:key name shader
(primitive (make-primitive-mode))
(color-target (make-color-target))
depth+stencil
multisample
(vertex-layout #())
(binding-layout #()))
(let* ((gpu (gpu:current-gpu))
(handle (gpu:make-render-pipeline gpu (shader-handle shader)
primitive color-target depth+stencil
multisample vertex-layout
binding-layout)))
(%make-render-pipeline gpu handle name shader primitive color-target
multisample depth+stencil vertex-layout binding-layout)))
(define (destroy-render-pipeline pipeline)
(unless (render-pipeline-destroyed? pipeline)
(gpu:destroy-render-pipeline (gpu:current-gpu)
(render-pipeline-handle pipeline))
(set-render-pipeline-destroyed! pipeline #t)))
|