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

DXC: Annotate new struct fields and enums #1989

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions generation/WinSDK/emitter.settings.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,9 @@ ICreateWithTransactionEx::CreateInstance::pObject=[ComOutPtr]
IClassFactory2::CreateInstanceLic::ppvObj=[ComOutPtr]
DxcCreateInstance::ppv=[ComOutPtr]
DxcCreateInstance2::ppv=[ComOutPtr]
IDxcContainerReflection::GetPartReflection::ppvObject=[ComOutPtr]
IDxcUtils::CreateReflection::ppvReflection=[ComOutPtr]
IDxcUtils::GetDxilContainerPart::ppPartData=[NativeArrayInfo(CountFieldName = "pPartSizeInBytes")]
IWbemServices::CreateInstanceEnum::ppEnum=[ComOutPtr]
StiCreateInstanceW::ppSti=[ComOutPtr]
IMFImageSharingEngineClassFactory::CreateInstanceFromUDN::ppEngine=[ComOutPtr]
Expand Down
140 changes: 126 additions & 14 deletions generation/WinSDK/enums.json
Original file line number Diff line number Diff line change
Expand Up @@ -28760,20 +28760,6 @@
"filter": "DXC_CP_",
"header": "dxcapi.h"
},
"members": [
{
"name": "DXC_CP_ACP",
"value": "0"
},
{
"name": "DXC_CP_UTF16",
"value": "1200"
},
{
"name": "DXC_CP_UTF8",
"value": "65001"
}
],
"uses": [
{
"interface": "IDxcBlobEncoding",
Expand Down Expand Up @@ -28819,6 +28805,132 @@
"interface": "IDxcUtils",
"method": "LoadFile",
"parameter": "pCodePage"
},
{
"struct": "DxcBuffer",
"field": "Encoding"
}
]
},
{
"name": "DxcValidatorFlags",
"flags": true,
"autoPopulate": {
"filter": "DxcValidatorFlags_",
"header": "dxcapi.h"
},
"uses": [
{
"interface": "IDxcValidator",
"method": "Validate",
"parameter": "Flags"
},
{
"interface": "IDxcValidator2",
"method": "ValidateWithDebug",
"parameter": "Flags"
}
]
},
{
"name": "DxcVersionInfoFlags",
"flags": true,
"autoPopulate": {
"filter": "DxcVersionInfoFlags_",
Comment on lines +28815 to +28839
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately both these static const UINT32s don't appear to be parsed by enums.json?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems more like a ClangSharp limitation than enums.json.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, either way it's something that I expected to show up, but it didn't. Should I manually declare "members", while leaving "autoPopulate" in place in hopes of getting a compilation conflict when ClangSharp can provide these to us, or is it a fix you can do elsewhere in the tooling?

As this PR shows we used to have manual fields for DXC_CP_ too (now unnecessary), while also relying on autoPopulate without conflicts being generated?

Copy link
Collaborator

@mikebattista mikebattista Nov 15, 2024

Choose a reason for hiding this comment

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

Yes you can manually declare the missing members together with autoPopulate. The sets will be merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool. Fixed it by removing it, because they can be autodetected.

I don't remember the status of this PR: I think I got stuck on the static const UINT32s not being parsed, only #defines? Is there any plan/solution for that?

Copy link
Contributor Author

@MarijnS95 MarijnS95 Nov 21, 2024

Choose a reason for hiding this comment

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

Seems more like a ClangSharp limitation than enums.json.

@mikebattista Am I right to assume that ClangSharp emits whatever it finds after preprocessing? I'd assume that all the preprocessor directives are flattened out, which is why the ConstantsScraper specifically looks for #define in source files:

private static readonly Regex DefineRegex =
new Regex(
@"^\s*#\s*define\s+([_A-Za-z][\dA-Za-z_]+)\s+(.+)");

This is the only code that looks at autoPopulate. Assuming that "actual C constants" are extracted from ClangSharp and written elsewhere (could it be ConstantWriter?), is this where we should insert extra logic to turn static const definitions into grouped enums as well?

"header": "dxcapi.h"
},
"uses": [
{
"interface": "IDxcVersionInfo",
"method": "GetFlags",
"parameter": "pFlags"
}
]
},
{
"name": "DXC_HASHFLAG",
"flags": true,
"autoPopulate": {
"filter": "DXC_HASHFLAG_",
"header": "dxcapi.h"
},
"uses": [
{
"struct": "DxcShaderHash",
"field": "Flags"
}
]
},
{
"name": "DXC_PART",
"flags": false,
"members": [
{
"name": "DXC_PART_PDB",
"value": "('I' | ('L' << 8) | ('D' << 16) | ('B' << 24))"
},
{
"name": "DXC_PART_PDB_NAME",
"value": "('I' | ('L' << 8) | ('D' << 16) | ('N' << 24))"
},
{
"name": "DXC_PART_PRIVATE_DATA",
"value": "('P' | ('R' << 8) | ('I' << 16) | ('V' << 24))"
},
{
"name": "DXC_PART_ROOT_SIGNATURE",
"value": "('R' | ('T' << 8) | ('S' << 16) | ('0' << 24))"
},
{
"name": "DXC_PART_DXIL",
"value": "('D' | ('X' << 8) | ('I' << 16) | ('L' << 24))"
},
{
"name": "DXC_PART_REFLECTION_DATA",
"value": "('S' | ('T' << 8) | ('A' << 16) | ('T' << 24))"
},
{
"name": "DXC_PART_SHADER_HASH",
"value": "('H' | ('A' << 8) | ('S' << 16) | ('H' << 24))"
},
{
"name": "DXC_PART_INPUT_SIGNATURE",
"value": "('I' | ('S' << 8) | ('G' << 16) | ('1' << 24))"
},
{
"name": "DXC_PART_OUTPUT_SIGNATURE",
"value": "('O' | ('S' << 8) | ('G' << 16) | ('1' << 24))"
},
{
"name": "DXC_PART_PATCH_CONSTANT_SIGNATURE",
"value": "('P' | ('S' << 8) | ('G' << 16) | ('1' << 24))"
}
],
"uses": [
{
"interface": "IDxcUtils",
"method": "GetDxilContainerPart",
"parameter": "DxcPart"
},
{
"interface": "IDxcContainerBuilder",
"method": "AddPart",
"parameter": "fourCC"
},
{
"interface": "IDxcContainerBuilder",
"method": "RemovePart",
"parameter": "fourCC"
},
{
"interface": "IDxcContainerReflection",
"method": "GetPartKind",
"parameter": "pResult"
},
{
"interface": "IDxcContainerReflection",
"method": "FindFirstPartKind",
"parameter": "kind"
}
]
},
Expand Down
25 changes: 25 additions & 0 deletions scripts/ChangesSinceLastRelease.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7074,3 +7074,28 @@ Windows.Win32.UI.Input.GameInput.IGameInputReading added
Windows.Win32.Storage.FileSystem.Apis.GetFileInformationByName added
# Namespace of IsCharLowerW seems wrong #2030
Windows.Win32.UI.Controls.Apis.IsCharLowerW => Windows.Win32.UI.WindowsAndMessaging.Apis.IsCharLowerW
# DXC: Annotate new struct fields and enums
Windows.Win32.Graphics.Direct3D.Dxc.Apis.DXC_HASHFLAG_INCLUDES_SOURCE removed
Windows.Win32.Graphics.Direct3D.Dxc.DXC_HASHFLAG added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_HASHFLAG.DXC_HASHFLAG_INCLUDES_SOURCE added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_DXIL added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_INPUT_SIGNATURE added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_OUTPUT_SIGNATURE added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_PATCH_CONSTANT_SIGNATURE added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_PDB added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_PDB_NAME added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_PRIVATE_DATA added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_REFLECTION_DATA added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_ROOT_SIGNATURE added
Windows.Win32.Graphics.Direct3D.Dxc.DXC_PART.DXC_PART_SHADER_HASH added
Windows.Win32.Graphics.Direct3D.Dxc.DxcBuffer.Encoding...System.UInt32 => Windows.Win32.Graphics.Direct3D.Dxc.DXC_CP
Windows.Win32.Graphics.Direct3D.Dxc.DxcShaderHash.Flags...System.UInt32 => Windows.Win32.Graphics.Direct3D.Dxc.DXC_HASHFLAG
Windows.Win32.Graphics.Direct3D.Dxc.IDxcContainerBuilder.AddPart : fourCC...UInt32 => DXC_PART
Windows.Win32.Graphics.Direct3D.Dxc.IDxcContainerBuilder.RemovePart : fourCC...UInt32 => DXC_PART
Windows.Win32.Graphics.Direct3D.Dxc.IDxcContainerReflection.FindFirstPartKind : kind...UInt32 => DXC_PART
Windows.Win32.Graphics.Direct3D.Dxc.IDxcContainerReflection.GetPartKind : pResult...UInt32* => DXC_PART*
Windows.Win32.Graphics.Direct3D.Dxc.IDxcContainerReflection.GetPartReflection : ppvObject : [In,Out] => [ComOutPtr,Out]
Windows.Win32.Graphics.Direct3D.Dxc.IDxcUtils.CreateReflection : ppvReflection : [In,Out] => [ComOutPtr,Out]
Windows.Win32.Graphics.Direct3D.Dxc.IDxcUtils.GetDxilContainerPart : DxcPart...UInt32 => DXC_PART
Windows.Win32.Graphics.Direct3D.Dxc.IDxcUtils.GetDxilContainerPart : ppPartData : [Out] => [NativeArrayInfo(CountFieldName=pPartSizeInBytes),Out]