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

Incorrect string marshaling when "ID3D12Object::SetName" was called #630

Closed
Cutano opened this issue Oct 9, 2021 · 3 comments · Fixed by #661
Closed

Incorrect string marshaling when "ID3D12Object::SetName" was called #630

Cutano opened this issue Oct 9, 2021 · 3 comments · Fixed by #661
Assignees
Labels
area-Core/BuildTools bug Something isn't working
Milestone

Comments

@Cutano
Copy link

Cutano commented Oct 9, 2021

Summary

SetName("DepthStencil")
But I got
(0x000001CAA011C1C0:'Dphtni)

Steps to reproduce

  • Platform:Desktop
  • Framework Version: .NET 6
  • API: DirectX
  • API Version: DirectX 12
ID3D12Resource* depthStencil;
.......... Some Code Here ............
depthStencil->SetName($"DepthStencil");

Then I got this error:

Execution (From D3D12): ID3D12CommandQueue::ExecuteCommandLists: An ID3D12Resource object (0x000001CAA011C1C0:'**Dphtni**) referenced in a command list ............

Comments

It looks like Silk is using Marshal.StringToHGlobalAnsi() rather than StringToBSTR(), which drops half of the letters due to the encoding.

image

image

@Cutano Cutano added the bug Something isn't working label Oct 9, 2021
@HurricanKai
Copy link
Member

So basically every second character makes it? I guess it's a problem with UTF16 vs UTF8, which indicates an annotation mistake. @Perksey assigning you for now, assuming this is BuildTools work?

@Cutano
Copy link
Author

Cutano commented Oct 9, 2021

So basically every second character makes it? I guess it's a problem with UTF16 vs UTF8, which indicates an annotation mistake. @Perksey assigning you for now, assuming this is BuildTools work?

Yes, the native API uses LPCWSTR to receive the name, which points to UTF-16 wchar.

HRESULT SetName(
  LPCWSTR Name
);

@Perksey
Copy link
Member

Perksey commented Oct 9, 2021

Will fix this for 2.10. Assuming that BuildTools already collects the LPCWSTR info, shouldn't be too much work...

@Perksey Perksey added this to the 2.X milestone Oct 9, 2021
Perksey added a commit that referenced this issue Nov 5, 2021
* Build improvements & dynamic Windows SDK resolution (backport from 3.0)

* Changes to some code formatting

* Fix build errors

* Fix build error

* Enhanced typedef-powered renaming

* Fix #652

* Marshal generic pointers in COM vtable wrapper functions

* String generation improvements (fixes #630)

* Sanity check, remove JetBrains.Annotations
Perksey added a commit that referenced this issue Mar 25, 2022
* Build improvements & dynamic Windows SDK resolution (backport from 3.0)

* Changes to some code formatting

* Fix build errors

* Fix build error

* Enhanced typedef-powered renaming

* Fix #652

* Marshal generic pointers in COM vtable wrapper functions

* String generation improvements (fixes #630)

* Sanity check, remove JetBrains.Annotations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Core/BuildTools bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants