1 /* 2 Copyright (c) 2019-2023 Timur Gafarov. 3 4 Boost Software License - Version 1.0 - August 17th, 2003 5 6 Permission is hereby granted, free of charge, to any person or organization 7 obtaining a copy of the software and accompanying documentation covered by 8 this license (the "Software") to use, reproduce, display, distribute, 9 execute, and transmit the Software, and to prepare derivative works of the 10 Software, and to permit third-parties to whom the Software is furnished to 11 do so, all subject to the following: 12 13 The copyright notices in the Software and this entire statement, including 14 the above license grant, this restriction and the following disclaimer, 15 must be included in all copies of the Software, in whole or in part, and 16 all derivative works of the Software, unless such copies or derivative 17 works are solely in the form of machine-executable object code generated by 18 a source language processor. 19 20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 23 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 24 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 25 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 DEALINGS IN THE SOFTWARE. 27 */ 28 module bindbc.wgpu.types2; 29 30 import bindbc.wgpu.types; 31 32 /* 33 * Type definitions from wgpu.h 34 */ 35 36 enum WGPUNativeSType 37 { 38 // Start at 6 to prevent collisions with webgpu STypes 39 DeviceExtras = 0x00030001, 40 RequiredLimitsExtras = 0x00030002, 41 PipelineLayoutExtras = 0x00030003, 42 ShaderModuleGLSLDescriptor = 0x00030004, 43 SupportedLimitsExtras = 0x00030005, 44 InstanceExtras = 0x00030006, 45 BindGroupEntryExtras = 0x00030007, 46 BindGroupLayoutEntryExtras = 0x00030008, 47 QuerySetDescriptorExtras = 0x00030009, 48 SurfaceConfigurationExtras = 0x0003000A, 49 Force32 = 0x7FFFFFFF 50 } 51 52 enum WGPUNativeFeature 53 { 54 PushConstants = 0x00030001, 55 TextureAdapterSpecificFormatFeatures = 0x00030002, 56 MultiDrawIndirect = 0x00030003, 57 MultiDrawIndirectCount = 0x00030004, 58 VertexWritableStorage = 0x00030005, 59 TextureBindingArray = 0x00030006, 60 SampledTextureAndStorageBufferArrayNonUniformIndexing = 0x00030007, 61 PipelineStatisticsQuery = 0x00030008, 62 Force32 = 0x7FFFFFFF 63 } 64 65 enum WGPULogLevel 66 { 67 Off = 0x00000000, 68 Error = 0x00000001, 69 Warn = 0x00000002, 70 Info = 0x00000003, 71 Debug = 0x00000004, 72 Trace = 0x00000005, 73 Force32 = 0x7FFFFFFF 74 } 75 76 enum WGPUInstanceBackend 77 { 78 All = 0x00000000, 79 Vulkan = 1 << 0, 80 GL = 1 << 1, 81 Metal = 1 << 2, 82 DX12 = 1 << 3, 83 DX11 = 1 << 4, 84 BrowserWebGPU = 1 << 5, 85 Primary = Vulkan | Metal | DX12 | BrowserWebGPU, 86 Secondary = GL | DX11, 87 Force32 = 0x7FFFFFFF 88 } 89 90 alias WGPUInstanceBackendFlags = WGPUFlags; 91 92 enum WGPUInstanceFlag 93 { 94 Default = 0x00000000, 95 Debug = 1 << 0, 96 Validation = 1 << 1, 97 DiscardHalLabels = 1 << 2, 98 Force32 = 0x7FFFFFFF 99 } 100 101 alias WGPUInstanceFlags = WGPUFlags; 102 103 enum WGPUDx12Compiler 104 { 105 Undefined = 0x00000000, 106 Fxc = 0x00000001, 107 Dxc = 0x00000002, 108 Force32 = 0x7FFFFFFF 109 } 110 111 enum WGPUGles3MinorVersion { 112 Automatic = 0x00000000, 113 Version0 = 0x00000001, 114 Version1 = 0x00000002, 115 Version2 = 0x00000003, 116 Force32 = 0x7FFFFFFF 117 } 118 119 enum WGPUPipelineStatisticName 120 { 121 VertexShaderInvocations = 0x00000000, 122 ClipperInvocations = 0x00000001, 123 ClipperPrimitivesOut = 0x00000002, 124 FragmentShaderInvocations = 0x00000003, 125 ComputeShaderInvocations = 0x00000004, 126 Force32 = 0x7FFFFFFF 127 } 128 129 enum WGPUNativeQueryType 130 { 131 PipelineStatistics = 0x00030000, 132 Force32 = 0x7FFFFFFF 133 } 134 135 struct WGPUInstanceExtras 136 { 137 WGPUChainedStruct chain; 138 WGPUInstanceBackendFlags backends; 139 WGPUInstanceFlags flags; 140 WGPUDx12Compiler dx12ShaderCompiler; 141 WGPUGles3MinorVersion gles3MinorVersion; 142 const char * dxilPath; 143 const char * dxcPath; 144 } 145 146 struct WGPUDeviceExtras 147 { 148 WGPUChainedStruct chain; 149 const(char)* tracePath; 150 } 151 152 struct WGPUNativeLimits { 153 uint maxPushConstantSize; 154 uint maxNonSamplerBindings; 155 } 156 157 struct WGPURequiredLimitsExtras 158 { 159 WGPUChainedStruct chain; 160 WGPUNativeLimits limits; 161 } 162 163 struct WGPUSupportedLimitsExtras 164 { 165 WGPUChainedStructOut chain; 166 WGPUNativeLimits limits; 167 } 168 169 struct WGPUPushConstantRange 170 { 171 alias WGPUShaderStageFlags = uint; 172 WGPUShaderStageFlags stages; 173 uint start; 174 uint end; 175 } 176 177 struct WGPUPipelineLayoutExtras 178 { 179 WGPUChainedStruct chain; 180 size_t pushConstantRangeCount; 181 const(WGPUPushConstantRange)* pushConstantRanges; 182 } 183 184 alias WGPUSubmissionIndex = ulong; 185 186 struct WGPUWrappedSubmissionIndex 187 { 188 WGPUQueue queue; 189 WGPUSubmissionIndex submissionIndex; 190 } 191 192 struct WGPUShaderDefine 193 { 194 const(char)* name; 195 const(char)* value; 196 } 197 198 struct WGPUShaderModuleGLSLDescriptor 199 { 200 WGPUChainedStruct chain; 201 WGPUShaderStage stage; 202 const(char)* code; 203 uint defineCount; 204 WGPUShaderDefine* defines; 205 } 206 207 struct WGPURegistryReport 208 { 209 size_t numAllocated; 210 size_t numKeptFromUser; 211 size_t numReleasedFromUser; 212 size_t numError; 213 size_t elementSize; 214 } 215 216 struct WGPUHubReport 217 { 218 WGPURegistryReport adapters; 219 WGPURegistryReport devices; 220 WGPURegistryReport queues; 221 WGPURegistryReport pipelineLayouts; 222 WGPURegistryReport shaderModules; 223 WGPURegistryReport bindGroupLayouts; 224 WGPURegistryReport bindGroups; 225 WGPURegistryReport commandBuffers; 226 WGPURegistryReport renderBundles; 227 WGPURegistryReport renderPipelines; 228 WGPURegistryReport computePipelines; 229 WGPURegistryReport querySets; 230 WGPURegistryReport buffers; 231 WGPURegistryReport textures; 232 WGPURegistryReport textureViews; 233 WGPURegistryReport samplers; 234 } 235 236 struct WGPUGlobalReport 237 { 238 WGPURegistryReport surfaces; 239 WGPUBackendType backendType; 240 WGPUHubReport vulkan; 241 WGPUHubReport metal; 242 WGPUHubReport dx12; 243 WGPUHubReport gl; 244 } 245 246 struct WGPUInstanceEnumerateAdapterOptions 247 { 248 const(WGPUChainedStruct)* nextInChain; 249 WGPUInstanceBackendFlags backends; 250 } 251 252 struct WGPUBindGroupEntryExtras 253 { 254 WGPUChainedStruct chain; 255 const(WGPUBuffer)* buffers; 256 size_t bufferCount; 257 const(WGPUSampler)* samplers; 258 size_t samplerCount; 259 const(WGPUTextureView)* textureViews; 260 size_t textureViewCount; 261 } 262 263 struct WGPUBindGroupLayoutEntryExtras 264 { 265 WGPUChainedStruct chain; 266 uint count; 267 } 268 269 struct WGPUQuerySetDescriptorExtras 270 { 271 WGPUChainedStruct chain; 272 const(WGPUPipelineStatisticName)* pipelineStatistics; 273 size_t pipelineStatisticCount; 274 } 275 276 struct WGPUSurfaceConfigurationExtras 277 { 278 WGPUChainedStruct chain; 279 WGPUBool desiredMaximumFrameLatency; 280 } 281 282 extern(C): 283 284 alias WGPULogCallback = void function (WGPULogLevel level, const(char)* message, void* userdata); 285 286 extern(C) @nogc nothrow: 287 288 alias WGPUProcGenerateReport = void function(WGPUInstance instance, WGPUGlobalReport* report); 289 alias WGPUProcInstanceEnumerateAdapters = size_t function(WGPUInstance instance, const(WGPUInstanceEnumerateAdapterOptions)* options, WGPUAdapter* adapters); 290 291 alias WGPUProcQueueSubmitForIndex = WGPUSubmissionIndex function(WGPUQueue queue, size_t commandCount, const(WGPUCommandBuffer)* commands); 292 293 // Returns true if the queue is empty, or false if there are more queue submissions still in flight. 294 alias WGPUProcDevicePoll = WGPUBool function(WGPUDevice device, WGPUBool wait, const(WGPUWrappedSubmissionIndex)* wrappedSubmissionIndex); 295 296 alias WGPUProcSetLogCallback = void function(WGPULogCallback callback, void* userdata); 297 298 alias WGPUProcSetLogLevel = void function(WGPULogLevel level); 299 300 alias WGPUProcGetVersion = uint function(); 301 302 alias WGPUProcRenderPassEncoderSetPushConstants = void function(WGPURenderPassEncoder encoder, WGPUShaderStageFlags stages, uint offset, uint sizeBytes, const(void)* data); 303 304 alias WGPUProcRenderPassEncoderMultiDrawIndirect = void function(WGPURenderPassEncoder encoder, WGPUBuffer buffer, ulong offset, uint count); 305 alias WGPUProcRenderPassEncoderMultiDrawIndexedIndirect = void function(WGPURenderPassEncoder encoder, WGPUBuffer buffer, ulong offset, uint count); 306 307 alias WGPUProcRenderPassEncoderMultiDrawIndirectCount = void function(WGPURenderPassEncoder encoder, WGPUBuffer buffer, ulong offset, WGPUBuffer count_buffer, ulong count_buffer_offset, uint max_count); 308 alias WGPUProcRenderPassEncoderMultiDrawIndexedIndirectCount = void function(WGPURenderPassEncoder encoder, WGPUBuffer buffer, ulong offset, WGPUBuffer count_buffer, ulong count_buffer_offset, uint max_count); 309 310 alias WGPUProcComputePassEncoderBeginPipelineStatisticsQuery = void function(WGPUComputePassEncoder computePassEncoder, WGPUQuerySet querySet, uint queryIndex); 311 alias WGPUProcComputePassEncoderEndPipelineStatisticsQuery = void function(WGPUComputePassEncoder computePassEncoder); 312 alias WGPUProcRenderPassEncoderBeginPipelineStatisticsQuery = void function(WGPURenderPassEncoder renderPassEncoder, WGPUQuerySet querySet, uint queryIndex); 313 alias WGPUProcRenderPassEncoderEndPipelineStatisticsQuery = void function(WGPURenderPassEncoder renderPassEncoder);