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

Consider member-level nonwritable decorations #384

Merged
merged 1 commit into from
Oct 11, 2018

Conversation

chrisforbes
Copy link
Contributor

Previously we only cared about whether the NonWritable decoration was
applied to an entire descriptor-backed OpVariable. This is problematic
for real-world shaders, because glslang emits per-member decorations
instead in all cases.

Adjust the logic to consider per-member decorations in these cases.
Fixes #73.

@jzulauf-lunarg
Copy link
Contributor

@zeux - pull request is intended to address your issue. If you had the time to test vs. your use case this would be greatly appreciated.

Copy link
Contributor

@jzulauf-lunarg jzulauf-lunarg left a comment

Choose a reason for hiding this comment

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

This is your baliwick, so I just have questions not issues...

layers/shader_validation.cpp Outdated Show resolved Hide resolved
}

case spv::OpTypeStruct:
case spv::OpTypeStruct: {
Copy link
Contributor

@jzulauf-lunarg jzulauf-lunarg Oct 10, 2018

Choose a reason for hiding this comment

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

Do we need to recur into struct member types for full coverage, or is this code guarantee to be at a leaf type? For example if a contained struct wasn't decorated as non-writable, but all of it's members were...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to my reading of the spec, this only applies to direct members of block types; The struct we're encountering here is the block itself.

GLSL disallows memory qualifiers on members of normal structs, even if that struct is then used in a block declaration.

Copy link
Contributor

@tobine tobine left a comment

Choose a reason for hiding this comment

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

LGTM with a couple potential clean-ups

}
}

// A buffer is writable if it's either flavor of storage buffer, and has any member not decorateddoesn't have all of its
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like an incomplete comment update here. Also did you clang-format as this looks a bit long.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passes clang-format. Something weird happened here, though...

@@ -766,7 +776,8 @@ static std::vector<std::pair<descriptor_slot_t, interface_var>> CollectInterface
v.type_id = insn.word(1);
out.emplace_back(std::make_pair(set, binding), v);

if (var_nonwritable.find(id) == var_nonwritable.end() && IsWritableDescriptorType(src, insn.word(1))) {
if (IsWritableDescriptorType(src, insn.word(1), insn.word(3) == spv::StorageClassStorageBuffer,
var_nonwritable.find(id) != var_nonwritable.end())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we know at this point that the entire object is non-writable can't we skip the call down to IsWriteableDescriptorType? I suspect there's a reason that you refactored to pass this info to the function but it's not clear to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm going to undo this. It made a lot more sense in some of the early versions of the change.

Previously we only cared about whether the NonWritable decoration was
applied to an entire descriptor-backed OpVariable. This is problematic
for real-world shaders, because glslang emits per-member decorations
instead in all cases.

Adjust the logic to consider per-member decorations in these cases.
Fixes #73.
@chrisforbes chrisforbes force-pushed the nonwritable-member-level branch from 0adbbcd to cb154ff Compare October 10, 2018 23:45
@chrisforbes
Copy link
Contributor Author

Updated.

@chrisforbes
Copy link
Contributor Author

I had some ideas while writing this about the direction to go for per-descriptor NonWritable and NonReadable tracking which we'll need "sometime", but adjusted this patch to just do exactly what it needs to for now.

@chrisforbes chrisforbes merged commit 8d31e5d into master Oct 11, 2018
@chrisforbes chrisforbes deleted the nonwritable-member-level branch October 12, 2018 23:19
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.

4 participants