@@ -75,76 +75,106 @@ impl super::DeviceShared {
75
75
Ok ( match self . render_passes . lock ( ) . entry ( key) {
76
76
Entry :: Occupied ( e) => * e. get ( ) ,
77
77
Entry :: Vacant ( e) => {
78
+ let super :: RenderPassKey {
79
+ ref colors,
80
+ ref depth_stencil,
81
+ sample_count,
82
+ multiview,
83
+ } = * e. key ( ) ;
84
+
78
85
let mut vk_attachments = Vec :: new ( ) ;
79
- let mut color_refs = Vec :: with_capacity ( e . key ( ) . colors . len ( ) ) ;
86
+ let mut color_refs = Vec :: with_capacity ( colors. len ( ) ) ;
80
87
let mut resolve_refs = Vec :: with_capacity ( color_refs. capacity ( ) ) ;
81
88
let mut ds_ref = None ;
82
- let samples = vk:: SampleCountFlags :: from_raw ( e . key ( ) . sample_count ) ;
89
+ let samples = vk:: SampleCountFlags :: from_raw ( sample_count) ;
83
90
let unused = vk:: AttachmentReference {
84
91
attachment : vk:: ATTACHMENT_UNUSED ,
85
92
layout : vk:: ImageLayout :: UNDEFINED ,
86
93
} ;
87
- for cat in e. key ( ) . colors . iter ( ) {
88
- let ( color_ref, resolve_ref) = if let Some ( cat) = cat. as_ref ( ) {
89
- let color_ref = vk:: AttachmentReference {
90
- attachment : vk_attachments. len ( ) as u32 ,
91
- layout : cat. base . layout ,
92
- } ;
93
- vk_attachments. push ( {
94
- let ( load_op, store_op) = conv:: map_attachment_ops ( cat. base . ops ) ;
95
- vk:: AttachmentDescription :: default ( )
96
- . format ( cat. base . format )
97
- . samples ( samples)
98
- . load_op ( load_op)
99
- . store_op ( store_op)
100
- . initial_layout ( cat. base . layout )
101
- . final_layout ( cat. base . layout )
102
- } ) ;
103
- let resolve_ref = if let Some ( ref rat) = cat. resolve {
104
- let ( load_op, store_op) = conv:: map_attachment_ops ( rat. ops ) ;
105
- let vk_attachment = vk:: AttachmentDescription :: default ( )
106
- . format ( rat. format )
107
- . samples ( vk:: SampleCountFlags :: TYPE_1 )
108
- . load_op ( load_op)
109
- . store_op ( store_op)
110
- . initial_layout ( rat. layout )
111
- . final_layout ( rat. layout ) ;
112
- vk_attachments. push ( vk_attachment) ;
113
-
114
- vk:: AttachmentReference {
115
- attachment : vk_attachments. len ( ) as u32 - 1 ,
116
- layout : rat. layout ,
117
- }
94
+ for cat in colors. iter ( ) {
95
+ let ( color_ref, resolve_ref) =
96
+ if let Some ( super :: ColorAttachmentKey { base, resolve } ) = cat {
97
+ let super :: AttachmentKey {
98
+ format,
99
+ layout,
100
+ ops,
101
+ } = * base;
102
+
103
+ let color_ref = vk:: AttachmentReference {
104
+ attachment : vk_attachments. len ( ) as u32 ,
105
+ layout,
106
+ } ;
107
+ vk_attachments. push ( {
108
+ let ( load_op, store_op) = conv:: map_attachment_ops ( ops) ;
109
+ vk:: AttachmentDescription :: default ( )
110
+ . format ( format)
111
+ . samples ( samples)
112
+ . load_op ( load_op)
113
+ . store_op ( store_op)
114
+ . initial_layout ( layout)
115
+ . final_layout ( layout)
116
+ } ) ;
117
+ let resolve_ref = if let Some ( rat) = resolve {
118
+ let super :: AttachmentKey {
119
+ format,
120
+ layout,
121
+ ops,
122
+ } = * rat;
123
+
124
+ let ( load_op, store_op) = conv:: map_attachment_ops ( ops) ;
125
+ let vk_attachment = vk:: AttachmentDescription :: default ( )
126
+ . format ( format)
127
+ . samples ( vk:: SampleCountFlags :: TYPE_1 )
128
+ . load_op ( load_op)
129
+ . store_op ( store_op)
130
+ . initial_layout ( layout)
131
+ . final_layout ( layout) ;
132
+ vk_attachments. push ( vk_attachment) ;
133
+
134
+ vk:: AttachmentReference {
135
+ attachment : vk_attachments. len ( ) as u32 - 1 ,
136
+ layout,
137
+ }
138
+ } else {
139
+ unused
140
+ } ;
141
+
142
+ ( color_ref, resolve_ref)
118
143
} else {
119
- unused
144
+ ( unused, unused )
120
145
} ;
121
146
122
- ( color_ref, resolve_ref)
123
- } else {
124
- ( unused, unused)
125
- } ;
126
-
127
147
color_refs. push ( color_ref) ;
128
148
resolve_refs. push ( resolve_ref) ;
129
149
}
130
150
131
- if let Some ( ref ds) = e. key ( ) . depth_stencil {
151
+ if let Some ( ds) = depth_stencil {
152
+ let super :: DepthStencilAttachmentKey {
153
+ ref base,
154
+ stencil_ops,
155
+ } = * ds;
156
+
157
+ let super :: AttachmentKey {
158
+ format,
159
+ layout,
160
+ ops,
161
+ } = * base;
162
+
132
163
ds_ref = Some ( vk:: AttachmentReference {
133
164
attachment : vk_attachments. len ( ) as u32 ,
134
- layout : ds . base . layout ,
165
+ layout,
135
166
} ) ;
136
- let ( load_op, store_op) = conv:: map_attachment_ops ( ds. base . ops ) ;
137
- let ( stencil_load_op, stencil_store_op) =
138
- conv:: map_attachment_ops ( ds. stencil_ops ) ;
167
+ let ( load_op, store_op) = conv:: map_attachment_ops ( ops) ;
168
+ let ( stencil_load_op, stencil_store_op) = conv:: map_attachment_ops ( stencil_ops) ;
139
169
let vk_attachment = vk:: AttachmentDescription :: default ( )
140
- . format ( ds . base . format )
170
+ . format ( format)
141
171
. samples ( samples)
142
172
. load_op ( load_op)
143
173
. store_op ( store_op)
144
174
. stencil_load_op ( stencil_load_op)
145
175
. stencil_store_op ( stencil_store_op)
146
- . initial_layout ( ds . base . layout )
147
- . final_layout ( ds . base . layout ) ;
176
+ . initial_layout ( layout)
177
+ . final_layout ( layout) ;
148
178
vk_attachments. push ( vk_attachment) ;
149
179
}
150
180
@@ -174,7 +204,7 @@ impl super::DeviceShared {
174
204
175
205
let mut multiview_info;
176
206
let mask;
177
- if let Some ( multiview) = e . key ( ) . multiview {
207
+ if let Some ( multiview) = multiview {
178
208
// Sanity checks, better to panic here than cause a driver crash
179
209
assert ! ( multiview. get( ) <= 8 ) ;
180
210
assert ! ( multiview. get( ) > 1 ) ;
0 commit comments