-
Notifications
You must be signed in to change notification settings - Fork 501
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
[sokol_gfx] Assign labels as debug names to D3D11 resources #1025
Conversation
Good change, but I want to give it a whirl before merging. We should try a change though which I think/hope allows us to get rid of the dxguid dependency: In sokol_app.h I'm defining any required COM IIDs inline like this: Lines 6317 to 6319 in 91ec4b5
Maybe we can do the same inline definition for the I seem to remember that linking with dxguid caused problems in some scenarios (like compiling via Zig which uses the mingw2 headers instead of the Windows SDK). Also another change request regarding this block:
Please create a wrapper function like this instead (all D3D API functions called by sokol-gfx have such a wrapper: Lines 9354 to 9360 in 91ec4b5
That's all for now :) |
PS: did you also check that calling |
Oh yeah, defining the GUIIDs inline is a very good idea, I didn't notice the ones that were already there, that's why I linked dxguid.
The reason why I didn't create a function like this is because
Oops, good catch! Somehow I completely forgot about that, since I always set the labels in my own code. But looking at the docs it should be fine. |
Ah right, in that case the macro totally makes sense. But can you add a little explanation comment above the macro? Because such things tend to come up after a while again ;)
Agreed, looks like nullptr is valid. |
Also added `_sg_win32_refguid` instead of taking a pointer directly in the macro...
Alright, I added the GUID constant and comments in the last commit |
Last changes look good. I just noticed a problem though I overlooked at first, those strlen calls on potential nullptrs: (UINT)strlen(desc->label) ..AFAIK strlen on a nullptr is UB. My suggestion would be to change the #define _sg_d3d11_setlabel(self, label) (self)->SetPrivateData(_sg_win32_refguid(_sg_d3d11_WKPDID_D3DDebugObjectName), label ? (UINT)strlen(label) : 0, label) ...calling this would then look a bit simpler: _sg_d3d11_setlabel(buf->d3d11.buf, desc->label); |
Yeah the setlabel macro is a very good idea, it makes it quite a lot simpler. I didn't know about the strlen UB, thanks for letting me know. |
Giving the PR a whirl now... |
And merged. I also added a blurb to the changelog. |
This change assigns the "label" field form resource desc structs to D3D11 resource objects, using
SetPrivateData
withWKPDID_D3DDebugObjectName
. This code is enabled only whenSOKOL_DEBUG
is defined.Note: this requires sokol_gfx to also link with
dxguid.lib
.Note: some resources have multiple "sub-resources", e.g. a shader has a vertex and a fragment shader resource. In those cases the label is the same for all sub-resources.
This is useful especially in RenderDoc (docs) and in D3D11 debugging messages.