-
Notifications
You must be signed in to change notification settings - Fork 58
[Migrated] NonUniform
decoration support
#120
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
Comments
Comment from DJMcNab (CONTRIBUTOR) on 2021-11-04T21:07:28Z 👍: 1 I mentioned this on discord, but I believe the reason that the decoration is optimised out here is because the entry point is generated, which calls the actual function; this call of the function then gets inlined, removing the decoration. That is, within the function context, your decoration is applying to the function argument, not the entry point variable. I however don't have a good suggestion for how this could be worked around, at least not without some support in rust-gpu. |
Comment from expenses (CONTRIBUTOR) on 2021-11-04T23:37:48Z @DJMcNab Right, thanks for investigating! And to clarify, this inlining happens in rust-gpu and not via the |
Comment from DJMcNab (CONTRIBUTOR) on 2021-11-05T07:59:03Z I haven't checked it through either way. I'd be inclined to think it's a I suppose one algorithm we could use is to decorate entry point variables with any variables which apply to the entry point function arguments in entry point decoration. This would make the |
Comment from expenses (CONTRIBUTOR) on 2021-11-05T10:26:03Z I did some testing by writing out the module between each pass. It seems that the DCE pass is removing the decoration. It's possible that it would get removed in other places as well. |
Comment from expenses (CONTRIBUTOR) on 2021-11-05T10:33:39Z Oh but before that, the inlining pass inlines the variable being decorated without updating the decoration. That should be the first thing to fix. |
Comment from khyperia (CONTRIBUTOR) on 2021-11-22T08:00:46Z Just a quick note, I don't think decorating |
Comment from expenses (CONTRIBUTOR) on 2021-12-08T23:06:38Z
Yeah, I guess you want |
Comment from ElectronicRU (CONTRIBUTOR) on 2021-12-09T15:33:36Z What about uniformity analysis? We already do rather heavy block-graph analyses in linker |
Comment from expenses (CONTRIBUTOR) on 2021-12-09T19:28:48Z I looked into implemented the support via an intrinsic and |
Comment from Jasper-Bekkers (CONTRIBUTOR) on 2021-12-11T16:44:15Z
For that please see #49 |
Comment from SiebenCorgie (CONTRIBUTOR) on 2023-03-29T15:02:35Z I tried to find out why @expenses decoration was removed before. For that, I added a Apparently, the However, this does not fix everything. Unfortunately it is not enough to keep the With all that in place, the correctly decorated code gets emitted for the following Rust code: fn some_function(..., image_array: &mut RuntimeArray<Image!(2D, type = f32, sampled = true)>){
let nonuniformly_calculated_index = ...;
let value = image_array
.index_nonuniform(nonuniformly_calculated_index)
.sample_nonuniform(
some_sampler,
some_vec2,
);
} A fix for now could be to just decorate that I didn't test RuntimeArrays of buffers ( |
Issue automatically imported from old repo: EmbarkStudios/rust-gpu#756
Old labels: t: enhancement,s: qptr may fix
Originally creatd by expenses on 2021-09-25T11:44:25Z
Occasionally, a shader variable requires the
NonUniform
decoration. One example of this is when doing a texture lookup in a ray-tracing shader, where the texture index might not be uniform with the neighbouring rays. See: https://github.com/expenses/ray-tracing-gallery/blob/cb0cb06cc60a5632150e606261a02ba26862ac09/shaders/closesthit.glsl#L136-L138.I've attempted to do this with
asm!
:but the decoration wasn't included in the final SPIR-V module. Perhaps it was optimized out? The
u32
->usize
conversion that is needed for accessing indexingRuntimeArray
s could be a problem as well.The text was updated successfully, but these errors were encountered: