@@ -12,7 +12,7 @@ fn discarding_color_target_resets_texture_init_state_check_visible_on_copy_after
12
12
let mut encoder = ctx
13
13
. device
14
14
. create_command_encoder ( & wgpu:: CommandEncoderDescriptor :: default ( ) ) ;
15
- drop ( encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
15
+ encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
16
16
label : Some ( "Color Discard" ) ,
17
17
color_attachments : & [ wgpu:: RenderPassColorAttachment {
18
18
view : & texture. create_view ( & wgpu:: TextureViewDescriptor :: default ( ) ) ,
@@ -23,7 +23,7 @@ fn discarding_color_target_resets_texture_init_state_check_visible_on_copy_after
23
23
} ,
24
24
} ] ,
25
25
depth_stencil_attachment : None ,
26
- } ) ) ;
26
+ } ) ;
27
27
ctx. queue . submit ( [ encoder. finish ( ) ] ) ;
28
28
}
29
29
{
@@ -47,7 +47,7 @@ fn discarding_color_target_resets_texture_init_state_check_visible_on_copy_in_sa
47
47
let mut encoder = ctx
48
48
. device
49
49
. create_command_encoder ( & wgpu:: CommandEncoderDescriptor :: default ( ) ) ;
50
- drop ( encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
50
+ encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
51
51
label : Some ( "Color Discard" ) ,
52
52
color_attachments : & [ wgpu:: RenderPassColorAttachment {
53
53
view : & texture. create_view ( & wgpu:: TextureViewDescriptor :: default ( ) ) ,
@@ -58,7 +58,7 @@ fn discarding_color_target_resets_texture_init_state_check_visible_on_copy_in_sa
58
58
} ,
59
59
} ] ,
60
60
depth_stencil_attachment : None ,
61
- } ) ) ;
61
+ } ) ;
62
62
copy_texture_to_buffer ( & mut encoder, & texture, & readback_buffer) ;
63
63
ctx. queue . submit ( [ encoder. finish ( ) ] ) ;
64
64
}
@@ -79,7 +79,7 @@ fn discarding_depth_target_resets_texture_init_state_check_visible_on_copy_in_sa
79
79
let mut encoder = ctx
80
80
. device
81
81
. create_command_encoder ( & wgpu:: CommandEncoderDescriptor :: default ( ) ) ;
82
- drop ( encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
82
+ encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
83
83
label : Some ( "Depth Discard" ) ,
84
84
color_attachments : & [ ] ,
85
85
depth_stencil_attachment : Some ( wgpu:: RenderPassDepthStencilAttachment {
@@ -93,7 +93,7 @@ fn discarding_depth_target_resets_texture_init_state_check_visible_on_copy_in_sa
93
93
store : false , // discard!
94
94
} ) ,
95
95
} ) ,
96
- } ) ) ;
96
+ } ) ;
97
97
copy_texture_to_buffer ( & mut encoder, & texture, & readback_buffer) ;
98
98
ctx. queue . submit ( [ encoder. finish ( ) ] ) ;
99
99
}
@@ -109,12 +109,12 @@ fn discarding_either_depth_or_stencil_aspect() {
109
109
& ctx,
110
110
wgpu:: TextureFormat :: Depth24PlusStencil8 ,
111
111
) ;
112
- // TODO: How do we test this other than "doesn't crash"? we can't copy the texture to/from buffers!
112
+ // TODO: How do we test this other than "doesn't crash"? We can't copy the texture to/from buffers, so we would need to do a copy in a shader
113
113
{
114
114
let mut encoder = ctx
115
115
. device
116
116
. create_command_encoder ( & wgpu:: CommandEncoderDescriptor :: default ( ) ) ;
117
- drop ( encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
117
+ encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
118
118
label : Some ( "Depth Discard, Stencil Load" ) ,
119
119
color_attachments : & [ ] ,
120
120
depth_stencil_attachment : Some ( wgpu:: RenderPassDepthStencilAttachment {
@@ -128,14 +128,14 @@ fn discarding_either_depth_or_stencil_aspect() {
128
128
store : true ,
129
129
} ) ,
130
130
} ) ,
131
- } ) ) ;
131
+ } ) ;
132
132
ctx. queue . submit ( [ encoder. finish ( ) ] ) ;
133
133
}
134
134
{
135
135
let mut encoder = ctx
136
136
. device
137
137
. create_command_encoder ( & wgpu:: CommandEncoderDescriptor :: default ( ) ) ;
138
- drop ( encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
138
+ encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
139
139
label : Some ( "Depth Load, Stencil Discard" ) ,
140
140
color_attachments : & [ ] ,
141
141
depth_stencil_attachment : Some ( wgpu:: RenderPassDepthStencilAttachment {
@@ -149,7 +149,7 @@ fn discarding_either_depth_or_stencil_aspect() {
149
149
store : false , // discard!
150
150
} ) ,
151
151
} ) ,
152
- } ) ) ;
152
+ } ) ;
153
153
ctx. queue . submit ( [ encoder. finish ( ) ] ) ;
154
154
}
155
155
} ) ;
@@ -174,8 +174,7 @@ fn create_white_texture_and_readback_buffer(
174
174
let format_desc = format. describe ( ) ;
175
175
176
176
// Size for tests is chosen so that we don't need to care about buffer alignments.
177
- assert_eq ! ( format_desc. block_dimensions. 0 , 1 ) ;
178
- assert_eq ! ( format_desc. block_dimensions. 1 , 1 ) ;
177
+ assert_eq ! ( format_desc. block_dimensions, ( 1 , 1 ) ) ;
179
178
assert_eq ! ( format_desc. block_size as u32 , BYTES_PER_PIXEL ) ;
180
179
assert_eq ! (
181
180
( TEXTURE_SIZE . width * format_desc. block_size as u32 ) % wgpu:: COPY_BYTES_PER_ROW_ALIGNMENT ,
@@ -209,14 +208,11 @@ fn create_white_texture_and_readback_buffer(
209
208
// This behavior is curious, but does not violate any spec - it is wgpu's job to pass this test no matter what a render target discard does.
210
209
211
210
// ... but that said, for depth/stencil textures we need to do a clear.
212
- if format == wgpu:: TextureFormat :: Depth32Float
213
- || format == wgpu:: TextureFormat :: Depth24PlusStencil8
214
- || format == wgpu:: TextureFormat :: Depth24Plus
215
- {
211
+ if format_desc. sample_type == wgpu:: TextureSampleType :: Depth {
216
212
let mut encoder = ctx
217
213
. device
218
214
. create_command_encoder ( & wgpu:: CommandEncoderDescriptor :: default ( ) ) ;
219
- drop ( encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
215
+ encoder. begin_render_pass ( & wgpu:: RenderPassDescriptor {
220
216
label : Some ( "Depth/Stencil setup" ) ,
221
217
color_attachments : & [ ] ,
222
218
depth_stencil_attachment : Some ( wgpu:: RenderPassDepthStencilAttachment {
@@ -230,7 +226,7 @@ fn create_white_texture_and_readback_buffer(
230
226
store : true ,
231
227
} ) ,
232
228
} ) ,
233
- } ) ) ;
229
+ } ) ;
234
230
ctx. queue . submit ( [ encoder. finish ( ) ] ) ;
235
231
} else {
236
232
let data = vec ! [ 255 ; buffer_size as usize ] ;
@@ -267,7 +263,7 @@ fn copy_texture_to_buffer(
267
263
wgpu:: ImageCopyTexture {
268
264
texture,
269
265
mip_level : 0 ,
270
- origin : wgpu:: Origin3d { x : 0 , y : 0 , z : 0 } ,
266
+ origin : wgpu:: Origin3d :: ZERO ,
271
267
aspect : wgpu:: TextureAspect :: All ,
272
268
} ,
273
269
wgpu:: ImageCopyBuffer {
@@ -279,16 +275,14 @@ fn copy_texture_to_buffer(
279
275
}
280
276
281
277
fn assert_buffer_is_zero ( readback_buffer : & wgpu:: Buffer , device : & wgpu:: Device ) {
282
- {
283
- let buffer_slice = readback_buffer. slice ( ..) ;
284
- let _ = buffer_slice. map_async ( wgpu:: MapMode :: Read ) ;
285
- device. poll ( wgpu:: Maintain :: Wait ) ;
286
- let buffer_view = buffer_slice. get_mapped_range ( ) ;
278
+ let buffer_slice = readback_buffer. slice ( ..) ;
279
+ let _ = buffer_slice. map_async ( wgpu:: MapMode :: Read ) ;
280
+ device. poll ( wgpu:: Maintain :: Wait ) ;
281
+ let buffer_view = buffer_slice. get_mapped_range ( ) ;
287
282
288
- assert ! (
289
- buffer_view. iter( ) . all( |b| * b == 0 ) ,
290
- "texture was not fully cleared"
291
- ) ;
292
- }
283
+ assert ! (
284
+ buffer_view. iter( ) . all( |b| * b == 0 ) ,
285
+ "texture was not fully cleared"
286
+ ) ;
293
287
readback_buffer. unmap ( ) ;
294
288
}
0 commit comments