forked from gfx-rs/gfx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1159: Zero initialize buffers r=kvark a=Wumpf **Connections** First half of gfx-rs#563, focusing solely on buffers and ignoring same issue for textures **Description** Tracks for each buffer which parts are initialized (i.e. set to zero). Identified three interaction points for this: * buffer mapping: Zeroing out ad-hoc and marking as initialized * queue write to buffer: Marks target buffer regions as initialized (i.e. optimizes away buffer init down the line) * use in binding or copy operation in a command buffer: * fine grained tracking of regions that may require init (or will be initialized implicitly) on each command buffer * set in motion on queue submit, init is exclusively with `fill_buffer` Todo list for Ready-to-Review - [x] memory barriers for `fill_buffer` calls - [x] better data structure for `memory_init_tracker` - [x] coarse filtering on command-buffer buffer init requirements (the list should almost always be empty whereas now it pushes any buffer use) - [x] improve naming of things - [x] at least pretend this is adequately tested Todo list beyond this PR * make data structures usable for textures * and.. well.. implement all this for textures! * explore reusing barrier tracker for memory init tracking? **Testing** * Some basic testing by doing some changes to wgpu-rs samples and watching them in in the debugger. * Added a ron test file for the player (love those!) to poke the feature a little bit * MemoryInitTracker comes with simple unit tests Overall this is a bit shallow but as so often in this area accurate testing is hard because the outcomes are quite indirect Co-authored-by: Andreas Reich <[email protected]>
- Loading branch information
Showing
14 changed files
with
765 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
( | ||
features: (bits: 0x0), | ||
expectations: [ | ||
( | ||
name: "mapped_at_creation: false, with MAP_WRITE", | ||
buffer: (index: 0, epoch: 1), | ||
offset: 0, | ||
data: Raw([0x00, 0x00, 0x00, 0x00]), | ||
), | ||
( | ||
name: "mapped_at_creation: false, without MAP_WRITE", | ||
buffer: (index: 1, epoch: 1), | ||
offset: 0, | ||
data: Raw([0x00, 0x00, 0x00, 0x00]), | ||
), | ||
( | ||
name: "partially written buffer", | ||
buffer: (index: 2, epoch: 1), | ||
offset: 0, | ||
data: Raw([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xBF, 0x00, 0x00, 0x80, 0xBF, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x80, 0x3F, 0x00, 0x00, 0x00, 0x00]), | ||
), | ||
], | ||
actions: [ | ||
CreateBuffer( | ||
Id(0, 1, Empty), | ||
( | ||
label: Some("mapped_at_creation: false, with MAP_WRITE"), | ||
size: 16, | ||
usage: ( | ||
bits: 131, // STORAGE + MAP_READ + MAP_WRITE | ||
), | ||
mapped_at_creation: false, | ||
), | ||
), | ||
CreateBuffer( | ||
Id(1, 1, Empty), | ||
( | ||
label: Some("mapped_at_creation: false, without MAP_WRITE"), | ||
size: 16, | ||
usage: ( | ||
bits: 129, // STORAGE + MAP_READ | ||
), | ||
mapped_at_creation: false, | ||
), | ||
), | ||
CreateBuffer( | ||
Id(2, 1, Empty), | ||
( | ||
label: Some("partially written"), | ||
size: 24, | ||
usage: ( | ||
bits: 9, // MAP_READ + COPY_DST | ||
), | ||
mapped_at_creation: false, | ||
), | ||
), | ||
WriteBuffer( | ||
id: Id(2, 1, Empty), | ||
data: "data1.bin", | ||
range: ( | ||
start: 4, | ||
end: 20, | ||
), | ||
queued: true, | ||
), | ||
|
||
// TODO: Add a buffer with `mapped_at_creation: true`. As of writing there's no unmap action we could insert here. | ||
Submit(1, []), | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.