-
Notifications
You must be signed in to change notification settings - Fork 248
Improve the calculation of location sizes for arrays and structs (revives #513) #798
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
Open
expenses
wants to merge
14
commits into
EmbarkStudios:main
Choose a base branch
from
expenses:revive-array-location-fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
152bc37
Revive the array location fix
expenses 605f166
Properly run test
expenses 52ac5f5
Use a recursive function for calculating the number of locations a st…
expenses 6df36f4
Remove debugging from the stderr
expenses e5fc2a5
Handle matrices
expenses 31ab929
Update crates/rustc_codegen_spirv/src/codegen_cx/entry.rs
expenses d3521a5
Normalise the stderr
expenses a76a184
Merge branch 'revive-array-location-fix' of github.com:expenses/rust-…
expenses 08d712a
Fix lint and avoid OpMemberName ordering shenanigans
expenses c3a29ea
Rename function and handle arrays of structs
expenses 8548d95
Run cargo fmt
expenses 47c7974
Merge remote-tracking branch 'origin/main' into HEAD
expenses b39390f
Rename -> location_count_of_type
expenses b720131
Fix tests
expenses File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// build-pass | ||
// compile-flags: -C llvm-args=--disassemble-globals | ||
|
||
use spirv_std::{ | ||
self as _, | ||
glam::{DVec3, IVec4, Mat3, Vec4}, | ||
}; | ||
|
||
#[spirv(matrix)] | ||
pub struct Mat4x3 { | ||
pub col_0: Vec4, | ||
pub col_1: Vec4, | ||
pub col_2: Vec4, | ||
} | ||
|
||
#[spirv(fragment)] | ||
pub fn main( | ||
one: [f32; 7], | ||
two: [f32; 3], | ||
three: Mat3, | ||
four: DVec3, | ||
five: IVec4, | ||
six: f32, | ||
seven: Mat4x3, | ||
eight: u32, | ||
) { | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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" | ||
OpDecorate %14 ArrayStride 4 | ||
OpDecorate %15 ArrayStride 4 | ||
OpMemberDecorate %11 0 Offset 0 | ||
OpMemberDecorate %11 1 Offset 16 | ||
OpMemberDecorate %11 2 Offset 32 | ||
OpMemberDecorate %12 0 Offset 0 | ||
OpDecorate %2 Location 0 | ||
OpDecorate %3 Location 7 | ||
OpDecorate %4 Location 10 | ||
OpDecorate %5 Location 13 | ||
OpDecorate %6 Location 15 | ||
OpDecorate %7 Location 16 | ||
OpDecorate %8 Location 17 | ||
OpDecorate %9 Location 20 | ||
%16 = OpTypeVoid | ||
%17 = OpTypeFloat 32 | ||
%18 = OpTypeInt 32 0 | ||
%19 = OpConstant %18 7 | ||
%14 = OpTypeArray %17 %19 | ||
%20 = OpConstant %18 3 | ||
%15 = OpTypeArray %17 %20 | ||
%21 = OpTypeVector %17 3 | ||
%11 = OpTypeStruct %21 %21 %21 | ||
%12 = OpTypeStruct %11 | ||
%22 = OpTypeFloat 64 | ||
%23 = OpTypeVector %22 3 | ||
%24 = OpTypeInt 32 1 | ||
%25 = OpTypeVector %24 4 | ||
%26 = OpTypeVector %17 4 | ||
%27 = OpTypeMatrix %26 3 | ||
%28 = OpTypeFunction %16 %14 %15 %12 %23 %25 %17 %27 %18 | ||
%29 = OpTypeFunction %16 | ||
%30 = OpTypePointer Input %14 | ||
%2 = OpVariable %30 Input | ||
%31 = OpTypePointer Input %15 | ||
%3 = OpVariable %31 Input | ||
%32 = OpTypePointer Input %12 | ||
%4 = OpVariable %32 Input | ||
%33 = OpTypePointer Input %23 | ||
%5 = OpVariable %33 Input | ||
%34 = OpTypePointer Input %25 | ||
%6 = OpVariable %34 Input | ||
%35 = OpTypePointer Input %17 | ||
%7 = OpVariable %35 Input | ||
%36 = OpTypePointer Input %27 | ||
%8 = OpVariable %36 Input | ||
%37 = OpTypePointer Input %18 | ||
%9 = OpVariable %37 Input |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
orlocation_slots_per_type
? "size_of" could get confused with the size in bytes, which AFAICT is not relevant here.