-
Notifications
You must be signed in to change notification settings - Fork 340
Push constant proposal #4612
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
Push constant proposal #4612
Changes from 1 commit
4070be3
815f74a
b6873f3
d4ae72b
f15e36a
dc9c645
3c5f60b
9650e61
6d92094
3c5a33e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,50 @@ No special requirements. | |
|
||
NOTE: Each [entry point](https://www.w3.org/TR/WGSL/#entry-point) can statically use at most one immediate data variable. | ||
|
||
Sample Code: | ||
``` | ||
struct Constants { | ||
inner: i32; | ||
} | ||
|
||
var<immediate_data> a : Constants; | ||
var<immediate_data> b : i32; | ||
var<immediate_data> c : i32; // unused | ||
|
||
fn uses_a() { | ||
let foo = a.inner; | ||
} | ||
|
||
fn uses_uses_a() { | ||
uses_a(); | ||
} | ||
|
||
fn uses_b() { | ||
let foo = b; | ||
} | ||
|
||
// Each entry point can statically use at most one immediate data variable. | ||
@compute @workgroup_size(1) | ||
fn main1() { | ||
uses_a(); | ||
} | ||
|
||
@compute @workgroup_size(1) | ||
fn main2() { | ||
uses_uses_a(); | ||
} | ||
|
||
@compute @workgroup_size(1) | ||
fn main3() { | ||
uses_b(); | ||
} | ||
|
||
@compute @workgroup_size(1) | ||
fn main4() { | ||
} | ||
|
||
``` | ||
|
||
# API | ||
|
||
## Limits | ||
|
@@ -64,11 +108,16 @@ Four new functions in `GPUCommandEncoder`. | |
|
||
```javascript | ||
interface mixin GPUBindingCommandsMixin { | ||
void setImmeidateDataU32(uint32_t offset, uint32_t value); | ||
void setImmediateDataI32(uint32_t offset, int32_t value); | ||
void setImmediateDataF32(uin32_t offset, float32_t value); | ||
void setImmediateDataRange(uint32_t rangeOffset, AllowSharedBufferSource data, optional dataOffset, optional size); | ||
} | ||
``` | ||
NOTE: rangeOffset: Offset in bytes into immediate data range to begin writing at. Requires multiple of 4 bytes. | ||
NOTE: dataOffset: Offset in into data to begin writing from. Given in elements if data is a TypedArray and bytes otherwise. | ||
shaoboyan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Open Questions: | ||
- Should immediates be defined per-stage? | ||
- wgpu currently has per-stage immediates (@teoxoy?) and we weren't sure if that is a feasible alternative. | ||
|
||
- Should pipelineLayout defines immediate range compatible? | ||
- Implementation internal immediate data usage could easily break compatibility. Implementation needs extra | ||
effort to ensure such compatibility. | ||
kainino0x marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+121
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this still an open question? There is this note on line 101:
|
Uh oh!
There was an error while loading. Please reload this page.