Skip to content

opt: Filter duplicate decorations during serialization - #6828

Merged
dneto0 merged 5 commits into
KhronosGroup:mainfrom
s-perron:wt/i8609_relaxed_precision
Aug 5, 2026
Merged

dneto0 merged 5 commits into
KhronosGroup:mainfrom
s-perron:wt/i8609_relaxed_precision

Conversation

@s-perron

@s-perron s-perron commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Add a mechanism to filter out duplicate decorations when writing the
SPIR-V module back to binary in Module::ToBinary. This prevents validation
errors when optimization passes (like loop unrolling) duplicate decorated
instructions.

The filtering uses a hash set of serialized instructions to identify and
skip duplicates.

A new parameter filter_duplicates is added to Module::ToBinary to
allow disabling this behavior, which is used during the optimizer's
integrity check to prevent false positive assertion failures.

Added unit test in module_test.cpp to verify the behavior.

Assisted by: Antigravity

Fixes: microsoft/DirectXShaderCompiler#8609

Add a mechanism to filter out duplicate decorations when writing the
SPIR-V module back to binary in Module::ToBinary. This prevents validation
errors when optimization passes (like loop unrolling) duplicate decorated
instructions.

The filtering uses a hash set of serialized instructions to identify and
skip duplicates.

A new parameter `filter_duplicates` is added to `Module::ToBinary` to
allow disabling this behavior, which is used during the optimizer's
integrity check to prevent false positive assertion failures.

Added unit test in `module_test.cpp` to verify the behavior.

Assisted by: Antigravity

Fixes: microsoft/DirectXShaderCompiler#8609
@s-perron
s-perron requested a review from dneto0 August 5, 2026 17:52

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the main blocker is the need for a method comment.

Comment thread source/opt/module.h Resolved
Comment thread source/opt/module.cpp Resolved
Comment thread test/opt/module_test.cpp Resolved
@s-perron
s-perron requested a review from dneto0 August 5, 2026 19:05

@dneto0 dneto0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice. thanks!

@dneto0
dneto0 merged commit 98098e9 into KhronosGroup:main Aug 5, 2026
4 checks passed
@damyanp

damyanp commented Aug 5, 2026

Copy link
Copy Markdown

@dneto0 / @s-perron - in the future, could you please avoid putting a "fixes xxxx" note in PRs here for issues that are in the DXC repo? It auto-closes those issues, which isn't really the desired behavior since we still have work to do to integrate the fix into DXC.

@dneto0

dneto0 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

@dneto0 / @s-perron - in the future, could you please avoid putting a "fixes xxxx" note in PRs here for issues that are in the DXC repo? It auto-closes those issues, which isn't really the desired behavior since we still have work to do to integrate the fix into DXC.

Sorry about that. I'll try to avoid that in future.
Instead, we should put "Issue: #####" or file and fix an issue in this repo.

@damyanp

damyanp commented Aug 6, 2026

Copy link
Copy Markdown

Sorry about that. I'll try to avoid that in future. Instead, we should put "Issue: #####" or file and fix an issue in this repo.

Thank you! I was pretty surprised that github behaved that way, I wouldn't have expected it at all! :)

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.

[SPIR-V] Validation Error: ID decorated with RelaxedPrecision multiple times is not allowed.

3 participants