Skip to content
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

[glsl/hlsl-out] Write sizes of arrays behind pointers in function arguments #2250

Merged
merged 4 commits into from
Feb 17, 2023

Conversation

pluiedev
Copy link
Contributor

@pluiedev pluiedev commented Feb 14, 2023

Arrays can be put behind pointers in inout and out parameters in GLSL and HLSL, whose dimensions must be specified to let array access compile. So, we specify their dimensions.

Fixes #2248

@codecov-commenter
Copy link

codecov-commenter commented Feb 14, 2023

Codecov Report

Merging #2250 (618834b) into master (1ad47f7) will decrease coverage by 0.26%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #2250      +/-   ##
==========================================
- Coverage   82.26%   82.01%   -0.26%     
==========================================
  Files          80       80              
  Lines       42927    43156     +229     
==========================================
+ Hits        35316    35396      +80     
- Misses       7611     7760     +149     
Impacted Files Coverage Δ
src/back/glsl/mod.rs 86.12% <100.00%> (+0.29%) ⬆️
src/front/wgsl/parse/mod.rs 88.28% <0.00%> (-7.79%) ⬇️
src/valid/interface.rs 77.01% <0.00%> (-1.76%) ⬇️
src/front/glsl/context.rs 92.00% <0.00%> (ø)
src/valid/mod.rs 82.90% <0.00%> (+0.70%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine, but it needs test coverage. There should be something in tests/in/access.wgsl that could be adapted to cover this.

@pluiedev
Copy link
Contributor Author

I'm trying to write a test now, but dealing with pointers to arrays is a bit annoying in WGSL... gimme a bit

arrays can be put behind pointers in inout and out parameters in GLSL,
whose dimensions must be specified to let array access
compile. so, we specify their dimensions.

fixes gfx-rs#2248
@pluiedev
Copy link
Contributor Author

Yikes.. looks like HLSL has the same bug??!

void assign_array_through_ptr_fn(inout float4 foo_2)
{
    foo_2 = Constructarray2_float4_((1.0).xxxx, (2.0).xxxx);
    return;
}

[numthreads(1, 1, 1)]
void assign_through_ptr(uint3 __global_invocation_id : SV_DispatchThreadID)
{
    if (all(__global_invocation_id == uint3(0u, 0u, 0u))) {
        val = (uint)0;
    }
    GroupMemoryBarrierWithGroupSync();
    float4 arr[2] = (float4[2])0;

    arr = Constructarray2_float4_((6.0).xxxx, (7.0).xxxx);
    assign_through_ptr_fn(val);
    assign_array_through_ptr_fn(arr);
    return;
}

Copy link
Member

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This is very similar to `e168c62`, except that this time it's a _one_ character fix.
Yippee-kay-yay
@pluiedev pluiedev changed the title [glsl-out] Write sizes of arrays behind pointers in function arguments [glsl/hlsl-out] Write sizes of arrays behind pointers in function arguments Feb 17, 2023
src/back/hlsl/writer.rs Show resolved Hide resolved
@jimblandy jimblandy enabled auto-merge (squash) February 17, 2023 00:39
@jimblandy jimblandy merged commit 58105a0 into gfx-rs:master Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[glsl-out] Array types used as function arguments get dropped
3 participants