Skip to content
This repository was archived by the owner on Oct 31, 2025. It is now read-only.

Improve the calculation of location sizes for arrays and structs (revives #513) - #798

Open
expenses wants to merge 14 commits into
EmbarkStudios:mainfrom
expenses:revive-array-location-fix
Open

Improve the calculation of location sizes for arrays and structs (revives #513)#798
expenses wants to merge 14 commits into
EmbarkStudios:mainfrom
expenses:revive-array-location-fix

Conversation

@expenses

@expensesexpenses commented Nov 14, 2021

Copy link
Copy Markdown
Contributor

See PR #513 that @Arc-blroth opened.

This PR builds on top of that to support structs and 3 or 4 component 64-bit scalar type vectors (see #513 (review)).

@expenses

expenses commented Nov 14, 2021

Copy link
Copy Markdown
ContributorAuthor

I haven't been able to test this with matrices yet as rust-gpu treats the glam Mat3s etc. as structs.

@expenses
expenses marked this pull request as ready for review November 14, 2021 12:50
Comment threadcrates/rustc_codegen_spirv/src/codegen_cx/entry.rs Outdated
@expenses

expenses commented Nov 14, 2021

Copy link
Copy Markdown
ContributorAuthor

So I still get validation and perf warning for the specific use case I wanted this for, but I can't do anything about that :P

UNASSIGNED-CoreValidation-Shader-InterfaceTypeMismatch(ERROR / SPEC): msgNum: -1227934722 - Validation Error: [ UNASSIGNED-CoreValidation-Shader-InterfaceTypeMismatch ] Object 0: handle = 0xead9370000000008, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0xb6cf33fe | Attribute type of 'VK_FORMAT_R32G32B32_SFLOAT' at location 5 does not match vertex shader input type of 'ptr to input struct of (struct of (vec3 of float32, vec3 of float32, vec3 of float32))' Objects: 1 [0] 0xead9370000000008, type: 15, name: NULL

UNASSIGNED-CoreValidation-Shader-OutputNotConsumed(WARN / PERF): msgNum: 101294395 - Validation Performance Warning: [ UNASSIGNED-CoreValidation-Shader-OutputNotConsumed ] Object 0: handle = 0xead9370000000008, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x609a13b | Vertex attribute at location 6 not consumed by vertex shader Objects: 1 [0] 0xead9370000000008, type: 15, name: NULL

UNASSIGNED-CoreValidation-Shader-OutputNotConsumed(WARN / PERF): msgNum: 101294395 - Validation Performance Warning: [ UNASSIGNED-CoreValidation-Shader-OutputNotConsumed ] Object 0: handle = 0xead9370000000008, type = VK_OBJECT_TYPE_SHADER_MODULE; | MessageID = 0x609a13b | Vertex attribute at location 7 not consumed by vertex shader Objects: 1 [0] 0xead9370000000008, type: 15, name: NULL

@eddybeddyb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM modulo the name of the new method.

}
}

fn location_size_of_type(&self, ty: Word) -> u32 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be renamed to location_count_of_type or location_slots_per_type? "size_of" could get confused with the size in bytes, which AFAICT is not relevant here.

Comment threadcrates/rustc_codegen_spirv/src/codegen_cx/entry.rs
// normalize-stderr-test "OpCapability VulkanMemoryModel\n" -> ""
// normalize-stderr-test "OpExtension .SPV_KHR_vulkan_memory_model.\n" -> ""
// normalize-stderr-test "OpMemoryModel Logical Vulkan" -> "OpMemoryModel Logical Simple"
// normalize-stderr-test "OpMemberName %12 0 .0.\n" -> ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's up with this rewrite rule? It seems like it's probably hiding a bug that should be fixed.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

This is here because the ordering of the OpMemberNames gets altered between runs:

running 1 test
diff of stderr:
OpCapability Float64
OpCapability Int16
OpCapability Int64
OpCapability Int8
OpCapability ShaderClockKHR
OpCapability Shader
OpExtension "SPV_KHR_shader_clock"
OpMemoryModel Logical Simple
OpEntryPoint Fragment %1 "main" %2 %3 %4 %5 %6 %7 %8 %9
OpExecutionMode %1 OriginUpperLeft
%10 = OpString "$OPSTRING_FILENAME/array_location_calculation.rs"
OpMemberName %11 0 "x_axis"
OpMemberName %11 1 "y_axis"
OpMemberName %11 2 "z_axis"
OpName %11 "spirv_std::glam::core::storage::Columns3<spirv_std::glam::XYZ<f32>>"
OpMemberName %12 0 "0"
OpName %12 "spirv_std::glam::Mat3"
OpName %13 "array_location_calculation::main"
OpName %2 "one"
OpName %3 "two"
OpName %4 "three"
OpName %5 "four"
OpName %6 "five"
OpName %7 "six"
OpName %8 "seven"
OpName %9 "eight"
OpMemberName %11 0 "x_axis"
OpMemberName %11 1 "y_axis"
OpMemberName %11 2 "z_axis"
-OpMemberName %12 0 "0"
-OpMemberName %12 0 "0"
OpMemberName %11 0 "x_axis"
OpMemberName %11 1 "y_axis"
OpMemberName %11 2 "z_axis"
+OpMemberName %12 0 "0"
+OpMemberName %12 0 "0"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hm, that seems like a bug.

@repi
repi removed the request for review from khyperiaJanuary 30, 2022 13:09
@expenses

Copy link
Copy Markdown
ContributorAuthor

Totally forgot about this - I need to check whether it's still needed.

@eddybeddyb added the s: waiting on review PRs that blocked on a team member's review. label May 21, 2022
@eddyb

Copy link
Copy Markdown
Contributor

Totally forgot about this - I need to check whether it's still needed.

Ah, didn't see this when I set the labels, I'll flip them.

@eddybeddyb added s: waiting on author PRs that blocked on the author implementing feedback. and removed s: waiting on review PRs that blocked on a team member's review. labels May 27, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

s: waiting on authorPRs that blocked on the author implementing feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@expenses@eddyb@khyperia