-
Notifications
You must be signed in to change notification settings - Fork 984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stand-alone passes #440
Stand-alone passes #440
Conversation
Judging purely by the number of lines, you can see how there is something crazy going on here. The last commits integrates peek-poke for serializing the command stream of a (compute) pass. The main driver for this (as opposed to an The cost of this is more Another interesting bit is |
I'm seeing something that looks like a compiler bug when running the compute example (e.g. with This is the offending piece: WGPURawComputePassId command_pass = //temp name
wgpu_command_encoder_begin_compute_pass(encoder, NULL); What I see is that
|
Hitting this in cbindgen (cc @emilio):
Will probably be able to work around, but still annoying... |
Alright, at this stage raw compute and render passes work for the examples of this repo 🎉 |
If you have a test-case for that I'd be happy to take a look. |
Tested on wgpu-rs examples (see gfx-rs/wgpu-rs#155), no regressions. I'm going to miss the immediate pass recording, but at this point it appears to me that having a single consistent code path for native and non-native is a bigger win. We can re-explore this direction later. |
Interestingly, this change can also be seen as a first step towards de-storaging some of the objects. I.e. going from id of |
Found an issue - since we are soft recording with this PR, we aren't keeping the objects alive after they are used in the recording. |
uint32_t start_slot, | ||
const WGPUBufferId *buffers, | ||
const WGPUBufferId *buffer_ids, | ||
const WGPUBufferAddress *offsets, | ||
uintptr_t length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly relevant to this PR but many of these uintptr_t
are uint64_t
in webgpu-headers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to #452
trackers, | ||
} | ||
} | ||
#[derive(Clone, Copy, Debug, PeekCopy, Poke)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be repr(C)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These don't need to be repr(C) because we never lay them out in memory that C code works with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought peek_poke expects to operate on repr(C)
types to have certain guarantees about the data layout, or at least the peek_poke examples seem to do that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I'll double check!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The webrender examples uses repr(C) because it was written for Gecko C++ code to see the types and copied verbatim into peek-poke.
That is to say, I consulted with @Gankra and it turns out there can be a slightly bigger chance of the compiler optimization (turning the struct poking into a memcopy) if it's repr(C)
. Still not a guarantee, still not a correctness concern, just a bit more likely.
So we should make these types repr(C)
as you suggest, at least the Rect
thing.
} | ||
|
||
#[derive(Clone, Copy, Debug, PeekCopy, Poke)] | ||
enum RenderCommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be repr(C)
?
} | ||
|
||
#[derive(Clone, Copy, Debug, PeekCopy, Poke)] | ||
pub struct Rect<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this supposed to be repr(C)
?
index: u8, | ||
num_dynamic_offsets: u8, | ||
bind_group_id: id::BindGroupId, | ||
phantom_offsets: PhantomSlice<BufferAddress>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found it a bit confusing to add PhantomSlice
to the end of these variants because I wasn't sure if they were markers for peek_poke
to know to treat them specially somehow.
Instead of using this marker type, could we replace it by comments to indicate that there is some dynamically sized array at the end of these variants and have decode
as a free function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think having at least some type-level semantic of the data following commands is helpful. having the decode
strictly associated with a PhantomSlice
makes it harder to fail when writing and maintaining this code. Comments wouldn't be as helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess one interesting (future) option would be for peek_poke to provide a marker type to declare the size of variable length arrays, i.e.
#[derive(PeekCopy, Poke)]
enum RenderCommand {
SetBindGroup {
index: u8,
num_dynamic_offsets: u8,
#[peek_poke(array_size = "num_dynamic_offsets")]
dynamic_offsets: peek_poke::VariableLengthArray<BufferAddress>,
},
/* ... */
}
@grovesNL thank you for having a look! I think we can proceed, no major concerns here. |
440: Stand-alone passes r=me,grovesNL a=kvark Fixes #438 Co-authored-by: Dzmitry Malyshau <[email protected]>
Build succeeded |
Fixes #438