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

Fixed Session::queryInterface not returning OK when querying for IUnknown/ISlangUnknown #5978

Merged
merged 1 commit into from
Jan 1, 2025

Conversation

PeturDarri
Copy link
Contributor

Hello,

I have been trying to use the Slang Compilation API in C# by interfacing with the COM-lite API.

I've been able to call the API functions by directly interfacing with the vtable in unsafe C#, but for my own sanity, I was trying to use the source generated ComWrappers API introduced in .NET 8 to handle everything for me. However, I kept running into a low-level runtime error when it tries to create a wrapper object for the Slang IGlobalSession object.

After a little digging, I found the issue. The .NET runtime is checking if the Slang IGlobalSession implements IUnknown by calling QueryInterface. IGlobalSession implements ISlangUnknown, which shares the same IID as IUnknown, so it should work, right?

Well, it would if it weren't for this small error in the code:

if (uuid == ISlangUnknown::getTypeGuid() && uuid == IGlobalSession::getTypeGuid())

That && is almost certainly supposed to be ||.

I've built with this change and confirmed it fixes the runtime error and allows me to use Slang in C#.

An AND operator was used where an OR should have been used.
@PeturDarri PeturDarri requested a review from a team as a code owner January 1, 2025 19:17
@CLAassistant
Copy link

CLAassistant commented Jan 1, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@csyonghe csyonghe left a comment

Choose a reason for hiding this comment

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

Thank you for getting to the bottom of this!

@csyonghe csyonghe added the pr: non-breaking PRs without breaking changes label Jan 1, 2025
@csyonghe csyonghe merged commit a13ef05 into shader-slang:master Jan 1, 2025
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: non-breaking PRs without breaking changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants