use enums instead of bitfields

This commit is contained in:
2026-06-27 21:03:40 +02:00
parent 60bb497ae6
commit 03dd84463a
3 changed files with 372 additions and 943 deletions
+37
View File
@@ -1164,6 +1164,42 @@ class RegistryParser : XmlParser
} }
strBuf.Clear(); strBuf.Clear();
if (type_name.StartsWith("Std")) for (let field in fields)
if (field.flags.HasFlag(.Bitfield))
{
int flagPost = 1;
strBuf.Append("enum ", type_name, " : uint32\n{\n");
for (let field in fields)
{
if (field.flags.HasFlag(.CommentOnly))
{
if (field.comment.IsEmpty) continue;
strBuf.Append('\t');
WriteComment(field.comment, strBuf);
strBuf.Append('\n');
continue;
}
Runtime.Assert(field.flags.HasFlag(.Bitfield));
if (field.name != "reserved")
{
strBuf.Append('\t');
strBuf.Append(field.name);
strBuf.Append(" = 0x");
flagPost.ToString(strBuf, "X8", null);
strBuf.Append(",\n");
}
flagPost <<= field.bitfieldWidth;
}
strBuf.Append('}');
feature.content = new:alloc .(strBuf);
vkTypes.Add(feature.name, feature);
fields.Clear();
fieldBufferIdx = -1;
return;
}
switch (_) switch (_)
{ {
case .Type_Struct: strBuf.Append("[CRepr]"); case .Type_Struct: strBuf.Append("[CRepr]");
@@ -1176,6 +1212,7 @@ class RegistryParser : XmlParser
{ {
if (field.flags.HasFlag(.CommentOnly)) if (field.flags.HasFlag(.CommentOnly))
{ {
if (field.comment.IsEmpty) continue;
strBuf.Append('\t'); strBuf.Append('\t');
WriteComment(field.comment, strBuf); WriteComment(field.comment, strBuf);
strBuf.Append('\n'); strBuf.Append('\n');
+335 -919
View File
File diff suppressed because it is too large Load Diff
-24
View File
@@ -4481,7 +4481,6 @@ struct VkPhysicalDevice : int
[CRepr] struct VkPhysicalDeviceLimits : this() [CRepr] struct VkPhysicalDeviceLimits : this()
{ {
public uint32 maxImageDimension1D = 0; // max 1D image dimension public uint32 maxImageDimension1D = 0; // max 1D image dimension
public uint32 maxImageDimension2D = 0; // max 2D image dimension public uint32 maxImageDimension2D = 0; // max 2D image dimension
public uint32 maxImageDimension3D = 0; // max 3D image dimension public uint32 maxImageDimension3D = 0; // max 3D image dimension
@@ -4491,12 +4490,10 @@ struct VkPhysicalDevice : int
public uint32 maxUniformBufferRange = 0; // max uniform buffer range (bytes) public uint32 maxUniformBufferRange = 0; // max uniform buffer range (bytes)
public uint32 maxStorageBufferRange = 0; // max storage buffer range (bytes) public uint32 maxStorageBufferRange = 0; // max storage buffer range (bytes)
public uint32 maxPushConstantsSize = 0; // max size of the push constants pool (bytes) public uint32 maxPushConstantsSize = 0; // max size of the push constants pool (bytes)
public uint32 maxMemoryAllocationCount = 0; // max number of device memory allocations supported public uint32 maxMemoryAllocationCount = 0; // max number of device memory allocations supported
public uint32 maxSamplerAllocationCount = 0; // max number of samplers that can be allocated on a device public uint32 maxSamplerAllocationCount = 0; // max number of samplers that can be allocated on a device
public VkDeviceSize bufferImageGranularity = default; // Granularity (in bytes) at which buffers and images can be bound to adjacent memory for simultaneous usage public VkDeviceSize bufferImageGranularity = default; // Granularity (in bytes) at which buffers and images can be bound to adjacent memory for simultaneous usage
public VkDeviceSize sparseAddressSpaceSize = default; // Total address space available for sparse allocations (bytes) public VkDeviceSize sparseAddressSpaceSize = default; // Total address space available for sparse allocations (bytes)
public uint32 maxBoundDescriptorSets = 0; // max number of descriptors sets that can be bound to a pipeline public uint32 maxBoundDescriptorSets = 0; // max number of descriptors sets that can be bound to a pipeline
public uint32 maxPerStageDescriptorSamplers = 0; // max number of samplers allowed per-stage in a descriptor set public uint32 maxPerStageDescriptorSamplers = 0; // max number of samplers allowed per-stage in a descriptor set
public uint32 maxPerStageDescriptorUniformBuffers = 0; // max number of uniform buffers allowed per-stage in a descriptor set public uint32 maxPerStageDescriptorUniformBuffers = 0; // max number of uniform buffers allowed per-stage in a descriptor set
@@ -4513,34 +4510,28 @@ struct VkPhysicalDevice : int
public uint32 maxDescriptorSetSampledImages = 0; // max number of sampled images allowed in all stages in a descriptor set public uint32 maxDescriptorSetSampledImages = 0; // max number of sampled images allowed in all stages in a descriptor set
public uint32 maxDescriptorSetStorageImages = 0; // max number of storage images allowed in all stages in a descriptor set public uint32 maxDescriptorSetStorageImages = 0; // max number of storage images allowed in all stages in a descriptor set
public uint32 maxDescriptorSetInputAttachments = 0; // max number of input attachments allowed in all stages in a descriptor set public uint32 maxDescriptorSetInputAttachments = 0; // max number of input attachments allowed in all stages in a descriptor set
public uint32 maxVertexInputAttributes = 0; // max number of vertex input attribute slots public uint32 maxVertexInputAttributes = 0; // max number of vertex input attribute slots
public uint32 maxVertexInputBindings = 0; // max number of vertex input binding slots public uint32 maxVertexInputBindings = 0; // max number of vertex input binding slots
public uint32 maxVertexInputAttributeOffset = 0; // max vertex input attribute offset added to vertex buffer offset public uint32 maxVertexInputAttributeOffset = 0; // max vertex input attribute offset added to vertex buffer offset
public uint32 maxVertexInputBindingStride = 0; // max vertex input binding stride public uint32 maxVertexInputBindingStride = 0; // max vertex input binding stride
public uint32 maxVertexOutputComponents = 0; // max number of output components written by vertex shader public uint32 maxVertexOutputComponents = 0; // max number of output components written by vertex shader
public uint32 maxTessellationGenerationLevel = 0; // max level supported by tessellation primitive generator public uint32 maxTessellationGenerationLevel = 0; // max level supported by tessellation primitive generator
public uint32 maxTessellationPatchSize = 0; // max patch size (vertices) public uint32 maxTessellationPatchSize = 0; // max patch size (vertices)
public uint32 maxTessellationControlPerVertexInputComponents = 0; // max number of input components per-vertex in TCS public uint32 maxTessellationControlPerVertexInputComponents = 0; // max number of input components per-vertex in TCS
public uint32 maxTessellationControlPerVertexOutputComponents = 0; // max number of output components per-vertex in TCS public uint32 maxTessellationControlPerVertexOutputComponents = 0; // max number of output components per-vertex in TCS
public uint32 maxTessellationControlPerPatchOutputComponents = 0; // max number of output components per-patch in TCS public uint32 maxTessellationControlPerPatchOutputComponents = 0; // max number of output components per-patch in TCS
public uint32 maxTessellationControlTotalOutputComponents = 0; // max total number of per-vertex and per-patch output components in TCS public uint32 maxTessellationControlTotalOutputComponents = 0; // max total number of per-vertex and per-patch output components in TCS
public uint32 maxTessellationEvaluationInputComponents = 0; // max number of input components per vertex in TES public uint32 maxTessellationEvaluationInputComponents = 0; // max number of input components per vertex in TES
public uint32 maxTessellationEvaluationOutputComponents = 0; // max number of output components per vertex in TES public uint32 maxTessellationEvaluationOutputComponents = 0; // max number of output components per vertex in TES
public uint32 maxGeometryShaderInvocations = 0; // max invocation count supported in geometry shader public uint32 maxGeometryShaderInvocations = 0; // max invocation count supported in geometry shader
public uint32 maxGeometryInputComponents = 0; // max number of input components read in geometry stage public uint32 maxGeometryInputComponents = 0; // max number of input components read in geometry stage
public uint32 maxGeometryOutputComponents = 0; // max number of output components written in geometry stage public uint32 maxGeometryOutputComponents = 0; // max number of output components written in geometry stage
public uint32 maxGeometryOutputVertices = 0; // max number of vertices that can be emitted in geometry stage public uint32 maxGeometryOutputVertices = 0; // max number of vertices that can be emitted in geometry stage
public uint32 maxGeometryTotalOutputComponents = 0; // max total number of components (all vertices) written in geometry stage public uint32 maxGeometryTotalOutputComponents = 0; // max total number of components (all vertices) written in geometry stage
public uint32 maxFragmentInputComponents = 0; // max number of input components read in fragment stage public uint32 maxFragmentInputComponents = 0; // max number of input components read in fragment stage
public uint32 maxFragmentOutputAttachments = 0; // max number of output attachments written in fragment stage public uint32 maxFragmentOutputAttachments = 0; // max number of output attachments written in fragment stage
public uint32 maxFragmentDualSrcAttachments = 0; // max number of output attachments written when using dual source blending public uint32 maxFragmentDualSrcAttachments = 0; // max number of output attachments written when using dual source blending
public uint32 maxFragmentCombinedOutputResources = 0; // max total number of storage buffers, storage images and output buffers public uint32 maxFragmentCombinedOutputResources = 0; // max total number of storage buffers, storage images and output buffers
public uint32 maxComputeSharedMemorySize = 0; // max total storage size of work group local storage (bytes) public uint32 maxComputeSharedMemorySize = 0; // max total storage size of work group local storage (bytes)
public uint32[3] maxComputeWorkGroupCount = .(); // max num of compute work groups that may be dispatched by a single command (x,y,z) public uint32[3] maxComputeWorkGroupCount = .(); // max num of compute work groups that may be dispatched by a single command (x,y,z)
public uint32 maxComputeWorkGroupInvocations = 0; // max total compute invocations in a single local work group public uint32 maxComputeWorkGroupInvocations = 0; // max total compute invocations in a single local work group
@@ -6231,7 +6222,6 @@ typealias VkQueryControlFlags = VkQueryControlFlagBits;
[CRepr] struct VkPipelineCacheHeaderVersionOne : this() [CRepr] struct VkPipelineCacheHeaderVersionOne : this()
{ {
public uint32 headerSize = 0; public uint32 headerSize = 0;
public VkPipelineCacheHeaderVersion headerVersion = default; public VkPipelineCacheHeaderVersion headerVersion = default;
public uint32 vendorID = 0; public uint32 vendorID = 0;
@@ -18522,18 +18512,15 @@ static { public const let VK_EXT_HDR_METADATA_EXTENSION_NAME = "VK_EXT_hdr_metad
[CRepr] struct VkHdrMetadataEXT : this() [CRepr] struct VkHdrMetadataEXT : this()
{ {
public const VkStructureType SType = .VK_STRUCTURE_TYPE_HDR_METADATA_EXT; public const VkStructureType SType = .VK_STRUCTURE_TYPE_HDR_METADATA_EXT;
public VkStructureType sType = SType; public VkStructureType sType = SType;
public void* pNext = null; public void* pNext = null;
public VkXYColorEXT displayPrimaryRed = default; // Display primary's Red public VkXYColorEXT displayPrimaryRed = default; // Display primary's Red
public VkXYColorEXT displayPrimaryGreen = default; // Display primary's Green public VkXYColorEXT displayPrimaryGreen = default; // Display primary's Green
public VkXYColorEXT displayPrimaryBlue = default; // Display primary's Blue public VkXYColorEXT displayPrimaryBlue = default; // Display primary's Blue
public VkXYColorEXT whitePoint = default; // Display primary's Blue public VkXYColorEXT whitePoint = default; // Display primary's Blue
public float maxLuminance = 0; // Display maximum luminance public float maxLuminance = 0; // Display maximum luminance
public float minLuminance = 0; // Display minimum luminance public float minLuminance = 0; // Display minimum luminance
public float maxContentLightLevel = 0; // Content maximum luminance public float maxContentLightLevel = 0; // Content maximum luminance
public float maxFrameAverageLightLevel = 0; public float maxFrameAverageLightLevel = 0;
@@ -20028,7 +20015,6 @@ static { public const let VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME = "VK_KHR
[CRepr] struct VkAccelerationStructureInstanceKHR : this() [CRepr] struct VkAccelerationStructureInstanceKHR : this()
{ {
public VkTransformMatrixKHR transform = default; public VkTransformMatrixKHR transform = default;
[Bitfield(.Public, .Bits(24), "instanceCustomIndex")] [Bitfield(.Public, .Bits(24), "instanceCustomIndex")]
[Bitfield(.Public, .Bits(8), "mask")] [Bitfield(.Public, .Bits(8), "mask")]
@@ -25954,7 +25940,6 @@ static { public const let VK_NV_RAY_TRACING_MOTION_BLUR_EXTENSION_NAME = "VK_NV_
[CRepr] struct VkAccelerationStructureMatrixMotionInstanceNV : this() [CRepr] struct VkAccelerationStructureMatrixMotionInstanceNV : this()
{ {
public VkTransformMatrixKHR transformT0 = default; public VkTransformMatrixKHR transformT0 = default;
public VkTransformMatrixKHR transformT1 = default; public VkTransformMatrixKHR transformT1 = default;
[Bitfield(.Public, .Bits(24), "instanceCustomIndex")] [Bitfield(.Public, .Bits(24), "instanceCustomIndex")]
@@ -25979,7 +25964,6 @@ static { public const let VK_NV_RAY_TRACING_MOTION_BLUR_EXTENSION_NAME = "VK_NV_
[CRepr] struct VkAccelerationStructureSRTMotionInstanceNV : this() [CRepr] struct VkAccelerationStructureSRTMotionInstanceNV : this()
{ {
public VkSRTDataNV transformT0 = default; public VkSRTDataNV transformT0 = default;
public VkSRTDataNV transformT1 = default; public VkSRTDataNV transformT1 = default;
[Bitfield(.Public, .Bits(24), "instanceCustomIndex")] [Bitfield(.Public, .Bits(24), "instanceCustomIndex")]
@@ -26523,7 +26507,6 @@ static { public const let VK_EXT_DEVICE_FAULT_EXTENSION_NAME = "VK_EXT_device_fa
[CRepr] struct VkDeviceFaultVendorBinaryHeaderVersionOneEXT : this() [CRepr] struct VkDeviceFaultVendorBinaryHeaderVersionOneEXT : this()
{ {
public uint32 headerSize = 0; public uint32 headerSize = 0;
public VkDeviceFaultVendorBinaryHeaderVersionEXT headerVersion = default; public VkDeviceFaultVendorBinaryHeaderVersionEXT headerVersion = default;
public uint32 vendorID = 0; public uint32 vendorID = 0;
@@ -30149,7 +30132,6 @@ struct VkOpticalFlowSessionNV : uint64
[CRepr] struct VkOpticalFlowSessionCreatePrivateDataInfoNV : this() [CRepr] struct VkOpticalFlowSessionCreatePrivateDataInfoNV : this()
{ {
public const VkStructureType SType = .VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_PRIVATE_DATA_INFO_NV; public const VkStructureType SType = .VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_PRIVATE_DATA_INFO_NV;
public VkStructureType sType = SType; public VkStructureType sType = SType;
public void* pNext = null; public void* pNext = null;
@@ -31052,7 +31034,6 @@ static { public const let VK_KHR_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME = "VK_KH
public VkStructureType sType = SType; public VkStructureType sType = SType;
public void* pNext = null; public void* pNext = null;
public uint32 presentModeCount = 0; public uint32 presentModeCount = 0;
public VkPresentModeKHR* pPresentModes = null; public VkPresentModeKHR* pPresentModes = null;
public Span<VkPresentModeKHR> presentModes public Span<VkPresentModeKHR> presentModes
{ {
@@ -31060,7 +31041,6 @@ static { public const let VK_KHR_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME = "VK_KH
set mut { pPresentModes = value.Ptr; presentModeCount = (.)value.Length; } set mut { pPresentModes = value.Ptr; presentModeCount = (.)value.Length; }
} }
public this(void* pNext, Span<VkPresentModeKHR> presentModes) : this() public this(void* pNext, Span<VkPresentModeKHR> presentModes) : this()
{ {
this.pNext = pNext; this.pNext = pNext;
@@ -34373,7 +34353,6 @@ static { public const let VK_NV_CLUSTER_ACCELERATION_STRUCTURE_EXTENSION_NAME =
[CRepr] struct VkClusterAccelerationStructureGeometryIndexAndGeometryFlagsNV : this() [CRepr] struct VkClusterAccelerationStructureGeometryIndexAndGeometryFlagsNV : this()
{ {
[Bitfield(.Public, .Bits(24), "geometryIndex")] [Bitfield(.Public, .Bits(24), "geometryIndex")]
[Bitfield(.Public, .Bits(5), "reserved")] [Bitfield(.Public, .Bits(5), "reserved")]
[Bitfield(.Public, .Bits(3), "geometryFlags")] [Bitfield(.Public, .Bits(3), "geometryFlags")]
@@ -34456,7 +34435,6 @@ typealias VkClusterAccelerationStructureAddressResolutionFlagsNV = VkClusterAcce
[CRepr] struct VkClusterAccelerationStructureBuildTriangleClusterInfoNV : this() [CRepr] struct VkClusterAccelerationStructureBuildTriangleClusterInfoNV : this()
{ {
public uint32 clusterID = 0; public uint32 clusterID = 0;
public VkClusterAccelerationStructureClusterFlagsNV clusterFlags = default; public VkClusterAccelerationStructureClusterFlagsNV clusterFlags = default;
[Bitfield(.Public, .Bits(9), "triangleCount")] [Bitfield(.Public, .Bits(9), "triangleCount")]
@@ -34500,7 +34478,6 @@ typealias VkClusterAccelerationStructureAddressResolutionFlagsNV = VkClusterAcce
[CRepr] struct VkClusterAccelerationStructureBuildTriangleClusterTemplateInfoNV : this() [CRepr] struct VkClusterAccelerationStructureBuildTriangleClusterTemplateInfoNV : this()
{ {
public uint32 clusterID = 0; public uint32 clusterID = 0;
public VkClusterAccelerationStructureClusterFlagsNV clusterFlags = default; public VkClusterAccelerationStructureClusterFlagsNV clusterFlags = default;
[Bitfield(.Public, .Bits(9), "triangleCount")] [Bitfield(.Public, .Bits(9), "triangleCount")]
@@ -36262,7 +36239,6 @@ static { public const uint32 VK_DATA_GRAPH_MODEL_TOOLCHAIN_VERSION_LENGTH_QCOM =
[CRepr] struct VkPipelineCacheHeaderVersionDataGraphQCOM : this() [CRepr] struct VkPipelineCacheHeaderVersionDataGraphQCOM : this()
{ {
public uint32 headerSize = 0; public uint32 headerSize = 0;
public VkPipelineCacheHeaderVersion headerVersion = default; public VkPipelineCacheHeaderVersion headerVersion = default;
public VkDataGraphModelCacheTypeQCOM cacheType = default; public VkDataGraphModelCacheTypeQCOM cacheType = default;