Skip to content

Commit

Permalink
Transfer offset decorations when legalizing laid-out structs (#5525)
Browse files Browse the repository at this point in the history
* Transfer offset decorations when legalizing laid-out structs

Struct legalization removing fields not representable in memory should transfer all
decorations in case the struct has already had offsets calculated.

Closes #5264.

* format code

---------

Co-authored-by: slangbot <[email protected]>
Co-authored-by: Yong He <[email protected]>
  • Loading branch information
3 people authored Nov 11, 2024
1 parent c0d0611 commit 9aa7adb
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 10 deletions.
9 changes: 7 additions & 2 deletions source/slang/slang-legalize-types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,13 @@ struct TupleTypeBuilder
fieldType = context->getBuilder()->getVoidType();

// TODO: shallow clone of modifiers, etc.

builder->createStructField(ordinaryStructType, ee.fieldKey, fieldType);
IRStructField* originalField = findStructField(originalStructType, ee.fieldKey);
IRStructField* newField =
builder->createStructField(ordinaryStructType, ee.fieldKey, fieldType);
// In case the original struct had offset decorations attached, transfer those as
// well. The original offsets should still be valid, since we only skip fields of
// types that aren't representable in memory.
originalField->transferDecorationsTo(newField);
}

ordinaryType = LegalType::simple((IRType*)ordinaryStructType);
Expand Down
1 change: 0 additions & 1 deletion tests/autodiff/existential-1.slang
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu

//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<float> outputBuffer;
Expand Down
1 change: 0 additions & 1 deletion tests/autodiff/existential-2.slang
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu

//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<float> outputBuffer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu

// outputBuffer is defined in IBSDF.slang
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0], stride=4):out,name=outputBuffer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type
//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu

// outputBuffer is defined in IBSDF.slang
//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
Expand Down
4 changes: 0 additions & 4 deletions tests/expected-failure-github.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ tests/language-feature/saturated-cooperation/fuse.slang (vk)
tests/bugs/byte-address-buffer-interlocked-add-f32.slang (vk)
tests/serialization/obfuscated-serialized-module-test.slang.2 syn (mtl)
tests/autodiff/custom-intrinsic.slang.2 syn (wgpu)
tests/autodiff/existential-1.slang.2 syn (wgpu)
tests/autodiff/existential-2.slang.2 syn (wgpu)
tests/autodiff/material/diff-bwd-falcor-material-system.slang.2 syn (wgpu)
tests/autodiff/material2/diff-bwd-falcor-material-system.slang.2 syn (wgpu)
tests/bugs/atomic-coerce.slang.3 syn (wgpu)
tests/bugs/buffer-swizzle-store.slang.3 syn (wgpu)
tests/bugs/dxbc-double-problem.slang.6 syn (wgpu)
Expand Down

0 comments on commit 9aa7adb

Please sign in to comment.