Skip to content

Commit 40727fc

Browse files
committed
Write docs for KhronosNonExclusiveVendor
1 parent b7ec820 commit 40727fc

1 file changed

Lines changed: 34 additions & 16 deletions

File tree

docs/for-contributors/Generator/generator-mods.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -413,34 +413,52 @@ Be aware that these link to the latest version. Silk's repo may be using an olde
413413

414414
Name affix categories:
415415

416-
- `KhronosFunctionDataType` - This is a suffix relevant to OpenGL-like APIs where functions like `glColor3` have
417-
variants such as `glColor3i`, `glColor3f`, and `glColor3b`. These suffixes indicate the data type that the function
418-
expects. In this case, integer, float, and byte, respectively. Silk's bindings configure these as discriminators so
419-
that they can be removed when removing them does not lead to method overload conflicts. `IdentifyFunctionDataTypes`
420-
must be set to true in the `MixKhronosData` configuration for this affix category to be identified.
421-
422-
- `KhronosHandleType` - This is a suffix resulting from the typedefs used by Khronos in their headers. For example,
423-
Vulkan uses the following macro to define handle types:
416+
- `KhronosFunctionDataType` - `IdentifyFunctionDataTypes` must be set to true in the `MixKhronosData` configuration for
417+
this affix category to be identified. This is a suffix relevant to OpenGL-like APIs where functions like `glColor3`
418+
have variants such as `glColor3i`, `glColor3f`, and `glColor3b`. These suffixes indicate the data type that the
419+
function expects. In this case, integer, float, and byte, respectively. Silk's bindings configure these as
420+
discriminators so that they can be removed when removing them does not lead to method overload conflicts.
421+
422+
- `KhronosHandleType` - This is a suffix used on handle structs resulting from the typedefs used by Khronos in their
423+
headers. For example, Vulkan uses the following macro to define handle types:
424424
`#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;`, used as `VK_DEFINE_HANDLE(VkInstance)`.
425425
Although Vulkan uses the handle type as `VkInstance`, `ClangScraper` outputs the type as `VkInstance_T` due to the
426426
typedef. As such, `MixKhronosData` identifies this suffix so that `PrettifyNames` can be configured to remove this
427427
suffix later.
428428

429-
- `KhronosImpliedVendor` - This is a suffix added when an enum member has the same vendor suffix as the containing enum
430-
type. This suffix exists in native code because the enum member is usually defined as a standalone, global constant
431-
without any other context whether the enum member is part of an extension. In C#, this is not a problem because the
432-
enum type itself conveys that information. For example, in Vulkan, `VkPresentModeKHR` in Vulkan is a `KHR` suffixed
433-
enum type that contains `VK_PRESENT_MODE_IMMEDIATE_KHR` as a member. In C#, this `KHR` suffix on the member is
434-
redundant. As such, Silk's bindings are configured to remove this suffix. `IdentifyEnumMemberImpliedVendors` must be
435-
set to true in the `MixKhronosData` configuration for this affix category to be identified.
429+
- `KhronosImpliedVendor` - `IdentifyEnumMemberImpliedVendors` must be set to true in the `MixKhronosData` configuration
430+
for this affix category to be identified. This is a suffix used on enum members instead of `KhronosVendor` when an
431+
enum member has the same vendor suffix as **the containing enum type. This suffix exists in native code because the
432+
enum member is usually defined as a standalone, global constant without any other context whether the enum member is
433+
part of an extension. In C#, this is not a problem because the enum type itself conveys that information. For example,
434+
in Vulkan, `VkPresentModeKHR` in Vulkan is a `KHR` suffixed enum type that contains `VK_PRESENT_MODE_IMMEDIATE_KHR` as
435+
a member. In C#, this `KHR` suffix on the member is redundant. As such, Silk's bindings are configured to remove this
436+
suffix.
436437

437438
- `KhronosNamespaceEnum` - This is a prefix added to the "namespace" enum of OpenGL-like APIs such as `GLEnum`,
438439
`ALEnum`, and `ALCEnum`. In this case, the value of the prefix would be `GL`, `AL`, and `ALC`, respectively. This is
439440
so that the casing of the prefix is preserved by `PrettifyNames`. As such, Silk's bindings leaves the affix category
440441
unconfigured in the `PrettifyNames` configuration so that `PrettifyNames` uses the default behavior of preserving the
441442
affix.
442443

443-
- `KhronosNonExclusiveVendor` - TODO
444+
- `KhronosNonExclusiveVendor` - `IdentifyEnumTypeNonExclusiveVendors` must be set to true in the `MixKhronosData`
445+
configuration for this affix category to be identified. This is a suffix used on enum types instead of `KhronosVendor`
446+
when the enum type's vendor suffix does not match the vendor suffixes used by the enum members contained within that
447+
type. For example, `BufferUsageARB` has the `ARB` vendor suffix, but contains non-suffixed members such as
448+
`GL_STREAM_DRAW`. Similarly, `GetMultisamplePNameNV` contains `ProgrammableSampleLocationARB`, which is also a
449+
mismatch. This affix category is only intended to be used for OpenGL-like APIs where enum member promotion was not
450+
fully defined, leading to inconsistent vendor suffixing where a non-promoted enum type contains a promoted enum
451+
member. Modern APIs like Vulkan do not have this issue. In modern APIs, there can be "mismatches", but those are cases
452+
where promoted enum types contain non-promoted enum members, which is allowed. As such, Silk's bindings enables
453+
`IdentifyEnumTypeNonExclusiveVendors` and configures `KhronosNonExclusiveVendor` affixes to be removed only for
454+
OpenGL-like APIs. Furthermore, `IdentifyEnumTypeNonExclusiveVendors` also interacts with
455+
`IdentifyEnumMemberImpliedVendors`. Specifically, if an enum type is identified to have a non-exclusive vendor, that
456+
vendor will not be used to identify implied vendors, as it is assumed that the non-exclusive vendor will be removed.
457+
Also note that the behavior of `IdentifyEnumTypeNonExclusiveVendors` can be considered "too aggressive" since it
458+
triggers off of *any* mismatch. For example, if a vendor suffixed enum type contains something generic such as
459+
`GL_NONE`, the enum type vendor suffix will still be identified as a `KhronosNonExclusiveVendor`. This behavior was
460+
ported from the now removed `NameTrimmer`-based implementation and is kept for simplicity and consistency with the old
461+
implementation.
444462

445463
- `KhronosVendor` - TODO
446464

0 commit comments

Comments
 (0)