summaryrefslogtreecommitdiff
path: root/chromium/third_party/dawn
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-13 15:05:36 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-02-14 10:33:47 +0000
commite684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch)
treed55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/third_party/dawn
parent2b94bfe47ccb6c08047959d1c26e392919550e86 (diff)
downloadqtwebengine-chromium-e684a3455bcc29a6e3e66a004e352dea4e1141e7.tar.gz
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922 Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/dawn')
-rw-r--r--chromium/third_party/dawn/.clang-format20
-rw-r--r--chromium/third_party/dawn/.gn27
-rw-r--r--chromium/third_party/dawn/AUTHORS6
-rw-r--r--chromium/third_party/dawn/BUILD.gn1004
-rw-r--r--chromium/third_party/dawn/CONTRIBUTING.md21
-rw-r--r--chromium/third_party/dawn/DEPS238
-rw-r--r--chromium/third_party/dawn/LICENSE202
-rw-r--r--chromium/third_party/dawn/OWNERS4
-rw-r--r--chromium/third_party/dawn/PRESUBMIT.py69
-rw-r--r--chromium/third_party/dawn/README.chromium12
-rw-r--r--chromium/third_party/dawn/README.md78
-rw-r--r--chromium/third_party/dawn/build_overrides/build.gni27
-rw-r--r--chromium/third_party/dawn/build_overrides/dawn.gni32
-rw-r--r--chromium/third_party/dawn/build_overrides/glslang.gni15
-rw-r--r--chromium/third_party/dawn/build_overrides/shaderc.gni16
-rw-r--r--chromium/third_party/dawn/build_overrides/spirv_tools.gni20
-rw-r--r--chromium/third_party/dawn/codereview.settings3
-rw-r--r--chromium/third_party/dawn/dawn.json1158
-rw-r--r--chromium/third_party/dawn/examples/Animometer.cpp174
-rw-r--r--chromium/third_party/dawn/examples/CHelloTriangle.cpp119
-rw-r--r--chromium/third_party/dawn/examples/ComputeBoids.cpp324
-rw-r--r--chromium/third_party/dawn/examples/CppHelloTriangle.cpp187
-rw-r--r--chromium/third_party/dawn/examples/CubeReflection.cpp321
-rw-r--r--chromium/third_party/dawn/examples/SampleUtils.cpp231
-rw-r--r--chromium/third_party/dawn/examples/SampleUtils.h34
-rw-r--r--chromium/third_party/dawn/examples/glTFViewer/Camera.inl67
-rw-r--r--chromium/third_party/dawn/examples/glTFViewer/README.md30
-rw-r--r--chromium/third_party/dawn/examples/glTFViewer/glTFViewer.cpp663
-rw-r--r--chromium/third_party/dawn/examples/glTFViewer/img/nxt-gltf-duck.jpgbin0 -> 16087 bytes
-rw-r--r--chromium/third_party/dawn/examples/glTFViewer/img/nxt-gltf-vc.jpgbin0 -> 95119 bytes
-rw-r--r--chromium/third_party/dawn/generator/extract_json.py35
-rw-r--r--chromium/third_party/dawn/generator/main.py572
-rw-r--r--chromium/third_party/dawn/generator/templates/api.c46
-rw-r--r--chromium/third_party/dawn/generator/templates/api.h106
-rw-r--r--chromium/third_party/dawn/generator/templates/apicpp.cpp130
-rw-r--r--chromium/third_party/dawn/generator/templates/apicpp.h174
-rw-r--r--chromium/third_party/dawn/generator/templates/apicpp_traits.h43
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_native/ProcTable.cpp178
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_native/ValidationUtils.cpp43
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_native/ValidationUtils.h31
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_native/api_structs.cpp37
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_native/api_structs.h37
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_wire/WireClient.cpp691
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_wire/WireCmd.cpp360
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_wire/WireCmd.h147
-rw-r--r--chromium/third_party/dawn/generator/templates/dawn_wire/WireServer.cpp648
-rw-r--r--chromium/third_party/dawn/generator/templates/mock_api.cpp113
-rw-r--r--chromium/third_party/dawn/generator/templates/mock_api.h117
-rw-r--r--chromium/third_party/dawn/infra/config/OWNERS2
-rw-r--r--chromium/third_party/dawn/infra/config/README.md1
-rw-r--r--chromium/third_party/dawn/infra/config/branch/cq.cfg34
-rw-r--r--chromium/third_party/dawn/infra/config/global/cr-buildbucket.cfg310
-rw-r--r--chromium/third_party/dawn/infra/config/global/luci-logdog.cfg17
-rw-r--r--chromium/third_party/dawn/infra/config/global/luci-milo.cfg103
-rw-r--r--chromium/third_party/dawn/infra/config/global/luci-scheduler.cfg150
-rw-r--r--chromium/third_party/dawn/infra/config/global/project.cfg4
-rw-r--r--chromium/third_party/dawn/infra/config/global/refs.cfg6
-rw-r--r--chromium/third_party/dawn/scripts/dawn_features.gni35
-rw-r--r--chromium/third_party/dawn/scripts/dawn_overrides_with_defaults.gni49
-rwxr-xr-xchromium/third_party/dawn/scripts/git-clang-format579
-rwxr-xr-xchromium/third_party/dawn/scripts/lint_clang_format.sh44
-rw-r--r--chromium/third_party/dawn/scripts/standalone.gclient10
-rwxr-xr-xchromium/third_party/dawn/scripts/travis_lint_format.sh27
-rw-r--r--chromium/third_party/dawn/src/common/Assert.cpp26
-rw-r--r--chromium/third_party/dawn/src/common/Assert.h80
-rw-r--r--chromium/third_party/dawn/src/common/BitSetIterator.h135
-rw-r--r--chromium/third_party/dawn/src/common/Compiler.h94
-rw-r--r--chromium/third_party/dawn/src/common/Constants.h30
-rw-r--r--chromium/third_party/dawn/src/common/DynamicLib.cpp100
-rw-r--r--chromium/third_party/dawn/src/common/DynamicLib.h54
-rw-r--r--chromium/third_party/dawn/src/common/HashUtils.h82
-rw-r--r--chromium/third_party/dawn/src/common/Math.cpp79
-rw-r--r--chromium/third_party/dawn/src/common/Math.h41
-rw-r--r--chromium/third_party/dawn/src/common/Platform.h52
-rw-r--r--chromium/third_party/dawn/src/common/Result.h335
-rw-r--r--chromium/third_party/dawn/src/common/Serial.h22
-rw-r--r--chromium/third_party/dawn/src/common/SerialMap.h75
-rw-r--r--chromium/third_party/dawn/src/common/SerialQueue.h86
-rw-r--r--chromium/third_party/dawn/src/common/SerialStorage.h315
-rw-r--r--chromium/third_party/dawn/src/common/SwapChainUtils.h40
-rw-r--r--chromium/third_party/dawn/src/common/vulkan_platform.h160
-rw-r--r--chromium/third_party/dawn/src/common/windows_with_undefs.h31
-rw-r--r--chromium/third_party/dawn/src/dawn_native/BindGroup.cpp209
-rw-r--r--chromium/third_party/dawn/src/dawn_native/BindGroup.h72
-rw-r--r--chromium/third_party/dawn/src/dawn_native/BindGroupLayout.cpp117
-rw-r--r--chromium/third_party/dawn/src/dawn_native/BindGroupLayout.h63
-rw-r--r--chromium/third_party/dawn/src/dawn_native/BlendState.cpp98
-rw-r--r--chromium/third_party/dawn/src/dawn_native/BlendState.h67
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Buffer.cpp270
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Buffer.h135
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Builder.cpp93
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Builder.h105
-rw-r--r--chromium/third_party/dawn/src/dawn_native/CommandAllocator.cpp228
-rw-r--r--chromium/third_party/dawn/src/dawn_native/CommandAllocator.h150
-rw-r--r--chromium/third_party/dawn/src/dawn_native/CommandBuffer.cpp702
-rw-r--r--chromium/third_party/dawn/src/dawn_native/CommandBuffer.h115
-rw-r--r--chromium/third_party/dawn/src/dawn_native/CommandBufferStateTracker.cpp170
-rw-r--r--chromium/third_party/dawn/src/dawn_native/CommandBufferStateTracker.h63
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Commands.cpp202
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Commands.h164
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ComputePassEncoder.cpp52
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ComputePassEncoder.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ComputePipeline.cpp50
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ComputePipeline.h34
-rw-r--r--chromium/third_party/dawn/src/dawn_native/DawnNative.cpp33
-rw-r--r--chromium/third_party/dawn/src/dawn_native/DepthStencilState.cpp137
-rw-r--r--chromium/third_party/dawn/src/dawn_native/DepthStencilState.h85
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Device.cpp299
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Device.h161
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Error.cpp35
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Error.h95
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ErrorData.cpp46
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ErrorData.h50
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Forward.h69
-rw-r--r--chromium/third_party/dawn/src/dawn_native/InputState.cpp171
-rw-r--r--chromium/third_party/dawn/src/dawn_native/InputState.h86
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ObjectBase.cpp29
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ObjectBase.h37
-rw-r--r--chromium/third_party/dawn/src/dawn_native/PassResourceUsage.h47
-rw-r--r--chromium/third_party/dawn/src/dawn_native/PerStage.cpp29
-rw-r--r--chromium/third_party/dawn/src/dawn_native/PerStage.h82
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Pipeline.cpp136
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Pipeline.h91
-rw-r--r--chromium/third_party/dawn/src/dawn_native/PipelineLayout.cpp76
-rw-r--r--chromium/third_party/dawn/src/dawn_native/PipelineLayout.h57
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ProgrammablePassEncoder.cpp83
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ProgrammablePassEncoder.h55
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Queue.cpp61
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Queue.h42
-rw-r--r--chromium/third_party/dawn/src/dawn_native/RefCounted.cpp77
-rw-r--r--chromium/third_party/dawn/src/dawn_native/RefCounted.h129
-rw-r--r--chromium/third_party/dawn/src/dawn_native/RenderPassDescriptor.cpp211
-rw-r--r--chromium/third_party/dawn/src/dawn_native/RenderPassDescriptor.h111
-rw-r--r--chromium/third_party/dawn/src/dawn_native/RenderPassEncoder.cpp147
-rw-r--r--chromium/third_party/dawn/src/dawn_native/RenderPassEncoder.h66
-rw-r--r--chromium/third_party/dawn/src/dawn_native/RenderPipeline.cpp222
-rw-r--r--chromium/third_party/dawn/src/dawn_native/RenderPipeline.h96
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Sampler.cpp40
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Sampler.h36
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ShaderModule.cpp259
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ShaderModule.h81
-rw-r--r--chromium/third_party/dawn/src/dawn_native/SwapChain.cpp118
-rw-r--r--chromium/third_party/dawn/src/dawn_native/SwapChain.h70
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Texture.cpp326
-rw-r--r--chromium/third_party/dawn/src/dawn_native/Texture.h92
-rw-r--r--chromium/third_party/dawn/src/dawn_native/ToBackend.h154
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupD3D12.cpp103
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupD3D12.h52
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp132
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupLayoutD3D12.h54
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/BlendStateD3D12.cpp108
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/BlendStateD3D12.h36
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/BufferD3D12.cpp251
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/BufferD3D12.h88
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/CommandAllocatorManager.cpp69
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/CommandAllocatorManager.h56
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/CommandBufferD3D12.cpp639
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/CommandBufferD3D12.h49
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/ComputePipelineD3D12.cpp66
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/ComputePipelineD3D12.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/DepthStencilStateD3D12.cpp98
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/DepthStencilStateD3D12.h38
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/DescriptorHeapAllocator.cpp132
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/DescriptorHeapAllocator.h83
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/DeviceD3D12.cpp357
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/DeviceD3D12.h129
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/Forward.h71
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/InputStateD3D12.cpp103
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/InputStateD3D12.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/NativeSwapChainImplD3D12.cpp118
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/NativeSwapChainImplD3D12.h58
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp116
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/PipelineLayoutD3D12.h44
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/PlatformFunctions.cpp74
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/PlatformFunctions.h75
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/QueueD3D12.cpp41
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/QueueD3D12.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/RenderPassDescriptorD3D12.cpp84
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/RenderPassDescriptorD3D12.h51
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/RenderPipelineD3D12.cpp179
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/RenderPipelineD3D12.h43
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/ResourceAllocator.cpp77
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/ResourceAllocator.h44
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/ResourceUploader.cpp73
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/ResourceUploader.h48
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/SamplerD3D12.cpp96
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/SamplerD3D12.h38
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/ShaderModuleD3D12.cpp65
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/ShaderModuleD3D12.h37
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/SwapChainD3D12.cpp59
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/SwapChainD3D12.h36
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/TextureCopySplitter.cpp209
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/TextureCopySplitter.h64
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/TextureD3D12.cpp253
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/TextureD3D12.h61
-rw-r--r--chromium/third_party/dawn/src/dawn_native/d3d12/d3d12_platform.h34
-rw-r--r--chromium/third_party/dawn/src/dawn_native/dawn_platform.h25
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/BlendStateMTL.h32
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/BlendStateMTL.mm99
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/BufferMTL.h72
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/BufferMTL.mm102
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/CommandBufferMTL.h48
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/CommandBufferMTL.mm530
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/ComputePipelineMTL.h41
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/ComputePipelineMTL.mm57
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/DepthStencilStateMTL.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/DepthStencilStateMTL.mm120
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/DeviceMTL.h98
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/DeviceMTL.mm300
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/Forward.h78
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/InputStateMTL.h37
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/InputStateMTL.mm111
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/PipelineLayoutMTL.h46
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/PipelineLayoutMTL.mm67
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/QueueMTL.h35
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/QueueMTL.mm37
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/RenderPipelineMTL.h42
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/RenderPipelineMTL.mm144
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/ResourceUploader.h42
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/ResourceUploader.mm57
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/SamplerMTL.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/SamplerMTL.mm75
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/ShaderModuleMTL.h55
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/ShaderModuleMTL.mm133
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/SwapChainMTL.h36
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/SwapChainMTL.mm50
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/TextureMTL.h53
-rw-r--r--chromium/third_party/dawn/src/dawn_native/metal/TextureMTL.mm147
-rw-r--r--chromium/third_party/dawn/src/dawn_native/null/NullBackend.cpp229
-rw-r--r--chromium/third_party/dawn/src/dawn_native/null/NullBackend.h186
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/BlendStateGL.cpp96
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/BlendStateGL.h33
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/BufferGL.cpp65
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/BufferGL.h48
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/CommandBufferGL.cpp683
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/CommandBufferGL.h45
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/ComputePipelineGL.cpp33
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/ComputePipelineGL.h37
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/DepthStencilStateGL.cpp116
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/DepthStencilStateGL.h34
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/DeviceGL.cpp126
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/DeviceGL.h74
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/Forward.h78
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/InputStateGL.cpp61
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/InputStateGL.h40
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/PersistentPipelineStateGL.cpp54
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/PersistentPipelineStateGL.h43
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/PipelineGL.cpp220
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/PipelineGL.h57
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/PipelineLayoutGL.cpp80
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/PipelineLayoutGL.h46
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/QueueGL.cpp31
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/QueueGL.h35
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/RenderPipelineGL.cpp73
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/RenderPipelineGL.h44
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/SamplerGL.cpp89
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/SamplerGL.h38
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/ShaderModuleGL.cpp136
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/ShaderModuleGL.h57
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/SwapChainGL.cpp48
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/SwapChainGL.h38
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/TextureGL.cpp173
-rw-r--r--chromium/third_party/dawn/src/dawn_native/opengl/TextureGL.h62
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupLayoutVk.cpp153
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupLayoutVk.h45
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupVk.cpp138
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupVk.h40
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BlendStateVk.cpp110
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BlendStateVk.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BufferUploader.cpp102
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BufferUploader.h43
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BufferVk.cpp269
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/BufferVk.h79
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/CommandBufferVk.cpp423
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/CommandBufferVk.h42
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/ComputePipelineVk.cpp59
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/ComputePipelineVk.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/DepthStencilStateVk.cpp112
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/DepthStencilStateVk.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/DeviceVk.cpp695
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/DeviceVk.h168
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/FencedDeleter.cpp173
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/FencedDeleter.h67
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/Forward.h75
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/InputStateVk.cpp109
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/InputStateVk.h41
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/MemoryAllocator.cpp133
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/MemoryAllocator.h58
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/NativeSwapChainImplVk.cpp209
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/NativeSwapChainImplVk.h69
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/PipelineLayoutVk.cpp70
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/PipelineLayoutVk.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/QueueVk.cpp39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/QueueVk.h36
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassCache.cpp209
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassCache.h81
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassDescriptorVk.cpp122
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassDescriptorVk.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/RenderPipelineVk.cpp229
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/RenderPipelineVk.h40
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/SamplerVk.cpp98
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/SamplerVk.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp57
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/SwapChainVk.cpp59
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/SwapChainVk.h39
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/TextureVk.cpp398
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/TextureVk.h64
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/VulkanFunctions.cpp221
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/VulkanFunctions.h215
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/VulkanInfo.cpp261
-rw-r--r--chromium/third_party/dawn/src/dawn_native/vulkan/VulkanInfo.h88
-rw-r--r--chromium/third_party/dawn/src/dawn_wire/WireCmd.h68
-rw-r--r--chromium/third_party/dawn/src/fuzzers/BUILD.gn173
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossFuzzer.cpp107
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossFuzzer.h44
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp46
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossGLSLFullFuzzer.cpp45
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp53
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossHLSLFullFuzzer.cpp46
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp47
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossMSLFullFuzzer.cpp45
-rw-r--r--chromium/third_party/dawn/src/fuzzers/DawnWireServerAndFrontendFuzzer.cpp57
-rw-r--r--chromium/third_party/dawn/src/fuzzers/StandaloneFuzzerMain.cpp62
-rw-r--r--chromium/third_party/dawn/src/include/dawn/EnumClassBitmasks.h162
-rw-r--r--chromium/third_party/dawn/src/include/dawn/dawn_export.h32
-rw-r--r--chromium/third_party/dawn/src/include/dawn/dawn_wsi.h85
-rw-r--r--chromium/third_party/dawn/src/include/dawn_native/D3D12Backend.h33
-rw-r--r--chromium/third_party/dawn/src/include/dawn_native/DawnNative.h37
-rw-r--r--chromium/third_party/dawn/src/include/dawn_native/MetalBackend.h31
-rw-r--r--chromium/third_party/dawn/src/include/dawn_native/NullBackend.h25
-rw-r--r--chromium/third_party/dawn/src/include/dawn_native/OpenGLBackend.h25
-rw-r--r--chromium/third_party/dawn/src/include/dawn_native/VulkanBackend.h38
-rw-r--r--chromium/third_party/dawn/src/include/dawn_native/dawn_native_export.h32
-rw-r--r--chromium/third_party/dawn/src/include/dawn_wire/Wire.h47
-rw-r--r--chromium/third_party/dawn/src/include/dawn_wire/dawn_wire_export.h32
-rw-r--r--chromium/third_party/dawn/src/utils/BackendBinding.cpp73
-rw-r--r--chromium/third_party/dawn/src/utils/BackendBinding.h53
-rw-r--r--chromium/third_party/dawn/src/utils/D3D12Binding.cpp60
-rw-r--r--chromium/third_party/dawn/src/utils/DawnHelpers.cpp227
-rw-r--r--chromium/third_party/dawn/src/utils/DawnHelpers.h68
-rw-r--r--chromium/third_party/dawn/src/utils/MetalBinding.mm133
-rw-r--r--chromium/third_party/dawn/src/utils/NullBinding.cpp40
-rw-r--r--chromium/third_party/dawn/src/utils/OpenGLBinding.cpp139
-rw-r--r--chromium/third_party/dawn/src/utils/SystemUtils.cpp39
-rw-r--r--chromium/third_party/dawn/src/utils/SystemUtils.h18
-rw-r--r--chromium/third_party/dawn/src/utils/TerribleCommandBuffer.cpp60
-rw-r--r--chromium/third_party/dawn/src/utils/TerribleCommandBuffer.h42
-rw-r--r--chromium/third_party/dawn/src/utils/VulkanBinding.cpp92
-rw-r--r--chromium/third_party/dawn/third_party/BUILD.gn361
-rw-r--r--chromium/third_party/dawn/third_party/CMakeLists.txt151
-rw-r--r--chromium/third_party/dawn/third_party/glad/include/KHR/khrplatform.h282
-rw-r--r--chromium/third_party/dawn/third_party/glad/include/glad/glad.h3691
-rw-r--r--chromium/third_party/dawn/third_party/glad/src/glad.c1814
-rw-r--r--chromium/third_party/dawn/third_party/picojson/picojson.h1040
-rw-r--r--chromium/third_party/dawn/third_party/tinygltfloader/tiny_gltf_loader.h2656
-rw-r--r--chromium/third_party/dawn/third_party/vulkan/vk_platform.h120
-rw-r--r--chromium/third_party/dawn/third_party/vulkan/vulkan.h6937
358 files changed, 55885 insertions, 0 deletions
diff --git a/chromium/third_party/dawn/.clang-format b/chromium/third_party/dawn/.clang-format
new file mode 100644
index 00000000000..bc75cdc9d7c
--- /dev/null
+++ b/chromium/third_party/dawn/.clang-format
@@ -0,0 +1,20 @@
+BasedOnStyle: Chromium
+Standard: Cpp11
+
+AllowShortFunctionsOnASingleLine: false
+
+ColumnLimit: 100
+
+# Use 4 space indents
+IndentWidth: 4
+ObjCBlockIndentWidth: 4
+AccessModifierOffset: -2
+
+# Nested namespaces are C++17, fake them by compacting namespaces for now.
+CompactNamespaces: true
+
+# This should result in only one indentation level with compacted namespaces
+NamespaceIndentation: All
+
+# Use this option once clang-format 6 is out.
+IndentPPDirectives: AfterHash
diff --git a/chromium/third_party/dawn/.gn b/chromium/third_party/dawn/.gn
new file mode 100644
index 00000000000..038d50ee8ee
--- /dev/null
+++ b/chromium/third_party/dawn/.gn
@@ -0,0 +1,27 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+buildconfig = "//build/config/BUILDCONFIG.gn"
+
+default_args = {
+ clang_use_chrome_plugins = false
+}
+
+check_targets = [
+ # Everything in BUILD.gn
+ "//:*",
+
+ # Everything in third_party/BUILD.gn
+ "//third_party/:*",
+]
diff --git a/chromium/third_party/dawn/AUTHORS b/chromium/third_party/dawn/AUTHORS
new file mode 100644
index 00000000000..32a6c3cec68
--- /dev/null
+++ b/chromium/third_party/dawn/AUTHORS
@@ -0,0 +1,6 @@
+# This is the list of Dawn authors for copyright purposes.
+#
+# This does not necessarily list everyone who has contributed code, since in
+# some cases, their employer may be the copyright holder. To see the full list
+# of contributors, see the revision history in source control.
+Google Inc.
diff --git a/chromium/third_party/dawn/BUILD.gn b/chromium/third_party/dawn/BUILD.gn
new file mode 100644
index 00000000000..1a4922ff975
--- /dev/null
+++ b/chromium/third_party/dawn/BUILD.gn
@@ -0,0 +1,1004 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("scripts/dawn_overrides_with_defaults.gni")
+import("scripts/dawn_features.gni")
+import("//build_overrides/build.gni")
+
+import("//testing/test.gni")
+
+###############################################################################
+# Template to wrap the Dawn code generator
+###############################################################################
+
+# Template to help with invocation of the Dawn code generator, looks like this:
+#
+# dawn_generator("my_target_gen") {
+# # Which generator target to output
+# target = "my_target"
+# # The list of expected outputs, generation fails if there's a mismatch
+# outputs = [
+# "MyTarget.cpp",
+# "MyTarget.h",
+# ]
+# }
+#
+# Using the generated files is done like so:
+#
+# shared_library("my_target") {
+# deps = [ ":my_target_gen "]
+# sources = get_target_outputs(":my_target_gen")
+# }
+#
+template("dawn_generator") {
+ # The base arguments for the generator: from this dawn.json, generate this
+ # target using templates in this directory.
+ generator_args = [
+ rebase_path("dawn.json", root_build_dir),
+ "--template-dir",
+ rebase_path("generator/templates", root_build_dir),
+ "--targets",
+ invoker.target,
+ ]
+
+ # Use the Jinja2 version pulled from the DEPS file. We do it so we don't
+ # have version problems, and users don't have to install Jinja2.
+ jinja2_python_path = rebase_path("${dawn_jinja2_dir}/..")
+ generator_args += [
+ "--extra-python-path",
+ jinja2_python_path,
+ ]
+
+ # For build parallelism GN wants to know the exact inputs and outputs of
+ # action targets like we use for our code generator. We avoid asking the
+ # generator about its inputs by using the "depfile" feature of GN/Ninja.
+ #
+ # A ninja limitation is that the depfile is a subset of Makefile that can
+ # contain a single target, so we output a single "JSON-tarball" instead.
+ json_tarball = "${target_gen_dir}/${target_name}.json_tarball"
+ json_tarball_depfile = "${json_tarball}.d"
+
+ generator_args += [
+ "--output-json-tarball",
+ rebase_path(json_tarball, root_build_dir),
+ "--depfile",
+ rebase_path(json_tarball_depfile, root_build_dir),
+ ]
+
+ # After the JSON tarball is created we need an action target to extract it
+ # with a list of its outputs. The invoker provided a list of expected
+ # outputs. To make sure the list is in sync between the generator and the
+ # build files, we write it to a file and ask the generator to assert it is
+ # correct.
+ expected_outputs_file = "${target_gen_dir}/${target_name}.expected_outputs"
+ write_file(expected_outputs_file, invoker.outputs)
+
+ generator_args += [
+ "--expected-outputs-file",
+ rebase_path(expected_outputs_file, root_build_dir),
+ ]
+
+ # The code generator invocation that will write the JSON tarball, check the
+ # outputs are what's expected and write a depfile for Ninja.
+ action("${target_name}_json_tarball") {
+ script = "generator/main.py"
+ outputs = [
+ json_tarball,
+ ]
+ depfile = json_tarball_depfile
+ args = generator_args
+ }
+
+ # Extract the JSON tarball into the target_gen_dir
+ action("${target_name}") {
+ script = "generator/extract_json.py"
+ args = [
+ rebase_path(json_tarball, root_build_dir),
+ rebase_path(target_gen_dir, root_build_dir),
+ ]
+
+ deps = [
+ ":${target_name}_json_tarball",
+ ]
+ inputs = [
+ json_tarball,
+ ]
+
+ # The expected output list is relative to the target_gen_dir but action
+ # target outputs are from the root dir so we need to rebase them.
+ outputs = []
+ foreach(source, invoker.outputs) {
+ outputs += [ "${target_gen_dir}/${source}" ]
+ }
+ }
+}
+
+###############################################################################
+# Common dawn libraries and configs
+###############################################################################
+
+config("libdawn_public") {
+ include_dirs = [
+ target_gen_dir,
+ "src/include",
+ ]
+}
+
+# Executable needs an rpath to find our shared libraries on OSX and Linux
+config("dawn_shared_library_public") {
+ if (is_mac) {
+ ldflags = [
+ "-rpath",
+ "@executable_path/",
+ ]
+ }
+
+ if (is_linux) {
+ configs = [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
+ }
+}
+
+config("dawn_internal") {
+ include_dirs = [ "src" ]
+
+ defines = []
+ if (dawn_always_assert || is_debug) {
+ defines += [ "DAWN_ENABLE_ASSERTS" ]
+ }
+
+ if (dawn_enable_d3d12) {
+ defines += [ "DAWN_ENABLE_BACKEND_D3D12" ]
+ }
+ if (dawn_enable_metal) {
+ defines += [ "DAWN_ENABLE_BACKEND_METAL" ]
+ }
+ if (dawn_enable_null) {
+ defines += [ "DAWN_ENABLE_BACKEND_NULL" ]
+ }
+ if (dawn_enable_opengl) {
+ defines += [ "DAWN_ENABLE_BACKEND_OPENGL" ]
+ }
+ if (dawn_enable_vulkan) {
+ defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ]
+ }
+
+ configs = [
+ ":libdawn_public",
+ ":dawn_shared_library_public",
+ ]
+
+ # Only internal Dawn targets can use this config, this means only targets in
+ # this BUILD.gn file.
+ visibility = [ ":*" ]
+}
+
+static_library("dawn_common") {
+ sources = [
+ "src/common/Assert.cpp",
+ "src/common/Assert.h",
+ "src/common/BitSetIterator.h",
+ "src/common/Compiler.h",
+ "src/common/DynamicLib.cpp",
+ "src/common/DynamicLib.h",
+ "src/common/HashUtils.h",
+ "src/common/Math.cpp",
+ "src/common/Math.h",
+ "src/common/Platform.h",
+ "src/common/Result.h",
+ "src/common/Serial.h",
+ "src/common/SerialMap.h",
+ "src/common/SerialQueue.h",
+ "src/common/SerialStorage.h",
+ "src/common/SwapChainUtils.h",
+ "src/common/vulkan_platform.h",
+ "src/common/windows_with_undefs.h",
+ ]
+
+ configs += [ ":dawn_internal" ]
+ deps = [
+ ":dawn_headers",
+ ]
+}
+
+###############################################################################
+# Dawn headers and libdawn.so
+###############################################################################
+
+dawn_generator("dawn_headers_gen") {
+ target = "dawn_headers"
+ outputs = [
+ "dawn/dawncpp.h",
+ "dawn/dawn.h",
+ "dawn/dawncpp_traits.h",
+ ]
+}
+
+source_set("dawn_headers") {
+ public_configs = [ ":libdawn_public" ]
+ deps = [
+ ":dawn_headers_gen",
+ ]
+
+ sources = get_target_outputs(":dawn_headers_gen")
+ sources += [
+ "src/include/dawn/EnumClassBitmasks.h",
+ "src/include/dawn/dawn_export.h",
+ "src/include/dawn/dawn_wsi.h",
+ ]
+}
+
+dawn_generator("libdawn_gen") {
+ target = "libdawn"
+ outputs = [
+ "dawn/dawncpp.cpp",
+ "dawn/dawn.c",
+ ]
+}
+
+config("libdawn_export") {
+ defines = [ "DAWN_IMPLEMENTATION" ]
+}
+
+source_set("libdawn_sources") {
+ public_deps = [
+ ":dawn_headers",
+ ]
+
+ deps = [
+ ":libdawn_gen",
+ ]
+ sources = get_target_outputs(":libdawn_gen")
+
+ # Put the export config public so that dependents use the same declspec.
+ public_configs = [ ":libdawn_export" ]
+}
+
+shared_library("libdawn") {
+ public_deps = [
+ ":dawn_headers",
+ ]
+
+ deps = [
+ ":libdawn_sources",
+ ]
+
+ # Tell dependents where to find this shared library
+ if (is_mac) {
+ ldflags = [
+ "-install_name",
+ "@rpath/${target_name}.dylib",
+ ]
+ }
+}
+
+###############################################################################
+# libdawn_native.so
+###############################################################################
+
+config("libdawn_native_internal") {
+ configs = [ ":dawn_internal" ]
+
+ # Suppress warnings that Metal isn't in the deployment target of Chrome
+ if (is_mac) {
+ cflags_objcc = [ "-Wno-unguarded-availability" ]
+ }
+}
+
+config("libdawn_native_export") {
+ defines = [ "DAWN_NATIVE_IMPLEMENTATION" ]
+}
+
+dawn_generator("libdawn_native_utils_gen") {
+ target = "dawn_native_utils"
+ outputs = [
+ "dawn_native/ProcTable.cpp",
+ "dawn_native/dawn_structs_autogen.h",
+ "dawn_native/dawn_structs_autogen.cpp",
+ "dawn_native/ValidationUtils_autogen.h",
+ "dawn_native/ValidationUtils_autogen.cpp",
+ ]
+}
+
+# Public libdawn_native headers so they can be publically visible for
+# dependencies of libdawn_native
+source_set("libdawn_native_headers") {
+ public_deps = [
+ ":dawn_headers",
+ ]
+ sources = [
+ "src/include/dawn_native/DawnNative.h",
+ "src/include/dawn_native/dawn_native_export.h",
+
+ # Include all backend's public headers so that dependencies can include
+ # them even when the backends are disabled.
+ "src/include/dawn_native/D3D12Backend.h",
+ "src/include/dawn_native/MetalBackend.h",
+ "src/include/dawn_native/NullBackend.h",
+ "src/include/dawn_native/OpenGLBackend.h",
+ "src/include/dawn_native/VulkanBackend.h",
+ ]
+}
+
+# The meat of the compilation for libdawn_native so that we can cheaply have
+# shared_library / static_library / component versions of it.
+source_set("libdawn_native_sources") {
+ deps = [
+ ":dawn_common",
+ ":libdawn_native_utils_gen",
+ "${dawn_spirv_tools_dir}:spvtools_val",
+ "third_party:spirv_cross",
+ ]
+ public_deps = [
+ ":libdawn_native_headers",
+ ]
+
+ # Put the export config public so that dependents use the same declspec.
+ public_configs = [ ":libdawn_native_export" ]
+
+ configs += [ ":libdawn_native_internal" ]
+ libs = []
+
+ sources = get_target_outputs(":libdawn_native_utils_gen")
+ sources += [
+ "src/dawn_native/BindGroup.cpp",
+ "src/dawn_native/BindGroup.h",
+ "src/dawn_native/BindGroupLayout.cpp",
+ "src/dawn_native/BindGroupLayout.h",
+ "src/dawn_native/BlendState.cpp",
+ "src/dawn_native/BlendState.h",
+ "src/dawn_native/Buffer.cpp",
+ "src/dawn_native/Buffer.h",
+ "src/dawn_native/Builder.cpp",
+ "src/dawn_native/Builder.h",
+ "src/dawn_native/CommandAllocator.cpp",
+ "src/dawn_native/CommandAllocator.h",
+ "src/dawn_native/CommandBuffer.cpp",
+ "src/dawn_native/CommandBuffer.h",
+ "src/dawn_native/CommandBufferStateTracker.cpp",
+ "src/dawn_native/CommandBufferStateTracker.h",
+ "src/dawn_native/Commands.cpp",
+ "src/dawn_native/Commands.h",
+ "src/dawn_native/ComputePassEncoder.cpp",
+ "src/dawn_native/ComputePassEncoder.h",
+ "src/dawn_native/ComputePipeline.cpp",
+ "src/dawn_native/ComputePipeline.h",
+ "src/dawn_native/DawnNative.cpp",
+ "src/dawn_native/DepthStencilState.cpp",
+ "src/dawn_native/DepthStencilState.h",
+ "src/dawn_native/Device.cpp",
+ "src/dawn_native/Device.h",
+ "src/dawn_native/Error.cpp",
+ "src/dawn_native/Error.h",
+ "src/dawn_native/ErrorData.cpp",
+ "src/dawn_native/ErrorData.h",
+ "src/dawn_native/Forward.h",
+ "src/dawn_native/InputState.cpp",
+ "src/dawn_native/InputState.h",
+ "src/dawn_native/ObjectBase.cpp",
+ "src/dawn_native/ObjectBase.h",
+ "src/dawn_native/PassResourceUsage.h",
+ "src/dawn_native/PerStage.cpp",
+ "src/dawn_native/PerStage.h",
+ "src/dawn_native/Pipeline.cpp",
+ "src/dawn_native/Pipeline.h",
+ "src/dawn_native/PipelineLayout.cpp",
+ "src/dawn_native/PipelineLayout.h",
+ "src/dawn_native/ProgrammablePassEncoder.cpp",
+ "src/dawn_native/ProgrammablePassEncoder.h",
+ "src/dawn_native/Queue.cpp",
+ "src/dawn_native/Queue.h",
+ "src/dawn_native/RefCounted.cpp",
+ "src/dawn_native/RefCounted.h",
+ "src/dawn_native/RenderPassDescriptor.cpp",
+ "src/dawn_native/RenderPassDescriptor.h",
+ "src/dawn_native/RenderPassEncoder.cpp",
+ "src/dawn_native/RenderPassEncoder.h",
+ "src/dawn_native/RenderPipeline.cpp",
+ "src/dawn_native/RenderPipeline.h",
+ "src/dawn_native/Sampler.cpp",
+ "src/dawn_native/Sampler.h",
+ "src/dawn_native/ShaderModule.cpp",
+ "src/dawn_native/ShaderModule.h",
+ "src/dawn_native/SwapChain.cpp",
+ "src/dawn_native/SwapChain.h",
+ "src/dawn_native/Texture.cpp",
+ "src/dawn_native/Texture.h",
+ "src/dawn_native/ToBackend.h",
+ "src/dawn_native/dawn_platform.h",
+ ]
+
+ if (dawn_enable_d3d12) {
+ libs += [ "dxguid.lib" ]
+ sources += [
+ "src/dawn_native/d3d12/BindGroupD3D12.cpp",
+ "src/dawn_native/d3d12/BindGroupD3D12.h",
+ "src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp",
+ "src/dawn_native/d3d12/BindGroupLayoutD3D12.h",
+ "src/dawn_native/d3d12/BlendStateD3D12.cpp",
+ "src/dawn_native/d3d12/BlendStateD3D12.h",
+ "src/dawn_native/d3d12/BufferD3D12.cpp",
+ "src/dawn_native/d3d12/BufferD3D12.h",
+ "src/dawn_native/d3d12/CommandAllocatorManager.cpp",
+ "src/dawn_native/d3d12/CommandAllocatorManager.h",
+ "src/dawn_native/d3d12/CommandBufferD3D12.cpp",
+ "src/dawn_native/d3d12/CommandBufferD3D12.h",
+ "src/dawn_native/d3d12/ComputePipelineD3D12.cpp",
+ "src/dawn_native/d3d12/ComputePipelineD3D12.h",
+ "src/dawn_native/d3d12/DepthStencilStateD3D12.cpp",
+ "src/dawn_native/d3d12/DepthStencilStateD3D12.h",
+ "src/dawn_native/d3d12/DescriptorHeapAllocator.cpp",
+ "src/dawn_native/d3d12/DescriptorHeapAllocator.h",
+ "src/dawn_native/d3d12/DeviceD3D12.cpp",
+ "src/dawn_native/d3d12/DeviceD3D12.h",
+ "src/dawn_native/d3d12/Forward.h",
+ "src/dawn_native/d3d12/InputStateD3D12.cpp",
+ "src/dawn_native/d3d12/InputStateD3D12.h",
+ "src/dawn_native/d3d12/NativeSwapChainImplD3D12.cpp",
+ "src/dawn_native/d3d12/NativeSwapChainImplD3D12.h",
+ "src/dawn_native/d3d12/PipelineLayoutD3D12.cpp",
+ "src/dawn_native/d3d12/PipelineLayoutD3D12.h",
+ "src/dawn_native/d3d12/PlatformFunctions.cpp",
+ "src/dawn_native/d3d12/PlatformFunctions.h",
+ "src/dawn_native/d3d12/QueueD3D12.cpp",
+ "src/dawn_native/d3d12/QueueD3D12.h",
+ "src/dawn_native/d3d12/RenderPassDescriptorD3D12.cpp",
+ "src/dawn_native/d3d12/RenderPassDescriptorD3D12.h",
+ "src/dawn_native/d3d12/RenderPipelineD3D12.cpp",
+ "src/dawn_native/d3d12/RenderPipelineD3D12.h",
+ "src/dawn_native/d3d12/ResourceAllocator.cpp",
+ "src/dawn_native/d3d12/ResourceAllocator.h",
+ "src/dawn_native/d3d12/ResourceUploader.cpp",
+ "src/dawn_native/d3d12/ResourceUploader.h",
+ "src/dawn_native/d3d12/SamplerD3D12.cpp",
+ "src/dawn_native/d3d12/SamplerD3D12.h",
+ "src/dawn_native/d3d12/ShaderModuleD3D12.cpp",
+ "src/dawn_native/d3d12/ShaderModuleD3D12.h",
+ "src/dawn_native/d3d12/SwapChainD3D12.cpp",
+ "src/dawn_native/d3d12/SwapChainD3D12.h",
+ "src/dawn_native/d3d12/TextureCopySplitter.cpp",
+ "src/dawn_native/d3d12/TextureCopySplitter.h",
+ "src/dawn_native/d3d12/TextureD3D12.cpp",
+ "src/dawn_native/d3d12/TextureD3D12.h",
+ "src/dawn_native/d3d12/d3d12_platform.h",
+ ]
+ }
+
+ if (dawn_enable_metal) {
+ libs += [
+ "Metal.framework",
+ "Cocoa.framework",
+ "IOKit.framework",
+ ]
+ sources += [
+ "src/dawn_native/metal/BlendStateMTL.h",
+ "src/dawn_native/metal/BlendStateMTL.mm",
+ "src/dawn_native/metal/BufferMTL.h",
+ "src/dawn_native/metal/BufferMTL.mm",
+ "src/dawn_native/metal/CommandBufferMTL.h",
+ "src/dawn_native/metal/CommandBufferMTL.mm",
+ "src/dawn_native/metal/ComputePipelineMTL.h",
+ "src/dawn_native/metal/ComputePipelineMTL.mm",
+ "src/dawn_native/metal/DepthStencilStateMTL.h",
+ "src/dawn_native/metal/DepthStencilStateMTL.mm",
+ "src/dawn_native/metal/DeviceMTL.h",
+ "src/dawn_native/metal/DeviceMTL.mm",
+ "src/dawn_native/metal/Forward.h",
+ "src/dawn_native/metal/InputStateMTL.h",
+ "src/dawn_native/metal/InputStateMTL.mm",
+ "src/dawn_native/metal/PipelineLayoutMTL.h",
+ "src/dawn_native/metal/PipelineLayoutMTL.mm",
+ "src/dawn_native/metal/QueueMTL.h",
+ "src/dawn_native/metal/QueueMTL.mm",
+ "src/dawn_native/metal/RenderPipelineMTL.h",
+ "src/dawn_native/metal/RenderPipelineMTL.mm",
+ "src/dawn_native/metal/ResourceUploader.h",
+ "src/dawn_native/metal/ResourceUploader.mm",
+ "src/dawn_native/metal/SamplerMTL.h",
+ "src/dawn_native/metal/SamplerMTL.mm",
+ "src/dawn_native/metal/ShaderModuleMTL.h",
+ "src/dawn_native/metal/ShaderModuleMTL.mm",
+ "src/dawn_native/metal/SwapChainMTL.h",
+ "src/dawn_native/metal/SwapChainMTL.mm",
+ "src/dawn_native/metal/TextureMTL.h",
+ "src/dawn_native/metal/TextureMTL.mm",
+ ]
+ }
+
+ if (dawn_enable_null) {
+ sources += [
+ "src/dawn_native/null/NullBackend.cpp",
+ "src/dawn_native/null/NullBackend.h",
+ ]
+ }
+
+ if (dawn_enable_opengl) {
+ deps += [ "third_party:glad" ]
+ sources += [
+ "src/dawn_native/opengl/BlendStateGL.cpp",
+ "src/dawn_native/opengl/BlendStateGL.h",
+ "src/dawn_native/opengl/BufferGL.cpp",
+ "src/dawn_native/opengl/BufferGL.h",
+ "src/dawn_native/opengl/CommandBufferGL.cpp",
+ "src/dawn_native/opengl/CommandBufferGL.h",
+ "src/dawn_native/opengl/ComputePipelineGL.cpp",
+ "src/dawn_native/opengl/ComputePipelineGL.h",
+ "src/dawn_native/opengl/DepthStencilStateGL.cpp",
+ "src/dawn_native/opengl/DepthStencilStateGL.h",
+ "src/dawn_native/opengl/DeviceGL.cpp",
+ "src/dawn_native/opengl/DeviceGL.h",
+ "src/dawn_native/opengl/Forward.h",
+ "src/dawn_native/opengl/InputStateGL.cpp",
+ "src/dawn_native/opengl/InputStateGL.h",
+ "src/dawn_native/opengl/PersistentPipelineStateGL.cpp",
+ "src/dawn_native/opengl/PersistentPipelineStateGL.h",
+ "src/dawn_native/opengl/PipelineGL.cpp",
+ "src/dawn_native/opengl/PipelineGL.h",
+ "src/dawn_native/opengl/PipelineLayoutGL.cpp",
+ "src/dawn_native/opengl/PipelineLayoutGL.h",
+ "src/dawn_native/opengl/QueueGL.cpp",
+ "src/dawn_native/opengl/QueueGL.h",
+ "src/dawn_native/opengl/RenderPipelineGL.cpp",
+ "src/dawn_native/opengl/RenderPipelineGL.h",
+ "src/dawn_native/opengl/SamplerGL.cpp",
+ "src/dawn_native/opengl/SamplerGL.h",
+ "src/dawn_native/opengl/ShaderModuleGL.cpp",
+ "src/dawn_native/opengl/ShaderModuleGL.h",
+ "src/dawn_native/opengl/SwapChainGL.cpp",
+ "src/dawn_native/opengl/SwapChainGL.h",
+ "src/dawn_native/opengl/TextureGL.cpp",
+ "src/dawn_native/opengl/TextureGL.h",
+ ]
+ }
+
+ if (dawn_enable_vulkan) {
+ deps += [ "third_party:vulkan_headers" ]
+ sources += [
+ "src/dawn_native/vulkan/BindGroupLayoutVk.cpp",
+ "src/dawn_native/vulkan/BindGroupLayoutVk.h",
+ "src/dawn_native/vulkan/BindGroupVk.cpp",
+ "src/dawn_native/vulkan/BindGroupVk.h",
+ "src/dawn_native/vulkan/BlendStateVk.cpp",
+ "src/dawn_native/vulkan/BlendStateVk.h",
+ "src/dawn_native/vulkan/BufferUploader.cpp",
+ "src/dawn_native/vulkan/BufferUploader.h",
+ "src/dawn_native/vulkan/BufferVk.cpp",
+ "src/dawn_native/vulkan/BufferVk.h",
+ "src/dawn_native/vulkan/CommandBufferVk.cpp",
+ "src/dawn_native/vulkan/CommandBufferVk.h",
+ "src/dawn_native/vulkan/ComputePipelineVk.cpp",
+ "src/dawn_native/vulkan/ComputePipelineVk.h",
+ "src/dawn_native/vulkan/DepthStencilStateVk.cpp",
+ "src/dawn_native/vulkan/DepthStencilStateVk.h",
+ "src/dawn_native/vulkan/DeviceVk.cpp",
+ "src/dawn_native/vulkan/DeviceVk.h",
+ "src/dawn_native/vulkan/FencedDeleter.cpp",
+ "src/dawn_native/vulkan/FencedDeleter.h",
+ "src/dawn_native/vulkan/Forward.h",
+ "src/dawn_native/vulkan/InputStateVk.cpp",
+ "src/dawn_native/vulkan/InputStateVk.h",
+ "src/dawn_native/vulkan/MemoryAllocator.cpp",
+ "src/dawn_native/vulkan/MemoryAllocator.h",
+ "src/dawn_native/vulkan/NativeSwapChainImplVk.cpp",
+ "src/dawn_native/vulkan/NativeSwapChainImplVk.h",
+ "src/dawn_native/vulkan/PipelineLayoutVk.cpp",
+ "src/dawn_native/vulkan/PipelineLayoutVk.h",
+ "src/dawn_native/vulkan/QueueVk.cpp",
+ "src/dawn_native/vulkan/QueueVk.h",
+ "src/dawn_native/vulkan/RenderPassCache.cpp",
+ "src/dawn_native/vulkan/RenderPassCache.h",
+ "src/dawn_native/vulkan/RenderPassDescriptorVk.cpp",
+ "src/dawn_native/vulkan/RenderPassDescriptorVk.h",
+ "src/dawn_native/vulkan/RenderPipelineVk.cpp",
+ "src/dawn_native/vulkan/RenderPipelineVk.h",
+ "src/dawn_native/vulkan/SamplerVk.cpp",
+ "src/dawn_native/vulkan/SamplerVk.h",
+ "src/dawn_native/vulkan/ShaderModuleVk.cpp",
+ "src/dawn_native/vulkan/ShaderModuleVk.h",
+ "src/dawn_native/vulkan/SwapChainVk.cpp",
+ "src/dawn_native/vulkan/SwapChainVk.h",
+ "src/dawn_native/vulkan/TextureVk.cpp",
+ "src/dawn_native/vulkan/TextureVk.h",
+ "src/dawn_native/vulkan/VulkanFunctions.cpp",
+ "src/dawn_native/vulkan/VulkanFunctions.h",
+ "src/dawn_native/vulkan/VulkanInfo.cpp",
+ "src/dawn_native/vulkan/VulkanInfo.h",
+ ]
+ }
+}
+
+# The shared library for libdawn_native for use by samples, tests, etc.
+shared_library("libdawn_native") {
+ deps = [
+ ":libdawn_native_sources",
+ ]
+
+ #Make headers publically visible
+ public_deps = [
+ ":libdawn_native_headers",
+ ]
+ public_configs = [ ":libdawn_public" ]
+
+ # Tell dependents where to find this shared library
+ if (is_mac) {
+ ldflags = [
+ "-install_name",
+ "@rpath/${target_name}.dylib",
+ ]
+ }
+}
+
+###############################################################################
+# libdawn_wire.so
+###############################################################################
+
+# Public libdawn_wire headers so they can be publically visible for
+# dependencies of libdawn_wire
+source_set("libdawn_wire_headers") {
+ public_deps = [
+ ":dawn_headers",
+ ]
+ sources = [
+ "src/include/dawn_wire/Wire.h",
+ "src/include/dawn_wire/dawn_wire_export.h",
+ ]
+}
+
+config("libdawn_wire_export") {
+ defines = [ "DAWN_WIRE_IMPLEMENTATION" ]
+}
+
+dawn_generator("libdawn_wire_gen") {
+ target = "dawn_wire"
+ outputs = [
+ "dawn_wire/WireServer.cpp",
+ "dawn_wire/WireCmd_autogen.h",
+ "dawn_wire/WireClient.cpp",
+ "dawn_wire/WireCmd_autogen.cpp",
+ ]
+}
+
+source_set("libdawn_wire_sources") {
+ deps = [
+ ":dawn_common",
+ ":libdawn_wire_gen",
+ ":libdawn_wire_headers",
+ ]
+
+ configs += [ ":dawn_internal" ]
+ sources = get_target_outputs(":libdawn_wire_gen")
+ sources += [ "src/dawn_wire/WireCmd.h" ]
+
+ # Make headers publically visible
+ public_deps = [
+ ":libdawn_wire_headers",
+ ]
+ public_configs = [ ":libdawn_public" ]
+
+ # Put the export config public so that dependents use the same declspec.
+ public_configs += [ ":libdawn_wire_export" ]
+}
+
+shared_library("libdawn_wire") {
+ deps = [
+ ":libdawn_wire_sources",
+ ]
+
+ # Make headers publically visible
+ public_deps = [
+ ":libdawn_wire_headers",
+ ]
+ public_configs = [ ":libdawn_public" ]
+
+ # Tell dependents where to find this shared library
+ if (is_mac) {
+ ldflags = [
+ "-install_name",
+ "@rpath/${target_name}.dylib",
+ ]
+ }
+}
+
+###############################################################################
+# Utils for tests and samples
+###############################################################################
+
+static_library("dawn_utils") {
+ configs += [ ":dawn_internal" ]
+
+ sources = [
+ "src/utils/BackendBinding.cpp",
+ "src/utils/BackendBinding.h",
+ "src/utils/DawnHelpers.cpp",
+ "src/utils/DawnHelpers.h",
+ "src/utils/SystemUtils.cpp",
+ "src/utils/SystemUtils.h",
+ "src/utils/TerribleCommandBuffer.cpp",
+ "src/utils/TerribleCommandBuffer.h",
+ ]
+ deps = [
+ ":dawn_common",
+ ":libdawn_native",
+ ":libdawn_wire",
+ "${dawn_shaderc_dir}:libshaderc",
+ "third_party:glfw",
+ ]
+ libs = []
+
+ if (dawn_enable_d3d12) {
+ sources += [ "src/utils/D3D12Binding.cpp" ]
+ }
+
+ if (dawn_enable_metal) {
+ sources += [ "src/utils/MetalBinding.mm" ]
+ libs += [
+ "Metal.framework",
+ "QuartzCore.framework",
+ ]
+
+ # Suppress warnings that Metal isn't in the deployment target of Chrome
+ if (is_mac) {
+ cflags_objcc = [ "-Wno-unguarded-availability" ]
+ }
+ }
+
+ if (dawn_enable_null) {
+ sources += [ "src/utils/NullBinding.cpp" ]
+ }
+
+ if (dawn_enable_opengl) {
+ sources += [ "src/utils/OpenGLBinding.cpp" ]
+ deps += [ "third_party:glad" ]
+ }
+
+ if (dawn_enable_vulkan) {
+ sources += [ "src/utils/VulkanBinding.cpp" ]
+ deps += [ "third_party:vulkan_headers" ]
+ }
+}
+
+###############################################################################
+# Dawn test targets
+###############################################################################
+
+dawn_generator("mock_dawn_gen") {
+ target = "mock_dawn"
+ outputs = [
+ "mock/mock_dawn.h",
+ "mock/mock_dawn.cpp",
+ ]
+}
+
+test("dawn_unittests") {
+ configs += [ ":dawn_internal" ]
+
+ deps = [
+ ":dawn_common",
+ ":dawn_headers",
+ ":dawn_utils",
+ ":libdawn",
+ ":libdawn_native_sources",
+ ":libdawn_wire",
+ ":mock_dawn_gen",
+ "third_party:gmock_and_gtest",
+ ]
+
+ # Add internal Dawn Native headers and config for internal unittests.
+ deps += [ ":libdawn_native_headers" ]
+ configs += [ ":libdawn_native_internal" ]
+
+ sources = get_target_outputs(":mock_dawn_gen")
+ sources += [
+ "src/tests/unittests/BitSetIteratorTests.cpp",
+ "src/tests/unittests/CommandAllocatorTests.cpp",
+ "src/tests/unittests/EnumClassBitmasksTests.cpp",
+ "src/tests/unittests/ErrorTests.cpp",
+ "src/tests/unittests/MathTests.cpp",
+ "src/tests/unittests/ObjectBaseTests.cpp",
+ "src/tests/unittests/PerStageTests.cpp",
+ "src/tests/unittests/RefCountedTests.cpp",
+ "src/tests/unittests/ResultTests.cpp",
+ "src/tests/unittests/SerialMapTests.cpp",
+ "src/tests/unittests/SerialQueueTests.cpp",
+ "src/tests/unittests/ToBackendTests.cpp",
+ "src/tests/unittests/WireTests.cpp",
+ "src/tests/unittests/validation/BindGroupValidationTests.cpp",
+ "src/tests/unittests/validation/BlendStateValidationTests.cpp",
+ "src/tests/unittests/validation/BufferValidationTests.cpp",
+ "src/tests/unittests/validation/CommandBufferValidationTests.cpp",
+ "src/tests/unittests/validation/ComputeValidationTests.cpp",
+ "src/tests/unittests/validation/CopyCommandsValidationTests.cpp",
+ "src/tests/unittests/validation/DepthStencilStateValidationTests.cpp",
+ "src/tests/unittests/validation/DynamicStateCommandValidationTests.cpp",
+ "src/tests/unittests/validation/InputStateValidationTests.cpp",
+ "src/tests/unittests/validation/PushConstantsValidationTests.cpp",
+ "src/tests/unittests/validation/QueueSubmitValidationTests.cpp",
+ "src/tests/unittests/validation/RenderPassDescriptorValidationTests.cpp",
+ "src/tests/unittests/validation/RenderPipelineValidationTests.cpp",
+ "src/tests/unittests/validation/ShaderModuleValidationTests.cpp",
+ "src/tests/unittests/validation/TextureViewValidationTests.cpp",
+ "src/tests/unittests/validation/ValidationTest.cpp",
+ "src/tests/unittests/validation/ValidationTest.h",
+ "src/tests/unittests/validation/VertexBufferValidationTests.cpp",
+ ]
+
+ if (dawn_enable_d3d12) {
+ sources += [ "src/tests/unittests/d3d12/CopySplitTests.cpp" ]
+ }
+
+ # When building inside Chromium, use their gtest main function because it is
+ # needed to run in swarming correctly.
+ if (build_with_chromium) {
+ sources += [ "//gpu/dawn_unittests_main.cc" ]
+ } else {
+ sources += [ "src/tests/UnittestsMain.cpp" ]
+ }
+}
+
+test("dawn_end2end_tests") {
+ configs += [ ":dawn_internal" ]
+
+ deps = [
+ ":dawn_common",
+ ":dawn_utils",
+ ":libdawn",
+ ":libdawn_native",
+ ":libdawn_wire",
+ "third_party:glfw",
+ "third_party:gmock_and_gtest",
+ ]
+
+ sources = [
+ "src/tests/DawnTest.cpp",
+ "src/tests/DawnTest.h",
+ "src/tests/end2end/BasicTests.cpp",
+ "src/tests/end2end/BindGroupTests.cpp",
+ "src/tests/end2end/BlendStateTests.cpp",
+ "src/tests/end2end/BufferTests.cpp",
+ "src/tests/end2end/ComputeCopyStorageBufferTests.cpp",
+ "src/tests/end2end/CopyTests.cpp",
+ "src/tests/end2end/DepthStencilStateTests.cpp",
+ "src/tests/end2end/DrawElementsTests.cpp",
+ "src/tests/end2end/IndexFormatTests.cpp",
+ "src/tests/end2end/InputStateTests.cpp",
+ "src/tests/end2end/PrimitiveTopologyTests.cpp",
+ "src/tests/end2end/PushConstantTests.cpp",
+ "src/tests/end2end/RenderPassLoadOpTests.cpp",
+ "src/tests/end2end/SamplerTests.cpp",
+ "src/tests/end2end/ScissorTests.cpp",
+ "src/tests/end2end/TextureViewTests.cpp",
+ "src/tests/end2end/ViewportOrientationTests.cpp",
+ ]
+
+ # When building inside Chromium, use their gtest main function because it is
+ # needed to run in swarming correctly.
+ if (build_with_chromium) {
+ sources += [ "//gpu/dawn_end2end_tests_main.cc" ]
+ } else {
+ sources += [ "src/tests/End2EndTestsMain.cpp" ]
+ }
+}
+
+###############################################################################
+# Dawn samples, only in standalone builds
+###############################################################################
+
+if (dawn_standalone) {
+ # Static library to contain code and dependencies common to all samples
+ static_library("dawn_sample_utils") {
+ sources = [
+ "examples/SampleUtils.cpp",
+ "examples/SampleUtils.h",
+ ]
+
+ # Export all of these as public deps so that `gn check` allows includes
+ public_deps = [
+ ":dawn_common",
+ ":dawn_utils",
+ ":libdawn",
+ ":libdawn_native",
+ ":libdawn_wire",
+ "third_party:glfw",
+ ]
+ public_configs = [ ":dawn_internal" ]
+ }
+
+ # Template for samples to avoid listing dawn_sample_utils as a dep every time
+ template("dawn_sample") {
+ executable(target_name) {
+ deps = [
+ ":dawn_sample_utils",
+ ]
+ forward_variables_from(invoker, "*", [ "deps" ])
+
+ if (defined(invoker.deps)) {
+ deps += invoker.deps
+ }
+ }
+ }
+
+ dawn_sample("CppHelloTriangle") {
+ sources = [
+ "examples/CppHelloTriangle.cpp",
+ ]
+ }
+
+ dawn_sample("CHelloTriangle") {
+ sources = [
+ "examples/CHelloTriangle.cpp",
+ ]
+ }
+
+ dawn_sample("ComputeBoids") {
+ sources = [
+ "examples/ComputeBoids.cpp",
+ ]
+ deps = [
+ "third_party:glm",
+ ]
+ }
+
+ dawn_sample("Animometer") {
+ sources = [
+ "examples/Animometer.cpp",
+ ]
+ }
+
+ dawn_sample("CubeReflection") {
+ sources = [
+ "examples/CubeReflection.cpp",
+ ]
+ deps = [
+ "third_party:glm",
+ ]
+ }
+
+ dawn_sample("glTFViewer") {
+ sources = [
+ "examples/glTFViewer/Camera.inl",
+ "examples/glTFViewer/glTFViewer.cpp",
+ ]
+ deps = [
+ "third_party:glm",
+ "third_party:tiny_gltf_loader",
+ ]
+ }
+
+ group("dawn_samples") {
+ deps = [
+ ":Animometer",
+ ":CHelloTriangle",
+ ":ComputeBoids",
+ ":CppHelloTriangle",
+ ":CubeReflection",
+ ":glTFViewer",
+ ]
+ }
+}
+
+###############################################################################
+# Fuzzers
+###############################################################################
+
+group("dawn_fuzzers") {
+ testonly = true
+ deps = [
+ "src/fuzzers:dawn_spirv_cross_glsl_fast_fuzzer",
+ "src/fuzzers:dawn_spirv_cross_glsl_full_fuzzer",
+ "src/fuzzers:dawn_spirv_cross_hlsl_fast_fuzzer",
+ "src/fuzzers:dawn_spirv_cross_hlsl_full_fuzzer",
+ "src/fuzzers:dawn_spirv_cross_msl_fast_fuzzer",
+ "src/fuzzers:dawn_spirv_cross_msl_full_fuzzer",
+ "src/fuzzers:dawn_wire_server_and_frontend_fuzzer",
+ ]
+}
diff --git a/chromium/third_party/dawn/CONTRIBUTING.md b/chromium/third_party/dawn/CONTRIBUTING.md
new file mode 100644
index 00000000000..c500c152805
--- /dev/null
+++ b/chromium/third_party/dawn/CONTRIBUTING.md
@@ -0,0 +1,21 @@
+# How to contribute
+
+We'd love to accept your patches and contributions to this project. There are
+just a few small guidelines you need to follow.
+
+## Contributor License Agreement
+
+Contributions to this project must be accompanied by a Contributor License
+Agreement. You (or your employer) retain the copyright to your contribution,
+this simply gives us permission to use and redistribute your contributions as
+part of the project. Head over to <https://cla.developers.google.com/> to see
+your current agreements on file or to sign a new one.
+
+You generally only need to submit a CLA once, so if you've already submitted one
+(even if it was for a different project), you probably don't need to do it
+again.
+
+## Code reviews
+
+All submissions, including submissions by project members, require review. We
+use [Dawn's Gerrit](https://dawn-review.googlesource.com) for this purpose.
diff --git a/chromium/third_party/dawn/DEPS b/chromium/third_party/dawn/DEPS
new file mode 100644
index 00000000000..69deb4a26f6
--- /dev/null
+++ b/chromium/third_party/dawn/DEPS
@@ -0,0 +1,238 @@
+use_relative_paths = True
+use_relative_hooks = True
+
+vars = {
+ 'chromium_git': 'https://chromium.googlesource.com',
+ 'dawn_git': 'https://dawn.googlesource.com',
+ 'github_git': 'https://github.com',
+
+ 'dawn_standalone': True,
+}
+
+deps = {
+ # Dependencies required to use GN/Clang in standalone
+ 'build': {
+ 'url': '{chromium_git}/chromium/src/build@2fb6537bf59c9c9a736997b8bd888ca0ecf54322',
+ 'condition': 'dawn_standalone',
+ },
+ 'buildtools': {
+ 'url': '{chromium_git}/chromium/buildtools@24ebce4578745db15274e180da1938ebc1358243',
+ 'condition': 'dawn_standalone',
+ },
+ 'tools/clang': {
+ 'url': '{chromium_git}/chromium/src/tools/clang@1d879cee563167a2b18baffb096cf9e29f2f9376',
+ 'condition': 'dawn_standalone',
+ },
+ 'third_party/binutils': {
+ 'url': '{chromium_git}/chromium/src/third_party/binutils@2be73f7fbf783d7a0b288e174a5773b67c7656bc',
+ 'condition': 'dawn_standalone',
+ },
+
+ # Testing, GTest and GMock
+ 'testing': {
+ 'url': '{chromium_git}/chromium/src/testing@b07830f6905ce9e33034ad14820bc0a58b6e9e41',
+ 'condition': 'dawn_standalone',
+ },
+ 'third_party/googletest': {
+ 'url': '{chromium_git}/external/github.com/google/googletest@98a0d007d7092b72eea0e501bb9ad17908a1a036',
+ 'condition': 'dawn_standalone',
+ },
+
+ # Jinja2 and MarkupSafe for the code generator
+ 'third_party/jinja2': {
+ 'url': '{chromium_git}/chromium/src/third_party/jinja2@b41863e42637544c2941b574c7877d3e1f663e25',
+ 'condition': 'dawn_standalone',
+ },
+ 'third_party/markupsafe': {
+ 'url': '{chromium_git}/chromium/src/third_party/markupsafe@8f45f5cfa0009d2a70589bcda0349b8cb2b72783',
+ 'condition': 'dawn_standalone',
+ },
+
+ # SPIRV-Cross
+ 'third_party/spirv-cross': {
+ 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Cross@a7697446b12666da353bb2bdafa792d988fb268c',
+ 'condition': 'dawn_standalone',
+ },
+
+ # SPIRV compiler dependencies: SPIRV-Tools, SPIRV-headers, glslang and shaderc
+ 'third_party/SPIRV-Tools': {
+ 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Tools@dab634da93d39763bc5b526de9d25104a3bd3b65',
+ 'condition': 'dawn_standalone',
+ },
+ 'third_party/spirv-headers': {
+ 'url': '{chromium_git}/external/github.com/KhronosGroup/SPIRV-Headers@7cb43009d543e90698dd300eb26dfd6d9a9bb100',
+ 'condition': 'dawn_standalone',
+ },
+ 'third_party/glslang': {
+ 'url': '{chromium_git}/external/github.com/KhronosGroup/glslang@0ac199df32687fe17b38cd2d0da64c3742e24fef',
+ 'condition': 'dawn_standalone',
+ },
+ 'third_party/shaderc': {
+ 'url': '{chromium_git}/external/github.com/google/shaderc@909f0d3d31e7e7c8f39b40ba0e1dd7f99b749776',
+ 'condition': 'dawn_standalone',
+ },
+
+ # GLFW for tests and samples
+ 'third_party/glfw': {
+ 'url': '{chromium_git}/external/github.com/glfw/glfw@2de2589f910b1a85905f425be4d32f33cec092df',
+ 'condition': 'dawn_standalone',
+ },
+
+ # Dependencies for samples: stb and GLM
+ 'third_party/stb': {
+ 'url': '{github_git}/nothings/stb.git@c7110588a4d24c4bb5155c184fbb77dd90b3116e',
+ 'condition': 'dawn_standalone',
+ },
+ 'third_party/glm': {
+ 'url': '{github_git}/g-truc/glm.git@06f084063fd6d9aa2ef6904517650700ae47b63d',
+ 'condition': 'dawn_standalone',
+ },
+
+ # Our own pre-compiled Linux clang-format 7.0 for presubmit
+ 'third_party/clang-format': {
+ 'url': '{dawn_git}/clang-format@2451c56cd368676cdb230fd5ad11731ab859f1a3',
+ 'condition': 'dawn_standalone and checkout_linux',
+ },
+}
+
+hooks = [
+ # Pull clang-format binaries using checked-in hashes.
+ {
+ 'name': 'clang_format_win',
+ 'pattern': '.',
+ 'condition': 'host_os == "win" and dawn_standalone',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=win32',
+ '--no_auth',
+ '--bucket', 'chromium-clang-format',
+ '-s', 'buildtools/win/clang-format.exe.sha1',
+ ],
+ },
+ {
+ 'name': 'clang_format_mac',
+ 'pattern': '.',
+ 'condition': 'host_os == "mac" and dawn_standalone',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=darwin',
+ '--no_auth',
+ '--bucket', 'chromium-clang-format',
+ '-s', 'buildtools/mac/clang-format.sha1',
+ ],
+ },
+ {
+ 'name': 'clang_format_linux',
+ 'pattern': '.',
+ 'condition': 'host_os == "linux" and dawn_standalone',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=linux*',
+ '--no_auth',
+ '--bucket', 'chromium-clang-format',
+ '-s', 'buildtools/linux64/clang-format.sha1',
+ ],
+ },
+
+ # Pull GN binaries using checked-in hashes.
+ {
+ 'name': 'gn_win',
+ 'pattern': '.',
+ 'condition': 'host_os == "win" and dawn_standalone',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=win32',
+ '--no_auth',
+ '--bucket', 'chromium-gn',
+ '-s', 'buildtools/win/gn.exe.sha1',
+ ],
+ },
+ {
+ 'name': 'gn_mac',
+ 'pattern': '.',
+ 'condition': 'host_os == "mac" and dawn_standalone',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=darwin',
+ '--no_auth',
+ '--bucket', 'chromium-gn',
+ '-s', 'buildtools/mac/gn.sha1',
+ ],
+ },
+ {
+ 'name': 'gn_linux64',
+ 'pattern': '.',
+ 'condition': 'host_os == "linux" and dawn_standalone',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--platform=linux*',
+ '--no_auth',
+ '--bucket', 'chromium-gn',
+ '-s', 'buildtools/linux64/gn.sha1',
+ ],
+ },
+
+ # Pull the compilers and system libraries for hermetic builds
+ {
+ 'name': 'sysroot_x86',
+ 'pattern': '.',
+ 'condition': 'checkout_linux and ((checkout_x86 or checkout_x64) and dawn_standalone)',
+ 'action': ['python', 'build/linux/sysroot_scripts/install-sysroot.py',
+ '--arch=x86'],
+ },
+ {
+ 'name': 'sysroot_x64',
+ 'pattern': '.',
+ 'condition': 'checkout_linux and (checkout_x64 and dawn_standalone)',
+ 'action': ['python', 'build/linux/sysroot_scripts/install-sysroot.py',
+ '--arch=x64'],
+ },
+ {
+ # Update the Windows toolchain if necessary. Must run before 'clang' below.
+ 'name': 'win_toolchain',
+ 'pattern': '.',
+ 'condition': 'checkout_win and dawn_standalone',
+ 'action': ['python', 'build/vs_toolchain.py', 'update', '--force'],
+ },
+ {
+ # Note: On Win, this should run after win_toolchain, as it may use it.
+ 'name': 'clang',
+ 'pattern': '.',
+ 'action': ['python', 'tools/clang/scripts/update.py'],
+ 'condition': 'dawn_standalone',
+ },
+ {
+ # Pull rc binaries using checked-in hashes.
+ 'name': 'rc_win',
+ 'pattern': '.',
+ 'condition': 'checkout_win and (host_os == "win" and dawn_standalone)',
+ 'action': [ 'download_from_google_storage',
+ '--no_resume',
+ '--no_auth',
+ '--bucket', 'chromium-browser-clang/rc',
+ '-s', 'build/toolchain/win/rc/win/rc.exe.sha1',
+ ],
+ },
+ # Pull binutils for linux hermetic builds
+ {
+ 'name': 'binutils',
+ 'pattern': 'src/third_party/binutils',
+ 'condition': 'host_os == "linux"',
+ 'action': [
+ 'python',
+ 'third_party/binutils/download.py',
+ ],
+ },
+ # Update build/util/LASTCHANGE.
+ {
+ 'name': 'lastchange',
+ 'pattern': '.',
+ 'action': ['python', 'build/util/lastchange.py',
+ '-o', 'build/util/LASTCHANGE'],
+ },
+]
+
+recursedeps = [
+ # buildtools provides clang_format, libc++, and libc++abi
+ 'buildtools',
+]
diff --git a/chromium/third_party/dawn/LICENSE b/chromium/third_party/dawn/LICENSE
new file mode 100644
index 00000000000..3afb763d207
--- /dev/null
+++ b/chromium/third_party/dawn/LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/chromium/third_party/dawn/OWNERS b/chromium/third_party/dawn/OWNERS
new file mode 100644
index 00000000000..06bf5663c5d
--- /dev/null
+++ b/chromium/third_party/dawn/OWNERS
@@ -0,0 +1,4 @@
+cwallez@chromium.org
+kainino@chromium.org
+
+# COMPONENT: Internals>GPU>Dawn
diff --git a/chromium/third_party/dawn/PRESUBMIT.py b/chromium/third_party/dawn/PRESUBMIT.py
new file mode 100644
index 00000000000..ae10063e7d5
--- /dev/null
+++ b/chromium/third_party/dawn/PRESUBMIT.py
@@ -0,0 +1,69 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+import platform
+import subprocess
+
+def _DoClangFormat(input_api, output_api):
+ # Our binary clang-format is a linux binary compiled for x64
+ if platform.system() != 'Linux' or platform.architecture()[0] != '64bit':
+ return [output_api.PresubmitNotifyResult('Skipping clang-format')]
+
+ # We need to know which commit to diff against. It doesn't seem to be exposed anywhere
+ # except in that private member of presubmit_support.Change. This is likely to break
+ # but hopefully we have an updated clang-format in CPID/GS before it does.
+ upstream_commit = input_api.change._upstream
+ if upstream_commit == None:
+ return []
+
+ lint_cmd = [
+ 'scripts/lint_clang_format.sh',
+ 'third_party/clang-format/clang-format',
+ upstream_commit
+ ]
+
+ # Make clang-format use our linux x64 sysroot because it is compiled with a version of
+ # stdlibc++ that's incompatible with the old libraries present on the bots.
+ env = {
+ 'LD_LIBRARY_PATH': os.path.join(
+ os.getcwd(),
+ 'build',
+ 'linux',
+ 'debian_sid_amd64-sysroot',
+ 'usr',
+ 'lib',
+ 'x86_64-linux-gnu'
+ )
+ }
+
+ # Call the linting script and forward the output as a notification or as an error
+ try:
+ output = subprocess.check_output(lint_cmd, env=env);
+ return [output_api.PresubmitNotifyResult(output)]
+ except subprocess.CalledProcessError as e:
+ return [output_api.PresubmitError(e.output)]
+
+def _DoCommonChecks(input_api, output_api):
+ results = []
+ results.extend(input_api.canned_checks.CheckChangedLUCIConfigs(input_api, output_api))
+ results.extend(input_api.canned_checks.CheckGNFormatted(input_api, output_api))
+ results.extend(_DoClangFormat(input_api, output_api))
+ return results
+
+def CheckChangeOnUpload(input_api, output_api):
+ return _DoCommonChecks(input_api, output_api)
+
+def CheckChangeOnCommit(input_api, output_api):
+ return _DoCommonChecks(input_api, output_api)
diff --git a/chromium/third_party/dawn/README.chromium b/chromium/third_party/dawn/README.chromium
new file mode 100644
index 00000000000..e14cc8b843e
--- /dev/null
+++ b/chromium/third_party/dawn/README.chromium
@@ -0,0 +1,12 @@
+Name: Dawn
+Short Name: dawn
+URL: https://dawn.googlesource.com/dawn
+License: Apache 2.0
+License File: LICENSE
+Security Critical: yes
+
+Description:
+Dawn is an implementation of the WebGPU standard exposed through a C/C++
+interface. It provides implementations on top of native graphics APIs like
+D3D12, Metal and Vulkan, as well as a client-server implementation to remote
+WebGPU outside sandboxed context like Chromium's render processes.
diff --git a/chromium/third_party/dawn/README.md b/chromium/third_party/dawn/README.md
new file mode 100644
index 00000000000..e9def8c4dd9
--- /dev/null
+++ b/chromium/third_party/dawn/README.md
@@ -0,0 +1,78 @@
+# Dawn, a WebGPU implementation
+
+Dawn (formerly NXT) is an open-source and cross-platform implementation of the work-in-progress WebGPU standard.
+It exposes a C/C++ API that maps almost one-to-one to the WebGPU IDL and can be managed as part of a larger system such as a Web browser.
+
+Dawn provides several WebGPU building blocks:
+ - **WebGPU C/C++ headers** that applications and other building blocks use.
+ - **A "native" implementation of WebGPU** using platforms' GPU APIs:
+ - **D3D12** on Windows 10
+ - **Metal** on OSX (and eventually iOS)
+ - **Vulkan** on Windows, Linux (eventually ChromeOS and Android too)
+ - OpenGL as best effort where available
+ - **A client-server implementation of WebGPU** for applications that are in a sandbox without access to native drivers
+
+## Directory structure
+
+- `dawn.json`: description of the API used to drive code generators.
+- `examples`: examples showing how Dawn is used.
+- `generator`: code generator for files produces from `dawn.json`
+ - `templates`: Jinja2 templates for the generator
+- `scripts`: scripts to support things like continuous testing, build files, etc.
+- `src`:
+ - `common`: helper code shared between core Dawn libraries and tests/samples
+ - `dawn_native`: native implementation of WebGPU, one subfolder per backend
+ - `dawn_wire`: client-server implementation of WebGPU
+ - `include`: public headers for Dawn
+ - `tests`: internal Dawn tests
+ - `end2end`: WebGPU tests performing GPU operations
+ - `unittests`: unittests and by extension tests not using the GPU
+ - `validation`: WebGPU validation tests not using the GPU (frontend tests)
+ - `utils`: helper code to use Dawn used by tests and samples
+- `third_party`: directory where dependencies live as well as their buildfiles.
+
+## Building Dawn
+
+Dawn uses the Chromium build system and dependency management so you need to [install depot_tools] and add it to the PATH.
+
+[install depot_tools]: http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
+
+On Linux you need to have the `pkg-config` command:
+```sh
+# Install pkg-config on Ubuntu
+sudo apt-get install pkg-config
+```
+
+Then get the source as follows:
+
+```sh
+# Clone the repo as "dawn"
+git clone https://dawn.googlesource.com/dawn dawn && cd dawn
+
+# Bootstrap the gclient configuration
+cp scripts/standalone.gclient .gclient
+
+# Fetch external dependencies and toolchains with gclient
+gclient sync
+```
+
+Then generate build files using `gn args out/Debug` or `gn args out/Release`.
+A text editor will appear asking build options, the most common option is `is_debug=true/false`; otherwise `gn args out/Release --list` shows all the possible options.
+
+Then use `ninja -C out/Release` to build dawn and for example `./out/Release/dawn_end2end_tests` to run the tests.
+
+## Contributing
+
+Please read and follow [CONTRIBUTING.md](/CONTRIBUTING.md).
+Dawn doesn't have a formal coding style yet, except what's defined by our clang format style.
+Overall try to use the same style and convention as code around your change.
+
+If you find issues with Dawn, please feel free to report them on the [bug tracker](https://bugs.chromium.org/p/dawn/issues/entry).
+
+## License
+
+Please see [LICENSE](/LICENSE).
+
+## Disclaimer
+
+This is not an officially supported Google product.
diff --git a/chromium/third_party/dawn/build_overrides/build.gni b/chromium/third_party/dawn/build_overrides/build.gni
new file mode 100644
index 00000000000..1acd4a16562
--- /dev/null
+++ b/chromium/third_party/dawn/build_overrides/build.gni
@@ -0,0 +1,27 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Tell Dawn and dependencies to not do Chromium-specific things
+build_with_chromium = false
+
+# Use Chromium's binutils to have "hermetic" builds on bots
+linux_use_bundled_binutils_override = true
+
+# In standalone Dawn builds, don't try to use the hermetic install of Xcode
+# that Chromium uses
+use_system_xcode = true
+
+# Android 32-bit non-component, non-clang builds cannot have symbol_level=2
+# due to 4GiB file size limit, see https://crbug.com/648948.
+ignore_elf32_limitations = false
diff --git a/chromium/third_party/dawn/build_overrides/dawn.gni b/chromium/third_party/dawn/build_overrides/dawn.gni
new file mode 100644
index 00000000000..4e186b202c0
--- /dev/null
+++ b/chromium/third_party/dawn/build_overrides/dawn.gni
@@ -0,0 +1,32 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# These are variables that are overridable by projects that include Dawn.
+# The values in this file are the defaults for when we are building from
+# Dawn's repository.
+
+# Whether we are building from Dawn's repository.
+# MUST be unset in other projects (will default to false).
+dawn_standalone = true
+
+# Defaults for these are set again in dawn_overrides_with_defaults.gni so that
+# users of Dawn don't have to set dirs if they happen to use the same as Dawn.
+
+# The paths to Dawn's dependencies
+dawn_jinja2_dir = "//third_party/jinja2"
+dawn_glfw_dir = "//third_party/glfw"
+dawn_googletest_dir = "//third_party/googletest"
+dawn_shaderc_dir = "//third_party/shaderc"
+dawn_spirv_tools_dir = "//third_party/SPIRV-Tools"
+dawn_spirv_cross_dir = "//third_party/spirv-cross"
diff --git a/chromium/third_party/dawn/build_overrides/glslang.gni b/chromium/third_party/dawn/build_overrides/glslang.gni
new file mode 100644
index 00000000000..c1b60e0c4db
--- /dev/null
+++ b/chromium/third_party/dawn/build_overrides/glslang.gni
@@ -0,0 +1,15 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+glslang_spirv_tools_dir = "//third_party/SPIRV-Tools"
diff --git a/chromium/third_party/dawn/build_overrides/shaderc.gni b/chromium/third_party/dawn/build_overrides/shaderc.gni
new file mode 100644
index 00000000000..df437e2abed
--- /dev/null
+++ b/chromium/third_party/dawn/build_overrides/shaderc.gni
@@ -0,0 +1,16 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+shaderc_glslang_dir = "//third_party/glslang"
+shaderc_spirv_tools_dir = "//third_party/SPIRV-Tools"
diff --git a/chromium/third_party/dawn/build_overrides/spirv_tools.gni b/chromium/third_party/dawn/build_overrides/spirv_tools.gni
new file mode 100644
index 00000000000..7e4559f259f
--- /dev/null
+++ b/chromium/third_party/dawn/build_overrides/spirv_tools.gni
@@ -0,0 +1,20 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# We are building inside Dawn
+spirv_tools_standalone = false
+
+# Paths to SPIRV-Tools dependencies in Dawn
+spirv_tools_googletest_dir = "//third_party/googletest"
+spirv_tools_spirv_headers_dir = "//third_party/spirv-headers"
diff --git a/chromium/third_party/dawn/codereview.settings b/chromium/third_party/dawn/codereview.settings
new file mode 100644
index 00000000000..3894052c3ab
--- /dev/null
+++ b/chromium/third_party/dawn/codereview.settings
@@ -0,0 +1,3 @@
+# This file is used by git cl to get repository specific information.
+GERRIT_HOST: True
+CODE_REVIEW_SERVER: https://dawn-review.googlesource.com
diff --git a/chromium/third_party/dawn/dawn.json b/chromium/third_party/dawn/dawn.json
new file mode 100644
index 00000000000..0437b814506
--- /dev/null
+++ b/chromium/third_party/dawn/dawn.json
@@ -0,0 +1,1158 @@
+{
+ "_comment": [
+ "Copyright 2017 The Dawn Authors",
+ "",
+ "Licensed under the Apache License, Version 2.0 (the \"License\");",
+ "you may not use this file except in compliance with the License.",
+ "You may obtain a copy of the License at",
+ "",
+ " http://www.apache.org/licenses/LICENSE-2.0",
+ "",
+ "Unless required by applicable law or agreed to in writing, software",
+ "distributed under the License is distributed on an \"AS IS\" BASIS,",
+ "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.",
+ "See the License for the specific language governing permissions and",
+ "limitations under the License."
+ ],
+ "address mode": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name":"repeat"},
+ {"value": 1, "name":"mirrored repeat"},
+ {"value": 2, "name":"clamp to edge"}
+ ]
+ },
+ "bind group": {
+ "category": "object"
+ },
+ "bind group builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "bind group"
+ },
+ {
+ "name": "set layout",
+ "args": [
+ {"name": "layout", "type": "bind group layout"}
+ ]
+ },
+ {
+ "name": "set buffer views",
+ "args": [
+ {"name": "start", "type": "uint32_t"},
+ {"name": "count", "type": "uint32_t"},
+ {"name": "buffer views", "type": "buffer view", "annotation": "const*", "length": "count"}
+ ]
+ },
+ {
+ "name": "set samplers",
+ "args": [
+ {"name": "start", "type": "uint32_t"},
+ {"name": "count", "type": "uint32_t"},
+ {"name": "samplers", "type": "sampler", "annotation": "const*", "length": "count"}
+ ]
+ },
+ {
+ "name": "set texture views",
+ "args": [
+ {"name": "start", "type": "uint32_t"},
+ {"name": "count", "type": "uint32_t"},
+ {"name": "texture views", "type": "texture view", "annotation": "const*", "length": "count"}
+ ]
+ }
+ ],
+ "TODO": [
+ "When resource are added, add methods for setting the content of the bind group"
+ ]
+ },
+ "bind group layout": {
+ "category": "object"
+ },
+ "bind group binding": {
+ "category": "structure",
+ "extensible": false,
+ "members": [
+ {"name": "binding", "type": "uint32_t"},
+ {"name": "visibility", "type": "shader stage bit"},
+ {"name": "type", "type": "binding type"}
+ ]
+ },
+ "bind group layout descriptor": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "num bindings", "type": "uint32_t"},
+ {"name": "bindings", "type": "bind group binding", "annotation": "const*", "length": "num bindings"}
+ ]
+ },
+ "binding type": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "uniform buffer"},
+ {"value": 1, "name": "sampler"},
+ {"value": 2, "name": "sampled texture"},
+ {"value": 3, "name": "storage buffer"}
+ ]
+ },
+ "blend descriptor": {
+ "category": "structure",
+ "extensible": false,
+ "members": [
+ {"name": "operation", "type": "blend operation"},
+ {"name": "src factor", "type": "blend factor"},
+ {"name": "dst factor", "type": "blend factor"}
+ ]
+ },
+ "blend factor": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "zero"},
+ {"value": 1, "name": "one"},
+ {"value": 2, "name": "src color"},
+ {"value": 3, "name": "one minus src color"},
+ {"value": 4, "name": "src alpha"},
+ {"value": 5, "name": "one minus src alpha"},
+ {"value": 6, "name": "dst color"},
+ {"value": 7, "name": "one minus dst color"},
+ {"value": 8, "name": "dst alpha"},
+ {"value": 9, "name": "one minus dst alpha"},
+ {"value": 10, "name": "src alpha saturated"},
+ {"value": 11, "name": "blend color"},
+ {"value": 12, "name": "one minus blend color"}
+ ]
+ },
+ "blend operation": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "add"},
+ {"value": 1, "name": "subtract"},
+ {"value": 2, "name": "reverse subtract"},
+ {"value": 3, "name": "min"},
+ {"value": 4, "name": "max"}
+ ]
+ },
+ "blend state": {
+ "category": "object"
+ },
+ "blend state builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "blend state"
+ },
+ {
+ "name": "set blend enabled",
+ "args": [
+ {"name": "blend enabled", "type": "bool"}
+ ]
+ },
+ {
+ "name": "set alpha blend",
+ "args": [
+ {"name": "alpha blend", "type": "blend descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "set color blend",
+ "args": [
+ {"name": "color blend", "type": "blend descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "set color write mask",
+ "args": [
+ {"name": "color write mask", "type": "color write mask"}
+ ]
+ }
+ ]
+ },
+ "bool": {
+ "category": "native"
+ },
+ "builder error status": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "success"},
+ {"value": 1, "name": "error", "TODO": "cwallez@chromium.org: recoverable errors like GPU OOM"},
+ {"value": 2, "name": "unknown"},
+ {"value": 3, "name": "context lost"}
+ ]
+ },
+ "builder error callback": {
+ "category": "natively defined"
+ },
+ "buffer": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "create buffer view builder",
+ "returns": "buffer view builder"
+ },
+ {
+ "name": "set sub data",
+ "args": [
+ {"name": "start", "type": "uint32_t"},
+ {"name": "count", "type": "uint32_t"},
+ {"name": "data", "type": "uint8_t", "annotation": "const*", "length": "count"}
+ ]
+ },
+ {
+ "_comment": "Contrary to set sub data, this is in char size",
+ "name": "map read async",
+ "args": [
+ {"name": "start", "type": "uint32_t"},
+ {"name": "size", "type": "uint32_t"},
+ {"name": "callback", "type": "buffer map read callback"},
+ {"name": "userdata", "type": "callback userdata"}
+ ]
+ },
+ {
+ "_comment": "Contrary to set sub data, this is in char size",
+ "name": "map write async",
+ "args": [
+ {"name": "start", "type": "uint32_t"},
+ {"name": "size", "type": "uint32_t"},
+ {"name": "callback", "type": "buffer map write callback"},
+ {"name": "userdata", "type": "callback userdata"}
+ ]
+ },
+ {
+ "name": "unmap"
+ }
+ ]
+ },
+ "buffer builder": {
+ "_comment": "This builder is kept for testing only",
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "buffer"
+ },
+ {
+ "name": "set size",
+ "args": [
+ {"name": "size", "type": "uint32_t"}
+ ]
+ }
+ ]
+ },
+ "buffer copy view": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "buffer", "type": "buffer"},
+ {"name": "offset", "type": "uint32_t"},
+ {"name": "row pitch", "type": "uint32_t"},
+ {"name": "image height", "type": "uint32_t"}
+ ]
+ },
+ "buffer descriptor": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "usage", "type": "buffer usage bit"},
+ {"name": "size", "type": "uint32_t"}
+ ]
+ },
+ "buffer map read callback": {
+ "category": "natively defined"
+ },
+ "buffer map write callback": {
+ "category": "natively defined"
+ },
+ "buffer map async status": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "success"},
+ {"value": 1, "name": "error"},
+ {"value": 2, "name": "unknown"},
+ {"value": 3, "name": "context lost"}
+ ]
+ },
+ "buffer usage bit": {
+ "category": "bitmask",
+ "values": [
+ {"value": 0, "name": "none"},
+ {"value": 1, "name": "map read"},
+ {"value": 2, "name": "map write"},
+ {"value": 4, "name": "transfer src"},
+ {"value": 8, "name": "transfer dst"},
+ {"value": 16, "name": "index"},
+ {"value": 32, "name": "vertex"},
+ {"value": 64, "name": "uniform"},
+ {"value": 128, "name": "storage"}
+ ]
+ },
+ "buffer view": {
+ "category": "object"
+ },
+ "buffer view builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "buffer view"
+ },
+ {
+ "name": "set extent",
+ "args": [
+ {"name": "offset", "type": "uint32_t"},
+ {"name": "size", "type": "uint32_t"}
+ ]
+ }
+ ]
+ },
+ "callback userdata": {
+ "category": "natively defined"
+ },
+ "char": {
+ "category": "native"
+ },
+ "color write mask": {
+ "category": "bitmask",
+ "values": [
+ {"value": 0, "name": "none"},
+ {"value": 1, "name": "red"},
+ {"value": 2, "name": "green"},
+ {"value": 4, "name": "blue"},
+ {"value": 8, "name": "alpha"},
+ {"value": 15, "name": "all"}
+ ]
+ },
+ "command buffer": {
+ "category": "object"
+ },
+ "command buffer builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "command buffer"
+ },
+ {
+ "name": "begin compute pass",
+ "returns": "compute pass encoder"
+ },
+ {
+ "name": "begin render pass",
+ "args": [
+ {"name": "info", "type": "render pass descriptor"}
+ ],
+ "returns": "render pass encoder"
+ },
+ {
+ "name": "copy buffer to buffer",
+ "args": [
+ {"name": "source", "type": "buffer"},
+ {"name": "source offset", "type": "uint32_t"},
+ {"name": "destination", "type": "buffer"},
+ {"name": "destination offset", "type": "uint32_t"},
+ {"name": "size", "type": "uint32_t"}
+ ],
+ "TODO": [
+ "Restrictions on the alignment of the copy? Cf Metal on OSX"
+ ]
+ },
+ {
+ "name": "copy buffer to texture",
+ "args": [
+ {"name": "source", "type": "buffer copy view", "annotation": "const*"},
+ {"name": "destination", "type": "texture copy view", "annotation": "const*"},
+ {"name": "copy size", "type": "extent 3D", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "copy texture to buffer",
+ "args": [
+ {"name": "source", "type": "texture copy view", "annotation": "const*"},
+ {"name": "destination", "type": "buffer copy view", "annotation": "const*"},
+ {"name": "copy size", "type": "extent 3D", "annotation": "const*"}
+ ]
+ }
+ ]
+ },
+ "compare function": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "never"},
+ {"value": 1, "name": "less"},
+ {"value": 2, "name": "less equal"},
+ {"value": 3, "name": "greater"},
+ {"value": 4, "name": "greater equal"},
+ {"value": 5, "name": "equal"},
+ {"value": 6, "name": "not equal"},
+ {"value": 7, "name": "always"}
+ ]
+ },
+ "compute pass encoder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "set compute pipeline",
+ "TODO": "This is called setPipeline in the WebGPU IDL",
+ "args": [
+ {"name": "pipeline", "type": "compute pipeline"}
+ ]
+ },
+ {
+ "name": "set push constants",
+ "TODO": [
+ "data should be void*",
+ "TODO Vulkan has an additional stage mask"
+ ],
+ "args": [
+ {"name": "stages", "type": "shader stage bit"},
+ {"name": "offset", "type": "uint32_t"},
+ {"name": "count", "type": "uint32_t"},
+ {"name": "data", "type": "uint32_t", "annotation": "const*", "length": "count"}
+ ]
+ },
+ {
+ "name": "set bind group",
+ "args": [
+ {"name": "group index", "type": "uint32_t"},
+ {"name": "group", "type": "bind group"}
+ ]
+ },
+ {
+ "name": "dispatch",
+ "args": [
+ {"name": "x", "type": "uint32_t"},
+ {"name": "y", "type": "uint32_t"},
+ {"name": "z", "type": "uint32_t"}
+ ]
+ },
+ {
+ "name": "end pass",
+ "TODO": "This returns the top-level encoder in the WebGPU IDL"
+ }
+ ]
+ },
+ "compute pipeline": {
+ "category": "object"
+ },
+ "compute pipeline descriptor": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "layout", "type": "pipeline layout"},
+ {"name": "module", "type": "shader module"},
+ {"name": "entry point", "type": "char", "annotation": "const*", "length": "strlen"}
+ ]
+ },
+ "device": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "create bind group builder",
+ "returns": "bind group builder"
+ },
+ {
+ "name": "create bind group layout",
+ "returns": "bind group layout",
+ "args": [
+ {"name": "descriptor", "type": "bind group layout descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "create blend state builder",
+ "returns": "blend state builder"
+ },
+ {
+ "name": "create buffer",
+ "returns": "buffer",
+ "args": [
+ {"name": "descriptor", "type": "buffer descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "create buffer builder for testing",
+ "returns": "buffer builder"
+ },
+ {
+ "name": "create command buffer builder",
+ "returns": "command buffer builder"
+ },
+ {
+ "name": "create depth stencil state builder",
+ "returns": "depth stencil state builder"
+ },
+ {
+ "name": "create render pass descriptor builder",
+ "returns": "render pass descriptor builder"
+ },
+ {
+ "name": "create input state builder",
+ "returns": "input state builder"
+ },
+ {
+ "name": "create compute pipeline",
+ "returns": "compute pipeline",
+ "args": [
+ {"name": "descriptor", "type": "compute pipeline descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "create render pipeline builder",
+ "returns": "render pipeline builder"
+ },
+ {
+ "name": "create pipeline layout",
+ "returns": "pipeline layout",
+ "args": [
+ {"name": "descriptor", "type": "pipeline layout descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "create queue",
+ "returns": "queue"
+ },
+ {
+ "name": "create sampler",
+ "returns": "sampler",
+ "args": [
+ {"name": "descriptor", "type": "sampler descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "create shader module",
+ "returns": "shader module",
+ "args": [
+ {"name": "descriptor", "type": "shader module descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "create swap chain builder",
+ "returns": "swap chain builder"
+ },
+ {
+ "name": "create texture",
+ "returns": "texture",
+ "args": [
+ {"name": "descriptor", "type": "texture descriptor", "annotation": "const*"}
+ ]
+ },
+ {
+ "name": "tick"
+ },
+ {
+ "name": "set error callback",
+ "args": [
+ {"name": "callback", "type": "device error callback"},
+ {"name": "userdata", "type": "callback userdata"}
+ ]
+ }
+ ]
+ },
+ "depth stencil state": {
+ "category": "object"
+ },
+ "depth stencil state builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "depth stencil state"
+ },
+ {
+ "name": "set depth compare function",
+ "args": [
+ {"name": "depth compare function", "type": "compare function"}
+ ]
+ },
+ {
+ "name": "set depth write enabled",
+ "args" : [
+ {"name": "enabled", "type": "bool"}
+ ]
+ },
+ {
+ "name": "set stencil function",
+ "args": [
+ {"name": "face", "type": "face"},
+ {"name": "stencil compare function", "type": "compare function"},
+ {"name": "stencil failure operation", "type": "stencil operation"},
+ {"name": "depth failure operation", "type": "stencil operation"},
+ {"name": "stencil pass operation", "type": "stencil operation"}
+ ]
+ },
+ {
+ "name": "set stencil mask",
+ "args": [
+ {"name": "read mask", "type": "uint32_t"},
+ {"name": "write mask", "type": "uint32_t"}
+ ]
+ }
+ ]
+ },
+ "device error callback": {
+ "category": "natively defined"
+ },
+ "extent 3D": {
+ "category": "structure",
+ "members": [
+ {"name": "width", "type": "uint32_t"},
+ {"name": "height", "type": "uint32_t"},
+ {"name": "depth", "type": "uint32_t"}
+ ]
+ },
+ "face": {
+ "category": "bitmask",
+ "values": [
+ {"value": 0, "name": "none"},
+ {"value": 1, "name": "back"},
+ {"value": 2, "name": "front"},
+ {"value": 3, "name": "both"}
+ ]
+ },
+ "filter mode": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name":"nearest"},
+ {"value": 1, "name":"linear"}
+ ]
+ },
+ "float": {
+ "category": "native"
+ },
+ "index format": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "uint16"},
+ {"value": 1, "name": "uint32"}
+ ]
+ },
+ "input state": {
+ "category": "object"
+ },
+ "input state builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "input state"
+ },
+ {
+ "name": "set attribute",
+ "args": [
+ {"name": "shader location", "type": "uint32_t"},
+ {"name": "binding slot", "type": "uint32_t"},
+ {"name": "format", "type": "vertex format"},
+ {"name": "offset", "type": "uint32_t"}
+ ]
+ },
+ {
+ "name": "set input",
+ "args": [
+ {"name": "binding slot", "type": "uint32_t"},
+ {"name": "stride", "type": "uint32_t"},
+ {"name": "step mode", "type": "input step mode"}
+ ]
+ }
+ ]
+ },
+ "input step mode": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "vertex"},
+ {"value": 1, "name": "instance"}
+ ]
+ },
+ "load op": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "clear"},
+ {"value": 1, "name": "load"}
+ ]
+ },
+ "origin 3D": {
+ "category": "structure",
+ "members": [
+ {"name": "x", "type": "uint32_t"},
+ {"name": "y", "type": "uint32_t"},
+ {"name": "z", "type": "uint32_t"}
+ ]
+ },
+ "pipeline layout": {
+ "category": "object"
+ },
+ "pipeline layout descriptor": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "num bind group layouts", "type": "uint32_t"},
+ {"name": "bind group layouts", "type": "bind group layout", "annotation": "const*", "length": "num bind group layouts"}
+ ]
+ },
+ "primitive topology": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "point list"},
+ {"value": 1, "name": "line list"},
+ {"value": 2, "name": "line strip"},
+ {"value": 3, "name": "triangle list"},
+ {"value": 4, "name": "triangle strip"}
+ ]
+ },
+ "queue": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "submit",
+ "args": [
+ {"name": "num commands", "type": "uint32_t"},
+ {"name": "commands", "type": "command buffer", "annotation": "const*", "length": "num commands"}
+ ]
+ }
+ ]
+ },
+ "render pass descriptor builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "render pass descriptor"
+ },
+ {
+ "name": "set color attachment",
+ "args": [
+ {"name": "attachment slot", "type": "uint32_t"},
+ {"name": "texture view", "type": "texture view"},
+ {"name": "load op", "type": "load op"}
+ ]
+ },
+ {
+ "name": "set color attachment clear color",
+ "TODO": "determine where to put these methods (probably BeginRenderPass?)",
+ "args": [
+ {"name": "attachment slot", "type": "uint32_t"},
+ {"name": "clear r", "type": "float"},
+ {"name": "clear g", "type": "float"},
+ {"name": "clear b", "type": "float"},
+ {"name": "clear a", "type": "float"}
+ ]
+ },
+ {
+ "name": "set depth stencil attachment",
+ "args": [
+ {"name": "texture view", "type": "texture view"},
+ {"name": "depth load op", "type": "load op"},
+ {"name": "stencil load op", "type": "load op"}
+ ]
+ },
+ {
+ "name": "set depth stencil attachment clear value",
+ "TODO": "determine where to put these methods (probably BeginRenderPass?)",
+ "args": [
+ {"name": "clear depth", "type": "float"},
+ {"name": "clear stencil", "type": "uint32_t"}
+ ]
+ }
+ ]
+ },
+ "render pass descriptor": {
+ "category": "object"
+ },
+ "render pass encoder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "set render pipeline",
+ "TODO": "This is called setPipeline in the WebGPU IDL",
+ "args": [
+ {"name": "pipeline", "type": "render pipeline"}
+ ]
+ },
+ {
+ "name": "set push constants",
+ "TODO": [
+ "data should be void*",
+ "TODO Vulkan has an additional stage mask"
+ ],
+ "args": [
+ {"name": "stages", "type": "shader stage bit"},
+ {"name": "offset", "type": "uint32_t"},
+ {"name": "count", "type": "uint32_t"},
+ {"name": "data", "type": "uint32_t", "annotation": "const*", "length": "count"}
+ ]
+ },
+ {
+ "name": "set bind group",
+ "args": [
+ {"name": "group index", "type": "uint32_t"},
+ {"name": "group", "type": "bind group"}
+ ]
+ },
+ {
+ "name": "draw arrays",
+ "args": [
+ {"name": "vertex count", "type": "uint32_t"},
+ {"name": "instance count", "type": "uint32_t"},
+ {"name": "first vertex", "type": "uint32_t"},
+ {"name": "first instance", "type": "uint32_t"}
+ ]
+ },
+ {
+ "name": "draw elements",
+ "args": [
+ {"name": "index count", "type": "uint32_t"},
+ {"name": "instance count", "type": "uint32_t"},
+ {"name": "first index", "type": "uint32_t"},
+ {"name": "first instance", "type": "uint32_t"}
+ ]
+ },
+ {
+ "name": "set stencil reference",
+ "args": [
+ {"name": "reference", "type": "uint32_t"}
+ ]
+ },
+ {
+ "name": "set blend color",
+ "args": [
+ {"name": "r", "type": "float"},
+ {"name": "g", "type": "float"},
+ {"name": "b", "type": "float"},
+ {"name": "a", "type": "float"}
+ ]
+ },
+ {
+ "name": "set scissor rect",
+ "args": [
+ {"name": "x", "type": "uint32_t"},
+ {"name": "y", "type": "uint32_t"},
+ {"name": "width", "type": "uint32_t"},
+ {"name": "height", "type": "uint32_t"}
+ ]
+ },
+ {
+ "name": "set vertex buffers",
+ "args": [
+ {"name": "start slot", "type": "uint32_t"},
+ {"name": "count", "type": "uint32_t"},
+ {"name": "buffers", "type": "buffer", "annotation": "const*", "length": "count"},
+ {"name": "offsets", "type": "uint32_t", "annotation": "const*", "length": "count"}
+ ]
+ },
+ {
+ "name": "set index buffer",
+ "args": [
+ {"name": "buffer", "type": "buffer"},
+ {"name": "offset", "type": "uint32_t"}
+ ]
+ },
+ {
+ "name": "end pass",
+ "TODO": "This returns the top-level encoder in the WebGPU IDL"
+ }
+ ]
+ },
+ "render pipeline": {
+ "category": "object"
+ },
+ "render pipeline builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "render pipeline"
+ },
+ {
+ "name": "set color attachment format",
+ "TODO": "Also need sample count",
+ "args": [
+ {"name": "attachment slot", "type": "uint32_t"},
+ {"name": "format", "type": "texture format"}
+ ]
+ },
+ {
+ "name": "set depth stencil attachment format",
+ "TODO": "Also need sample count",
+ "args": [
+ {"name": "format", "type": "texture format"}
+ ]
+ },
+ {
+ "name": "set color attachment blend state",
+ "args": [
+ {"name": "attachment slot", "type": "uint32_t"},
+ {"name": "blend state", "type": "blend state"}
+ ]
+ },
+ {
+ "name": "set depth stencil state",
+ "args": [
+ {"name": "depth stencil state", "type": "depth stencil state"}
+ ]
+ },
+ {
+ "name": "set index format",
+ "args": [
+ {"name": "format", "type": "index format"}
+ ]
+ },
+ {
+ "name": "set input state",
+ "args": [
+ {"name": "input", "type": "input state"}
+ ]
+ },
+ {
+ "name": "set layout",
+ "args": [
+ {"name": "layout", "type": "pipeline layout"}
+ ]
+ },
+ {
+ "name": "set primitive topology",
+ "args": [
+ {"name": "primitive topology", "type": "primitive topology"}
+ ]
+ },
+ {
+ "name": "set stage",
+ "args": [
+ {"name": "stage", "type": "shader stage"},
+ {"name": "module", "type": "shader module"},
+ {"name": "entry point", "type": "char", "annotation": "const*", "length": "strlen"}
+ ]
+ }
+ ]
+ },
+ "sampler": {
+ "category": "object"
+ },
+ "sampler descriptor": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "mag filter", "type": "filter mode"},
+ {"name": "min filter", "type": "filter mode"},
+ {"name": "mipmap filter", "type": "filter mode"},
+ {"name": "address mode u", "type": "address mode"},
+ {"name": "address mode v", "type": "address mode"},
+ {"name": "address mode w", "type": "address mode"}
+ ]
+ },
+ "shader module": {
+ "category": "object"
+ },
+ "shader module descriptor": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "code size", "type": "uint32_t"},
+ {"name": "code", "type": "uint32_t", "annotation": "const*", "length": "code size"}
+ ]
+ },
+ "shader stage": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "vertex"},
+ {"value": 1, "name": "fragment"},
+ {"value": 2, "name": "compute"}
+ ]
+ },
+ "shader stage bit": {
+ "category": "bitmask",
+ "values": [
+ {"value": 0, "name": "none"},
+ {"value": 1, "name": "vertex"},
+ {"value": 2, "name": "fragment"},
+ {"value": 4, "name": "compute"}
+ ]
+ },
+ "stencil operation": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "keep"},
+ {"value": 1, "name": "zero"},
+ {"value": 2, "name": "replace"},
+ {"value": 3, "name": "invert"},
+ {"value": 4, "name": "increment clamp"},
+ {"value": 5, "name": "decrement clamp"},
+ {"value": 6, "name": "increment wrap"},
+ {"value": 7, "name": "decrement wrap"}
+ ]
+ },
+ "swap chain": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "configure",
+ "args": [
+ {"name": "format", "type": "texture format"},
+ {"name": "allowed usage", "type": "texture usage bit"},
+ {"name": "width", "type": "uint32_t"},
+ {"name": "height", "type": "uint32_t"}
+ ]
+ },
+ {
+ "name": "get next texture",
+ "returns": "texture"
+ },
+ {
+ "name": "present",
+ "args": [
+ {"name": "texture", "type": "texture"}
+ ]
+ }
+ ]
+ },
+ "swap chain builder": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "get result",
+ "returns": "swap chain"
+ },
+ {
+ "name": "set implementation",
+ "args": [
+ {"name": "implementation", "type": "uint64_t"}
+ ]
+ }
+ ]
+ },
+ "texture": {
+ "category": "object",
+ "methods": [
+ {
+ "name": "create default texture view",
+ "returns": "texture view"
+ },
+ {
+ "name": "create texture view",
+ "returns": "texture view",
+ "args": [
+ {"name": "descriptor", "type": "texture view descriptor", "annotation": "const*"}
+ ]
+ }
+ ]
+ },
+ "texture aspect": {
+ "category": "bitmask",
+ "values": [
+ {"value": 1, "name": "color"},
+ {"value": 2, "name": "depth"},
+ {"value": 4, "name": "stencil"}
+ ]
+ },
+ "texture copy view": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "texture", "type": "texture"},
+ {"name": "level", "type": "uint32_t"},
+ {"name": "slice", "type": "uint32_t"},
+ {"name": "origin", "type": "origin 3D"},
+ {"name": "aspect", "type": "texture aspect"}
+ ]
+ },
+ "texture descriptor": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "usage", "type": "texture usage bit"},
+ {"name": "dimension", "type": "texture dimension"},
+ {"name": "size", "type": "extent 3D"},
+ {"name": "array layer", "type": "uint32_t"},
+ {"name": "format", "type": "texture format"},
+ {"name": "level count", "type": "uint32_t"}
+ ]
+ },
+ "texture dimension": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "2D"}
+ ]
+ },
+ "texture format": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "r8 g8 b8 a8 unorm"},
+ {"value": 1, "name": "r8 g8 unorm"},
+ {"value": 2, "name": "r8 unorm"},
+ {"value": 3, "name": "r8 g8 b8 a8 uint"},
+ {"value": 4, "name": "r8 g8 uint"},
+ {"value": 5, "name": "r8 uint"},
+ {"value": 6, "name": "b8 g8 r8 a8 unorm"},
+ {"value": 7, "name": "d32 float s8 uint"}
+ ]
+ },
+ "texture usage bit": {
+ "category": "bitmask",
+ "values": [
+ {"value": 0, "name": "none"},
+ {"value": 1, "name": "transfer src"},
+ {"value": 2, "name": "transfer dst"},
+ {"value": 4, "name": "sampled"},
+ {"value": 8, "name": "storage"},
+ {"value": 16, "name": "output attachment"},
+ {"value": 32, "name": "present"}
+ ]
+ },
+ "texture view descriptor": {
+ "category": "structure",
+ "extensible": true,
+ "members": [
+ {"name": "format", "type": "texture format"},
+ {"name": "dimension", "type": "texture view dimension"},
+ {"name": "base mip level", "type": "uint32_t"},
+ {"name": "level count", "type": "uint32_t"},
+ {"name": "base array layer", "type": "uint32_t"},
+ {"name": "layer count", "type": "uint32_t"}
+ ],
+ "TODO": [
+ "jiawei.shao@intel.com: Allow choosing the aspect (depth vs. stencil)"
+ ]
+ },
+ "texture view": {
+ "category": "object"
+ },
+ "texture view dimension": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "2D"},
+ {"value": 1, "name": "2D array"},
+ {"value": 2, "name": "cube"},
+ {"value": 3, "name": "cube array"}
+ ],
+ "TODO": [
+ "jiawei.shao@intel.com: support 1D and 3D texture views"
+ ]
+ },
+ "vertex format": {
+ "category": "enum",
+ "values": [
+ {"value": 0, "name": "float r32 g32 b32 a32"},
+ {"value": 1, "name": "float r32 g32 b32"},
+ {"value": 2, "name": "float r32 g32"},
+ {"value": 3, "name": "float r32"},
+ {"value": 4, "name": "int r32 g32 b32 a32"},
+ {"value": 5, "name": "int r32 g32 b32"},
+ {"value": 6, "name": "int r32 g32"},
+ {"value": 7, "name": "int r32"},
+ {"value": 8, "name": "ushort r16 g16 b16 a16"},
+ {"value": 9, "name": "ushort r16 g16"},
+ {"value": 10, "name": "unorm r8 g8 b8 a8"},
+ {"value": 11, "name": "unorm r8 g8"}
+ ]
+ },
+ "void": {
+ "category": "native"
+ },
+ "uint32_t": {
+ "category": "native"
+ },
+ "uint64_t": {
+ "category": "native"
+ },
+ "uint8_t": {
+ "category": "native"
+ }
+}
diff --git a/chromium/third_party/dawn/examples/Animometer.cpp b/chromium/third_party/dawn/examples/Animometer.cpp
new file mode 100644
index 00000000000..9e0eff9073a
--- /dev/null
+++ b/chromium/third_party/dawn/examples/Animometer.cpp
@@ -0,0 +1,174 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "SampleUtils.h"
+
+#include "utils/DawnHelpers.h"
+#include "utils/SystemUtils.h"
+
+#include <cstdlib>
+#include <cstdio>
+#include <vector>
+
+dawn::Device device;
+dawn::Queue queue;
+dawn::SwapChain swapchain;
+dawn::TextureView depthStencilView;
+dawn::RenderPipeline pipeline;
+
+float RandomFloat(float min, float max) {
+ float zeroOne = rand() / float(RAND_MAX);
+ return zeroOne * (max - min) + min;
+}
+
+struct ShaderData {
+ float scale;
+ float time;
+ float offsetX;
+ float offsetY;
+ float scalar;
+ float scalarOffset;
+};
+
+static std::vector<ShaderData> shaderData;
+
+void init() {
+ device = CreateCppDawnDevice();
+
+ queue = device.CreateQueue();
+ swapchain = GetSwapChain(device);
+ swapchain.Configure(GetPreferredSwapChainTextureFormat(),
+ dawn::TextureUsageBit::OutputAttachment, 640, 480);
+
+ dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
+ #version 450
+
+ layout(push_constant) uniform ConstantsBlock {
+ float scale;
+ float time;
+ float offsetX;
+ float offsetY;
+ float scalar;
+ float scalarOffset;
+ } c;
+
+ layout(location = 0) out vec4 v_color;
+
+ const vec4 positions[3] = vec4[3](
+ vec4( 0.0f, 0.1f, 0.0f, 1.0f),
+ vec4(-0.1f, -0.1f, 0.0f, 1.0f),
+ vec4( 0.1f, -0.1f, 0.0f, 1.0f)
+ );
+
+ const vec4 colors[3] = vec4[3](
+ vec4(1.0f, 0.0f, 0.0f, 1.0f),
+ vec4(0.0f, 1.0f, 0.0f, 1.0f),
+ vec4(0.0f, 0.0f, 1.0f, 1.0f)
+ );
+
+ void main() {
+ vec4 position = positions[gl_VertexIndex];
+ vec4 color = colors[gl_VertexIndex];
+
+ float fade = mod(c.scalarOffset + c.time * c.scalar / 10.0, 1.0);
+ if (fade < 0.5) {
+ fade = fade * 2.0;
+ } else {
+ fade = (1.0 - fade) * 2.0;
+ }
+ float xpos = position.x * c.scale;
+ float ypos = position.y * c.scale;
+ float angle = 3.14159 * 2.0 * fade;
+ float xrot = xpos * cos(angle) - ypos * sin(angle);
+ float yrot = xpos * sin(angle) + ypos * cos(angle);
+ xpos = xrot + c.offsetX;
+ ypos = yrot + c.offsetY;
+ v_color = vec4(fade, 1.0 - fade, 0.0, 1.0) + color;
+ gl_Position = vec4(xpos, ypos, 0.0, 1.0);
+ })"
+ );
+
+ dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
+ #version 450
+ layout(location = 0) out vec4 fragColor;
+ layout(location = 0) in vec4 v_color;
+ void main() {
+ fragColor = v_color;
+ })");
+
+ depthStencilView = CreateDefaultDepthStencilView(device);
+
+ pipeline = device.CreateRenderPipelineBuilder()
+ .SetColorAttachmentFormat(0, GetPreferredSwapChainTextureFormat())
+ .SetDepthStencilAttachmentFormat(dawn::TextureFormat::D32FloatS8Uint)
+ .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
+ .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
+ .GetResult();
+
+ shaderData.resize(10000);
+ for (auto& data : shaderData) {
+ data.scale = RandomFloat(0.2f, 0.4f);
+ data.time = 0.0;
+ data.offsetX = RandomFloat(-0.9f, 0.9f);
+ data.offsetY = RandomFloat(-0.9f, 0.9f);
+ data.scalar = RandomFloat(0.5f, 2.0f);
+ data.scalarOffset = RandomFloat(0.0f, 10.0f);
+ }
+}
+
+void frame() {
+ dawn::Texture backbuffer;
+ dawn::RenderPassDescriptor renderPass;
+ GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
+
+ static int f = 0;
+ f++;
+
+ size_t i = 0;
+
+ dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
+ {
+ dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+ pass.SetRenderPipeline(pipeline);
+
+ for (int k = 0; k < 10000; k++) {
+ shaderData[i].time = f / 60.0f;
+ pass.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 6, reinterpret_cast<uint32_t*>(&shaderData[i]));
+ pass.DrawArrays(3, 1, 0, 0);
+ i++;
+ }
+
+ pass.EndPass();
+ }
+
+ dawn::CommandBuffer commands = builder.GetResult();
+ queue.Submit(1, &commands);
+ swapchain.Present(backbuffer);
+ DoFlush();
+ fprintf(stderr, "frame %i\n", f);
+}
+
+int main(int argc, const char* argv[]) {
+ if (!InitSample(argc, argv)) {
+ return 1;
+ }
+ init();
+
+ while (!ShouldQuit()) {
+ frame();
+ utils::USleep(16000);
+ }
+
+ // TODO release stuff
+}
diff --git a/chromium/third_party/dawn/examples/CHelloTriangle.cpp b/chromium/third_party/dawn/examples/CHelloTriangle.cpp
new file mode 100644
index 00000000000..1d87073d16b
--- /dev/null
+++ b/chromium/third_party/dawn/examples/CHelloTriangle.cpp
@@ -0,0 +1,119 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "SampleUtils.h"
+
+#include "utils/DawnHelpers.h"
+#include "utils/SystemUtils.h"
+
+dawnDevice device;
+dawnQueue queue;
+dawnSwapChain swapchain;
+dawnRenderPipeline pipeline;
+
+dawnTextureFormat swapChainFormat;
+
+void init() {
+ device = CreateCppDawnDevice().Release();
+ queue = dawnDeviceCreateQueue(device);
+
+ {
+ dawnSwapChainBuilder builder = dawnDeviceCreateSwapChainBuilder(device);
+ uint64_t swapchainImpl = GetSwapChainImplementation();
+ dawnSwapChainBuilderSetImplementation(builder, swapchainImpl);
+ swapchain = dawnSwapChainBuilderGetResult(builder);
+ dawnSwapChainBuilderRelease(builder);
+ }
+ swapChainFormat = static_cast<dawnTextureFormat>(GetPreferredSwapChainTextureFormat());
+ dawnSwapChainConfigure(swapchain, swapChainFormat, DAWN_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, 640,
+ 480);
+
+ const char* vs =
+ "#version 450\n"
+ "const vec2 pos[3] = vec2[3](vec2(0.0f, 0.5f), vec2(-0.5f, -0.5f), vec2(0.5f, -0.5f));\n"
+ "void main() {\n"
+ " gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n"
+ "}\n";
+ dawnShaderModule vsModule = utils::CreateShaderModule(dawn::Device(device), dawn::ShaderStage::Vertex, vs).Release();
+
+ const char* fs =
+ "#version 450\n"
+ "layout(location = 0) out vec4 fragColor;"
+ "void main() {\n"
+ " fragColor = vec4(1.0, 0.0, 0.0, 1.0);\n"
+ "}\n";
+ dawnShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, fs).Release();
+
+ {
+ dawnRenderPipelineBuilder builder = dawnDeviceCreateRenderPipelineBuilder(device);
+ dawnRenderPipelineBuilderSetColorAttachmentFormat(builder, 0, swapChainFormat);
+ dawnRenderPipelineBuilderSetStage(builder, DAWN_SHADER_STAGE_VERTEX, vsModule, "main");
+ dawnRenderPipelineBuilderSetStage(builder, DAWN_SHADER_STAGE_FRAGMENT, fsModule, "main");
+ pipeline = dawnRenderPipelineBuilderGetResult(builder);
+ dawnRenderPipelineBuilderRelease(builder);
+ }
+
+ dawnShaderModuleRelease(vsModule);
+ dawnShaderModuleRelease(fsModule);
+}
+
+void frame() {
+ dawnTexture backbuffer = dawnSwapChainGetNextTexture(swapchain);
+ dawnTextureView backbufferView;
+ {
+ backbufferView = dawnTextureCreateDefaultTextureView(backbuffer);
+ }
+ dawnRenderPassDescriptor renderpassInfo;
+ {
+ dawnRenderPassDescriptorBuilder builder = dawnDeviceCreateRenderPassDescriptorBuilder(device);
+ dawnRenderPassDescriptorBuilderSetColorAttachment(builder, 0, backbufferView, DAWN_LOAD_OP_CLEAR);
+ renderpassInfo = dawnRenderPassDescriptorBuilderGetResult(builder);
+ dawnRenderPassDescriptorBuilderRelease(builder);
+ }
+ dawnCommandBuffer commands;
+ {
+ dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device);
+
+ dawnRenderPassEncoder pass = dawnCommandBufferBuilderBeginRenderPass(builder, renderpassInfo);
+ dawnRenderPassEncoderSetRenderPipeline(pass, pipeline);
+ dawnRenderPassEncoderDrawArrays(pass, 3, 1, 0, 0);
+ dawnRenderPassEncoderEndPass(pass);
+ dawnRenderPassEncoderRelease(pass);
+
+ commands = dawnCommandBufferBuilderGetResult(builder);
+ dawnCommandBufferBuilderRelease(builder);
+ }
+
+ dawnQueueSubmit(queue, 1, &commands);
+ dawnCommandBufferRelease(commands);
+ dawnSwapChainPresent(swapchain, backbuffer);
+ dawnRenderPassDescriptorRelease(renderpassInfo);
+ dawnTextureViewRelease(backbufferView);
+
+ DoFlush();
+}
+
+int main(int argc, const char* argv[]) {
+ if (!InitSample(argc, argv)) {
+ return 1;
+ }
+ init();
+
+ while (!ShouldQuit()) {
+ frame();
+ utils::USleep(16000);
+ }
+
+ // TODO release stuff
+}
diff --git a/chromium/third_party/dawn/examples/ComputeBoids.cpp b/chromium/third_party/dawn/examples/ComputeBoids.cpp
new file mode 100644
index 00000000000..869f95f4b28
--- /dev/null
+++ b/chromium/third_party/dawn/examples/ComputeBoids.cpp
@@ -0,0 +1,324 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "SampleUtils.h"
+
+#include "utils/DawnHelpers.h"
+#include "utils/SystemUtils.h"
+
+#include <array>
+#include <cstring>
+#include <random>
+
+#include <glm/glm.hpp>
+
+dawn::Device device;
+dawn::Queue queue;
+dawn::SwapChain swapchain;
+dawn::TextureView depthStencilView;
+
+dawn::Buffer modelBuffer;
+std::array<dawn::Buffer, 2> particleBuffers;
+
+dawn::RenderPipeline renderPipeline;
+
+dawn::Buffer updateParams;
+dawn::ComputePipeline updatePipeline;
+std::array<dawn::BindGroup, 2> updateBGs;
+
+size_t pingpong = 0;
+
+static const uint32_t kNumParticles = 1000;
+
+struct Particle {
+ glm::vec2 pos;
+ glm::vec2 vel;
+};
+
+struct SimParams {
+ float deltaT;
+ float rule1Distance;
+ float rule2Distance;
+ float rule3Distance;
+ float rule1Scale;
+ float rule2Scale;
+ float rule3Scale;
+ int particleCount;
+};
+
+void initBuffers() {
+ glm::vec2 model[3] = {
+ {-0.01, -0.02},
+ {0.01, -0.02},
+ {0.00, 0.02},
+ };
+ modelBuffer = utils::CreateBufferFromData(device, model, sizeof(model), dawn::BufferUsageBit::Vertex);
+
+ SimParams params = { 0.04f, 0.1f, 0.025f, 0.025f, 0.02f, 0.05f, 0.005f, kNumParticles };
+ updateParams = utils::CreateBufferFromData(device, &params, sizeof(params), dawn::BufferUsageBit::Uniform);
+
+ std::vector<Particle> initialParticles(kNumParticles);
+ {
+ std::mt19937 generator;
+ std::uniform_real_distribution<float> dist(-1.0f, 1.0f);
+ for (auto& p : initialParticles)
+ {
+ p.pos = glm::vec2(dist(generator), dist(generator));
+ p.vel = glm::vec2(dist(generator), dist(generator)) * 0.1f;
+ }
+ }
+
+ for (size_t i = 0; i < 2; i++) {
+ dawn::BufferDescriptor descriptor;
+ descriptor.size = sizeof(Particle) * kNumParticles;
+ descriptor.usage = dawn::BufferUsageBit::TransferDst | dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Storage;
+ particleBuffers[i] = device.CreateBuffer(&descriptor);
+
+ particleBuffers[i].SetSubData(0,
+ sizeof(Particle) * kNumParticles,
+ reinterpret_cast<uint8_t*>(initialParticles.data()));
+ }
+}
+
+void initRender() {
+ dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
+ #version 450
+ layout(location = 0) in vec2 a_particlePos;
+ layout(location = 1) in vec2 a_particleVel;
+ layout(location = 2) in vec2 a_pos;
+ void main() {
+ float angle = -atan(a_particleVel.x, a_particleVel.y);
+ vec2 pos = vec2(a_pos.x * cos(angle) - a_pos.y * sin(angle),
+ a_pos.x * sin(angle) + a_pos.y * cos(angle));
+ gl_Position = vec4(pos + a_particlePos, 0, 1);
+ }
+ )");
+
+ dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
+ #version 450
+ layout(location = 0) out vec4 fragColor;
+ void main() {
+ fragColor = vec4(1.0);
+ }
+ )");
+
+ dawn::InputState inputState = device.CreateInputStateBuilder()
+ .SetAttribute(0, 0, dawn::VertexFormat::FloatR32G32, offsetof(Particle, pos))
+ .SetAttribute(1, 0, dawn::VertexFormat::FloatR32G32, offsetof(Particle, vel))
+ .SetInput(0, sizeof(Particle), dawn::InputStepMode::Instance)
+ .SetAttribute(2, 1, dawn::VertexFormat::FloatR32G32, 0)
+ .SetInput(1, sizeof(glm::vec2), dawn::InputStepMode::Vertex)
+ .GetResult();
+
+ depthStencilView = CreateDefaultDepthStencilView(device);
+
+ renderPipeline = device.CreateRenderPipelineBuilder()
+ .SetColorAttachmentFormat(0, GetPreferredSwapChainTextureFormat())
+ .SetDepthStencilAttachmentFormat(dawn::TextureFormat::D32FloatS8Uint)
+ .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
+ .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
+ .SetInputState(inputState)
+ .GetResult();
+}
+
+void initSim() {
+ dawn::ShaderModule module = utils::CreateShaderModule(device, dawn::ShaderStage::Compute, R"(
+ #version 450
+
+ struct Particle {
+ vec2 pos;
+ vec2 vel;
+ };
+
+ layout(std140, set = 0, binding = 0) uniform SimParams {
+ float deltaT;
+ float rule1Distance;
+ float rule2Distance;
+ float rule3Distance;
+ float rule1Scale;
+ float rule2Scale;
+ float rule3Scale;
+ int particleCount;
+ } params;
+
+ layout(std140, set = 0, binding = 1) buffer ParticlesA {
+ Particle particles[1000];
+ } particlesA;
+
+ layout(std140, set = 0, binding = 2) buffer ParticlesB {
+ Particle particles[1000];
+ } particlesB;
+
+ void main() {
+ // https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
+
+ uint index = gl_GlobalInvocationID.x;
+ if (index >= params.particleCount) { return; }
+
+ vec2 vPos = particlesA.particles[index].pos;
+ vec2 vVel = particlesA.particles[index].vel;
+
+ vec2 cMass = vec2(0.0, 0.0);
+ vec2 cVel = vec2(0.0, 0.0);
+ vec2 colVel = vec2(0.0, 0.0);
+ int cMassCount = 0;
+ int cVelCount = 0;
+
+ vec2 pos;
+ vec2 vel;
+ for (int i = 0; i < params.particleCount; ++i) {
+ if (i == index) { continue; }
+ pos = particlesA.particles[i].pos.xy;
+ vel = particlesA.particles[i].vel.xy;
+
+ if (distance(pos, vPos) < params.rule1Distance) {
+ cMass += pos;
+ cMassCount++;
+ }
+ if (distance(pos, vPos) < params.rule2Distance) {
+ colVel -= (pos - vPos);
+ }
+ if (distance(pos, vPos) < params.rule3Distance) {
+ cVel += vel;
+ cVelCount++;
+ }
+ }
+ if (cMassCount > 0) {
+ cMass = cMass / cMassCount - vPos;
+ }
+ if (cVelCount > 0) {
+ cVel = cVel / cVelCount;
+ }
+
+ vVel += cMass * params.rule1Scale + colVel * params.rule2Scale + cVel * params.rule3Scale;
+
+ // clamp velocity for a more pleasing simulation.
+ vVel = normalize(vVel) * clamp(length(vVel), 0.0, 0.1);
+
+ // kinematic update
+ vPos += vVel * params.deltaT;
+
+ // Wrap around boundary
+ if (vPos.x < -1.0) vPos.x = 1.0;
+ if (vPos.x > 1.0) vPos.x = -1.0;
+ if (vPos.y < -1.0) vPos.y = 1.0;
+ if (vPos.y > 1.0) vPos.y = -1.0;
+
+ particlesB.particles[index].pos = vPos;
+
+ // Write back
+ particlesB.particles[index].vel = vVel;
+ }
+ )");
+
+ auto bgl = utils::MakeBindGroupLayout(
+ device, {
+ {0, dawn::ShaderStageBit::Compute, dawn::BindingType::UniformBuffer},
+ {1, dawn::ShaderStageBit::Compute, dawn::BindingType::StorageBuffer},
+ {2, dawn::ShaderStageBit::Compute, dawn::BindingType::StorageBuffer},
+ });
+
+ dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
+
+ dawn::ComputePipelineDescriptor csDesc;
+ csDesc.module = module;
+ csDesc.entryPoint = "main";
+ csDesc.layout = pl;
+ updatePipeline = device.CreateComputePipeline(&csDesc);
+
+ dawn::BufferView updateParamsView = updateParams.CreateBufferViewBuilder()
+ .SetExtent(0, sizeof(SimParams))
+ .GetResult();
+
+ std::array<dawn::BufferView, 2> views;
+ for (uint32_t i = 0; i < 2; ++i) {
+ views[i] = particleBuffers[i].CreateBufferViewBuilder()
+ .SetExtent(0, kNumParticles * sizeof(Particle))
+ .GetResult();
+ }
+
+ for (uint32_t i = 0; i < 2; ++i) {
+ updateBGs[i] = device.CreateBindGroupBuilder()
+ .SetLayout(bgl)
+ .SetBufferViews(0, 1, &updateParamsView)
+ .SetBufferViews(1, 1, &views[i])
+ .SetBufferViews(2, 1, &views[(i + 1) % 2])
+ .GetResult();
+ }
+}
+
+dawn::CommandBuffer createCommandBuffer(const dawn::RenderPassDescriptor& renderPass, size_t i) {
+ static const uint32_t zeroOffsets[1] = {0};
+ auto& bufferDst = particleBuffers[(i + 1) % 2];
+ dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
+
+ {
+ dawn::ComputePassEncoder pass = builder.BeginComputePass();
+ pass.SetComputePipeline(updatePipeline);
+ pass.SetBindGroup(0, updateBGs[i]);
+ pass.Dispatch(kNumParticles, 1, 1);
+ pass.EndPass();
+ }
+
+ {
+ dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+ pass.SetRenderPipeline(renderPipeline);
+ pass.SetVertexBuffers(0, 1, &bufferDst, zeroOffsets);
+ pass.SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets);
+ pass.DrawArrays(3, kNumParticles, 0, 0);
+ pass.EndPass();
+ }
+
+ return builder.GetResult();
+}
+
+void init() {
+ device = CreateCppDawnDevice();
+
+ queue = device.CreateQueue();
+ swapchain = GetSwapChain(device);
+ swapchain.Configure(GetPreferredSwapChainTextureFormat(),
+ dawn::TextureUsageBit::OutputAttachment, 640, 480);
+
+ initBuffers();
+ initRender();
+ initSim();
+}
+
+void frame() {
+ dawn::Texture backbuffer;
+ dawn::RenderPassDescriptor renderPass;
+ GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
+
+ dawn::CommandBuffer commandBuffer = createCommandBuffer(renderPass, pingpong);
+ queue.Submit(1, &commandBuffer);
+ swapchain.Present(backbuffer);
+ DoFlush();
+
+ pingpong = (pingpong + 1) % 2;
+}
+
+int main(int argc, const char* argv[]) {
+ if (!InitSample(argc, argv)) {
+ return 1;
+ }
+ init();
+
+ while (!ShouldQuit()) {
+ frame();
+ utils::USleep(16000);
+ }
+
+ // TODO release stuff
+}
diff --git a/chromium/third_party/dawn/examples/CppHelloTriangle.cpp b/chromium/third_party/dawn/examples/CppHelloTriangle.cpp
new file mode 100644
index 00000000000..de60b2e654e
--- /dev/null
+++ b/chromium/third_party/dawn/examples/CppHelloTriangle.cpp
@@ -0,0 +1,187 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "SampleUtils.h"
+
+#include "utils/DawnHelpers.h"
+#include "utils/SystemUtils.h"
+
+#include <vector>
+
+dawn::Device device;
+
+dawn::Buffer indexBuffer;
+dawn::Buffer vertexBuffer;
+
+dawn::Texture texture;
+dawn::Sampler sampler;
+
+dawn::Queue queue;
+dawn::SwapChain swapchain;
+dawn::TextureView depthStencilView;
+dawn::RenderPipeline pipeline;
+dawn::BindGroup bindGroup;
+
+void initBuffers() {
+ static const uint32_t indexData[3] = {
+ 0, 1, 2,
+ };
+ indexBuffer = utils::CreateBufferFromData(device, indexData, sizeof(indexData), dawn::BufferUsageBit::Index);
+
+ static const float vertexData[12] = {
+ 0.0f, 0.5f, 0.0f, 1.0f,
+ -0.5f, -0.5f, 0.0f, 1.0f,
+ 0.5f, -0.5f, 0.0f, 1.0f,
+ };
+ vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData), dawn::BufferUsageBit::Vertex);
+}
+
+void initTextures() {
+ dawn::TextureDescriptor descriptor;
+ descriptor.dimension = dawn::TextureDimension::e2D;
+ descriptor.size.width = 1024;
+ descriptor.size.height = 1024;
+ descriptor.size.depth = 1;
+ descriptor.arrayLayer = 1;
+ descriptor.format = dawn::TextureFormat::R8G8B8A8Unorm;
+ descriptor.levelCount = 1;
+ descriptor.usage = dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled;
+ texture = device.CreateTexture(&descriptor);
+
+ dawn::SamplerDescriptor samplerDesc = utils::GetDefaultSamplerDescriptor();
+ sampler = device.CreateSampler(&samplerDesc);
+
+ // Initialize the texture with arbitrary data until we can load images
+ std::vector<uint8_t> data(4 * 1024 * 1024, 0);
+ for (size_t i = 0; i < data.size(); ++i) {
+ data[i] = static_cast<uint8_t>(i % 253);
+ }
+
+ dawn::Buffer stagingBuffer = utils::CreateBufferFromData(device, data.data(), static_cast<uint32_t>(data.size()), dawn::BufferUsageBit::TransferSrc);
+ dawn::BufferCopyView bufferCopyView = utils::CreateBufferCopyView(stagingBuffer, 0, 0, 0);
+ dawn::TextureCopyView textureCopyView =
+ utils::CreateTextureCopyView(texture, 0, 0, {0, 0, 0}, dawn::TextureAspect::Color);
+ dawn::Extent3D copySize = {1024, 1024, 1};
+ dawn::CommandBuffer copy =
+ device.CreateCommandBufferBuilder()
+ .CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize)
+ .GetResult();
+
+ queue.Submit(1, &copy);
+}
+
+void init() {
+ device = CreateCppDawnDevice();
+
+ queue = device.CreateQueue();
+ swapchain = GetSwapChain(device);
+ swapchain.Configure(GetPreferredSwapChainTextureFormat(),
+ dawn::TextureUsageBit::OutputAttachment, 640, 480);
+
+ initBuffers();
+ initTextures();
+
+ dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
+ #version 450
+ layout(location = 0) in vec4 pos;
+ void main() {
+ gl_Position = pos;
+ })"
+ );
+
+ dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
+ #version 450
+ layout(set = 0, binding = 0) uniform sampler mySampler;
+ layout(set = 0, binding = 1) uniform texture2D myTexture;
+
+ layout(location = 0) out vec4 fragColor;
+ void main() {
+ fragColor = texture(sampler2D(myTexture, mySampler), gl_FragCoord.xy / vec2(640.0, 480.0));
+ })");
+
+ auto inputState = device.CreateInputStateBuilder()
+ .SetAttribute(0, 0, dawn::VertexFormat::FloatR32G32B32A32, 0)
+ .SetInput(0, 4 * sizeof(float), dawn::InputStepMode::Vertex)
+ .GetResult();
+
+ auto bgl = utils::MakeBindGroupLayout(
+ device, {
+ {0, dawn::ShaderStageBit::Fragment, dawn::BindingType::Sampler},
+ {1, dawn::ShaderStageBit::Fragment, dawn::BindingType::SampledTexture},
+ });
+
+ dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
+
+ depthStencilView = CreateDefaultDepthStencilView(device);
+
+ pipeline = device.CreateRenderPipelineBuilder()
+ .SetColorAttachmentFormat(0, GetPreferredSwapChainTextureFormat())
+ .SetDepthStencilAttachmentFormat(dawn::TextureFormat::D32FloatS8Uint)
+ .SetLayout(pl)
+ .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
+ .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
+ .SetIndexFormat(dawn::IndexFormat::Uint32)
+ .SetInputState(inputState)
+ .GetResult();
+
+ dawn::TextureView view = texture.CreateDefaultTextureView();
+
+ bindGroup = device.CreateBindGroupBuilder()
+ .SetLayout(bgl)
+ .SetSamplers(0, 1, &sampler)
+ .SetTextureViews(1, 1, &view)
+ .GetResult();
+}
+
+struct {uint32_t a; float b;} s;
+void frame() {
+ s.a = (s.a + 1) % 256;
+ s.b += 0.02f;
+ if (s.b >= 1.0f) {s.b = 0.0f;}
+
+ dawn::Texture backbuffer;
+ dawn::RenderPassDescriptor renderPass;
+ GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
+
+ static const uint32_t vertexBufferOffsets[1] = {0};
+ dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
+ {
+ dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+ pass.SetRenderPipeline(pipeline);
+ pass.SetBindGroup(0, bindGroup);
+ pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
+ pass.SetIndexBuffer(indexBuffer, 0);
+ pass.DrawElements(3, 1, 0, 0);
+ pass.EndPass();
+ }
+
+ dawn::CommandBuffer commands = builder.GetResult();
+ queue.Submit(1, &commands);
+ swapchain.Present(backbuffer);
+ DoFlush();
+}
+
+int main(int argc, const char* argv[]) {
+ if (!InitSample(argc, argv)) {
+ return 1;
+ }
+ init();
+
+ while (!ShouldQuit()) {
+ frame();
+ utils::USleep(16000);
+ }
+
+ // TODO release stuff
+}
diff --git a/chromium/third_party/dawn/examples/CubeReflection.cpp b/chromium/third_party/dawn/examples/CubeReflection.cpp
new file mode 100644
index 00000000000..5a5f658822e
--- /dev/null
+++ b/chromium/third_party/dawn/examples/CubeReflection.cpp
@@ -0,0 +1,321 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "SampleUtils.h"
+
+#include "utils/DawnHelpers.h"
+#include "utils/SystemUtils.h"
+
+#include <vector>
+#include <glm/glm.hpp>
+#include <glm/gtc/matrix_transform.hpp>
+#include <glm/gtc/type_ptr.hpp>
+
+dawn::Device device;
+
+dawn::Buffer indexBuffer;
+dawn::Buffer vertexBuffer;
+dawn::Buffer planeBuffer;
+dawn::Buffer cameraBuffer;
+dawn::Buffer transformBuffer[2];
+
+dawn::BindGroup cameraBindGroup;
+dawn::BindGroup bindGroup[2];
+dawn::BindGroup cubeTransformBindGroup[2];
+
+dawn::Queue queue;
+dawn::SwapChain swapchain;
+dawn::TextureView depthStencilView;
+dawn::RenderPipeline pipeline;
+dawn::RenderPipeline planePipeline;
+dawn::RenderPipeline reflectionPipeline;
+
+void initBuffers() {
+ static const uint32_t indexData[6*6] = {
+ 0, 1, 2,
+ 0, 2, 3,
+
+ 4, 5, 6,
+ 4, 6, 7,
+
+ 8, 9, 10,
+ 8, 10, 11,
+
+ 12, 13, 14,
+ 12, 14, 15,
+
+ 16, 17, 18,
+ 16, 18, 19,
+
+ 20, 21, 22,
+ 20, 22, 23
+ };
+ indexBuffer = utils::CreateBufferFromData(device, indexData, sizeof(indexData), dawn::BufferUsageBit::Index);
+
+ static const float vertexData[6 * 4 * 6] = {
+ -1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
+ 1.0, -1.0, 1.0, 1.0, 0.0, 0.0,
+ 1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
+ -1.0, 1.0, 1.0, 1.0, 0.0, 0.0,
+
+ -1.0, -1.0, -1.0, 1.0, 1.0, 0.0,
+ -1.0, 1.0, -1.0, 1.0, 1.0, 0.0,
+ 1.0, 1.0, -1.0, 1.0, 1.0, 0.0,
+ 1.0, -1.0, -1.0, 1.0, 1.0, 0.0,
+
+ -1.0, 1.0, -1.0, 1.0, 0.0, 1.0,
+ -1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
+ 1.0, 1.0, 1.0, 1.0, 0.0, 1.0,
+ 1.0, 1.0, -1.0, 1.0, 0.0, 1.0,
+
+ -1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
+ 1.0, -1.0, -1.0, 0.0, 1.0, 0.0,
+ 1.0, -1.0, 1.0, 0.0, 1.0, 0.0,
+ -1.0, -1.0, 1.0, 0.0, 1.0, 0.0,
+
+ 1.0, -1.0, -1.0, 0.0, 1.0, 1.0,
+ 1.0, 1.0, -1.0, 0.0, 1.0, 1.0,
+ 1.0, 1.0, 1.0, 0.0, 1.0, 1.0,
+ 1.0, -1.0, 1.0, 0.0, 1.0, 1.0,
+
+ -1.0, -1.0, -1.0, 1.0, 1.0, 1.0,
+ -1.0, -1.0, 1.0, 1.0, 1.0, 1.0,
+ -1.0, 1.0, 1.0, 1.0, 1.0, 1.0,
+ -1.0, 1.0, -1.0, 1.0, 1.0, 1.0
+ };
+ vertexBuffer = utils::CreateBufferFromData(device, vertexData, sizeof(vertexData), dawn::BufferUsageBit::Vertex);
+
+ static const float planeData[6 * 4] = {
+ -2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
+ 2.0, -1.0, -2.0, 0.5, 0.5, 0.5,
+ 2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
+ -2.0, -1.0, 2.0, 0.5, 0.5, 0.5,
+ };
+ planeBuffer = utils::CreateBufferFromData(device, planeData, sizeof(planeData), dawn::BufferUsageBit::Vertex);
+}
+
+struct CameraData {
+ glm::mat4 view;
+ glm::mat4 proj;
+} cameraData;
+
+void init() {
+ device = CreateCppDawnDevice();
+
+ queue = device.CreateQueue();
+ swapchain = GetSwapChain(device);
+ swapchain.Configure(GetPreferredSwapChainTextureFormat(),
+ dawn::TextureUsageBit::OutputAttachment, 640, 480);
+
+ initBuffers();
+
+ dawn::ShaderModule vsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
+ #version 450
+ layout(set = 0, binding = 0) uniform cameraData {
+ mat4 view;
+ mat4 proj;
+ } camera;
+ layout(set = 0, binding = 1) uniform modelData {
+ mat4 modelMatrix;
+ };
+ layout(location = 0) in vec3 pos;
+ layout(location = 1) in vec3 col;
+ layout(location = 2) out vec3 f_col;
+ void main() {
+ f_col = col;
+ gl_Position = camera.proj * camera.view * modelMatrix * vec4(pos, 1.0);
+ })"
+ );
+
+ dawn::ShaderModule fsModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
+ #version 450
+ layout(location = 2) in vec3 f_col;
+ layout(location = 0) out vec4 fragColor;
+ void main() {
+ fragColor = vec4(f_col, 1.0);
+ })");
+
+ dawn::ShaderModule fsReflectionModule =
+ utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
+ #version 450
+ layout(location = 2) in vec3 f_col;
+ layout(location = 0) out vec4 fragColor;
+ void main() {
+ fragColor = vec4(mix(f_col, vec3(0.5, 0.5, 0.5), 0.5), 1.0);
+ })");
+
+ auto inputState = device.CreateInputStateBuilder()
+ .SetAttribute(0, 0, dawn::VertexFormat::FloatR32G32B32, 0)
+ .SetAttribute(1, 0, dawn::VertexFormat::FloatR32G32B32, 3 * sizeof(float))
+ .SetInput(0, 6 * sizeof(float), dawn::InputStepMode::Vertex)
+ .GetResult();
+
+ auto bgl = utils::MakeBindGroupLayout(
+ device, {
+ {0, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
+ {1, dawn::ShaderStageBit::Vertex, dawn::BindingType::UniformBuffer},
+ });
+
+ dawn::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
+
+ dawn::BufferDescriptor cameraBufDesc;
+ cameraBufDesc.size = sizeof(CameraData);
+ cameraBufDesc.usage = dawn::BufferUsageBit::TransferDst | dawn::BufferUsageBit::Uniform;
+ cameraBuffer = device.CreateBuffer(&cameraBufDesc);
+
+ glm::mat4 transform(1.0);
+ transformBuffer[0] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4), dawn::BufferUsageBit::Uniform);
+
+ transform = glm::translate(transform, glm::vec3(0.f, -2.f, 0.f));
+ transformBuffer[1] = utils::CreateBufferFromData(device, &transform, sizeof(glm::mat4), dawn::BufferUsageBit::Uniform);
+
+ dawn::BufferView cameraBufferView = cameraBuffer.CreateBufferViewBuilder()
+ .SetExtent(0, sizeof(CameraData))
+ .GetResult();
+
+ dawn::BufferView transformBufferView[2] = {
+ transformBuffer[0].CreateBufferViewBuilder()
+ .SetExtent(0, sizeof(glm::mat4))
+ .GetResult(),
+ transformBuffer[1].CreateBufferViewBuilder()
+ .SetExtent(0, sizeof(glm::mat4))
+ .GetResult(),
+ };
+
+ bindGroup[0] = device.CreateBindGroupBuilder()
+ .SetLayout(bgl)
+ .SetBufferViews(0, 1, &cameraBufferView)
+ .SetBufferViews(1, 1, &transformBufferView[0])
+ .GetResult();
+
+ bindGroup[1] = device.CreateBindGroupBuilder()
+ .SetLayout(bgl)
+ .SetBufferViews(0, 1, &cameraBufferView)
+ .SetBufferViews(1, 1, &transformBufferView[1])
+ .GetResult();
+
+ depthStencilView = CreateDefaultDepthStencilView(device);
+
+ auto depthStencilState = device.CreateDepthStencilStateBuilder()
+ .SetDepthCompareFunction(dawn::CompareFunction::Less)
+ .SetDepthWriteEnabled(true)
+ .GetResult();
+
+ pipeline = device.CreateRenderPipelineBuilder()
+ .SetColorAttachmentFormat(0, GetPreferredSwapChainTextureFormat())
+ .SetDepthStencilAttachmentFormat(dawn::TextureFormat::D32FloatS8Uint)
+ .SetLayout(pl)
+ .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
+ .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
+ .SetIndexFormat(dawn::IndexFormat::Uint32)
+ .SetInputState(inputState)
+ .SetDepthStencilState(depthStencilState)
+ .GetResult();
+
+ auto planeStencilState = device.CreateDepthStencilStateBuilder()
+ .SetDepthCompareFunction(dawn::CompareFunction::Less)
+ .SetDepthWriteEnabled(false)
+ .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Always, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
+ .GetResult();
+
+ planePipeline = device.CreateRenderPipelineBuilder()
+ .SetColorAttachmentFormat(0, GetPreferredSwapChainTextureFormat())
+ .SetDepthStencilAttachmentFormat(dawn::TextureFormat::D32FloatS8Uint)
+ .SetLayout(pl)
+ .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
+ .SetStage(dawn::ShaderStage::Fragment, fsModule, "main")
+ .SetInputState(inputState)
+ .SetDepthStencilState(planeStencilState)
+ .GetResult();
+
+ auto reflectionStencilState = device.CreateDepthStencilStateBuilder()
+ .SetDepthCompareFunction(dawn::CompareFunction::Less)
+ .SetDepthWriteEnabled(true)
+ .SetStencilFunction(dawn::Face::Both, dawn::CompareFunction::Equal, dawn::StencilOperation::Keep, dawn::StencilOperation::Keep, dawn::StencilOperation::Replace)
+ .GetResult();
+
+ reflectionPipeline = device.CreateRenderPipelineBuilder()
+ .SetColorAttachmentFormat(0, GetPreferredSwapChainTextureFormat())
+ .SetDepthStencilAttachmentFormat(dawn::TextureFormat::D32FloatS8Uint)
+ .SetLayout(pl)
+ .SetStage(dawn::ShaderStage::Vertex, vsModule, "main")
+ .SetStage(dawn::ShaderStage::Fragment, fsReflectionModule, "main")
+ .SetInputState(inputState)
+ .SetDepthStencilState(reflectionStencilState)
+ .GetResult();
+
+ cameraData.proj = glm::perspective(glm::radians(45.0f), 1.f, 1.0f, 100.0f);
+}
+
+struct {uint32_t a; float b;} s;
+void frame() {
+ s.a = (s.a + 1) % 256;
+ s.b += 0.01f;
+ if (s.b >= 1.0f) {s.b = 0.0f;}
+ static const uint32_t vertexBufferOffsets[1] = {0};
+
+ cameraData.view = glm::lookAt(
+ glm::vec3(8.f * std::sin(glm::radians(s.b * 360.f)), 2.f, 8.f * std::cos(glm::radians(s.b * 360.f))),
+ glm::vec3(0.0f, 0.0f, 0.0f),
+ glm::vec3(0.0f, -1.0f, 0.0f)
+ );
+
+ cameraBuffer.SetSubData(0, sizeof(CameraData), reinterpret_cast<uint8_t*>(&cameraData));
+
+ dawn::Texture backbuffer;
+ dawn::RenderPassDescriptor renderPass;
+ GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
+
+ dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
+ {
+ dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+ pass.SetRenderPipeline(pipeline);
+ pass.SetBindGroup(0, bindGroup[0]);
+ pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
+ pass.SetIndexBuffer(indexBuffer, 0);
+ pass.DrawElements(36, 1, 0, 0);
+
+ pass.SetStencilReference(0x1);
+ pass.SetRenderPipeline(planePipeline);
+ pass.SetBindGroup(0, bindGroup[0]);
+ pass.SetVertexBuffers(0, 1, &planeBuffer, vertexBufferOffsets);
+ pass.DrawElements(6, 1, 0, 0);
+
+ pass.SetRenderPipeline(reflectionPipeline);
+ pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
+ pass.SetBindGroup(0, bindGroup[1]);
+ pass.DrawElements(36, 1, 0, 0);
+
+ pass.EndPass();
+ }
+
+ dawn::CommandBuffer commands = builder.GetResult();
+ queue.Submit(1, &commands);
+ swapchain.Present(backbuffer);
+ DoFlush();
+}
+
+int main(int argc, const char* argv[]) {
+ if (!InitSample(argc, argv)) {
+ return 1;
+ }
+ init();
+
+ while (!ShouldQuit()) {
+ frame();
+ utils::USleep(16000);
+ }
+
+ // TODO release stuff
+}
diff --git a/chromium/third_party/dawn/examples/SampleUtils.cpp b/chromium/third_party/dawn/examples/SampleUtils.cpp
new file mode 100644
index 00000000000..0c01964a1ae
--- /dev/null
+++ b/chromium/third_party/dawn/examples/SampleUtils.cpp
@@ -0,0 +1,231 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "SampleUtils.h"
+
+#include "common/Assert.h"
+#include "common/Platform.h"
+#include "utils/BackendBinding.h"
+#include "utils/TerribleCommandBuffer.h"
+
+#include <dawn/dawn.h>
+#include <dawn/dawncpp.h>
+#include <dawn/dawn_wsi.h>
+#include <dawn_native/DawnNative.h>
+#include "GLFW/glfw3.h"
+
+#include <cstring>
+#include <iostream>
+
+void PrintDeviceError(const char* message, dawn::CallbackUserdata) {
+ std::cout << "Device error: " << message << std::endl;
+}
+
+void PrintGLFWError(int code, const char* message) {
+ std::cout << "GLFW error: " << code << " - " << message << std::endl;
+}
+
+enum class CmdBufType {
+ None,
+ Terrible,
+ //TODO(cwallez@chromium.org) double terrible cmdbuf
+};
+
+// Default to D3D12, Metal, Vulkan, OpenGL in that order as D3D12 and Metal are the preferred on
+// their respective platforms, and Vulkan is preferred to OpenGL
+#if defined(DAWN_ENABLE_BACKEND_D3D12)
+ static utils::BackendType backendType = utils::BackendType::D3D12;
+#elif defined(DAWN_ENABLE_BACKEND_METAL)
+ static utils::BackendType backendType = utils::BackendType::Metal;
+#elif defined(DAWN_ENABLE_BACKEND_OPENGL)
+ static utils::BackendType backendType = utils::BackendType::OpenGL;
+#elif defined(DAWN_ENABLE_BACKEND_VULKAN)
+ static utils::BackendType backendType = utils::BackendType::Vulkan;
+#else
+ #error
+#endif
+
+static CmdBufType cmdBufType = CmdBufType::Terrible;
+static utils::BackendBinding* binding = nullptr;
+
+static GLFWwindow* window = nullptr;
+
+static dawn_wire::CommandHandler* wireServer = nullptr;
+static dawn_wire::CommandHandler* wireClient = nullptr;
+static utils::TerribleCommandBuffer* c2sBuf = nullptr;
+static utils::TerribleCommandBuffer* s2cBuf = nullptr;
+
+dawn::Device CreateCppDawnDevice() {
+ binding = utils::CreateBinding(backendType);
+ if (binding == nullptr) {
+ return dawn::Device();
+ }
+
+ glfwSetErrorCallback(PrintGLFWError);
+ if (!glfwInit()) {
+ return dawn::Device();
+ }
+
+ binding->SetupGLFWWindowHints();
+ window = glfwCreateWindow(640, 480, "Dawn window", nullptr, nullptr);
+ if (!window) {
+ return dawn::Device();
+ }
+
+ binding->SetWindow(window);
+
+ dawnDevice backendDevice = binding->CreateDevice();
+ dawnProcTable backendProcs = dawn_native::GetProcs();
+
+ dawnDevice cDevice = nullptr;
+ dawnProcTable procs;
+ switch (cmdBufType) {
+ case CmdBufType::None:
+ procs = backendProcs;
+ cDevice = backendDevice;
+ break;
+
+ case CmdBufType::Terrible:
+ {
+ c2sBuf = new utils::TerribleCommandBuffer();
+ s2cBuf = new utils::TerribleCommandBuffer();
+
+ wireServer = dawn_wire::NewServerCommandHandler(backendDevice, backendProcs, s2cBuf);
+ c2sBuf->SetHandler(wireServer);
+
+ dawnDevice clientDevice;
+ dawnProcTable clientProcs;
+ wireClient = dawn_wire::NewClientDevice(&clientProcs, &clientDevice, c2sBuf);
+ s2cBuf->SetHandler(wireClient);
+
+ procs = clientProcs;
+ cDevice = clientDevice;
+ }
+ break;
+ }
+
+ dawnSetProcs(&procs);
+ procs.deviceSetErrorCallback(cDevice, PrintDeviceError, 0);
+ return dawn::Device::Acquire(cDevice);
+}
+
+uint64_t GetSwapChainImplementation() {
+ return binding->GetSwapChainImplementation();
+}
+
+dawn::TextureFormat GetPreferredSwapChainTextureFormat() {
+ DoFlush();
+ return static_cast<dawn::TextureFormat>(binding->GetPreferredSwapChainTextureFormat());
+}
+
+dawn::SwapChain GetSwapChain(const dawn::Device &device) {
+ return device.CreateSwapChainBuilder()
+ .SetImplementation(GetSwapChainImplementation())
+ .GetResult();
+}
+
+dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device) {
+ dawn::TextureDescriptor descriptor;
+ descriptor.dimension = dawn::TextureDimension::e2D;
+ descriptor.size.width = 640;
+ descriptor.size.height = 480;
+ descriptor.size.depth = 1;
+ descriptor.arrayLayer = 1;
+ descriptor.format = dawn::TextureFormat::D32FloatS8Uint;
+ descriptor.levelCount = 1;
+ descriptor.usage = dawn::TextureUsageBit::OutputAttachment;
+ auto depthStencilTexture = device.CreateTexture(&descriptor);
+ return depthStencilTexture.CreateDefaultTextureView();
+}
+
+void GetNextRenderPassDescriptor(const dawn::Device& device,
+ const dawn::SwapChain& swapchain,
+ const dawn::TextureView& depthStencilView,
+ dawn::Texture* backbuffer,
+ dawn::RenderPassDescriptor* info) {
+ *backbuffer = swapchain.GetNextTexture();
+ auto backbufferView = backbuffer->CreateDefaultTextureView();
+ *info = device.CreateRenderPassDescriptorBuilder()
+ .SetColorAttachment(0, backbufferView, dawn::LoadOp::Clear)
+ .SetDepthStencilAttachment(depthStencilView, dawn::LoadOp::Clear, dawn::LoadOp::Clear)
+ .GetResult();
+}
+
+bool InitSample(int argc, const char** argv) {
+ for (int i = 1; i < argc; i++) {
+ if (std::string("-b") == argv[i] || std::string("--backend") == argv[i]) {
+ i++;
+ if (i < argc && std::string("d3d12") == argv[i]) {
+ backendType = utils::BackendType::D3D12;
+ continue;
+ }
+ if (i < argc && std::string("metal") == argv[i]) {
+ backendType = utils::BackendType::Metal;
+ continue;
+ }
+ if (i < argc && std::string("null") == argv[i]) {
+ backendType = utils::BackendType::Null;
+ continue;
+ }
+ if (i < argc && std::string("opengl") == argv[i]) {
+ backendType = utils::BackendType::OpenGL;
+ continue;
+ }
+ if (i < argc && std::string("vulkan") == argv[i]) {
+ backendType = utils::BackendType::Vulkan;
+ continue;
+ }
+ fprintf(stderr, "--backend expects a backend name (opengl, metal, d3d12, null, vulkan)\n");
+ return false;
+ }
+ if (std::string("-c") == argv[i] || std::string("--command-buffer") == argv[i]) {
+ i++;
+ if (i < argc && std::string("none") == argv[i]) {
+ cmdBufType = CmdBufType::None;
+ continue;
+ }
+ if (i < argc && std::string("terrible") == argv[i]) {
+ cmdBufType = CmdBufType::Terrible;
+ continue;
+ }
+ fprintf(stderr, "--command-buffer expects a command buffer name (none, terrible)\n");
+ return false;
+ }
+ if (std::string("-h") == argv[i] || std::string("--help") == argv[i]) {
+ printf("Usage: %s [-b BACKEND] [-c COMMAND_BUFFER]\n", argv[0]);
+ printf(" BACKEND is one of: d3d12, metal, null, opengl, vulkan\n");
+ printf(" COMMAND_BUFFER is one of: none, terrible\n");
+ return false;
+ }
+ }
+ return true;
+}
+
+void DoFlush() {
+ if (cmdBufType == CmdBufType::Terrible) {
+ bool c2sSuccess = c2sBuf->Flush();
+ bool s2cSuccess = s2cBuf->Flush();
+
+ ASSERT(c2sSuccess && s2cSuccess);
+ }
+ glfwPollEvents();
+}
+
+bool ShouldQuit() {
+ return glfwWindowShouldClose(window);
+}
+
+GLFWwindow* GetGLFWWindow() {
+ return window;
+}
diff --git a/chromium/third_party/dawn/examples/SampleUtils.h b/chromium/third_party/dawn/examples/SampleUtils.h
new file mode 100644
index 00000000000..bbe37b269f3
--- /dev/null
+++ b/chromium/third_party/dawn/examples/SampleUtils.h
@@ -0,0 +1,34 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <dawn/dawncpp.h>
+#include <dawn/dawn_wsi.h>
+
+bool InitSample(int argc, const char** argv);
+void DoFlush();
+bool ShouldQuit();
+
+struct GLFWwindow;
+struct GLFWwindow* GetGLFWWindow();
+
+dawn::Device CreateCppDawnDevice();
+uint64_t GetSwapChainImplementation();
+dawn::TextureFormat GetPreferredSwapChainTextureFormat();
+dawn::SwapChain GetSwapChain(const dawn::Device& device);
+dawn::TextureView CreateDefaultDepthStencilView(const dawn::Device& device);
+void GetNextRenderPassDescriptor(const dawn::Device& device,
+ const dawn::SwapChain& swapchain,
+ const dawn::TextureView& depthStencilView,
+ dawn::Texture* backbuffer,
+ dawn::RenderPassDescriptor* info);
diff --git a/chromium/third_party/dawn/examples/glTFViewer/Camera.inl b/chromium/third_party/dawn/examples/glTFViewer/Camera.inl
new file mode 100644
index 00000000000..530e8b17314
--- /dev/null
+++ b/chromium/third_party/dawn/examples/glTFViewer/Camera.inl
@@ -0,0 +1,67 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+class Camera {
+ public:
+ Camera()
+ : _azimuth(glm::radians(45.f)),
+ _altitude(glm::radians(30.f)),
+ _radius(10.f),
+ _center(0, 0, 0),
+ _dirty(true) {
+ recalculate();
+ }
+
+ void rotate(float dAzimuth, float dAltitude) {
+ _dirty = true;
+ _azimuth = glm::mod(_azimuth + dAzimuth, glm::radians(360.f));
+ _altitude = glm::clamp(_altitude + dAltitude, glm::radians(-89.f), glm::radians(89.f));
+ }
+
+ void pan(float dX, float dY) {
+ recalculate();
+ glm::vec3 vX = glm::normalize(glm::cross(-_eyeDir, glm::vec3(0, 1, 0)));
+ glm::vec3 vY = glm::normalize(glm::cross(_eyeDir, vX));
+ _center += vX * dX * _radius + vY * dY * _radius;
+ }
+
+ void zoom(float factor) {
+ _dirty = true;
+ _radius = _radius * glm::exp(-factor);
+ }
+
+ glm::mat4 view() {
+ if (_dirty) {
+ recalculate();
+ }
+ return _view;
+ }
+ private:
+ void recalculate() {
+ glm::vec4 eye4 = glm::vec4(1, 0, 0, 1);
+ eye4 = glm::rotate(glm::mat4(), _altitude, glm::vec3(0, 0, 1)) * eye4;
+ eye4 = glm::rotate(glm::mat4(), _azimuth, glm::vec3(0, 1, 0)) * eye4;
+ _eyeDir = glm::vec3(eye4);
+
+ _view = glm::lookAt(_center + _eyeDir * _radius, _center, glm::vec3(0, -1, 0));
+ _dirty = false;
+ }
+ float _azimuth;
+ float _altitude;
+ float _radius;
+ glm::vec3 _center;
+ glm::vec3 _eyeDir;
+ bool _dirty;
+ glm::mat4 _view;
+};
diff --git a/chromium/third_party/dawn/examples/glTFViewer/README.md b/chromium/third_party/dawn/examples/glTFViewer/README.md
new file mode 100644
index 00000000000..d1ddf6bde99
--- /dev/null
+++ b/chromium/third_party/dawn/examples/glTFViewer/README.md
@@ -0,0 +1,30 @@
+# Dawn glTF Viewer
+
+This is a barebones glTF model viewer using the Dawn API. It is intended as a
+proof of concept for the API and is not a robust model viewer. It can load
+basic mesh/texture data from a few
+[glTF sample models](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/1.0),
+such as:
+
+* 2CylinderEngine
+* BoxWithoutIndices
+* Cesium Man
+* Duck
+* Monster
+* VC (Virtual City)
+
+## Usage
+
+`build/examples/glTFViewer/glTFViewer path/to/Duck.gltf`
+
+`build/examples/glTFViewer/glTFViewer path/to/Duck.gltf --backend metal`
+
+## Screenshots
+
+Duck:
+
+![Duck](img/nxt-gltf-duck.jpg)
+
+VC (Virtual City):
+
+![Virtual City](img/nxt-gltf-vc.jpg)
diff --git a/chromium/third_party/dawn/examples/glTFViewer/glTFViewer.cpp b/chromium/third_party/dawn/examples/glTFViewer/glTFViewer.cpp
new file mode 100644
index 00000000000..873a2461c9f
--- /dev/null
+++ b/chromium/third_party/dawn/examples/glTFViewer/glTFViewer.cpp
@@ -0,0 +1,663 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Enable this before including any headers as we want inttypes.h to define
+// format macros such as PRId64 that are used in picojson.
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
+#endif
+
+#include "../SampleUtils.h"
+
+#include "common/Assert.h"
+#include "common/Math.h"
+#include "common/Constants.h"
+#include "utils/DawnHelpers.h"
+#include "utils/SystemUtils.h"
+
+#include <bitset>
+#define GLM_FORCE_DEPTH_ZERO_TO_ONE
+#include <glm/mat4x4.hpp>
+#include <glm/gtc/matrix_inverse.hpp>
+#include <glm/gtc/matrix_transform.hpp>
+#include <glm/gtc/type_ptr.hpp>
+
+#define TINYGLTF_LOADER_IMPLEMENTATION
+#define STB_IMAGE_IMPLEMENTATION
+#define PICOJSON_ASSERT ASSERT
+#undef __STDC_FORMAT_MACROS
+#include <tinygltfloader/tiny_gltf_loader.h>
+
+#include "GLFW/glfw3.h"
+
+#include "Camera.inl"
+
+namespace gl {
+ enum {
+ Triangles = 0x0004,
+ UnsignedShort = 0x1403,
+ UnsignedInt = 0x1405,
+ Float = 0x1406,
+ RGBA = 0x1908,
+ Nearest = 0x2600,
+ Linear = 0x2601,
+ NearestMipmapNearest = 0x2700,
+ LinearMipmapNearest = 0x2701,
+ NearestMipmapLinear = 0x2702,
+ LinearMipmapLinear = 0x2703,
+ ArrayBuffer = 0x8892,
+ ElementArrayBuffer = 0x8893,
+ FragmentShader = 0x8B30,
+ VertexShader = 0x8B31,
+ FloatVec2 = 0x8B50,
+ FloatVec3 = 0x8B51,
+ FloatVec4 = 0x8B52,
+ };
+}
+
+struct MaterialInfo {
+ dawn::RenderPipeline pipeline;
+ dawn::BindGroup bindGroup0;
+ std::map<uint32_t, std::string> slotSemantics;
+};
+
+struct u_transform_block {
+ glm::mat4 modelViewProj;
+ glm::mat4 modelInvTr;
+};
+
+dawn::Device device;
+dawn::Queue queue;
+dawn::SwapChain swapchain;
+dawn::TextureView depthStencilView;
+
+dawn::Buffer defaultBuffer;
+std::map<std::string, dawn::Buffer> buffers;
+std::map<std::string, dawn::CommandBuffer> commandBuffers;
+std::map<uint32_t, std::string> slotSemantics = {{0, "POSITION"}, {1, "NORMAL"}, {2, "TEXCOORD_0"}};
+
+std::map<std::string, dawn::Sampler> samplers;
+std::map<std::string, dawn::TextureView> textures;
+
+tinygltf::Scene scene;
+glm::mat4 projection = glm::perspective(glm::radians(60.f), 640.f/480, 0.1f, 2000.f);
+Camera camera;
+
+// Helpers
+namespace {
+ std::string getFilePathExtension(const std::string &FileName) {
+ if (FileName.find_last_of(".") != std::string::npos) {
+ return FileName.substr(FileName.find_last_of(".") + 1);
+ }
+ return "";
+ }
+
+ bool techniqueParameterTypeToVertexFormat(int type, dawn::VertexFormat *format) {
+ switch (type) {
+ case gl::FloatVec2:
+ *format = dawn::VertexFormat::FloatR32G32;
+ return true;
+ case gl::FloatVec3:
+ *format = dawn::VertexFormat::FloatR32G32B32;
+ return true;
+ case gl::FloatVec4:
+ *format = dawn::VertexFormat::FloatR32G32B32A32;
+ return true;
+ default:
+ return false;
+ }
+ }
+}
+
+// Initialization
+namespace {
+ void initBuffers() {
+ dawn::BufferDescriptor descriptor;
+ descriptor.size = 256;
+ descriptor.usage = dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Index;
+ defaultBuffer = device.CreateBuffer(&descriptor);
+
+ for (const auto& bv : scene.bufferViews) {
+ const auto& iBufferViewID = bv.first;
+ const auto& iBufferView = bv.second;
+
+ dawn::BufferUsageBit usage = dawn::BufferUsageBit::None;
+ switch (iBufferView.target) {
+ case gl::ArrayBuffer:
+ usage |= dawn::BufferUsageBit::Vertex;
+ break;
+ case gl::ElementArrayBuffer:
+ usage |= dawn::BufferUsageBit::Index;
+ break;
+ case 0:
+ fprintf(stderr, "TODO: buffer view has no target; skipping\n");
+ continue;
+ default:
+ fprintf(stderr, "unsupported buffer view target %d\n", iBufferView.target);
+ continue;
+ }
+ const auto& iBuffer = scene.buffers.at(iBufferView.buffer);
+
+ size_t iBufferViewSize =
+ iBufferView.byteLength ? iBufferView.byteLength :
+ (iBuffer.data.size() - iBufferView.byteOffset);
+ auto oBuffer = utils::CreateBufferFromData(device, &iBuffer.data.at(iBufferView.byteOffset), static_cast<uint32_t>(iBufferViewSize), usage);
+ buffers[iBufferViewID] = std::move(oBuffer);
+ }
+ }
+
+ const MaterialInfo& getMaterial(const std::string& iMaterialID, size_t stridePos, size_t strideNor, size_t strideTxc) {
+ static std::map<std::tuple<std::string, size_t, size_t, size_t>, MaterialInfo> materials;
+ auto key = make_tuple(iMaterialID, stridePos, strideNor, strideTxc);
+ auto materialIterator = materials.find(key);
+ if (materialIterator != materials.end()) {
+ return materialIterator->second;
+ }
+
+ const auto& iMaterial = scene.materials.at(iMaterialID);
+ const auto& iTechnique = scene.techniques.at(iMaterial.technique);
+
+ bool hasTexture = false;
+ std::string iTextureID;
+ {
+ auto it = iMaterial.values.find("diffuse");
+ if (it != iMaterial.values.end() && !it->second.string_value.empty()) {
+ hasTexture = true;
+ iTextureID = it->second.string_value;
+ }
+ }
+
+ auto oVSModule = utils::CreateShaderModule(device, dawn::ShaderStage::Vertex, R"(
+ #version 450
+
+ layout(push_constant) uniform u_transform_block {
+ mat4 modelViewProj;
+ mat4 modelInvTr;
+ } u_transform;
+
+ layout(location = 0) in vec4 a_position;
+ layout(location = 1) in vec3 a_normal;
+ layout(location = 2) in vec2 a_texcoord;
+
+ layout(location = 0) out vec3 v_normal;
+ layout(location = 1) out vec2 v_texcoord;
+
+ void main() {
+ v_normal = (u_transform.modelInvTr * vec4(normalize(a_normal), 0)).rgb;
+ v_texcoord = a_texcoord;
+ gl_Position = u_transform.modelViewProj * a_position;
+ })");
+
+ auto oFSSourceTextured = R"(
+ #version 450
+
+ layout(set = 0, binding = 0) uniform sampler u_samp;
+ layout(set = 0, binding = 1) uniform texture2D u_tex;
+
+ layout(location = 0) in vec3 v_normal;
+ layout(location = 1) in vec2 v_texcoord;
+
+ layout(location = 0) out vec4 fragcolor;
+
+ void main() {
+ const vec3 lightdir = normalize(vec3(-1, -2, 3));
+ vec3 normal = normalize(v_normal);
+ float diffuse = abs(dot(lightdir, normal));
+ float diffamb = diffuse * 0.85 + 0.15;
+ vec3 albedo = texture(sampler2D(u_tex, u_samp), v_texcoord).rgb;
+ fragcolor = vec4(diffamb * albedo, 1);
+ })";
+ auto oFSSourceUntextured = R"(
+ #version 450
+
+ layout(location = 0) in vec3 v_normal;
+ layout(location = 1) in vec2 v_texcoord;
+
+ layout(location = 0) out vec4 fragcolor;
+
+ void main() {
+ const vec3 lightdir = normalize(vec3(-1, -2, 3));
+ vec3 normal = normalize(v_normal);
+ float diffuse = abs(dot(lightdir, normal));
+ float diffamb = diffuse * 0.85 + 0.15;
+ fragcolor = vec4(vec3(diffamb), 1);
+ })";
+
+ auto oFSModule = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, hasTexture ? oFSSourceTextured : oFSSourceUntextured);
+
+ dawn::InputStateBuilder builder = device.CreateInputStateBuilder();
+ std::bitset<3> slotsSet;
+ for (const auto& a : iTechnique.attributes) {
+ const auto iAttributeName = a.first;
+ const auto iParameter = iTechnique.parameters.at(a.second);
+ dawn::VertexFormat format;
+ if (!techniqueParameterTypeToVertexFormat(iParameter.type, &format)) {
+ fprintf(stderr, "unsupported technique parameter type %d\n", iParameter.type);
+ continue;
+ }
+ if (iParameter.semantic == "POSITION") {
+ builder.SetAttribute(0, 0, format, 0);
+ builder.SetInput(0, static_cast<uint32_t>(stridePos), dawn::InputStepMode::Vertex);
+ slotsSet.set(0);
+ } else if (iParameter.semantic == "NORMAL") {
+ builder.SetAttribute(1, 1, format, 0);
+ builder.SetInput(1, static_cast<uint32_t>(strideNor), dawn::InputStepMode::Vertex);
+ slotsSet.set(1);
+ } else if (iParameter.semantic == "TEXCOORD_0") {
+ builder.SetAttribute(2, 2, format, 0);
+ builder.SetInput(2, static_cast<uint32_t>(strideTxc), dawn::InputStepMode::Vertex);
+ slotsSet.set(2);
+ } else {
+ fprintf(stderr, "unsupported technique attribute semantic %s\n", iParameter.semantic.c_str());
+ }
+ // TODO: use iAttributeParameter.node?
+ }
+ for (uint32_t i = 0; i < slotsSet.size(); i++) {
+ if (slotsSet[i]) {
+ continue;
+ }
+ builder.SetAttribute(i, i, dawn::VertexFormat::FloatR32G32B32A32, 0);
+ builder.SetInput(i, 0, dawn::InputStepMode::Vertex);
+ }
+ auto inputState = builder.GetResult();
+
+ constexpr dawn::ShaderStageBit kNoStages{};
+ dawn::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
+ device, {
+ {0, hasTexture ? dawn::ShaderStageBit::Fragment : kNoStages,
+ dawn::BindingType::Sampler},
+ {1, hasTexture ? dawn::ShaderStageBit::Fragment : kNoStages,
+ dawn::BindingType::SampledTexture},
+ });
+
+ auto depthStencilState = device.CreateDepthStencilStateBuilder()
+ .SetDepthCompareFunction(dawn::CompareFunction::Less)
+ .SetDepthWriteEnabled(true)
+ .GetResult();
+
+ auto pipelineLayout = utils::MakeBasicPipelineLayout(device, &bindGroupLayout);
+ auto pipeline = device.CreateRenderPipelineBuilder()
+ .SetColorAttachmentFormat(0, GetPreferredSwapChainTextureFormat())
+ .SetDepthStencilAttachmentFormat(dawn::TextureFormat::D32FloatS8Uint)
+ .SetLayout(pipelineLayout)
+ .SetStage(dawn::ShaderStage::Vertex, oVSModule, "main")
+ .SetStage(dawn::ShaderStage::Fragment, oFSModule, "main")
+ .SetIndexFormat(dawn::IndexFormat::Uint16)
+ .SetInputState(inputState)
+ .SetDepthStencilState(depthStencilState)
+ .GetResult();
+
+ auto bindGroupBuilder = device.CreateBindGroupBuilder();
+ bindGroupBuilder.SetLayout(bindGroupLayout);
+
+ if (hasTexture) {
+ const auto& textureView = textures[iTextureID];
+ const auto& iSamplerID = scene.textures[iTextureID].sampler;
+ bindGroupBuilder.SetSamplers(0, 1, &samplers[iSamplerID]);
+ bindGroupBuilder.SetTextureViews(1, 1, &textureView);
+ }
+
+ MaterialInfo material = {
+ pipeline.Get(),
+ bindGroupBuilder.GetResult(),
+ std::map<uint32_t, std::string>(),
+ };
+ materials[key] = std::move(material);
+ return materials.at(key);
+ }
+
+ void initSamplers() {
+ for (const auto& s : scene.samplers) {
+ const auto& iSamplerID = s.first;
+ const auto& iSampler = s.second;
+
+ dawn::SamplerDescriptor desc = utils::GetDefaultSamplerDescriptor();
+ // TODO: wrap modes
+
+ switch (iSampler.magFilter) {
+ case gl::Nearest:
+ desc.magFilter = dawn::FilterMode::Nearest;
+ break;
+ case gl::Linear:
+ desc.magFilter = dawn::FilterMode::Linear;
+ break;
+ default:
+ fprintf(stderr, "unsupported magFilter %d\n", iSampler.magFilter);
+ break;
+ }
+ switch (iSampler.minFilter) {
+ case gl::Nearest:
+ case gl::NearestMipmapNearest:
+ case gl::NearestMipmapLinear:
+ desc.minFilter = dawn::FilterMode::Nearest;
+ break;
+ case gl::Linear:
+ case gl::LinearMipmapNearest:
+ case gl::LinearMipmapLinear:
+ desc.minFilter = dawn::FilterMode::Linear;
+ break;
+ default:
+ fprintf(stderr, "unsupported minFilter %d\n", iSampler.magFilter);
+ break;
+ }
+ switch (iSampler.minFilter) {
+ case gl::NearestMipmapNearest:
+ case gl::LinearMipmapNearest:
+ desc.mipmapFilter = dawn::FilterMode::Nearest;
+ break;
+ case gl::NearestMipmapLinear:
+ case gl::LinearMipmapLinear:
+ desc.mipmapFilter = dawn::FilterMode::Linear;
+ break;
+ }
+
+ samplers[iSamplerID] = device.CreateSampler(&desc);
+ }
+ }
+
+ void initTextures() {
+ for (const auto& t : scene.textures) {
+ const auto& iTextureID = t.first;
+ const auto& iTexture = t.second;
+ const auto& iImage = scene.images[iTexture.source];
+
+ dawn::TextureFormat format = dawn::TextureFormat::R8G8B8A8Unorm;
+ switch (iTexture.format) {
+ case gl::RGBA:
+ format = dawn::TextureFormat::R8G8B8A8Unorm;
+ break;
+ default:
+ fprintf(stderr, "unsupported texture format %d\n", iTexture.format);
+ continue;
+ }
+
+ dawn::TextureDescriptor descriptor;
+ descriptor.dimension = dawn::TextureDimension::e2D;
+ descriptor.size.width = iImage.width;
+ descriptor.size.height = iImage.height;
+ descriptor.size.depth = 1;
+ descriptor.arrayLayer = 1;
+ descriptor.format = format;
+ descriptor.levelCount = 1;
+ descriptor.usage = dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Sampled;
+ auto oTexture = device.CreateTexture(&descriptor);
+ // TODO: release this texture
+
+ const uint8_t* origData = iImage.image.data();
+ const uint8_t* data = nullptr;
+ std::vector<uint8_t> newData;
+
+ uint32_t width = static_cast<uint32_t>(iImage.width);
+ uint32_t height = static_cast<uint32_t>(iImage.height);
+ uint32_t rowSize = width * 4;
+ uint32_t rowPitch = Align(rowSize, kTextureRowPitchAlignment);
+
+ if (iImage.component == 3 || iImage.component == 4) {
+ if (rowSize != rowPitch || iImage.component == 3) {
+ newData.resize(rowPitch * height);
+ uint32_t pixelsPerRow = rowPitch / 4;
+ for (uint32_t y = 0; y < height; ++y) {
+ for (uint32_t x = 0; x < width; ++x) {
+ size_t oldIndex = x + y * height;
+ size_t newIndex = x + y * pixelsPerRow;
+ if (iImage.component == 4) {
+ newData[4 * newIndex + 0] = origData[4 * oldIndex + 0];
+ newData[4 * newIndex + 1] = origData[4 * oldIndex + 1];
+ newData[4 * newIndex + 2] = origData[4 * oldIndex + 2];
+ newData[4 * newIndex + 3] = origData[4 * oldIndex + 3];
+ } else if (iImage.component == 3) {
+ newData[4 * newIndex + 0] = origData[3 * oldIndex + 0];
+ newData[4 * newIndex + 1] = origData[3 * oldIndex + 1];
+ newData[4 * newIndex + 2] = origData[3 * oldIndex + 2];
+ newData[4 * newIndex + 3] = 255;
+ }
+ }
+ }
+ data = newData.data();
+ } else {
+ data = origData;
+ }
+ } else {
+ fprintf(stderr, "unsupported image.component %d\n", iImage.component);
+ }
+
+ dawn::Buffer staging = utils::CreateBufferFromData(device, data, rowPitch * iImage.height, dawn::BufferUsageBit::TransferSrc);
+ dawn::BufferCopyView bufferCopyView =
+ utils::CreateBufferCopyView(staging, 0, rowPitch, 0);
+ dawn::TextureCopyView textureCopyView =
+ utils::CreateTextureCopyView(oTexture, 0, 0, {0, 0, 0}, dawn::TextureAspect::Color);
+ dawn::Extent3D copySize = {iImage.width, iImage.height, 1};
+ auto cmdbuf = device.CreateCommandBufferBuilder()
+ .CopyBufferToTexture(&bufferCopyView, &textureCopyView, &copySize)
+ .GetResult();
+ queue.Submit(1, &cmdbuf);
+
+ textures[iTextureID] = oTexture.CreateDefaultTextureView();
+ }
+ }
+
+ void init() {
+ device = CreateCppDawnDevice();
+
+ queue = device.CreateQueue();
+ swapchain = GetSwapChain(device);
+ swapchain.Configure(GetPreferredSwapChainTextureFormat(),
+ dawn::TextureUsageBit::OutputAttachment, 640, 480);
+
+ depthStencilView = CreateDefaultDepthStencilView(device);
+
+ initBuffers();
+ initSamplers();
+ initTextures();
+ }
+}
+
+// Drawing
+namespace {
+ void drawMesh(dawn::RenderPassEncoder& pass, const tinygltf::Mesh& iMesh, const glm::mat4& model) {
+ for (const auto& iPrim : iMesh.primitives) {
+ if (iPrim.mode != gl::Triangles) {
+ fprintf(stderr, "unsupported primitive mode %d\n", iPrim.mode);
+ continue;
+ }
+
+ u_transform_block transforms = {
+ (projection * camera.view() * model),
+ glm::inverseTranspose(model),
+ };
+
+ size_t strides[3] = {0};
+ for (const auto& s : slotSemantics) {
+ if (s.first < 3) {
+ auto it = iPrim.attributes.find(s.second);
+ if (it == iPrim.attributes.end()) {
+ continue;
+ }
+ const auto& iAccessorName = it->second;
+ strides[s.first] = scene.accessors.at(iAccessorName).byteStride;
+ }
+ }
+ const MaterialInfo& material = getMaterial(iPrim.material, strides[0], strides[1], strides[2]);
+ pass.SetRenderPipeline(material.pipeline);
+ pass.SetBindGroup(0, material.bindGroup0);
+ pass.SetPushConstants(dawn::ShaderStageBit::Vertex,
+ 0, sizeof(u_transform_block) / sizeof(uint32_t),
+ reinterpret_cast<const uint32_t*>(&transforms));
+
+ uint32_t vertexCount = 0;
+ for (const auto& s : slotSemantics) {
+ uint32_t slot = s.first;
+ auto it = iPrim.attributes.find(s.second);
+ if (it == iPrim.attributes.end()) {
+ uint32_t zero = 0;
+ pass.SetVertexBuffers(slot, 1, &defaultBuffer, &zero);
+ continue;
+ }
+ const auto& iAccessor = scene.accessors.at(it->second);
+ if (iAccessor.componentType != gl::Float ||
+ (iAccessor.type != TINYGLTF_TYPE_VEC4 && iAccessor.type != TINYGLTF_TYPE_VEC3 && iAccessor.type != TINYGLTF_TYPE_VEC2)) {
+ fprintf(stderr, "unsupported vertex accessor component type %d and type %d\n", iAccessor.componentType, iAccessor.type);
+ continue;
+ }
+
+ if (vertexCount == 0) {
+ vertexCount = static_cast<uint32_t>(iAccessor.count);
+ }
+ const auto& oBuffer = buffers.at(iAccessor.bufferView);
+ uint32_t iBufferOffset = static_cast<uint32_t>(iAccessor.byteOffset);
+ pass.SetVertexBuffers(slot, 1, &oBuffer, &iBufferOffset);
+ }
+
+ if (!iPrim.indices.empty()) {
+ const auto& iIndices = scene.accessors.at(iPrim.indices);
+ // DrawElements
+ if (iIndices.componentType != gl::UnsignedShort || iIndices.type != TINYGLTF_TYPE_SCALAR) {
+ fprintf(stderr, "unsupported index accessor component type %d and type %d\n", iIndices.componentType, iIndices.type);
+ continue;
+ }
+ const auto& oIndicesBuffer = buffers.at(iIndices.bufferView);
+ pass.SetIndexBuffer(oIndicesBuffer, static_cast<uint32_t>(iIndices.byteOffset));
+ pass.DrawElements(static_cast<uint32_t>(iIndices.count), 1, 0, 0);
+ } else {
+ // DrawArrays
+ pass.DrawArrays(vertexCount, 1, 0, 0);
+ }
+ }
+ }
+
+ void drawNode(dawn::RenderPassEncoder& pass, const tinygltf::Node& node, const glm::mat4& parent = glm::mat4()) {
+ glm::mat4 model;
+ if (node.matrix.size() == 16) {
+ model = glm::make_mat4(node.matrix.data());
+ } else {
+ if (node.scale.size() == 3) {
+ glm::vec3 scale = glm::make_vec3(node.scale.data());
+ model = glm::scale(model, scale);
+ }
+ if (node.rotation.size() == 4) {
+ glm::quat rotation = glm::make_quat(node.rotation.data());
+ model = glm::mat4_cast(rotation) * model;
+ }
+ if (node.translation.size() == 3) {
+ glm::vec3 translation = glm::make_vec3(node.translation.data());
+ model = glm::translate(model, translation);
+ }
+ }
+ model = parent * model;
+
+ for (const auto& meshID : node.meshes) {
+ drawMesh(pass, scene.meshes[meshID], model);
+ }
+ for (const auto& child : node.children) {
+ drawNode(pass, scene.nodes.at(child), model);
+ }
+ }
+
+ void frame() {
+ dawn::Texture backbuffer;
+ dawn::RenderPassDescriptor renderPass;
+ GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
+
+ const auto& defaultSceneNodes = scene.scenes.at(scene.defaultScene);
+ dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
+ {
+ dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+ for (const auto& n : defaultSceneNodes) {
+ const auto& node = scene.nodes.at(n);
+ drawNode(pass, node);
+ }
+ pass.EndPass();
+ }
+
+ dawn::CommandBuffer commands = builder.GetResult();
+ queue.Submit(1, &commands);
+
+ swapchain.Present(backbuffer);
+ DoFlush();
+ }
+}
+
+// Mouse camera control
+namespace {
+ bool buttons[GLFW_MOUSE_BUTTON_LAST + 1] = {0};
+
+ void mouseButtonCallback(GLFWwindow*, int button, int action, int) {
+ buttons[button] = (action == GLFW_PRESS);
+ }
+
+ void cursorPosCallback(GLFWwindow*, double mouseX, double mouseY) {
+ static double oldX, oldY;
+ float dX = static_cast<float>(mouseX - oldX);
+ float dY = static_cast<float>(mouseY - oldY);
+ oldX = mouseX;
+ oldY = mouseY;
+
+ if (buttons[2] || (buttons[0] && buttons[1])) {
+ camera.pan(-dX * 0.002f, dY * 0.002f);
+ } else if (buttons[0]) {
+ camera.rotate(dX * 0.01f, dY * 0.01f);
+ } else if (buttons[1]) {
+ camera.zoom(dY * -0.005f);
+ }
+ }
+
+ void scrollCallback(GLFWwindow*, double, double yoffset) {
+ camera.zoom(static_cast<float>(yoffset) * 0.04f);
+ }
+}
+
+int main(int argc, const char* argv[]) {
+ if (!InitSample(argc, argv)) {
+ return 1;
+ }
+ if (argc < 2) {
+ fprintf(stderr, "Usage: %s model.gltf [... Dawn Options]\n", argv[0]);
+ return 1;
+ }
+
+ tinygltf::TinyGLTFLoader loader;
+ std::string err;
+ std::string input_filename(argv[1]);
+ std::string ext = getFilePathExtension(input_filename);
+
+ bool ret = false;
+ if (ext.compare("glb") == 0) {
+ // assume binary glTF.
+ ret = loader.LoadBinaryFromFile(&scene, &err, input_filename.c_str());
+ } else {
+ // assume ascii glTF.
+ ret = loader.LoadASCIIFromFile(&scene, &err, input_filename.c_str());
+ }
+ if (!err.empty()) {
+ fprintf(stderr, "ERR: %s\n", err.c_str());
+ }
+ if (!ret) {
+ fprintf(stderr, "Failed to load .glTF : %s\n", argv[1]);
+ exit(-1);
+ }
+
+ init();
+
+ GLFWwindow* window = GetGLFWWindow();
+ glfwSetMouseButtonCallback(window, mouseButtonCallback);
+ glfwSetCursorPosCallback(window, cursorPosCallback);
+ glfwSetScrollCallback(window, scrollCallback);
+
+ while (!ShouldQuit()) {
+ frame();
+ utils::USleep(16000);
+ }
+
+ // TODO release stuff
+}
diff --git a/chromium/third_party/dawn/examples/glTFViewer/img/nxt-gltf-duck.jpg b/chromium/third_party/dawn/examples/glTFViewer/img/nxt-gltf-duck.jpg
new file mode 100644
index 00000000000..da78162a75b
--- /dev/null
+++ b/chromium/third_party/dawn/examples/glTFViewer/img/nxt-gltf-duck.jpg
Binary files differ
diff --git a/chromium/third_party/dawn/examples/glTFViewer/img/nxt-gltf-vc.jpg b/chromium/third_party/dawn/examples/glTFViewer/img/nxt-gltf-vc.jpg
new file mode 100644
index 00000000000..29f969497ae
--- /dev/null
+++ b/chromium/third_party/dawn/examples/glTFViewer/img/nxt-gltf-vc.jpg
Binary files differ
diff --git a/chromium/third_party/dawn/generator/extract_json.py b/chromium/third_party/dawn/generator/extract_json.py
new file mode 100644
index 00000000000..2cc4b3d6f61
--- /dev/null
+++ b/chromium/third_party/dawn/generator/extract_json.py
@@ -0,0 +1,35 @@
+#!/usr/bin/env python2
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+import os, sys, json
+
+if __name__ == "__main__":
+ if len(sys.argv) != 3:
+ print("Usage: extract_json.py JSON DIR")
+ sys.exit(1)
+
+ with open(sys.argv[1]) as f:
+ files = json.loads(f.read())
+
+ output_dir = sys.argv[2]
+
+ for (name, content) in files.iteritems():
+ output_file = output_dir + os.path.sep + name
+
+ directory = os.path.dirname(output_file)
+ if not os.path.exists(directory):
+ os.makedirs(directory)
+
+ with open(output_file, 'w') as outfile:
+ outfile.write(content)
diff --git a/chromium/third_party/dawn/generator/main.py b/chromium/third_party/dawn/generator/main.py
new file mode 100644
index 00000000000..e58daac59ee
--- /dev/null
+++ b/chromium/third_party/dawn/generator/main.py
@@ -0,0 +1,572 @@
+#!/usr/bin/env python2
+# Copyright 2017 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+############################################################
+# COMMON
+############################################################
+from collections import namedtuple
+
+class Name:
+ def __init__(self, name, native=False):
+ self.native = native
+ if native:
+ self.chunks = [name]
+ else:
+ self.chunks = name.split(' ')
+
+ def CamelChunk(self, chunk):
+ return chunk[0].upper() + chunk[1:]
+
+ def canonical_case(self):
+ return (' '.join(self.chunks)).lower()
+
+ def concatcase(self):
+ return ''.join(self.chunks)
+
+ def camelCase(self):
+ return self.chunks[0] + ''.join([self.CamelChunk(chunk) for chunk in self.chunks[1:]])
+
+ def CamelCase(self):
+ return ''.join([self.CamelChunk(chunk) for chunk in self.chunks])
+
+ def SNAKE_CASE(self):
+ return '_'.join([chunk.upper() for chunk in self.chunks])
+
+ def snake_case(self):
+ return '_'.join(self.chunks)
+
+class Type:
+ def __init__(self, name, record, native=False):
+ self.record = record
+ self.dict_name = name
+ self.name = Name(name, native=native)
+ self.category = record['category']
+ self.is_builder = self.name.canonical_case().endswith(" builder")
+
+EnumValue = namedtuple('EnumValue', ['name', 'value'])
+class EnumType(Type):
+ def __init__(self, name, record):
+ Type.__init__(self, name, record)
+ self.values = [EnumValue(Name(m['name']), m['value']) for m in self.record['values']]
+
+BitmaskValue = namedtuple('BitmaskValue', ['name', 'value'])
+class BitmaskType(Type):
+ def __init__(self, name, record):
+ Type.__init__(self, name, record)
+ self.values = [BitmaskValue(Name(m['name']), m['value']) for m in self.record['values']]
+ self.full_mask = 0
+ for value in self.values:
+ self.full_mask = self.full_mask | value.value
+
+class NativeType(Type):
+ def __init__(self, name, record):
+ Type.__init__(self, name, record, native=True)
+
+class NativelyDefined(Type):
+ def __init__(self, name, record):
+ Type.__init__(self, name, record)
+
+class MethodArgument:
+ def __init__(self, name, typ, annotation, optional):
+ self.name = name
+ self.type = typ
+ self.annotation = annotation
+ self.length = None
+ self.optional = optional
+
+Method = namedtuple('Method', ['name', 'return_type', 'arguments'])
+class ObjectType(Type):
+ def __init__(self, name, record):
+ Type.__init__(self, name, record)
+ self.methods = []
+ self.native_methods = []
+ self.built_type = None
+
+class StructureMember:
+ def __init__(self, name, typ, annotation, optional):
+ self.name = name
+ self.type = typ
+ self.annotation = annotation
+ self.length = None
+ self.optional = optional
+
+class StructureType(Type):
+ def __init__(self, name, record):
+ Type.__init__(self, name, record)
+ self.extensible = record.get("extensible", False)
+ self.members = []
+
+############################################################
+# PARSE
+############################################################
+import json
+
+def is_native_method(method):
+ return method.return_type.category == "natively defined" or \
+ any([arg.type.category == "natively defined" for arg in method.arguments])
+
+def link_object(obj, types):
+ def make_method(record):
+ arguments = []
+ arguments_by_name = {}
+ for a in record.get('args', []):
+ arg = MethodArgument(Name(a['name']), types[a['type']],
+ a.get('annotation', 'value'), a.get('optional', False))
+ arguments.append(arg)
+ arguments_by_name[arg.name.canonical_case()] = arg
+
+ for (arg, a) in zip(arguments, record.get('args', [])):
+ if arg.annotation != 'value':
+ if not 'length' in a:
+ if arg.type.category == 'structure':
+ arg.length = "constant"
+ arg.constant_length = 1
+ else:
+ assert(False)
+ elif a['length'] == 'strlen':
+ arg.length = 'strlen'
+ else:
+ arg.length = arguments_by_name[a['length']]
+
+ return Method(Name(record['name']), types[record.get('returns', 'void')], arguments)
+
+ methods = [make_method(m) for m in obj.record.get('methods', [])]
+ obj.methods = [method for method in methods if not is_native_method(method)]
+ obj.native_methods = [method for method in methods if is_native_method(method)]
+
+ # Compute the built object type for builders
+ if obj.is_builder:
+ for method in obj.methods:
+ if method.name.canonical_case() == "get result":
+ obj.built_type = method.return_type
+ break
+ assert(obj.built_type != None)
+
+def link_structure(struct, types):
+ def make_member(m):
+ return StructureMember(Name(m['name']), types[m['type']],
+ m.get('annotation', 'value'), m.get('optional', False))
+
+ members = []
+ members_by_name = {}
+ for m in struct.record['members']:
+ member = make_member(m)
+ members.append(member)
+ members_by_name[member.name.canonical_case()] = member
+ struct.members = members
+
+ for (member, m) in zip(members, struct.record['members']):
+ # TODO(kainino@chromium.org): More robust pointer/length handling?
+ if 'length' in m:
+ if m['length'] == 'strlen':
+ member.length = 'strlen'
+ else:
+ member.length = members_by_name[m['length']]
+
+# Sort structures so that if struct A has struct B as a member, then B is listed before A
+# This is a form of topological sort where we try to keep the order reasonably similar to the
+# original order (though th sort isn't technically stable).
+# It works by computing for each struct type what is the depth of its DAG of dependents, then
+# resorting based on that depth using Python's stable sort. This makes a toposort because if
+# A depends on B then its depth will be bigger than B's. It is also nice because all nodes
+# with the same depth are kept in the input order.
+def topo_sort_structure(structs):
+ for struct in structs:
+ struct.visited = False
+ struct.subdag_depth = 0
+
+ def compute_depth(struct):
+ if struct.visited:
+ return struct.subdag_depth
+
+ max_dependent_depth = 0
+ for member in struct.members:
+ if member.type.category == 'structure' and member.annotation == 'value':
+ max_dependent_depth = max(max_dependent_depth, compute_depth(member.type) + 1)
+
+ struct.subdag_depth = max_dependent_depth
+ struct.visited = True
+ return struct.subdag_depth
+
+ for struct in structs:
+ compute_depth(struct)
+
+ result = sorted(structs, key=lambda struct: struct.subdag_depth)
+
+ for struct in structs:
+ del struct.visited
+ del struct.subdag_depth
+
+ return result
+
+def parse_json(json):
+ category_to_parser = {
+ 'bitmask': BitmaskType,
+ 'enum': EnumType,
+ 'native': NativeType,
+ 'natively defined': NativelyDefined,
+ 'object': ObjectType,
+ 'structure': StructureType,
+ }
+
+ types = {}
+
+ by_category = {}
+ for name in category_to_parser.keys():
+ by_category[name] = []
+
+ for (name, record) in json.items():
+ if name[0] == '_':
+ continue
+ category = record['category']
+ parsed = category_to_parser[category](name, record)
+ by_category[category].append(parsed)
+ types[name] = parsed
+
+ for obj in by_category['object']:
+ link_object(obj, types)
+
+ for struct in by_category['structure']:
+ link_structure(struct, types)
+
+ for category in by_category.keys():
+ by_category[category] = sorted(by_category[category], key=lambda typ: typ.name.canonical_case())
+
+ by_category['structure'] = topo_sort_structure(by_category['structure'])
+
+ return {
+ 'types': types,
+ 'by_category': by_category
+ }
+
+#############################################################
+# OUTPUT
+#############################################################
+import re, os, sys
+from collections import OrderedDict
+
+kExtraPythonPath = '--extra-python-path'
+
+# Try using an additional python path from the arguments if present. This
+# isn't done through the regular argparse because PreprocessingLoader uses
+# jinja2 in the global scope before "main" gets to run.
+if kExtraPythonPath in sys.argv:
+ path = sys.argv[sys.argv.index(kExtraPythonPath) + 1]
+ sys.path.insert(1, path)
+
+import jinja2
+
+# A custom Jinja2 template loader that removes the extra indentation
+# of the template blocks so that the output is correctly indented
+class PreprocessingLoader(jinja2.BaseLoader):
+ def __init__(self, path):
+ self.path = path
+
+ def get_source(self, environment, template):
+ path = os.path.join(self.path, template)
+ if not os.path.exists(path):
+ raise jinja2.TemplateNotFound(template)
+ mtime = os.path.getmtime(path)
+ with open(path) as f:
+ source = self.preprocess(f.read())
+ return source, path, lambda: mtime == os.path.getmtime(path)
+
+ blockstart = re.compile('{%-?\s*(if|for|block)[^}]*%}')
+ blockend = re.compile('{%-?\s*end(if|for|block)[^}]*%}')
+
+ def preprocess(self, source):
+ lines = source.split('\n')
+
+ # Compute the current indentation level of the template blocks and remove their indentation
+ result = []
+ indentation_level = 0
+
+ for line in lines:
+ # The capture in the regex adds one element per block start or end so we divide by two
+ # there is also an extra line chunk corresponding to the line end, so we substract it.
+ numends = (len(self.blockend.split(line)) - 1) // 2
+ indentation_level -= numends
+
+ line = self.remove_indentation(line, indentation_level)
+
+ # Manually perform the lstrip_blocks jinja2 env options as it available starting from 2.7
+ # and Travis only has Jinja 2.6
+ if line.lstrip().startswith('{%'):
+ line = line.lstrip()
+
+ result.append(line)
+
+ numstarts = (len(self.blockstart.split(line)) - 1) // 2
+ indentation_level += numstarts
+
+ return '\n'.join(result) + '\n'
+
+ def remove_indentation(self, line, n):
+ for _ in range(n):
+ if line.startswith(' '):
+ line = line[4:]
+ elif line.startswith('\t'):
+ line = line[1:]
+ else:
+ assert(line.strip() == '')
+ return line
+
+FileRender = namedtuple('FileRender', ['template', 'output', 'params_dicts'])
+
+FileOutput = namedtuple('FileOutput', ['name', 'content'])
+
+def do_renders(renders, template_dir):
+ env = jinja2.Environment(loader=PreprocessingLoader(template_dir), trim_blocks=True, line_comment_prefix='//*')
+
+ outputs = []
+ for render in renders:
+ params = {}
+ for param_dict in render.params_dicts:
+ params.update(param_dict)
+ content = env.get_template(render.template).render(**params)
+ outputs.append(FileOutput(render.output, content))
+
+ return outputs
+
+#############################################################
+# MAIN SOMETHING WHATEVER
+#############################################################
+import argparse, sys
+
+def as_varName(*names):
+ return names[0].camelCase() + ''.join([name.CamelCase() for name in names[1:]])
+
+def as_cType(name):
+ if name.native:
+ return name.concatcase()
+ else:
+ return 'dawn' + name.CamelCase()
+
+def as_cppType(name):
+ if name.native:
+ return name.concatcase()
+ else:
+ return name.CamelCase()
+
+def decorate(name, typ, arg):
+ if arg.annotation == 'value':
+ return typ + ' ' + name
+ elif arg.annotation == '*':
+ return typ + '* ' + name
+ elif arg.annotation == 'const*':
+ return typ + ' const * ' + name
+ else:
+ assert(False)
+
+def annotated(typ, arg):
+ name = as_varName(arg.name)
+ return decorate(name, typ, arg)
+
+def as_cEnum(type_name, value_name):
+ assert(not type_name.native and not value_name.native)
+ return 'DAWN' + '_' + type_name.SNAKE_CASE() + '_' + value_name.SNAKE_CASE()
+
+def as_cppEnum(value_name):
+ assert(not value_name.native)
+ if value_name.concatcase()[0].isdigit():
+ return "e" + value_name.CamelCase()
+ return value_name.CamelCase()
+
+def as_cMethod(type_name, method_name):
+ assert(not type_name.native and not method_name.native)
+ return 'dawn' + type_name.CamelCase() + method_name.CamelCase()
+
+def as_MethodSuffix(type_name, method_name):
+ assert(not type_name.native and not method_name.native)
+ return type_name.CamelCase() + method_name.CamelCase()
+
+def as_cProc(type_name, method_name):
+ assert(not type_name.native and not method_name.native)
+ return 'dawn' + 'Proc' + type_name.CamelCase() + method_name.CamelCase()
+
+def as_frontendType(typ):
+ if typ.category == 'object':
+ if typ.is_builder:
+ return typ.name.CamelCase() + '*'
+ else:
+ return typ.name.CamelCase() + 'Base*'
+ elif typ.category in ['bitmask', 'enum']:
+ return 'dawn::' + typ.name.CamelCase()
+ elif typ.category == 'structure':
+ return as_cppType(typ.name)
+ else:
+ return as_cType(typ.name)
+
+def cpp_native_methods(types, typ):
+ methods = typ.methods + typ.native_methods
+
+ if typ.is_builder:
+ methods.append(Method(Name('set error callback'), types['void'], [
+ MethodArgument(Name('callback'), types['builder error callback'], 'value', False),
+ MethodArgument(Name('userdata1'), types['callback userdata'], 'value', False),
+ MethodArgument(Name('userdata2'), types['callback userdata'], 'value', False),
+ ]))
+
+ return methods
+
+def c_native_methods(types, typ):
+ return cpp_native_methods(types, typ) + [
+ Method(Name('reference'), types['void'], []),
+ Method(Name('release'), types['void'], []),
+ ]
+
+def js_native_methods(types, typ):
+ return cpp_native_methods(types, typ)
+
+def debug(text):
+ print(text)
+
+def get_renders_for_targets(api_params, targets):
+ base_params = {
+ 'enumerate': enumerate,
+ 'format': format,
+ 'len': len,
+ 'debug': debug,
+
+ 'Name': lambda name: Name(name),
+
+ 'as_annotated_cType': lambda arg: annotated(as_cType(arg.type.name), arg),
+ 'as_annotated_cppType': lambda arg: annotated(as_cppType(arg.type.name), arg),
+ 'as_cEnum': as_cEnum,
+ 'as_cppEnum': as_cppEnum,
+ 'as_cMethod': as_cMethod,
+ 'as_MethodSuffix': as_MethodSuffix,
+ 'as_cProc': as_cProc,
+ 'as_cType': as_cType,
+ 'as_cppType': as_cppType,
+ 'as_varName': as_varName,
+ 'decorate': decorate,
+ }
+
+ renders = []
+
+ c_params = {'native_methods': lambda typ: c_native_methods(api_params['types'], typ)}
+ cpp_params = {'native_methods': lambda typ: cpp_native_methods(api_params['types'], typ)}
+
+ if 'dawn_headers' in targets:
+ renders.append(FileRender('api.h', 'dawn/dawn.h', [base_params, api_params, c_params]))
+ renders.append(FileRender('apicpp.h', 'dawn/dawncpp.h', [base_params, api_params, cpp_params]))
+ renders.append(FileRender('apicpp_traits.h', 'dawn/dawncpp_traits.h', [base_params, api_params, cpp_params]))
+
+ if 'libdawn' in targets:
+ additional_params = {'native_methods': lambda typ: cpp_native_methods(api_params['types'], typ)}
+ renders.append(FileRender('api.c', 'dawn/dawn.c', [base_params, api_params, c_params]))
+ renders.append(FileRender('apicpp.cpp', 'dawn/dawncpp.cpp', [base_params, api_params, cpp_params]))
+
+ if 'mock_dawn' in targets:
+ renders.append(FileRender('mock_api.h', 'mock/mock_dawn.h', [base_params, api_params, c_params]))
+ renders.append(FileRender('mock_api.cpp', 'mock/mock_dawn.cpp', [base_params, api_params, c_params]))
+
+ if 'dawn_native_utils' in targets:
+ frontend_params = [
+ base_params,
+ api_params,
+ c_params,
+ {
+ 'as_frontendType': lambda typ: as_frontendType(typ), # TODO as_frontendType and friends take a Type and not a Name :(
+ 'as_annotated_frontendType': lambda arg: annotated(as_frontendType(arg.type), arg)
+ }
+ ]
+
+ renders.append(FileRender('dawn_native/ValidationUtils.h', 'dawn_native/ValidationUtils_autogen.h', frontend_params))
+ renders.append(FileRender('dawn_native/ValidationUtils.cpp', 'dawn_native/ValidationUtils_autogen.cpp', frontend_params))
+ renders.append(FileRender('dawn_native/api_structs.h', 'dawn_native/dawn_structs_autogen.h', frontend_params))
+ renders.append(FileRender('dawn_native/api_structs.cpp', 'dawn_native/dawn_structs_autogen.cpp', frontend_params))
+ renders.append(FileRender('dawn_native/ProcTable.cpp', 'dawn_native/ProcTable.cpp', frontend_params))
+
+ if 'dawn_wire' in targets:
+ wire_params = [
+ base_params,
+ api_params,
+ c_params,
+ {
+ 'as_wireType': lambda typ: typ.name.CamelCase() + '*' if typ.category == 'object' else as_cppType(typ.name)
+ }
+ ]
+ renders.append(FileRender('dawn_wire/WireCmd.h', 'dawn_wire/WireCmd_autogen.h', wire_params))
+ renders.append(FileRender('dawn_wire/WireCmd.cpp', 'dawn_wire/WireCmd_autogen.cpp', wire_params))
+ renders.append(FileRender('dawn_wire/WireClient.cpp', 'dawn_wire/WireClient.cpp', wire_params))
+ renders.append(FileRender('dawn_wire/WireServer.cpp', 'dawn_wire/WireServer.cpp', wire_params))
+
+ return renders
+
+def output_to_json(outputs, output_json):
+ json_root = {}
+ for output in outputs:
+ json_root[output.name] = output.content
+
+ with open(output_json, 'w') as f:
+ f.write(json.dumps(json_root))
+
+def output_depfile(depfile, output, dependencies):
+ with open(depfile, 'w') as f:
+ f.write(output + ": " + " ".join(dependencies))
+
+def main():
+ allowed_targets = ['dawn_headers', 'libdawn', 'mock_dawn', 'dawn_wire', "dawn_native_utils"]
+
+ parser = argparse.ArgumentParser(
+ description = 'Generates code for various target for Dawn.',
+ formatter_class = argparse.ArgumentDefaultsHelpFormatter
+ )
+ parser.add_argument('json', metavar='DAWN_JSON', nargs=1, type=str, help ='The DAWN JSON definition to use.')
+ parser.add_argument('-t', '--template-dir', default='templates', type=str, help='Directory with template files.')
+ parser.add_argument('-T', '--targets', required=True, type=str, help='Comma-separated subset of targets to output. Available targets: ' + ', '.join(allowed_targets))
+ parser.add_argument(kExtraPythonPath, default=None, type=str, help='Additional python path to set before loading Jinja2')
+ parser.add_argument('--output-json-tarball', default=None, type=str, help='Name of the "JSON tarball" to create (tar is too annoying to use in python).')
+ parser.add_argument('--depfile', default=None, type=str, help='Name of the Ninja depfile to create for the JSON tarball')
+ parser.add_argument('--expected-outputs-file', default=None, type=str, help="File to compare outputs with and fail if it doesn't match")
+
+ args = parser.parse_args()
+
+ # Load and parse the API json file
+ with open(args.json[0]) as f:
+ loaded_json = json.loads(f.read())
+ api_params = parse_json(loaded_json)
+
+ targets = args.targets.split(',')
+ renders = get_renders_for_targets(api_params, targets)
+
+ # The caller wants to assert that the outputs are what it expects.
+ # Load the file and compare with our renders.
+ if args.expected_outputs_file != None:
+ with open(args.expected_outputs_file) as f:
+ expected = set([line.strip() for line in f.readlines()])
+
+ actual = set()
+ actual.update([render.output for render in renders])
+
+ if actual != expected:
+ print("Wrong expected outputs, caller expected:\n " + repr(list(expected)))
+ print("Actual output:\n " + repr(list(actual)))
+ return 1
+
+ outputs = do_renders(renders, args.template_dir)
+
+ # Output the tarball and its depfile
+ if args.output_json_tarball != None:
+ output_to_json(outputs, args.output_json_tarball)
+
+ dependencies = [args.template_dir + os.path.sep + render.template for render in renders]
+ dependencies.append(args.json[0])
+ output_depfile(args.depfile, args.output_json_tarball, dependencies)
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/third_party/dawn/generator/templates/api.c b/chromium/third_party/dawn/generator/templates/api.c
new file mode 100644
index 00000000000..b1c09f99aa2
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/api.c
@@ -0,0 +1,46 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "dawn/dawn.h"
+
+static dawnProcTable procs;
+
+static dawnProcTable nullProcs;
+
+void dawnSetProcs(const dawnProcTable* procs_) {
+ if (procs_) {
+ procs = *procs_;
+ } else {
+ procs = nullProcs;
+ }
+}
+
+{% for type in by_category["object"] %}
+ {% for method in native_methods(type) %}
+ {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}(
+ {{-as_cType(type.name)}} {{as_varName(type.name)}}
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ ) {
+ {% if method.return_type.name.canonical_case() != "void" %}return {% endif %}
+ procs.{{as_varName(type.name, method.name)}}({{as_varName(type.name)}}
+ {%- for arg in method.arguments -%}
+ , {{as_varName(arg.name)}}
+ {%- endfor -%}
+ );
+ }
+ {% endfor %}
+
+{% endfor %}
diff --git a/chromium/third_party/dawn/generator/templates/api.h b/chromium/third_party/dawn/generator/templates/api.h
new file mode 100644
index 00000000000..0b8a19a3041
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/api.h
@@ -0,0 +1,106 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#ifndef DAWN_DAWN_H_
+#define DAWN_DAWN_H_
+
+#include "dawn/dawn_export.h"
+
+#include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
+
+{% for type in by_category["object"] %}
+ typedef struct {{as_cType(type.name)}}Impl* {{as_cType(type.name)}};
+{% endfor %}
+
+{% for type in by_category["enum"] + by_category["bitmask"] %}
+ typedef enum {
+ {% for value in type.values %}
+ {{as_cEnum(type.name, value.name)}} = 0x{{format(value.value, "08X")}},
+ {% endfor %}
+ {{as_cEnum(type.name, Name("force32"))}} = 0x7FFFFFFF
+ } {{as_cType(type.name)}};
+
+{% endfor %}
+
+{% for type in by_category["structure"] %}
+ typedef struct {{as_cType(type.name)}} {
+ {% if type.extensible %}
+ const void* nextInChain;
+ {% endif %}
+ {% for member in type.members %}
+ {{as_annotated_cType(member)}};
+ {% endfor %}
+ } {{as_cType(type.name)}};
+
+{% endfor %}
+
+// Custom types depending on the target language
+typedef uint64_t dawnCallbackUserdata;
+typedef void (*dawnDeviceErrorCallback)(const char* message, dawnCallbackUserdata userdata);
+typedef void (*dawnBuilderErrorCallback)(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
+typedef void (*dawnBufferMapReadCallback)(dawnBufferMapAsyncStatus status, const void* data, dawnCallbackUserdata userdata);
+typedef void (*dawnBufferMapWriteCallback)(dawnBufferMapAsyncStatus status, void* data, dawnCallbackUserdata userdata);
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+{% for type in by_category["object"] %}
+ // Procs of {{type.name.CamelCase()}}
+ {% for method in native_methods(type) %}
+ typedef {{as_cType(method.return_type.name)}} (*{{as_cProc(type.name, method.name)}})(
+ {{-as_cType(type.name)}} {{as_varName(type.name)}}
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ );
+ {% endfor %}
+
+{% endfor %}
+
+struct dawnProcTable_s {
+ {% for type in by_category["object"] %}
+ {% for method in native_methods(type) %}
+ {{as_cProc(type.name, method.name)}} {{as_varName(type.name, method.name)}};
+ {% endfor %}
+
+ {% endfor %}
+};
+typedef struct dawnProcTable_s dawnProcTable;
+
+// Stuff below is for convenience and will forward calls to a static dawnProcTable.
+
+// Set which dawnProcTable will be used
+DAWN_EXPORT void dawnSetProcs(const dawnProcTable* procs);
+
+{% for type in by_category["object"] %}
+ // Methods of {{type.name.CamelCase()}}
+ {% for method in native_methods(type) %}
+ DAWN_EXPORT {{as_cType(method.return_type.name)}} {{as_cMethod(type.name, method.name)}}(
+ {{-as_cType(type.name)}} {{as_varName(type.name)}}
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ );
+ {% endfor %}
+
+{% endfor %}
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // DAWN_DAWN_H_
diff --git a/chromium/third_party/dawn/generator/templates/apicpp.cpp b/chromium/third_party/dawn/generator/templates/apicpp.cpp
new file mode 100644
index 00000000000..4a5935683b2
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/apicpp.cpp
@@ -0,0 +1,130 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "dawncpp.h"
+
+namespace dawn {
+
+ {% for type in by_category["enum"] + by_category["bitmask"] %}
+ {% set CppType = as_cppType(type.name) %}
+ {% set CType = as_cType(type.name) %}
+
+ static_assert(sizeof({{CppType}}) == sizeof({{CType}}), "sizeof mismatch for {{CppType}}");
+ static_assert(alignof({{CppType}}) == alignof({{CType}}), "alignof mismatch for {{CppType}}");
+
+ {% for value in type.values %}
+ static_assert(static_cast<uint32_t>({{CppType}}::{{as_cppEnum(value.name)}}) == {{as_cEnum(type.name, value.name)}}, "value mismatch for {{CppType}}::{{as_cppEnum(value.name)}}");
+ {% endfor %}
+
+ {% endfor %}
+
+
+ {% for type in by_category["structure"] %}
+ {% set CppType = as_cppType(type.name) %}
+ {% set CType = as_cType(type.name) %}
+
+ static_assert(sizeof({{CppType}}) == sizeof({{CType}}), "sizeof mismatch for {{CppType}}");
+ static_assert(alignof({{CppType}}) == alignof({{CType}}), "alignof mismatch for {{CppType}}");
+
+ {% if type.extensible %}
+ static_assert(offsetof({{CppType}}, nextInChain) == offsetof({{CType}}, nextInChain),
+ "offsetof mismatch for {{CppType}}::nextInChain");
+ {% endif %}
+ {% for member in type.members %}
+ {% set memberName = member.name.camelCase() %}
+ static_assert(offsetof({{CppType}}, {{memberName}}) == offsetof({{CType}}, {{memberName}}),
+ "offsetof mismatch for {{CppType}}::{{memberName}}");
+ {% endfor %}
+
+ {% endfor %}
+
+ {% for type in by_category["object"] %}
+ {% set CppType = as_cppType(type.name) %}
+ {% set CType = as_cType(type.name) %}
+
+ static_assert(sizeof({{CppType}}) == sizeof({{CType}}), "sizeof mismatch for {{CppType}}");
+ static_assert(alignof({{CppType}}) == alignof({{CType}}), "alignof mismatch for {{CppType}}");
+
+ {% macro render_cpp_method_declaration(type, method) %}
+ {% set CppType = as_cppType(type.name) %}
+ {% if method.return_type.name.concatcase() == "void" and type.is_builder -%}
+ {{CppType}} const&
+ {%- else -%}
+ {{as_cppType(method.return_type.name)}}
+ {%- endif -%}
+ {{" "}}{{CppType}}::{{method.name.CamelCase()}}(
+ {%- for arg in method.arguments -%}
+ {%- if not loop.first %}, {% endif -%}
+ {%- if arg.type.category == "object" and arg.annotation == "value" -%}
+ {{as_cppType(arg.type.name)}} const& {{as_varName(arg.name)}}
+ {%- else -%}
+ {{as_annotated_cppType(arg)}}
+ {%- endif -%}
+ {%- endfor -%}
+ ) const
+ {%- endmacro %}
+
+ {% macro render_cpp_to_c_method_call(type, method) -%}
+ {{as_cMethod(type.name, method.name)}}(Get()
+ {%- for arg in method.arguments -%},{{" "}}
+ {%- if arg.annotation == "value" -%}
+ {%- if arg.type.category == "object" -%}
+ {{as_varName(arg.name)}}.Get()
+ {%- elif arg.type.category == "enum" or arg.type.category == "bitmask" -%}
+ static_cast<{{as_cType(arg.type.name)}}>({{as_varName(arg.name)}})
+ {%- elif arg.type.category in ["native", "natively defined"] -%}
+ {{as_varName(arg.name)}}
+ {%- else -%}
+ UNHANDLED
+ {%- endif -%}
+ {%- else -%}
+ reinterpret_cast<{{decorate("", as_cType(arg.type.name), arg)}}>({{as_varName(arg.name)}})
+ {%- endif -%}
+ {%- endfor -%}
+ )
+ {%- endmacro %}
+
+ {% for method in native_methods(type) %}
+ {{render_cpp_method_declaration(type, method)}} {
+ {% if method.return_type.name.concatcase() == "void" %}
+ {{render_cpp_to_c_method_call(type, method)}};
+ {% if type.is_builder %}
+ return *this;
+ {% endif %}
+ {% else %}
+ auto result = {{render_cpp_to_c_method_call(type, method)}};
+ {% if method.return_type.category == "native" %}
+ return result;
+ {% elif method.return_type.category == "object" %}
+ return {{as_cppType(method.return_type.name)}}::Acquire(result);
+ {% else %}
+ return static_cast<{{as_cppType(method.return_type.name)}}>(result);
+ {% endif%}
+ {% endif %}
+ }
+ {% endfor %}
+ void {{CppType}}::DawnReference({{CType}} handle) {
+ if (handle != nullptr) {
+ {{as_cMethod(type.name, Name("reference"))}}(handle);
+ }
+ }
+ void {{CppType}}::DawnRelease({{CType}} handle) {
+ if (handle != nullptr) {
+ {{as_cMethod(type.name, Name("release"))}}(handle);
+ }
+ }
+
+ {% endfor %}
+
+}
diff --git a/chromium/third_party/dawn/generator/templates/apicpp.h b/chromium/third_party/dawn/generator/templates/apicpp.h
new file mode 100644
index 00000000000..af142b04c02
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/apicpp.h
@@ -0,0 +1,174 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#ifndef DAWN_DAWNCPP_H_
+#define DAWN_DAWNCPP_H_
+
+#include "dawn/dawn.h"
+#include "dawn/dawn_export.h"
+#include "dawn/EnumClassBitmasks.h"
+
+namespace dawn {
+
+ {% for type in by_category["enum"] %}
+ enum class {{as_cppType(type.name)}} : uint32_t {
+ {% for value in type.values %}
+ {{as_cppEnum(value.name)}} = 0x{{format(value.value, "08X")}},
+ {% endfor %}
+ };
+
+ {% endfor %}
+
+ {% for type in by_category["bitmask"] %}
+ enum class {{as_cppType(type.name)}} : uint32_t {
+ {% for value in type.values %}
+ {{as_cppEnum(value.name)}} = 0x{{format(value.value, "08X")}},
+ {% endfor %}
+ };
+
+ {% endfor %}
+
+ {% for type in by_category["bitmask"] %}
+ template<>
+ struct IsDawnBitmask<{{as_cppType(type.name)}}> {
+ static constexpr bool enable = true;
+ };
+
+ {% endfor %}
+
+ {% for type in by_category["natively defined"] %}
+ using {{as_cppType(type.name)}} = {{as_cType(type.name)}};
+ {% endfor %}
+
+ {% for type in by_category["object"] %}
+ class {{as_cppType(type.name)}};
+ {% endfor %}
+
+ {% for type in by_category["structure"] %}
+ struct {{as_cppType(type.name)}};
+ {% endfor %}
+
+ template<typename Derived, typename CType>
+ class ObjectBase {
+ public:
+ ObjectBase() = default;
+ ObjectBase(CType handle): mHandle(handle) {
+ if (mHandle) Derived::DawnReference(mHandle);
+ }
+ ~ObjectBase() {
+ if (mHandle) Derived::DawnRelease(mHandle);
+ }
+
+ ObjectBase(ObjectBase const& other)
+ : ObjectBase(other.Get()) {
+ }
+ Derived& operator=(ObjectBase const& other) {
+ if (&other != this) {
+ if (mHandle) Derived::DawnRelease(mHandle);
+ mHandle = other.mHandle;
+ if (mHandle) Derived::DawnReference(mHandle);
+ }
+
+ return static_cast<Derived&>(*this);
+ }
+
+ ObjectBase(ObjectBase&& other) {
+ mHandle = other.mHandle;
+ other.mHandle = 0;
+ }
+ Derived& operator=(ObjectBase&& other) {
+ if (&other != this) {
+ if (mHandle) Derived::DawnRelease(mHandle);
+ mHandle = other.mHandle;
+ other.mHandle = 0;
+ }
+
+ return static_cast<Derived&>(*this);
+ }
+
+ explicit operator bool() const {
+ return mHandle != nullptr;
+ }
+ CType Get() const {
+ return mHandle;
+ }
+ CType Release() {
+ CType result = mHandle;
+ mHandle = 0;
+ return result;
+ }
+ static Derived Acquire(CType handle) {
+ Derived result;
+ result.mHandle = handle;
+ return result;
+ }
+
+ protected:
+ CType mHandle = nullptr;
+ };
+
+ {% macro render_cpp_method_declaration(type, method) %}
+ {% set CppType = as_cppType(type.name) %}
+ {% if method.return_type.name.concatcase() == "void" and type.is_builder -%}
+ {{CppType}} const&
+ {%- else -%}
+ {{as_cppType(method.return_type.name)}}
+ {%- endif -%}
+ {{" "}}{{method.name.CamelCase()}}(
+ {%- for arg in method.arguments -%}
+ {%- if not loop.first %}, {% endif -%}
+ {%- if arg.type.category == "object" and arg.annotation == "value" -%}
+ {{as_cppType(arg.type.name)}} const& {{as_varName(arg.name)}}
+ {%- else -%}
+ {{as_annotated_cppType(arg)}}
+ {%- endif -%}
+ {%- endfor -%}
+ ) const
+ {%- endmacro %}
+
+ {% for type in by_category["object"] %}
+ {% set CppType = as_cppType(type.name) %}
+ {% set CType = as_cType(type.name) %}
+ class DAWN_EXPORT {{CppType}} : public ObjectBase<{{CppType}}, {{CType}}> {
+ public:
+ using ObjectBase::ObjectBase;
+ using ObjectBase::operator=;
+
+ {% for method in native_methods(type) %}
+ {{render_cpp_method_declaration(type, method)}};
+ {% endfor %}
+
+ private:
+ friend ObjectBase<{{CppType}}, {{CType}}>;
+ static void DawnReference({{CType}} handle);
+ static void DawnRelease({{CType}} handle);
+ };
+
+ {% endfor %}
+
+ {% for type in by_category["structure"] %}
+ struct {{as_cppType(type.name)}} {
+ {% if type.extensible %}
+ const void* nextInChain = nullptr;
+ {% endif %}
+ {% for member in type.members %}
+ {{as_annotated_cppType(member)}};
+ {% endfor %}
+ };
+
+ {% endfor %}
+
+} // namespace dawn
+
+#endif // DAWN_DAWNCPP_H_
diff --git a/chromium/third_party/dawn/generator/templates/apicpp_traits.h b/chromium/third_party/dawn/generator/templates/apicpp_traits.h
new file mode 100644
index 00000000000..4741ded867e
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/apicpp_traits.h
@@ -0,0 +1,43 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#ifndef DAWN_DAWNCPP_TRAITS_H_
+#define DAWN_DAWNCPP_TRAITS_H_
+
+#include "dawncpp.h"
+
+#include <type_traits>
+
+namespace dawn {
+
+ template<typename Builder>
+ using BuiltObject = decltype(std::declval<Builder>().GetResult());
+
+ template<typename BuiltObject>
+ struct BuiltObjectTrait {
+ };
+
+ {% for type in by_category["object"] if type.is_builder %}
+ template<>
+ struct BuiltObjectTrait<BuiltObject<{{as_cppType(type.name)}}>> {
+ using Builder = {{as_cppType(type.name)}};
+ };
+ {% endfor %}
+
+ template<typename BuiltObject>
+ using Builder = typename BuiltObjectTrait<BuiltObject>::Builder;
+
+}
+
+#endif // DAWN_DAWNCPP_TRAITS_H_
diff --git a/chromium/third_party/dawn/generator/templates/dawn_native/ProcTable.cpp b/chromium/third_party/dawn/generator/templates/dawn_native/ProcTable.cpp
new file mode 100644
index 00000000000..21c29269f8a
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_native/ProcTable.cpp
@@ -0,0 +1,178 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "common/Assert.h"
+
+#include "dawn_native/dawn_platform.h"
+#include "dawn_native/DawnNative.h"
+#include "dawn_native/ErrorData.h"
+#include "dawn_native/ValidationUtils_autogen.h"
+
+{% for type in by_category["object"] %}
+ {% if not type.is_builder and type.name.canonical_case() not in ["buffer view", "texture view"] %}
+ #include "dawn_native/{{type.name.CamelCase()}}.h"
+ {% endif %}
+{% endfor %}
+
+namespace dawn_native {
+
+ namespace {
+
+ {% set methodsWithExtraValidation = (
+ "CommandBufferBuilderGetResult",
+ ) %}
+
+ {% for type in by_category["object"] %}
+ {% for method in native_methods(type) %}
+ {% set suffix = as_MethodSuffix(type.name, method.name) %}
+
+ //* Autogenerated part of the entry point validation
+ //* - Check that enum and bitmaks are in the correct range
+ //* - Check that builders have not been consumed already
+ bool ValidateBase{{suffix}}(
+ {{-as_frontendType(type)}} self
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_frontendType(arg)}}
+ {%- endfor -%}
+ ) {
+ {% if type.is_builder and method.name.canonical_case() not in ("release", "reference") %}
+ if (!self->CanBeUsed()) {
+ self->GetDevice()->HandleError("Builder cannot be used after GetResult");
+ return false;
+ }
+ {% else %}
+ DAWN_UNUSED(self);
+ {% endif %}
+ bool error = false;
+ DAWN_UNUSED(error);
+ {% for arg in method.arguments %}
+ {% set cppType = as_cppType(arg.type.name) %}
+ {% set argName = as_varName(arg.name) %}
+ {% if arg.type.category in ["enum", "bitmask"] %}
+ MaybeError {{argName}}Valid = Validate{{cppType}}(static_cast<dawn::{{cppType}}>({{argName}}));
+ if ({{argName}}Valid.IsError()) {
+ delete {{argName}}Valid.AcquireError();
+ error = true;
+ }
+ {% else %}
+ DAWN_UNUSED({{argName}});
+ {% endif %}
+ if (error) {
+ {% if type.is_builder %}
+ self->HandleError("Bad value in {{suffix}}");
+ {% else %}
+ self->GetDevice()->HandleError("Bad value in {{suffix}}");
+ {% endif %}
+ return false;
+ }
+ {% endfor %}
+ return true;
+ }
+
+ //* Entry point with validation
+ {{as_cType(method.return_type.name)}} Validating{{suffix}}(
+ {{-as_cType(type.name)}} cSelf
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ ) {
+ //* Perform conversion between C types and frontend types
+ auto self = reinterpret_cast<{{as_frontendType(type)}}>(cSelf);
+
+ {% for arg in method.arguments %}
+ {% set varName = as_varName(arg.name) %}
+ {% if arg.type.category in ["enum", "bitmask"] %}
+ auto {{varName}}_ = static_cast<{{as_frontendType(arg.type)}}>({{varName}});
+ {% elif arg.annotation != "value" or arg.type.category == "object" %}
+ auto {{varName}}_ = reinterpret_cast<{{decorate("", as_frontendType(arg.type), arg)}}>({{varName}});
+ {% else %}
+ auto {{varName}}_ = {{as_varName(arg.name)}};
+ {% endif %}
+ {%- endfor-%}
+
+ //* Do the autogenerated checks
+ bool valid = ValidateBase{{suffix}}(self
+ {%- for arg in method.arguments -%}
+ , {{as_varName(arg.name)}}_
+ {%- endfor -%}
+ );
+
+ //* Some function have very heavy checks in a separate method, so that they
+ //* can be skipped in the NonValidatingEntryPoints.
+ {% if suffix in methodsWithExtraValidation %}
+ if (valid) {
+ MaybeError error = self->Validate{{method.name.CamelCase()}}(
+ {%- for arg in method.arguments -%}
+ {% if not loop.first %}, {% endif %}{{as_varName(arg.name)}}_
+ {%- endfor -%}
+ );
+ //* Builders want to handle error themselves, unpack the error and make
+ //* the builder handle it.
+ {% if type.is_builder %}
+ if (error.IsError()) {
+ ErrorData* errorData = error.AcquireError();
+ self->HandleError(errorData->GetMessage().c_str());
+ delete errorData;
+ valid = false;
+ }
+ {% else %}
+ //* Non-builder errors are handled by the device
+ valid = !self->GetDevice()->ConsumedError(std::move(error));
+ {% endif %}
+ }
+ {% endif %}
+
+ //* HACK(cwallez@chromium.org): special casing GetResult so that the error callback
+ //* is called if needed. Without this, no call to HandleResult would happen, and the
+ //* error callback would always get called with an Unknown status
+ {% if type.is_builder and method.name.canonical_case() == "get result" %}
+ if (!valid) {
+ {{as_frontendType(method.return_type)}} fakeResult = nullptr;
+ bool shouldBeFalse = self->HandleResult(fakeResult);
+ ASSERT(shouldBeFalse == false);
+ }
+ {% endif %}
+
+ {% if method.return_type.name.canonical_case() == "void" %}
+ if (!valid) return;
+ {% else %}
+ if (!valid) {
+ return {};
+ }
+ auto result =
+ {%- endif %}
+ self->{{method.name.CamelCase()}}(
+ {%- for arg in method.arguments -%}
+ {%- if not loop.first %}, {% endif -%}
+ {{as_varName(arg.name)}}_
+ {%- endfor -%}
+ );
+ {% if method.return_type.name.canonical_case() != "void" %}
+ return reinterpret_cast<{{as_cType(method.return_type.name)}}>(result);
+ {% endif %}
+ }
+ {% endfor %}
+ {% endfor %}
+ }
+
+ dawnProcTable GetProcsAutogen() {
+ dawnProcTable table;
+ {% for type in by_category["object"] %}
+ {% for method in native_methods(type) %}
+ table.{{as_varName(type.name, method.name)}} = Validating{{as_MethodSuffix(type.name, method.name)}};
+ {% endfor %}
+ {% endfor %}
+ return table;
+ }
+}
diff --git a/chromium/third_party/dawn/generator/templates/dawn_native/ValidationUtils.cpp b/chromium/third_party/dawn/generator/templates/dawn_native/ValidationUtils.cpp
new file mode 100644
index 00000000000..ac98da478e0
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_native/ValidationUtils.cpp
@@ -0,0 +1,43 @@
+//* Copyright 2018 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "dawn_native/ValidationUtils_autogen.h"
+
+namespace dawn_native {
+
+ {% for type in by_category["enum"] %}
+ MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value) {
+ switch (value) {
+ {% for value in type.values %}
+ case dawn::{{as_cppType(type.name)}}::{{as_cppEnum(value.name)}}:
+ return {};
+ {% endfor %}
+ default:
+ return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}");
+ }
+ }
+
+ {% endfor %}
+
+ {% for type in by_category["bitmask"] %}
+ MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value) {
+ if ((value & static_cast<dawn::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
+ return {};
+ }
+ return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}");
+ }
+
+ {% endfor %}
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/generator/templates/dawn_native/ValidationUtils.h b/chromium/third_party/dawn/generator/templates/dawn_native/ValidationUtils.h
new file mode 100644
index 00000000000..0e0d3854cf1
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_native/ValidationUtils.h
@@ -0,0 +1,31 @@
+//* Copyright 2018 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#ifndef BACKEND_VALIDATIONUTILS_H_
+#define BACKEND_VALIDATIONUTILS_H_
+
+#include "dawn/dawncpp.h"
+
+#include "dawn_native/Error.h"
+
+namespace dawn_native {
+
+ // Helper functions to check the value of enums and bitmasks
+ {% for type in by_category["enum"] + by_category["bitmask"] %}
+ MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value);
+ {% endfor %}
+
+} // namespace dawn_native
+
+#endif // BACKEND_VALIDATIONUTILS_H_
diff --git a/chromium/third_party/dawn/generator/templates/dawn_native/api_structs.cpp b/chromium/third_party/dawn/generator/templates/dawn_native/api_structs.cpp
new file mode 100644
index 00000000000..2956830c322
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_native/api_structs.cpp
@@ -0,0 +1,37 @@
+//* Copyright 2018 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "dawn_native/dawn_structs_autogen.h"
+
+namespace dawn_native {
+
+ {% for type in by_category["structure"] %}
+ {% set CppType = as_cppType(type.name) %}
+ {% set CType = as_cType(type.name) %}
+
+ static_assert(sizeof({{CppType}}) == sizeof({{CType}}), "sizeof mismatch for {{CppType}}");
+ static_assert(alignof({{CppType}}) == alignof({{CType}}), "alignof mismatch for {{CppType}}");
+
+ {% if type.extensible %}
+ static_assert(offsetof({{CppType}}, nextInChain) == offsetof({{CType}}, nextInChain),
+ "offsetof mismatch for {{CppType}}::nextInChain");
+ {% endif %}
+ {% for member in type.members %}
+ {% set memberName = member.name.camelCase() %}
+ static_assert(offsetof({{CppType}}, {{memberName}}) == offsetof({{CType}}, {{memberName}}),
+ "offsetof mismatch for {{CppType}}::{{memberName}}");
+ {% endfor %}
+
+ {% endfor %}
+}
diff --git a/chromium/third_party/dawn/generator/templates/dawn_native/api_structs.h b/chromium/third_party/dawn/generator/templates/dawn_native/api_structs.h
new file mode 100644
index 00000000000..6de4da64de4
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_native/api_structs.h
@@ -0,0 +1,37 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#ifndef DAWNNATIVE_DAWN_STRUCTS_H_
+#define DAWNNATIVE_DAWN_STRUCTS_H_
+
+#include "dawn/dawncpp.h"
+#include "dawn_native/Forward.h"
+
+namespace dawn_native {
+
+ {% for type in by_category["structure"] %}
+ struct {{as_cppType(type.name)}} {
+ {% if type.extensible %}
+ const void* nextInChain = nullptr;
+ {% endif %}
+ {% for member in type.members %}
+ {{as_annotated_frontendType(member)}};
+ {% endfor %}
+ };
+
+ {% endfor %}
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_DAWN_STRUCTS_H_
diff --git a/chromium/third_party/dawn/generator/templates/dawn_wire/WireClient.cpp b/chromium/third_party/dawn/generator/templates/dawn_wire/WireClient.cpp
new file mode 100644
index 00000000000..117cfad5dcc
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_wire/WireClient.cpp
@@ -0,0 +1,691 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "dawn_wire/Wire.h"
+#include "dawn_wire/WireCmd.h"
+
+#include "common/Assert.h"
+
+#include <cstring>
+#include <cstdlib>
+#include <map>
+#include <memory>
+#include <string>
+#include <vector>
+
+namespace dawn_wire {
+
+ //* Client side implementation of the API, will serialize everything to memory to send to the server side.
+ namespace client {
+
+ class Device;
+
+ struct BuilderCallbackData {
+ bool Call(dawnBuilderErrorStatus status, const char* message) {
+ if (canCall && callback != nullptr) {
+ canCall = true;
+ callback(status, message, userdata1, userdata2);
+ return true;
+ }
+
+ return false;
+ }
+
+ //* For help with development, prints all builder errors by default.
+ dawnBuilderErrorCallback callback = nullptr;
+ dawnCallbackUserdata userdata1 = 0;
+ dawnCallbackUserdata userdata2 = 0;
+ bool canCall = true;
+ };
+
+ //* All non-Device objects of the client side have:
+ //* - A pointer to the device to get where to serialize commands
+ //* - The external reference count
+ //* - An ID that is used to refer to this object when talking with the server side
+ struct ObjectBase {
+ ObjectBase(Device* device, uint32_t refcount, uint32_t id)
+ :device(device), refcount(refcount), id(id) {
+ }
+
+ Device* device;
+ uint32_t refcount;
+ uint32_t id;
+
+ BuilderCallbackData builderCallback;
+ };
+
+ {% set special_objects = [
+ "device",
+ "buffer",
+ ] %}
+ {% for type in by_category["object"] if not type.name.canonical_case() in special_objects %}
+ struct {{type.name.CamelCase()}} : ObjectBase {
+ using ObjectBase::ObjectBase;
+ };
+ {% endfor %}
+
+ struct Buffer : ObjectBase {
+ using ObjectBase::ObjectBase;
+
+ ~Buffer() {
+ //* Callbacks need to be fired in all cases, as they can handle freeing resources
+ //* so we call them with "Unknown" status.
+ ClearMapRequests(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN);
+
+ if (mappedData) {
+ free(mappedData);
+ }
+ }
+
+ void ClearMapRequests(dawnBufferMapAsyncStatus status) {
+ for (auto& it : requests) {
+ if (it.second.isWrite) {
+ it.second.writeCallback(status, nullptr, it.second.userdata);
+ } else {
+ it.second.readCallback(status, nullptr, it.second.userdata);
+ }
+ }
+ requests.clear();
+ }
+
+ //* We want to defer all the validation to the server, which means we could have multiple
+ //* map request in flight at a single time and need to track them separately.
+ //* On well-behaved applications, only one request should exist at a single time.
+ struct MapRequestData {
+ dawnBufferMapReadCallback readCallback = nullptr;
+ dawnBufferMapWriteCallback writeCallback = nullptr;
+ dawnCallbackUserdata userdata = 0;
+ uint32_t size = 0;
+ bool isWrite = false;
+ };
+ std::map<uint32_t, MapRequestData> requests;
+ uint32_t requestSerial = 0;
+
+ //* Only one mapped pointer can be active at a time because Unmap clears all the in-flight requests.
+ void* mappedData = nullptr;
+ size_t mappedDataSize = 0;
+ bool isWriteMapped = false;
+ };
+
+ //* TODO(cwallez@chromium.org): Do something with objects before they are destroyed ?
+ //* - Call still uncalled builder callbacks
+ template<typename T>
+ class ObjectAllocator {
+ public:
+ struct ObjectAndSerial {
+ ObjectAndSerial(std::unique_ptr<T> object, uint32_t serial)
+ : object(std::move(object)), serial(serial) {
+ }
+ std::unique_ptr<T> object;
+ uint32_t serial;
+ };
+
+ ObjectAllocator(Device* device) : mDevice(device) {
+ // ID 0 is nullptr
+ mObjects.emplace_back(nullptr, 0);
+ }
+
+ ObjectAndSerial* New() {
+ uint32_t id = GetNewId();
+ T* result = new T(mDevice, 1, id);
+ auto object = std::unique_ptr<T>(result);
+
+ if (id >= mObjects.size()) {
+ ASSERT(id == mObjects.size());
+ mObjects.emplace_back(std::move(object), 0);
+ } else {
+ ASSERT(mObjects[id].object == nullptr);
+ //* TODO(cwallez@chromium.org): investigate if overflows could cause bad things to happen
+ mObjects[id].serial++;
+ mObjects[id].object = std::move(object);
+ }
+
+ return &mObjects[id];
+ }
+ void Free(T* obj) {
+ FreeId(obj->id);
+ mObjects[obj->id].object = nullptr;
+ }
+
+ T* GetObject(uint32_t id) {
+ if (id >= mObjects.size()) {
+ return nullptr;
+ }
+ return mObjects[id].object.get();
+ }
+
+ uint32_t GetSerial(uint32_t id) {
+ if (id >= mObjects.size()) {
+ return 0;
+ }
+ return mObjects[id].serial;
+ }
+
+ private:
+ uint32_t GetNewId() {
+ if (mFreeIds.empty()) {
+ return mCurrentId ++;
+ }
+ uint32_t id = mFreeIds.back();
+ mFreeIds.pop_back();
+ return id;
+ }
+ void FreeId(uint32_t id) {
+ mFreeIds.push_back(id);
+ }
+
+ // 0 is an ID reserved to represent nullptr
+ uint32_t mCurrentId = 1;
+ std::vector<uint32_t> mFreeIds;
+ std::vector<ObjectAndSerial> mObjects;
+ Device* mDevice;
+ };
+
+ //* The client wire uses the global Dawn device to store its global data such as the serializer
+ //* and the object id allocators.
+ class Device : public ObjectBase, public ObjectIdProvider {
+ public:
+ Device(CommandSerializer* serializer)
+ : ObjectBase(this, 1, 1),
+ {% for type in by_category["object"] if not type.name.canonical_case() == "device" %}
+ {{type.name.camelCase()}}(this),
+ {% endfor %}
+ mSerializer(serializer) {
+ }
+
+ void* GetCmdSpace(size_t size) {
+ return mSerializer->GetCmdSpace(size);
+ }
+
+ {% for type in by_category["object"] if not type.name.canonical_case() == "device" %}
+ ObjectAllocator<{{type.name.CamelCase()}}> {{type.name.camelCase()}};
+ {% endfor %}
+
+ // Implementation of the ObjectIdProvider interface
+ {% for type in by_category["object"] %}
+ ObjectId GetId({{as_cType(type.name)}} object) const final {
+ return reinterpret_cast<{{as_wireType(type)}}>(object)->id;
+ }
+ ObjectId GetOptionalId({{as_cType(type.name)}} object) const final {
+ if (object == nullptr) {
+ return 0;
+ }
+ return GetId(object);
+ }
+ {% endfor %}
+
+ void HandleError(const char* message) {
+ if (errorCallback) {
+ errorCallback(message, errorUserdata);
+ }
+ }
+
+ dawnDeviceErrorCallback errorCallback = nullptr;
+ dawnCallbackUserdata errorUserdata;
+
+ private:
+ CommandSerializer* mSerializer = nullptr;
+ };
+
+ //* Implementation of the client API functions.
+ {% for type in by_category["object"] %}
+ {% set Type = type.name.CamelCase() %}
+ {% set cType = as_cType(type.name) %}
+
+ {% for method in type.methods %}
+ {% set Suffix = as_MethodSuffix(type.name, method.name) %}
+
+ {{as_cType(method.return_type.name)}} Client{{Suffix}}(
+ {{-cType}} cSelf
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ ) {
+ auto self = reinterpret_cast<{{as_wireType(type)}}>(cSelf);
+ Device* device = self->device;
+ {{Suffix}}Cmd cmd;
+
+ //* Create the structure going on the wire on the stack and fill it with the value
+ //* arguments so it can compute its size.
+ cmd.self = cSelf;
+
+ //* For object creation, store the object ID the client will use for the result.
+ {% if method.return_type.category == "object" %}
+ auto* allocation = self->device->{{method.return_type.name.camelCase()}}.New();
+
+ {% if type.is_builder %}
+ //* We are in GetResult, so the callback that should be called is the
+ //* currently set one. Copy it over to the created object and prevent the
+ //* builder from calling the callback on destruction.
+ allocation->object->builderCallback = self->builderCallback;
+ self->builderCallback.canCall = false;
+ {% endif %}
+
+ cmd.resultId = allocation->object->id;
+ cmd.resultSerial = allocation->serial;
+ {% endif %}
+
+ {% for arg in method.arguments %}
+ cmd.{{as_varName(arg.name)}} = {{as_varName(arg.name)}};
+ {% endfor %}
+
+ //* Allocate space to send the command and copy the value args over.
+ size_t requiredSize = cmd.GetRequiredSize();
+ char* allocatedBuffer = static_cast<char*>(device->GetCmdSpace(requiredSize));
+ cmd.Serialize(allocatedBuffer, *device);
+
+ {% if method.return_type.category == "object" %}
+ return reinterpret_cast<{{as_cType(method.return_type.name)}}>(allocation->object.get());
+ {% endif %}
+ }
+ {% endfor %}
+
+ {% if type.is_builder %}
+ void Client{{as_MethodSuffix(type.name, Name("set error callback"))}}({{cType}} cSelf,
+ dawnBuilderErrorCallback callback,
+ dawnCallbackUserdata userdata1,
+ dawnCallbackUserdata userdata2) {
+ {{Type}}* self = reinterpret_cast<{{Type}}*>(cSelf);
+ self->builderCallback.callback = callback;
+ self->builderCallback.userdata1 = userdata1;
+ self->builderCallback.userdata2 = userdata2;
+ }
+ {% endif %}
+
+ {% if not type.name.canonical_case() == "device" %}
+ //* When an object's refcount reaches 0, notify the server side of it and delete it.
+ void Client{{as_MethodSuffix(type.name, Name("release"))}}({{cType}} cObj) {
+ {{Type}}* obj = reinterpret_cast<{{Type}}*>(cObj);
+ obj->refcount --;
+
+ if (obj->refcount > 0) {
+ return;
+ }
+
+ obj->builderCallback.Call(DAWN_BUILDER_ERROR_STATUS_UNKNOWN, "Unknown");
+
+ {{as_MethodSuffix(type.name, Name("destroy"))}}Cmd cmd;
+ cmd.objectId = obj->id;
+
+ auto allocCmd = static_cast<decltype(cmd)*>(obj->device->GetCmdSpace(sizeof(cmd)));
+ *allocCmd = cmd;
+
+ obj->device->{{type.name.camelCase()}}.Free(obj);
+ }
+
+ void Client{{as_MethodSuffix(type.name, Name("reference"))}}({{cType}} cObj) {
+ {{Type}}* obj = reinterpret_cast<{{Type}}*>(cObj);
+ obj->refcount ++;
+ }
+ {% endif %}
+ {% endfor %}
+
+ void ClientBufferMapReadAsync(dawnBuffer cBuffer, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) {
+ Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
+
+ uint32_t serial = buffer->requestSerial++;
+ ASSERT(buffer->requests.find(serial) == buffer->requests.end());
+
+ Buffer::MapRequestData request;
+ request.readCallback = callback;
+ request.userdata = userdata;
+ request.size = size;
+ request.isWrite = false;
+ buffer->requests[serial] = request;
+
+ BufferMapAsyncCmd cmd;
+ cmd.bufferId = buffer->id;
+ cmd.requestSerial = serial;
+ cmd.start = start;
+ cmd.size = size;
+ cmd.isWrite = false;
+
+ auto allocCmd = static_cast<decltype(cmd)*>(buffer->device->GetCmdSpace(sizeof(cmd)));
+ *allocCmd = cmd;
+ }
+
+ void ClientBufferMapWriteAsync(dawnBuffer cBuffer, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) {
+ Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
+
+ uint32_t serial = buffer->requestSerial++;
+ ASSERT(buffer->requests.find(serial) == buffer->requests.end());
+
+ Buffer::MapRequestData request;
+ request.writeCallback = callback;
+ request.userdata = userdata;
+ request.size = size;
+ request.isWrite = true;
+ buffer->requests[serial] = request;
+
+ BufferMapAsyncCmd cmd;
+ cmd.bufferId = buffer->id;
+ cmd.requestSerial = serial;
+ cmd.start = start;
+ cmd.size = size;
+ cmd.isWrite = true;
+
+ auto allocCmd = static_cast<decltype(cmd)*>(buffer->device->GetCmdSpace(sizeof(cmd)));
+ *allocCmd = cmd;
+ }
+
+ void ProxyClientBufferUnmap(dawnBuffer cBuffer) {
+ Buffer* buffer = reinterpret_cast<Buffer*>(cBuffer);
+
+ //* Invalidate the local pointer, and cancel all other in-flight requests that would turn into
+ //* errors anyway (you can't double map). This prevents race when the following happens, where
+ //* the application code would have unmapped a buffer but still receive a callback:
+ //* - Client -> Server: MapRequest1, Unmap, MapRequest2
+ //* - Server -> Client: Result of MapRequest1
+ //* - Unmap locally on the client
+ //* - Server -> Client: Result of MapRequest2
+ if (buffer->mappedData) {
+
+ // If the buffer was mapped for writing, send the update to the data to the server
+ if (buffer->isWriteMapped) {
+ BufferUpdateMappedDataCmd cmd;
+ cmd.bufferId = buffer->id;
+ cmd.dataLength = static_cast<uint32_t>(buffer->mappedDataSize);
+
+ auto allocCmd = static_cast<decltype(cmd)*>(buffer->device->GetCmdSpace(sizeof(cmd)));
+ *allocCmd = cmd;
+
+ void* dataAlloc = buffer->device->GetCmdSpace(cmd.dataLength);
+ memcpy(dataAlloc, buffer->mappedData, cmd.dataLength);
+ }
+
+ free(buffer->mappedData);
+ buffer->mappedData = nullptr;
+ }
+ buffer->ClearMapRequests(DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN);
+
+ ClientBufferUnmap(cBuffer);
+ }
+
+ void ClientDeviceReference(dawnDevice) {
+ }
+
+ void ClientDeviceRelease(dawnDevice) {
+ }
+
+ void ClientDeviceSetErrorCallback(dawnDevice cSelf, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) {
+ Device* self = reinterpret_cast<Device*>(cSelf);
+ self->errorCallback = callback;
+ self->errorUserdata = userdata;
+ }
+
+ // Some commands don't have a custom wire format, but need to be handled manually to update
+ // some client-side state tracking. For these we have two functions:
+ // - An autogenerated Client{{suffix}} method that sends the command on the wire
+ // - A manual ProxyClient{{suffix}} method that will be inserted in the proctable instead of
+ // the autogenerated one, and that will have to call Client{{suffix}}
+ {% set proxied_commands = ["BufferUnmap"] %}
+
+ dawnProcTable GetProcs() {
+ dawnProcTable table;
+ {% for type in by_category["object"] %}
+ {% for method in native_methods(type) %}
+ {% set suffix = as_MethodSuffix(type.name, method.name) %}
+ {% if suffix in proxied_commands %}
+ table.{{as_varName(type.name, method.name)}} = ProxyClient{{suffix}};
+ {% else %}
+ table.{{as_varName(type.name, method.name)}} = Client{{suffix}};
+ {% endif %}
+ {% endfor %}
+ {% endfor %}
+ return table;
+ }
+
+ class Client : public CommandHandler {
+ public:
+ Client(Device* device) : mDevice(device) {
+ }
+
+ const char* HandleCommands(const char* commands, size_t size) override {
+ while (size >= sizeof(ReturnWireCmd)) {
+ ReturnWireCmd cmdId = *reinterpret_cast<const ReturnWireCmd*>(commands);
+
+ bool success = false;
+ switch (cmdId) {
+ case ReturnWireCmd::DeviceErrorCallback:
+ success = HandleDeviceErrorCallbackCmd(&commands, &size);
+ break;
+ {% for type in by_category["object"] if type.is_builder %}
+ case ReturnWireCmd::{{type.name.CamelCase()}}ErrorCallback:
+ success = Handle{{type.name.CamelCase()}}ErrorCallbackCmd(&commands, &size);
+ break;
+ {% endfor %}
+ case ReturnWireCmd::BufferMapReadAsyncCallback:
+ success = HandleBufferMapReadAsyncCallback(&commands, &size);
+ break;
+ case ReturnWireCmd::BufferMapWriteAsyncCallback:
+ success = HandleBufferMapWriteAsyncCallback(&commands, &size);
+ break;
+ default:
+ success = false;
+ }
+
+ if (!success) {
+ return nullptr;
+ }
+ }
+
+ if (size != 0) {
+ return nullptr;
+ }
+
+ return commands;
+ }
+
+ private:
+ Device* mDevice = nullptr;
+
+ //* Helper function for the getting of the command data in command handlers.
+ //* Checks there is enough data left, updates the buffer / size and returns
+ //* the command (or nullptr for an error).
+ template <typename T>
+ static const T* GetData(const char** buffer, size_t* size, size_t count) {
+ // TODO(cwallez@chromium.org): Check for overflow
+ size_t totalSize = count * sizeof(T);
+ if (*size < totalSize) {
+ return nullptr;
+ }
+
+ const T* data = reinterpret_cast<const T*>(*buffer);
+
+ *buffer += totalSize;
+ *size -= totalSize;
+
+ return data;
+ }
+ template <typename T>
+ static const T* GetCommand(const char** commands, size_t* size) {
+ return GetData<T>(commands, size, 1);
+ }
+
+ bool HandleDeviceErrorCallbackCmd(const char** commands, size_t* size) {
+ const auto* cmd = GetCommand<ReturnDeviceErrorCallbackCmd>(commands, size);
+ if (cmd == nullptr) {
+ return false;
+ }
+
+ const char* message = GetData<char>(commands, size, cmd->messageStrlen + 1);
+ if (message == nullptr || message[cmd->messageStrlen] != '\0') {
+ return false;
+ }
+
+ mDevice->HandleError(message);
+
+ return true;
+ }
+
+ {% for type in by_category["object"] if type.is_builder %}
+ {% set Type = type.name.CamelCase() %}
+ bool Handle{{Type}}ErrorCallbackCmd(const char** commands, size_t* size) {
+ const auto* cmd = GetCommand<Return{{Type}}ErrorCallbackCmd>(commands, size);
+ if (cmd == nullptr) {
+ return false;
+ }
+
+ const char* message = GetData<char>(commands, size, cmd->messageStrlen + 1);
+ if (message == nullptr || message[cmd->messageStrlen] != '\0') {
+ return false;
+ }
+
+ auto* builtObject = mDevice->{{type.built_type.name.camelCase()}}.GetObject(cmd->builtObjectId);
+ uint32_t objectSerial = mDevice->{{type.built_type.name.camelCase()}}.GetSerial(cmd->builtObjectId);
+
+ //* The object might have been deleted or a new object created with the same ID.
+ if (builtObject == nullptr || objectSerial != cmd->builtObjectSerial) {
+ return true;
+ }
+
+ bool called = builtObject->builderCallback.Call(static_cast<dawnBuilderErrorStatus>(cmd->status), message);
+
+ // Unhandled builder errors are forwarded to the device
+ if (!called && cmd->status != DAWN_BUILDER_ERROR_STATUS_SUCCESS && cmd->status != DAWN_BUILDER_ERROR_STATUS_UNKNOWN) {
+ mDevice->HandleError(("Unhandled builder error: " + std::string(message)).c_str());
+ }
+
+ return true;
+ }
+ {% endfor %}
+
+ bool HandleBufferMapReadAsyncCallback(const char** commands, size_t* size) {
+ const auto* cmd = GetCommand<ReturnBufferMapReadAsyncCallbackCmd>(commands, size);
+ if (cmd == nullptr) {
+ return false;
+ }
+
+ //* Unconditionnally get the data from the buffer so that the correct amount of data is
+ //* consumed from the buffer, even when we ignore the command and early out.
+ const char* requestData = nullptr;
+ if (cmd->status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
+ requestData = GetData<char>(commands, size, cmd->dataLength);
+ if (requestData == nullptr) {
+ return false;
+ }
+ }
+
+ auto* buffer = mDevice->buffer.GetObject(cmd->bufferId);
+ uint32_t bufferSerial = mDevice->buffer.GetSerial(cmd->bufferId);
+
+ //* The buffer might have been deleted or recreated so this isn't an error.
+ if (buffer == nullptr || bufferSerial != cmd->bufferSerial) {
+ return true;
+ }
+
+ //* The requests can have been deleted via an Unmap so this isn't an error.
+ auto requestIt = buffer->requests.find(cmd->requestSerial);
+ if (requestIt == buffer->requests.end()) {
+ return true;
+ }
+
+ //* It is an error for the server to call the read callback when we asked for a map write
+ if (requestIt->second.isWrite) {
+ return false;
+ }
+
+ auto request = requestIt->second;
+ //* Delete the request before calling the callback otherwise the callback could be fired a
+ //* second time. If, for example, buffer.Unmap() is called inside the callback.
+ buffer->requests.erase(requestIt);
+
+ //* On success, we copy the data locally because the IPC buffer isn't valid outside of this function
+ if (cmd->status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
+ //* The server didn't send the right amount of data, this is an error and could cause
+ //* the application to crash if we did call the callback.
+ if (request.size != cmd->dataLength) {
+ return false;
+ }
+
+ ASSERT(requestData != nullptr);
+
+ if (buffer->mappedData != nullptr) {
+ return false;
+ }
+
+ buffer->isWriteMapped = false;
+ buffer->mappedDataSize = request.size;
+ buffer->mappedData = malloc(request.size);
+ memcpy(buffer->mappedData, requestData, request.size);
+
+ request.readCallback(static_cast<dawnBufferMapAsyncStatus>(cmd->status), buffer->mappedData, request.userdata);
+ } else {
+ request.readCallback(static_cast<dawnBufferMapAsyncStatus>(cmd->status), nullptr, request.userdata);
+ }
+
+ return true;
+ }
+
+ bool HandleBufferMapWriteAsyncCallback(const char** commands, size_t* size) {
+ const auto* cmd = GetCommand<ReturnBufferMapWriteAsyncCallbackCmd>(commands, size);
+ if (cmd == nullptr) {
+ return false;
+ }
+
+ auto* buffer = mDevice->buffer.GetObject(cmd->bufferId);
+ uint32_t bufferSerial = mDevice->buffer.GetSerial(cmd->bufferId);
+
+ //* The buffer might have been deleted or recreated so this isn't an error.
+ if (buffer == nullptr || bufferSerial != cmd->bufferSerial) {
+ return true;
+ }
+
+ //* The requests can have been deleted via an Unmap so this isn't an error.
+ auto requestIt = buffer->requests.find(cmd->requestSerial);
+ if (requestIt == buffer->requests.end()) {
+ return true;
+ }
+
+ //* It is an error for the server to call the write callback when we asked for a map read
+ if (!requestIt->second.isWrite) {
+ return false;
+ }
+
+ auto request = requestIt->second;
+ //* Delete the request before calling the callback otherwise the callback could be fired a second time. If, for example, buffer.Unmap() is called inside the callback.
+ buffer->requests.erase(requestIt);
+
+ //* On success, we copy the data locally because the IPC buffer isn't valid outside of this function
+ if (cmd->status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
+ if (buffer->mappedData != nullptr) {
+ return false;
+ }
+
+ buffer->isWriteMapped = true;
+ buffer->mappedDataSize = request.size;
+ buffer->mappedData = malloc(request.size);
+ memset(buffer->mappedData, 0, request.size);
+
+ request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(cmd->status), buffer->mappedData, request.userdata);
+ } else {
+ request.writeCallback(static_cast<dawnBufferMapAsyncStatus>(cmd->status), nullptr, request.userdata);
+ }
+
+ return true;
+ }
+ };
+
+ }
+
+ CommandHandler* NewClientDevice(dawnProcTable* procs, dawnDevice* device, CommandSerializer* serializer) {
+ auto clientDevice = new client::Device(serializer);
+
+ *device = reinterpret_cast<dawnDeviceImpl*>(clientDevice);
+ *procs = client::GetProcs();
+
+ return new client::Client(clientDevice);
+ }
+
+} // namespace dawn_wire
diff --git a/chromium/third_party/dawn/generator/templates/dawn_wire/WireCmd.cpp b/chromium/third_party/dawn/generator/templates/dawn_wire/WireCmd.cpp
new file mode 100644
index 00000000000..ceb828f123d
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_wire/WireCmd.cpp
@@ -0,0 +1,360 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "dawn_wire/WireCmd.h"
+
+#include "common/Assert.h"
+
+#include <cstring>
+
+//* Helper macros so that the main [de]serialization functions can be written in a generic manner.
+
+//* Outputs an rvalue that's the number of elements a pointer member points to.
+{% macro member_length(member, record_accessor) -%}
+ {%- if member.length == "constant" -%}
+ {{member.constant_length}}
+ {%- else -%}
+ {{record_accessor}}{{as_varName(member.length.name)}}
+ {%- endif -%}
+{%- endmacro %}
+
+//* Outputs the type that will be used on the wire for the member
+{% macro member_transfer_type(member) -%}
+ {%- if member.type.category == "object" -%}
+ ObjectId
+ {%- elif member.type.category == "structure" -%}
+ {{as_cType(member.type.name)}}Transfer
+ {%- else -%}
+ {{as_cType(member.type.name)}}
+ {%- endif -%}
+{%- endmacro %}
+
+//* Outputs the size of one element of the type that will be used on the wire for the member
+{% macro member_transfer_sizeof(member) -%}
+ sizeof({{member_transfer_type(member)}})
+{%- endmacro %}
+
+//* Outputs the serialization code to put `in` in `out`
+{% macro serialize_member(member, in, out) %}
+ {%- if member.type.category == "object" -%}
+ {% set Optional = "Optional" if member.optional else "" %}
+ {{out}} = provider.Get{{Optional}}Id({{in}});
+ {% elif member.type.category == "structure"%}
+ {{as_cType(member.type.name)}}Serialize({{in}}, &{{out}}, buffer, provider);
+ {%- else -%}
+ {{out}} = {{in}};
+ {%- endif -%}
+{% endmacro %}
+
+//* Outputs the deserialization code to put `in` in `out`
+{% macro deserialize_member(member, in, out) %}
+ {%- if member.type.category == "object" -%}
+ {% set Optional = "Optional" if member.optional else "" %}
+ DESERIALIZE_TRY(resolver.Get{{Optional}}FromId({{in}}, &{{out}}));
+ {% elif member.type.category == "structure"%}
+ DESERIALIZE_TRY({{as_cType(member.type.name)}}Deserialize(&{{out}}, &{{in}}, buffer, size, allocator, resolver));
+ {%- else -%}
+ {{out}} = {{in}};
+ {%- endif -%}
+{% endmacro %}
+
+//* The main [de]serialization macro
+
+//* Methods are very similar to structures that have one member corresponding to each arguments.
+//* This macro takes advantage of the similarity to output [de]serialization code for a record
+//* that is either a structure or a method, with some special cases for each.
+{% macro write_serialization_methods(name, members, as_method=None, as_struct=None, is_return_command=False) %}
+ {% set Return = "Return" if is_return_command else "" %}
+ {% set is_method = as_method != None %}
+ {% set is_struct = as_struct != None %}
+
+ //* Structure for the wire format of each of the records. Members that are values
+ //* are embedded directly in the structure. Other members are assumed to be in the
+ //* memory directly following the structure in the buffer.
+ struct {{name}}Transfer {
+ {% if is_method %}
+ //* Start the transfer structure with the command ID, so that casting to WireCmd gives the ID.
+ {{Return}}WireCmd commandId;
+
+ //* Methods always have an implicit "self" argument.
+ ObjectId self;
+
+ //* Methods that return objects need to declare to the server which ID will be used for the
+ //* return value.
+ {% if as_method.return_type.category == "object" %}
+ ObjectId resultId;
+ ObjectSerial resultSerial;
+ {% endif %}
+ {% endif %}
+
+ //* Value types are directly in the command, objects being replaced with their IDs.
+ {% for member in members if member.annotation == "value" %}
+ {{member_transfer_type(member)}} {{as_varName(member.name)}};
+ {% endfor %}
+
+ //* const char* have their length embedded directly in the command.
+ {% for member in members if member.length == "strlen" %}
+ size_t {{as_varName(member.name)}}Strlen;
+ {% endfor %}
+ };
+
+ //* Returns the required transfer size for `record` in addition to the transfer structure.
+ size_t {{name}}GetExtraRequiredSize(const {{name}}& record) {
+ DAWN_UNUSED(record);
+
+ size_t result = 0;
+
+ //* Special handling of const char* that have their length embedded directly in the command
+ {% for member in members if member.length == "strlen" %}
+ result += std::strlen(record.{{as_varName(member.name)}});
+ {% endfor %}
+
+ //* Gather how much space will be needed for pointer members.
+ {% for member in members if member.annotation != "value" and member.length != "strlen" %}
+ {
+ size_t memberLength = {{member_length(member, "record.")}};
+ result += memberLength * {{member_transfer_sizeof(member)}};
+
+ //* Structures might contain more pointers so we need to add their extra size as well.
+ {% if member.type.category == "structure" %}
+ for (size_t i = 0; i < memberLength; ++i) {
+ result += {{as_cType(member.type.name)}}GetExtraRequiredSize(record.{{as_varName(member.name)}}[i]);
+ }
+ {% endif %}
+ }
+ {% endfor %}
+
+ return result;
+ }
+ // GetExtraRequiredSize isn't used for structures that are value members of other structures
+ // because we assume they cannot contain pointers themselves.
+ DAWN_UNUSED_FUNC({{name}}GetExtraRequiredSize);
+
+ //* Serializes `record` into `transfer`, using `buffer` to get more space for pointed-to data
+ //* and `provider` to serialize objects.
+ void {{name}}Serialize(const {{name}}& record, {{name}}Transfer* transfer,
+ char* buffer, const ObjectIdProvider& provider) {
+ DAWN_UNUSED(provider);
+ DAWN_UNUSED(buffer);
+
+ //* Handle special transfer members of methods.
+ {% if is_method %}
+ {% if as_method.return_type.category == "object" %}
+ transfer->resultId = record.resultId;
+ transfer->resultSerial = record.resultSerial;
+ {% endif %}
+
+ transfer->commandId = {{Return}}WireCmd::{{name}};
+ transfer->self = provider.GetId(record.self);
+ {% endif %}
+
+ //* Value types are directly in the transfer record, objects being replaced with their IDs.
+ {% for member in members if member.annotation == "value" %}
+ {% set memberName = as_varName(member.name) %}
+ {{serialize_member(member, "record." + memberName, "transfer->" + memberName)}}
+ {% endfor %}
+
+ //* Special handling of const char* that have their length embedded directly in the command
+ {% for member in members if member.length == "strlen" %}
+ {% set memberName = as_varName(member.name) %}
+ transfer->{{memberName}}Strlen = std::strlen(record.{{memberName}});
+
+ memcpy(buffer, record.{{memberName}}, transfer->{{memberName}}Strlen);
+ buffer += transfer->{{memberName}}Strlen;
+ {% endfor %}
+
+ //* Allocate space and write the non-value arguments in it.
+ {% for member in members if member.annotation != "value" and member.length != "strlen" %}
+ {% set memberName = as_varName(member.name) %}
+ {
+ size_t memberLength = {{member_length(member, "record.")}};
+ auto memberBuffer = reinterpret_cast<{{member_transfer_type(member)}}*>(buffer);
+
+ buffer += memberLength * {{member_transfer_sizeof(member)}};
+ for (size_t i = 0; i < memberLength; ++i) {
+ {{serialize_member(member, "record." + memberName + "[i]", "memberBuffer[i]" )}}
+ }
+ }
+ {% endfor %}
+ }
+
+ //* Deserializes `transfer` into `record` getting more serialized data from `buffer` and `size`
+ //* if needed, using `allocator` to store pointed-to values and `resolver` to translate object
+ //* Ids to actual objects.
+ DeserializeResult {{name}}Deserialize({{name}}* record, const {{name}}Transfer* transfer,
+ const char** buffer, size_t* size, DeserializeAllocator* allocator, const ObjectIdResolver& resolver) {
+ DAWN_UNUSED(allocator);
+ DAWN_UNUSED(resolver);
+ DAWN_UNUSED(buffer);
+ DAWN_UNUSED(size);
+
+ //* Handle special transfer members for methods
+ {% if is_method %}
+ {% if as_method.return_type.category == "object" %}
+ record->resultId = transfer->resultId;
+ record->resultSerial = transfer->resultSerial;
+ {% endif %}
+
+ ASSERT(transfer->commandId == {{Return}}WireCmd::{{name}});
+
+ record->selfId = transfer->self;
+ //* This conversion is done after the copying of result* and selfId: Deserialize
+ //* guarantees they are filled even if there is an ID for an error object for the
+ //* Maybe monad mechanism.
+ DESERIALIZE_TRY(resolver.GetFromId(record->selfId, &record->self));
+
+ //* The object resolver returns a success even if the object is null because the
+ //* frontend is reponsible to validate that (null objects sometimes have special
+ //* meanings). However it is never valid to call a method on a null object so we
+ //* can error out in that case.
+ if (record->self == nullptr) {
+ return DeserializeResult::FatalError;
+ }
+ {% endif %}
+
+ {% if is_struct and as_struct.extensible %}
+ record->nextInChain = nullptr;
+ {% endif %}
+
+ //* Value types are directly in the transfer record, objects being replaced with their IDs.
+ {% for member in members if member.annotation == "value" %}
+ {% set memberName = as_varName(member.name) %}
+ {{deserialize_member(member, "transfer->" + memberName, "record->" + memberName)}}
+ {% endfor %}
+
+ //* Special handling of const char* that have their length embedded directly in the command
+ {% for member in members if member.length == "strlen" %}
+ {% set memberName = as_varName(member.name) %}
+ {
+ size_t stringLength = transfer->{{memberName}}Strlen;
+ const char* stringInBuffer = nullptr;
+ DESERIALIZE_TRY(GetPtrFromBuffer(buffer, size, stringLength, &stringInBuffer));
+
+ char* copiedString = nullptr;
+ DESERIALIZE_TRY(GetSpace(allocator, stringLength + 1, &copiedString));
+ memcpy(copiedString, stringInBuffer, stringLength);
+ copiedString[stringLength] = '\0';
+ record->{{memberName}} = copiedString;
+ }
+ {% endfor %}
+
+ //* Get extra buffer data, and copy pointed to values in extra allocated space.
+ {% for member in members if member.annotation != "value" and member.length != "strlen" %}
+ {% set memberName = as_varName(member.name) %}
+ {
+ size_t memberLength = {{member_length(member, "record->")}};
+ auto memberBuffer = reinterpret_cast<const {{member_transfer_type(member)}}*>(buffer);
+ DESERIALIZE_TRY(GetPtrFromBuffer(buffer, size, memberLength, &memberBuffer));
+
+ {{as_cType(member.type.name)}}* copiedMembers = nullptr;
+ DESERIALIZE_TRY(GetSpace(allocator, memberLength, &copiedMembers));
+ record->{{memberName}} = copiedMembers;
+
+ for (size_t i = 0; i < memberLength; ++i) {
+ {{deserialize_member(member, "memberBuffer[i]", "copiedMembers[i]")}}
+ }
+ }
+ {% endfor %}
+
+ return DeserializeResult::Success;
+ }
+{% endmacro %}
+
+namespace dawn_wire {
+
+ // Macro to simplify error handling, similar to DAWN_TRY but for DeserializeResult.
+#define DESERIALIZE_TRY(EXPR) \
+ { \
+ DeserializeResult exprResult = EXPR; \
+ if (exprResult != DeserializeResult::Success) { \
+ return exprResult; \
+ } \
+ }
+
+ namespace {
+
+ // Consumes from (buffer, size) enough memory to contain T[count] and return it in data.
+ // Returns FatalError if not enough memory was available
+ template <typename T>
+ DeserializeResult GetPtrFromBuffer(const char** buffer, size_t* size, size_t count, const T** data) {
+ // TODO(cwallez@chromium.org): For robustness we would need to handle overflows here.
+ size_t totalSize = sizeof(T) * count;
+ if (totalSize > *size) {
+ return DeserializeResult::FatalError;
+ }
+
+ *data = reinterpret_cast<const T*>(*buffer);
+ *buffer += totalSize;
+ *size -= totalSize;
+
+ return DeserializeResult::Success;
+ }
+
+ // Allocates enough space from allocator to countain T[count] and return it in out.
+ // Return FatalError if the allocator couldn't allocate the memory.
+ template <typename T>
+ DeserializeResult GetSpace(DeserializeAllocator* allocator, size_t count, T** out) {
+ // TODO(cwallez@chromium.org): For robustness we would need to handle overflows here.
+ size_t totalSize = sizeof(T) * count;
+ *out = static_cast<T*>(allocator->GetSpace(totalSize));
+ if (*out == nullptr) {
+ return DeserializeResult::FatalError;
+ }
+
+ return DeserializeResult::Success;
+ }
+
+ //* Output structure [de]serialization first because it is used by methods.
+ {% for type in by_category["structure"] %}
+ {% set name = as_cType(type.name) %}
+ {{write_serialization_methods(name, type.members, as_struct=type)}}
+ {% endfor %}
+
+ // * Output [de]serialization helpers for methods
+ {% for type in by_category["object"] %}
+ {% for method in type.methods %}
+ {% set name = as_MethodSuffix(type.name, method.name) %}
+
+ using {{name}} = {{name}}Cmd;
+ {{write_serialization_methods(name, method.arguments, as_method=method)}}
+ {% endfor %}
+ {% endfor %}
+ } // anonymous namespace
+
+ {% for type in by_category["object"] %}
+ {% for method in type.methods %}
+ {% set name = as_MethodSuffix(type.name, method.name) %}
+ {% set Cmd = name + "Cmd" %}
+
+ size_t {{Cmd}}::GetRequiredSize() const {
+ return sizeof({{name}}Transfer) + {{name}}GetExtraRequiredSize(*this);
+ }
+
+ void {{Cmd}}::Serialize(char* buffer, const ObjectIdProvider& objectIdProvider) const {
+ auto transfer = reinterpret_cast<{{name}}Transfer*>(buffer);
+ buffer += sizeof({{name}}Transfer);
+
+ {{name}}Serialize(*this, transfer, buffer, objectIdProvider);
+ }
+
+ DeserializeResult {{Cmd}}::Deserialize(const char** buffer, size_t* size, DeserializeAllocator* allocator, const ObjectIdResolver& resolver) {
+ const {{name}}Transfer* transfer = nullptr;
+ DESERIALIZE_TRY(GetPtrFromBuffer(buffer, size, 1, &transfer));
+
+ return {{name}}Deserialize(this, transfer, buffer, size, allocator, resolver);
+ }
+ {% endfor %}
+ {% endfor %}
+
+} // namespace dawn_wire
diff --git a/chromium/third_party/dawn/generator/templates/dawn_wire/WireCmd.h b/chromium/third_party/dawn/generator/templates/dawn_wire/WireCmd.h
new file mode 100644
index 00000000000..2d5300872d3
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_wire/WireCmd.h
@@ -0,0 +1,147 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#ifndef DAWNWIRE_WIRECMD_AUTOGEN_H_
+#define DAWNWIRE_WIRECMD_AUTOGEN_H_
+
+namespace dawn_wire {
+
+ using ObjectId = uint32_t;
+ using ObjectSerial = uint32_t;
+
+ enum class DeserializeResult {
+ Success,
+ FatalError,
+ ErrorObject,
+ };
+
+ // Interface to allocate more space to deserialize pointed-to data.
+ // nullptr is treated as an error.
+ class DeserializeAllocator {
+ public:
+ virtual void* GetSpace(size_t size) = 0;
+ };
+
+ // Interface to convert an ID to a server object, if possible.
+ // Methods return FatalError if the ID is for a non-existent object, ErrorObject if the
+ // object is an error value and Success otherwise.
+ class ObjectIdResolver {
+ public:
+ {% for type in by_category["object"] %}
+ virtual DeserializeResult GetFromId(ObjectId id, {{as_cType(type.name)}}* out) const = 0;
+ virtual DeserializeResult GetOptionalFromId(ObjectId id, {{as_cType(type.name)}}* out) const = 0;
+ {% endfor %}
+ };
+
+ // Interface to convert a client object to its ID for the wiring.
+ class ObjectIdProvider {
+ public:
+ {% for type in by_category["object"] %}
+ virtual ObjectId GetId({{as_cType(type.name)}} object) const = 0;
+ virtual ObjectId GetOptionalId({{as_cType(type.name)}} object) const = 0;
+ {% endfor %}
+ };
+
+ //* Enum used as a prefix to each command on the wire format.
+ enum class WireCmd : uint32_t {
+ {% for type in by_category["object"] %}
+ {% for method in type.methods %}
+ {{as_MethodSuffix(type.name, method.name)}},
+ {% endfor %}
+ {{as_MethodSuffix(type.name, Name("destroy"))}},
+ {% endfor %}
+ BufferMapAsync,
+ BufferUpdateMappedDataCmd,
+ };
+
+ {% for type in by_category["object"] %}
+ {% for method in type.methods %}
+ {% set Suffix = as_MethodSuffix(type.name, method.name) %}
+ {% set Cmd = Suffix + "Cmd" %}
+
+ //* These are "structure" version of the list of arguments to the different Dawn methods.
+ //* They provide helpers to serialize/deserialize to/from a buffer.
+ struct {{Cmd}} {
+ //* From a filled structure, compute how much size will be used in the serialization buffer.
+ size_t GetRequiredSize() const;
+
+ //* Serialize the structure and everything it points to into serializeBuffer which must be
+ //* big enough to contain all the data (as queried from GetRequiredSize).
+ void Serialize(char* serializeBuffer, const ObjectIdProvider& objectIdProvider) const;
+
+ //* Deserializes the structure from a buffer, consuming a maximum of *size bytes. When this
+ //* function returns, buffer and size will be updated by the number of bytes consumed to
+ //* deserialize the structure. Structures containing pointers will use allocator to get
+ //* scratch space to deserialize the pointed-to data.
+ //* Deserialize returns:
+ //* - Success if everything went well (yay!)
+ //* - FatalError is something bad happened (buffer too small for example)
+ //* - ErrorObject if one if the deserialized object is an error value, for the implementation
+ //* of the Maybe monad.
+ //* If the return value is not FatalError, selfId, resultId and resultSerial (if present) are
+ //* filled.
+ DeserializeResult Deserialize(const char** buffer, size_t* size, DeserializeAllocator* allocator, const ObjectIdResolver& resolver);
+
+ {{as_cType(type.name)}} self;
+
+ //* Command handlers want to know the object ID in addition to the backing object.
+ //* Doesn't need to be filled before Serialize, or GetRequiredSize.
+ ObjectId selfId;
+
+ //* Commands creating objects say which ID the created object will be referred as.
+ {% if method.return_type.category == "object" %}
+ ObjectId resultId;
+ ObjectSerial resultSerial;
+ {% endif %}
+
+ {% for arg in method.arguments %}
+ {{as_annotated_cType(arg)}};
+ {% endfor %}
+ };
+ {% endfor %}
+
+ //* The command structure used when sending that an ID is destroyed.
+ {% set Suffix = as_MethodSuffix(type.name, Name("destroy")) %}
+ struct {{Suffix}}Cmd {
+ WireCmd commandId = WireCmd::{{Suffix}};
+ ObjectId objectId;
+ };
+
+ {% endfor %}
+
+ //* Enum used as a prefix to each command on the return wire format.
+ enum class ReturnWireCmd : uint32_t {
+ DeviceErrorCallback,
+ {% for type in by_category["object"] if type.is_builder %}
+ {{type.name.CamelCase()}}ErrorCallback,
+ {% endfor %}
+ BufferMapReadAsyncCallback,
+ BufferMapWriteAsyncCallback,
+ };
+
+ //* Command for the server calling a builder status callback.
+ {% for type in by_category["object"] if type.is_builder %}
+ struct Return{{type.name.CamelCase()}}ErrorCallbackCmd {
+ ReturnWireCmd commandId = ReturnWireCmd::{{type.name.CamelCase()}}ErrorCallback;
+
+ ObjectId builtObjectId;
+ ObjectSerial builtObjectSerial;
+ uint32_t status;
+ size_t messageStrlen;
+ };
+ {% endfor %}
+
+} // namespace dawn_wire
+
+#endif // DAWNWIRE_WIRECMD_AUTOGEN_H_
diff --git a/chromium/third_party/dawn/generator/templates/dawn_wire/WireServer.cpp b/chromium/third_party/dawn/generator/templates/dawn_wire/WireServer.cpp
new file mode 100644
index 00000000000..ebc341760bd
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/dawn_wire/WireServer.cpp
@@ -0,0 +1,648 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "dawn_wire/Wire.h"
+#include "dawn_wire/WireCmd.h"
+
+#include "common/Assert.h"
+
+#include <algorithm>
+#include <cstdlib>
+#include <cstring>
+#include <vector>
+
+namespace dawn_wire {
+
+ namespace server {
+ class Server;
+
+ struct MapUserdata {
+ Server* server;
+ uint32_t bufferId;
+ uint32_t bufferSerial;
+ uint32_t requestSerial;
+ uint32_t size;
+ bool isWrite;
+ };
+
+ //* Stores what the backend knows about the type.
+ template<typename T>
+ struct ObjectDataBase {
+ //* The backend-provided handle and serial to this object.
+ T handle;
+ uint32_t serial = 0;
+
+ //* Built object ID and serial, needed to send to the client along with builder error callbacks
+ //* TODO(cwallez@chromium.org) only have this for builder T
+ uint32_t builtObjectId = 0;
+ uint32_t builtObjectSerial = 0;
+
+ //* Used by the error-propagation mechanism to know if this object is an error.
+ //* TODO(cwallez@chromium.org): this is doubling the memory usage of
+ //* std::vector<ObjectDataBase> consider making it a special marker value in handle instead.
+ bool valid;
+ //* Whether this object has been allocated, used by the KnownObjects queries
+ //* TODO(cwallez@chromium.org): make this an internal bit vector in KnownObjects.
+ bool allocated;
+
+ //* TODO(cwallez@chromium.org): this is only useful for buffers
+ void* mappedData = nullptr;
+ size_t mappedDataSize = 0;
+ };
+
+ //* Keeps track of the mapping between client IDs and backend objects.
+ template<typename T>
+ class KnownObjects {
+ public:
+ using Data = ObjectDataBase<T>;
+
+ KnownObjects() {
+ //* Pre-allocate ID 0 to refer to the null handle.
+ Data nullObject;
+ nullObject.handle = nullptr;
+ nullObject.valid = true;
+ nullObject.allocated = true;
+ mKnown.push_back(nullObject);
+ }
+
+ //* Get a backend objects for a given client ID.
+ //* Returns nullptr if the ID hasn't previously been allocated.
+ const Data* Get(uint32_t id) const {
+ if (id >= mKnown.size()) {
+ return nullptr;
+ }
+
+ const Data* data = &mKnown[id];
+
+ if (!data->allocated) {
+ return nullptr;
+ }
+
+ return data;
+ }
+ Data* Get(uint32_t id) {
+ if (id >= mKnown.size()) {
+ return nullptr;
+ }
+
+ Data* data = &mKnown[id];
+
+ if (!data->allocated) {
+ return nullptr;
+ }
+
+ return data;
+ }
+
+ //* Allocates the data for a given ID and returns it.
+ //* Returns nullptr if the ID is already allocated, or too far ahead.
+ //* Invalidates all the Data*
+ Data* Allocate(uint32_t id) {
+ if (id > mKnown.size()) {
+ return nullptr;
+ }
+
+ Data data;
+ data.allocated = true;
+ data.valid = false;
+ data.handle = nullptr;
+
+ if (id >= mKnown.size()) {
+ mKnown.push_back(data);
+ return &mKnown.back();
+ }
+
+ if (mKnown[id].allocated) {
+ return nullptr;
+ }
+
+ mKnown[id] = data;
+ return &mKnown[id];
+ }
+
+ //* Marks an ID as deallocated
+ void Free(uint32_t id) {
+ ASSERT(id < mKnown.size());
+ mKnown[id].allocated = false;
+ }
+
+ private:
+ std::vector<Data> mKnown;
+ };
+
+ void ForwardDeviceErrorToServer(const char* message, dawnCallbackUserdata userdata);
+
+ {% for type in by_category["object"] if type.is_builder%}
+ void Forward{{type.name.CamelCase()}}ToClient(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
+ {% endfor %}
+
+ void ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status, const void* ptr, dawnCallbackUserdata userdata);
+ void ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status, void* ptr, dawnCallbackUserdata userdata);
+
+ // A really really simple implementation of the DeserializeAllocator. It's main feature
+ // is that it has some inline storage so as to avoid allocations for the majority of
+ // commands.
+ class ServerAllocator : public DeserializeAllocator {
+ public:
+ ServerAllocator() {
+ Reset();
+ }
+
+ ~ServerAllocator() {
+ Reset();
+ }
+
+ void* GetSpace(size_t size) override {
+ // Return space in the current buffer if possible first.
+ if (mRemainingSize >= size) {
+ char* buffer = mCurrentBuffer;
+ mCurrentBuffer += size;
+ mRemainingSize -= size;
+ return buffer;
+ }
+
+ // Otherwise allocate a new buffer and try again.
+ size_t allocationSize = std::max(size, size_t(2048));
+ char* allocation = static_cast<char*>(malloc(allocationSize));
+ if (allocation == nullptr) {
+ return nullptr;
+ }
+
+ mAllocations.push_back(allocation);
+ mCurrentBuffer = allocation;
+ mRemainingSize = allocationSize;
+ return GetSpace(size);
+ }
+
+ void Reset() {
+ for (auto allocation : mAllocations) {
+ free(allocation);
+ }
+ mAllocations.clear();
+
+ // The initial buffer is the inline buffer so that some allocations can be skipped
+ mCurrentBuffer = mStaticBuffer;
+ mRemainingSize = sizeof(mStaticBuffer);
+ }
+
+ private:
+ size_t mRemainingSize = 0;
+ char* mCurrentBuffer = nullptr;
+ char mStaticBuffer[2048];
+ std::vector<char*> mAllocations;
+ };
+
+ class Server : public CommandHandler, public ObjectIdResolver {
+ public:
+ Server(dawnDevice device, const dawnProcTable& procs, CommandSerializer* serializer)
+ : mProcs(procs), mSerializer(serializer) {
+ //* The client-server knowledge is bootstrapped with device 1.
+ auto* deviceData = mKnownDevice.Allocate(1);
+ deviceData->handle = device;
+ deviceData->valid = true;
+
+ auto userdata = static_cast<dawnCallbackUserdata>(reinterpret_cast<intptr_t>(this));
+ procs.deviceSetErrorCallback(device, ForwardDeviceErrorToServer, userdata);
+ }
+
+ void OnDeviceError(const char* message) {
+ ReturnDeviceErrorCallbackCmd cmd;
+ cmd.messageStrlen = std::strlen(message);
+
+ auto allocCmd = static_cast<ReturnDeviceErrorCallbackCmd*>(GetCmdSpace(sizeof(cmd)));
+ *allocCmd = cmd;
+
+ char* messageAlloc = static_cast<char*>(GetCmdSpace(cmd.messageStrlen + 1));
+ strcpy(messageAlloc, message);
+ }
+
+ {% for type in by_category["object"] if type.is_builder%}
+ {% set Type = type.name.CamelCase() %}
+ void On{{Type}}Error(dawnBuilderErrorStatus status, const char* message, uint32_t id, uint32_t serial) {
+ auto* builder = mKnown{{Type}}.Get(id);
+
+ if (builder == nullptr || builder->serial != serial) {
+ return;
+ }
+
+ if (status != DAWN_BUILDER_ERROR_STATUS_SUCCESS) {
+ builder->valid = false;
+ }
+
+ if (status != DAWN_BUILDER_ERROR_STATUS_UNKNOWN) {
+ //* Unknown is the only status that can be returned without a call to GetResult
+ //* so we are guaranteed to have created an object.
+ ASSERT(builder->builtObjectId != 0);
+
+ Return{{Type}}ErrorCallbackCmd cmd;
+ cmd.builtObjectId = builder->builtObjectId;
+ cmd.builtObjectSerial = builder->builtObjectSerial;
+ cmd.status = status;
+ cmd.messageStrlen = std::strlen(message);
+
+ auto allocCmd = static_cast<Return{{Type}}ErrorCallbackCmd*>(GetCmdSpace(sizeof(cmd)));
+ *allocCmd = cmd;
+ char* messageAlloc = static_cast<char*>(GetCmdSpace(strlen(message) + 1));
+ strcpy(messageAlloc, message);
+ }
+ }
+ {% endfor %}
+
+ void OnMapReadAsyncCallback(dawnBufferMapAsyncStatus status, const void* ptr, MapUserdata* data) {
+ ReturnBufferMapReadAsyncCallbackCmd cmd;
+ cmd.bufferId = data->bufferId;
+ cmd.bufferSerial = data->bufferSerial;
+ cmd.requestSerial = data->requestSerial;
+ cmd.status = status;
+ cmd.dataLength = 0;
+
+ auto allocCmd = static_cast<ReturnBufferMapReadAsyncCallbackCmd*>(GetCmdSpace(sizeof(cmd)));
+ *allocCmd = cmd;
+
+ if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
+ allocCmd->dataLength = data->size;
+
+ void* dataAlloc = GetCmdSpace(data->size);
+ memcpy(dataAlloc, ptr, data->size);
+ }
+
+ delete data;
+ }
+
+ void OnMapWriteAsyncCallback(dawnBufferMapAsyncStatus status, void* ptr, MapUserdata* data) {
+ ReturnBufferMapWriteAsyncCallbackCmd cmd;
+ cmd.bufferId = data->bufferId;
+ cmd.bufferSerial = data->bufferSerial;
+ cmd.requestSerial = data->requestSerial;
+ cmd.status = status;
+
+ auto allocCmd = static_cast<ReturnBufferMapWriteAsyncCallbackCmd*>(GetCmdSpace(sizeof(cmd)));
+ *allocCmd = cmd;
+
+ if (status == DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS) {
+ auto* selfData = mKnownBuffer.Get(data->bufferId);
+ ASSERT(selfData != nullptr);
+
+ selfData->mappedData = ptr;
+ selfData->mappedDataSize = data->size;
+ }
+
+ delete data;
+ }
+
+ const char* HandleCommands(const char* commands, size_t size) override {
+ mProcs.deviceTick(mKnownDevice.Get(1)->handle);
+
+ while (size >= sizeof(WireCmd)) {
+ WireCmd cmdId = *reinterpret_cast<const WireCmd*>(commands);
+
+ bool success = false;
+ switch (cmdId) {
+ {% for type in by_category["object"] %}
+ {% for method in type.methods %}
+ {% set Suffix = as_MethodSuffix(type.name, method.name) %}
+ case WireCmd::{{Suffix}}:
+ success = Handle{{Suffix}}(&commands, &size);
+ break;
+ {% endfor %}
+ {% set Suffix = as_MethodSuffix(type.name, Name("destroy")) %}
+ case WireCmd::{{Suffix}}:
+ success = Handle{{Suffix}}(&commands, &size);
+ break;
+ {% endfor %}
+ case WireCmd::BufferMapAsync:
+ success = HandleBufferMapAsync(&commands, &size);
+ break;
+ case WireCmd::BufferUpdateMappedDataCmd:
+ success = HandleBufferUpdateMappedData(&commands, &size);
+ break;
+
+ default:
+ success = false;
+ }
+
+ if (!success) {
+ return nullptr;
+ }
+ mAllocator.Reset();
+ }
+
+ if (size != 0) {
+ return nullptr;
+ }
+
+ return commands;
+ }
+
+ private:
+ dawnProcTable mProcs;
+ CommandSerializer* mSerializer = nullptr;
+
+ ServerAllocator mAllocator;
+
+ void* GetCmdSpace(size_t size) {
+ return mSerializer->GetCmdSpace(size);
+ }
+
+ // Implementation of the ObjectIdResolver interface
+ {% for type in by_category["object"] %}
+ DeserializeResult GetFromId(ObjectId id, {{as_cType(type.name)}}* out) const final {
+ auto data = mKnown{{type.name.CamelCase()}}.Get(id);
+ if (data == nullptr) {
+ return DeserializeResult::FatalError;
+ }
+
+ *out = data->handle;
+ if (data->valid) {
+ return DeserializeResult::Success;
+ } else {
+ return DeserializeResult::ErrorObject;
+ }
+ }
+
+ DeserializeResult GetOptionalFromId(ObjectId id, {{as_cType(type.name)}}* out) const final {
+ if (id == 0) {
+ *out = nullptr;
+ return DeserializeResult::Success;
+ }
+
+ return GetFromId(id, out);
+ }
+ {% endfor %}
+
+ //* The list of known IDs for each object type.
+ {% for type in by_category["object"] %}
+ KnownObjects<{{as_cType(type.name)}}> mKnown{{type.name.CamelCase()}};
+ {% endfor %}
+
+ //* Helper function for the getting of the command data in command handlers.
+ //* Checks there is enough data left, updates the buffer / size and returns
+ //* the command (or nullptr for an error).
+ template <typename T>
+ static const T* GetData(const char** buffer, size_t* size, size_t count) {
+ // TODO(cwallez@chromium.org): Check for overflow
+ size_t totalSize = count * sizeof(T);
+ if (*size < totalSize) {
+ return nullptr;
+ }
+
+ const T* data = reinterpret_cast<const T*>(*buffer);
+
+ *buffer += totalSize;
+ *size -= totalSize;
+
+ return data;
+ }
+ template <typename T>
+ static const T* GetCommand(const char** commands, size_t* size) {
+ return GetData<T>(commands, size, 1);
+ }
+
+ {% set custom_pre_handler_commands = ["BufferUnmap"] %}
+
+ bool PreHandleBufferUnmap(const BufferUnmapCmd& cmd) {
+ auto* selfData = mKnownBuffer.Get(cmd.selfId);
+ ASSERT(selfData != nullptr);
+
+ selfData->mappedData = nullptr;
+
+ return true;
+ }
+
+ //* Implementation of the command handlers
+ {% for type in by_category["object"] %}
+ {% for method in type.methods %}
+ {% set Suffix = as_MethodSuffix(type.name, method.name) %}
+
+ //* The generic command handlers
+
+ bool Handle{{Suffix}}(const char** commands, size_t* size) {
+ {{Suffix}}Cmd cmd;
+ DeserializeResult deserializeResult = cmd.Deserialize(commands, size, &mAllocator, *this);
+
+ if (deserializeResult == DeserializeResult::FatalError) {
+ return false;
+ }
+
+ {% if Suffix in custom_pre_handler_commands %}
+ if (!PreHandle{{Suffix}}(cmd)) {
+ return false;
+ }
+ {% endif %}
+
+ //* Unpack 'self'
+ auto* selfData = mKnown{{type.name.CamelCase()}}.Get(cmd.selfId);
+ ASSERT(selfData != nullptr);
+
+ //* In all cases allocate the object data as it will be refered-to by the client.
+ {% set return_type = method.return_type %}
+ {% set returns = return_type.name.canonical_case() != "void" %}
+ {% if returns %}
+ {% set Type = method.return_type.name.CamelCase() %}
+ auto* resultData = mKnown{{Type}}.Allocate(cmd.resultId);
+ if (resultData == nullptr) {
+ return false;
+ }
+ resultData->serial = cmd.resultSerial;
+
+ {% if type.is_builder %}
+ selfData->builtObjectId = cmd.resultId;
+ selfData->builtObjectSerial = cmd.resultSerial;
+ {% endif %}
+ {% endif %}
+
+ //* After the data is allocated, apply the argument error propagation mechanism
+ if (deserializeResult == DeserializeResult::ErrorObject) {
+ {% if type.is_builder %}
+ selfData->valid = false;
+ //* If we are in GetResult, fake an error callback
+ {% if returns %}
+ On{{type.name.CamelCase()}}Error(DAWN_BUILDER_ERROR_STATUS_ERROR, "Maybe monad", cmd.selfId, selfData->serial);
+ {% endif %}
+ {% endif %}
+ return true;
+ }
+
+ {% if returns %}
+ auto result ={{" "}}
+ {%- endif %}
+ mProcs.{{as_varName(type.name, method.name)}}(cmd.self
+ {%- for arg in method.arguments -%}
+ , cmd.{{as_varName(arg.name)}}
+ {%- endfor -%}
+ );
+
+ {% if returns %}
+ resultData->handle = result;
+ resultData->valid = result != nullptr;
+
+ //* builders remember the ID of the object they built so that they can send it
+ //* in the callback to the client.
+ {% if return_type.is_builder %}
+ if (result != nullptr) {
+ uint64_t userdata1 = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(this));
+ uint64_t userdata2 = (uint64_t(resultData->serial) << uint64_t(32)) + cmd.resultId;
+ mProcs.{{as_varName(return_type.name, Name("set error callback"))}}(result, Forward{{return_type.name.CamelCase()}}ToClient, userdata1, userdata2);
+ }
+ {% endif %}
+ {% endif %}
+
+ return true;
+ }
+ {% endfor %}
+
+ //* Handlers for the destruction of objects: clients do the tracking of the
+ //* reference / release and only send destroy on refcount = 0.
+ {% set Suffix = as_MethodSuffix(type.name, Name("destroy")) %}
+ bool Handle{{Suffix}}(const char** commands, size_t* size) {
+ const auto* cmd = GetCommand<{{Suffix}}Cmd>(commands, size);
+ if (cmd == nullptr) {
+ return false;
+ }
+
+ ObjectId objectId = cmd->objectId;
+
+ //* ID 0 are reserved for nullptr and cannot be destroyed.
+ if (objectId == 0) {
+ return false;
+ }
+
+ auto* data = mKnown{{type.name.CamelCase()}}.Get(objectId);
+ if (data == nullptr) {
+ return false;
+ }
+
+ if (data->valid) {
+ mProcs.{{as_varName(type.name, Name("release"))}}(data->handle);
+ }
+
+ mKnown{{type.name.CamelCase()}}.Free(objectId);
+ return true;
+ }
+ {% endfor %}
+
+ bool HandleBufferMapAsync(const char** commands, size_t* size) {
+ //* These requests are just forwarded to the buffer, with userdata containing what the client
+ //* will require in the return command.
+ const auto* cmd = GetCommand<BufferMapAsyncCmd>(commands, size);
+ if (cmd == nullptr) {
+ return false;
+ }
+
+ ObjectId bufferId = cmd->bufferId;
+ uint32_t requestSerial = cmd->requestSerial;
+ uint32_t requestSize = cmd->size;
+ uint32_t requestStart = cmd->start;
+ bool isWrite = cmd->isWrite;
+
+ //* The null object isn't valid as `self`
+ if (bufferId == 0) {
+ return false;
+ }
+
+ auto* buffer = mKnownBuffer.Get(bufferId);
+ if (buffer == nullptr) {
+ return false;
+ }
+
+ auto* data = new MapUserdata;
+ data->server = this;
+ data->bufferId = bufferId;
+ data->bufferSerial = buffer->serial;
+ data->requestSerial = requestSerial;
+ data->size = requestSize;
+ data->isWrite = isWrite;
+
+ auto userdata = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(data));
+
+ if (!buffer->valid) {
+ //* Fake the buffer returning a failure, data will be freed in this call.
+ if (isWrite) {
+ ForwardBufferMapWriteAsync(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
+ } else {
+ ForwardBufferMapReadAsync(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
+ }
+ return true;
+ }
+
+ if (isWrite) {
+ mProcs.bufferMapWriteAsync(buffer->handle, requestStart, requestSize, ForwardBufferMapWriteAsync, userdata);
+ } else {
+ mProcs.bufferMapReadAsync(buffer->handle, requestStart, requestSize, ForwardBufferMapReadAsync, userdata);
+ }
+
+ return true;
+ }
+
+ bool HandleBufferUpdateMappedData(const char** commands, size_t* size) {
+ const auto* cmd = GetCommand<BufferUpdateMappedDataCmd>(commands, size);
+ if (cmd == nullptr) {
+ return false;
+ }
+
+ ObjectId bufferId = cmd->bufferId;
+ size_t dataLength = cmd->dataLength;
+
+ //* The null object isn't valid as `self`
+ if (bufferId == 0) {
+ return false;
+ }
+
+ auto* buffer = mKnownBuffer.Get(bufferId);
+ if (buffer == nullptr || !buffer->valid || buffer->mappedData == nullptr ||
+ buffer->mappedDataSize != dataLength) {
+ return false;
+ }
+
+ const char* data = GetData<char>(commands, size, dataLength);
+ if (data == nullptr) {
+ return false;
+ }
+
+ memcpy(buffer->mappedData, data, dataLength);
+
+ return true;
+ }
+ };
+
+ void ForwardDeviceErrorToServer(const char* message, dawnCallbackUserdata userdata) {
+ auto server = reinterpret_cast<Server*>(static_cast<intptr_t>(userdata));
+ server->OnDeviceError(message);
+ }
+
+ {% for type in by_category["object"] if type.is_builder%}
+ void Forward{{type.name.CamelCase()}}ToClient(dawnBuilderErrorStatus status, const char* message, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) {
+ auto server = reinterpret_cast<Server*>(static_cast<uintptr_t>(userdata1));
+ uint32_t id = userdata2 & 0xFFFFFFFFu;
+ uint32_t serial = userdata2 >> uint64_t(32);
+ server->On{{type.name.CamelCase()}}Error(status, message, id, serial);
+ }
+ {% endfor %}
+
+ void ForwardBufferMapReadAsync(dawnBufferMapAsyncStatus status, const void* ptr, dawnCallbackUserdata userdata) {
+ auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
+ data->server->OnMapReadAsyncCallback(status, ptr, data);
+ }
+
+ void ForwardBufferMapWriteAsync(dawnBufferMapAsyncStatus status, void* ptr, dawnCallbackUserdata userdata) {
+ auto data = reinterpret_cast<MapUserdata*>(static_cast<uintptr_t>(userdata));
+ data->server->OnMapWriteAsyncCallback(status, ptr, data);
+ }
+ }
+
+ CommandHandler* NewServerCommandHandler(dawnDevice device, const dawnProcTable& procs, CommandSerializer* serializer) {
+ return new server::Server(device, procs, serializer);
+ }
+
+} // namespace dawn_wire
diff --git a/chromium/third_party/dawn/generator/templates/mock_api.cpp b/chromium/third_party/dawn/generator/templates/mock_api.cpp
new file mode 100644
index 00000000000..3c39d71357a
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/mock_api.cpp
@@ -0,0 +1,113 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#include "mock_dawn.h"
+
+namespace {
+ {% for type in by_category["object"] %}
+ {% for method in native_methods(type) if len(method.arguments) < 10 %}
+ {{as_cType(method.return_type.name)}} Forward{{as_MethodSuffix(type.name, method.name)}}(
+ {{-as_cType(type.name)}} self
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ ) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
+ return object->procs->{{as_MethodSuffix(type.name, method.name)}}(self
+ {%- for arg in method.arguments -%}
+ , {{as_varName(arg.name)}}
+ {%- endfor -%}
+ );
+ }
+ {% endfor %}
+
+ {% endfor %}
+}
+
+ProcTableAsClass::~ProcTableAsClass() {
+}
+
+void ProcTableAsClass::GetProcTableAndDevice(dawnProcTable* table, dawnDevice* device) {
+ *device = GetNewDevice();
+
+ {% for type in by_category["object"] %}
+ {% for method in native_methods(type) if len(method.arguments) < 10 %}
+ table->{{as_varName(type.name, method.name)}} = reinterpret_cast<{{as_cProc(type.name, method.name)}}>(Forward{{as_MethodSuffix(type.name, method.name)}});
+ {% endfor %}
+ {% endfor %}
+}
+
+void ProcTableAsClass::DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
+ object->deviceErrorCallback = callback;
+ object->userdata1 = userdata;
+
+ OnDeviceSetErrorCallback(self, callback, userdata);
+}
+
+void ProcTableAsClass::BufferMapReadAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
+ object->mapReadCallback = callback;
+ object->userdata1 = userdata;
+
+ OnBufferMapReadAsyncCallback(self, start, size, callback, userdata);
+}
+
+void ProcTableAsClass::BufferMapWriteAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
+ object->mapWriteCallback = callback;
+ object->userdata1 = userdata;
+
+ OnBufferMapWriteAsyncCallback(self, start, size, callback, userdata);
+}
+
+void ProcTableAsClass::CallDeviceErrorCallback(dawnDevice device, const char* message) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(device);
+ object->deviceErrorCallback(message, object->userdata1);
+}
+void ProcTableAsClass::CallBuilderErrorCallback(void* builder , dawnBuilderErrorStatus status, const char* message) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(builder);
+ object->builderErrorCallback(status, message, object->userdata1, object->userdata2);
+}
+void ProcTableAsClass::CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
+ object->mapReadCallback(status, data, object->userdata1);
+}
+
+void ProcTableAsClass::CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(buffer);
+ object->mapWriteCallback(status, data, object->userdata1);
+}
+
+{% for type in by_category["object"] if type.is_builder %}
+ void ProcTableAsClass::{{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) {
+ auto object = reinterpret_cast<ProcTableAsClass::Object*>(self);
+ object->builderErrorCallback = callback;
+ object->userdata1 = userdata1;
+ object->userdata2 = userdata2;
+
+ OnBuilderSetErrorCallback(reinterpret_cast<dawnBufferBuilder>(self), callback, userdata1, userdata2);
+ }
+{% endfor %}
+
+{% for type in by_category["object"] %}
+ {{as_cType(type.name)}} ProcTableAsClass::GetNew{{type.name.CamelCase()}}() {
+ mObjects.emplace_back(new Object);
+ mObjects.back()->procs = this;
+ return reinterpret_cast<{{as_cType(type.name)}}>(mObjects.back().get());
+ }
+{% endfor %}
+
+MockProcTable::MockProcTable() {
+}
diff --git a/chromium/third_party/dawn/generator/templates/mock_api.h b/chromium/third_party/dawn/generator/templates/mock_api.h
new file mode 100644
index 00000000000..b82a22afa3e
--- /dev/null
+++ b/chromium/third_party/dawn/generator/templates/mock_api.h
@@ -0,0 +1,117 @@
+//* Copyright 2017 The Dawn Authors
+//*
+//* Licensed under the Apache License, Version 2.0 (the "License");
+//* you may not use this file except in compliance with the License.
+//* You may obtain a copy of the License at
+//*
+//* http://www.apache.org/licenses/LICENSE-2.0
+//*
+//* Unless required by applicable law or agreed to in writing, software
+//* distributed under the License is distributed on an "AS IS" BASIS,
+//* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//* See the License for the specific language governing permissions and
+//* limitations under the License.
+
+#ifndef MOCK_DAWN_H
+#define MOCK_DAWN_H
+
+#include <gmock/gmock.h>
+#include <dawn/dawn.h>
+
+#include <memory>
+
+// An abstract base class representing a proc table so that API calls can be mocked. Most API calls
+// are directly represented by a delete virtual method but others need minimal state tracking to be
+// useful as mocks.
+class ProcTableAsClass {
+ public:
+ virtual ~ProcTableAsClass();
+
+ void GetProcTableAndDevice(dawnProcTable* table, dawnDevice* device);
+
+ // Creates an object that can be returned by a mocked call as in WillOnce(Return(foo)).
+ // It returns an object of the write type that isn't equal to any previously returned object.
+ // Otherwise some mock expectation could be triggered by two different objects having the same
+ // value.
+ {% for type in by_category["object"] %}
+ {{as_cType(type.name)}} GetNew{{type.name.CamelCase()}}();
+ {% endfor %}
+
+ {% for type in by_category["object"] %}
+ {% for method in type.methods if len(method.arguments) < 10 %}
+ virtual {{as_cType(method.return_type.name)}} {{as_MethodSuffix(type.name, method.name)}}(
+ {{-as_cType(type.name)}} {{as_varName(type.name)}}
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ ) = 0;
+ {% endfor %}
+ virtual void {{as_MethodSuffix(type.name, Name("reference"))}}({{as_cType(type.name)}} self) = 0;
+ virtual void {{as_MethodSuffix(type.name, Name("release"))}}({{as_cType(type.name)}} self) = 0;
+
+ // Stores callback and userdata and calls OnBuilderSetErrorCallback
+ {% if type.is_builder %}
+ void {{as_MethodSuffix(type.name, Name("set error callback"))}}({{as_cType(type.name)}} self, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2);
+ {% endif %}
+ {% endfor %}
+
+ // Stores callback and userdata and calls the On* methods
+ void DeviceSetErrorCallback(dawnDevice self, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata);
+ void BufferMapReadAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata);
+ void BufferMapWriteAsync(dawnBuffer self, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata);
+
+
+ // Special cased mockable methods
+ virtual void OnDeviceSetErrorCallback(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata) = 0;
+ virtual void OnBuilderSetErrorCallback(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2) = 0;
+ virtual void OnBufferMapReadAsyncCallback(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata) = 0;
+ virtual void OnBufferMapWriteAsyncCallback(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata) = 0;
+
+ // Calls the stored callbacks
+ void CallDeviceErrorCallback(dawnDevice device, const char* message);
+ void CallBuilderErrorCallback(void* builder , dawnBuilderErrorStatus status, const char* message);
+ void CallMapReadCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, const void* data);
+ void CallMapWriteCallback(dawnBuffer buffer, dawnBufferMapAsyncStatus status, void* data);
+
+ struct Object {
+ ProcTableAsClass* procs = nullptr;
+ dawnDeviceErrorCallback deviceErrorCallback = nullptr;
+ dawnBuilderErrorCallback builderErrorCallback = nullptr;
+ dawnBufferMapReadCallback mapReadCallback = nullptr;
+ dawnBufferMapWriteCallback mapWriteCallback = nullptr;
+ dawnCallbackUserdata userdata1 = 0;
+ dawnCallbackUserdata userdata2 = 0;
+ };
+
+ private:
+ // Remembers the values returned by GetNew* so they can be freed.
+ std::vector<std::unique_ptr<Object>> mObjects;
+};
+
+class MockProcTable : public ProcTableAsClass {
+ public:
+ MockProcTable();
+
+ {% for type in by_category["object"] %}
+ {% for method in type.methods if len(method.arguments) < 10 %}
+ MOCK_METHOD{{len(method.arguments) + 1}}(
+ {{-as_MethodSuffix(type.name, method.name)}},
+ {{as_cType(method.return_type.name)}}(
+ {{-as_cType(type.name)}} {{as_varName(type.name)}}
+ {%- for arg in method.arguments -%}
+ , {{as_annotated_cType(arg)}}
+ {%- endfor -%}
+ ));
+ {% endfor %}
+
+ MOCK_METHOD1({{as_MethodSuffix(type.name, Name("reference"))}}, void({{as_cType(type.name)}} self));
+ MOCK_METHOD1({{as_MethodSuffix(type.name, Name("release"))}}, void({{as_cType(type.name)}} self));
+ {% endfor %}
+
+ MOCK_METHOD3(OnDeviceSetErrorCallback, void(dawnDevice device, dawnDeviceErrorCallback callback, dawnCallbackUserdata userdata));
+ MOCK_METHOD4(OnBuilderSetErrorCallback, void(dawnBufferBuilder builder, dawnBuilderErrorCallback callback, dawnCallbackUserdata userdata1, dawnCallbackUserdata userdata2));
+ MOCK_METHOD5(OnBufferMapReadAsyncCallback, void(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapReadCallback callback, dawnCallbackUserdata userdata));
+ MOCK_METHOD5(OnBufferMapWriteAsyncCallback, void(dawnBuffer buffer, uint32_t start, uint32_t size, dawnBufferMapWriteCallback callback, dawnCallbackUserdata userdata));
+};
+
+#endif // MOCK_DAWN_H
diff --git a/chromium/third_party/dawn/infra/config/OWNERS b/chromium/third_party/dawn/infra/config/OWNERS
new file mode 100644
index 00000000000..6b5005f6688
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/OWNERS
@@ -0,0 +1,2 @@
+cwallez@chromium.org
+tandrii@chromium.org
diff --git a/chromium/third_party/dawn/infra/config/README.md b/chromium/third_party/dawn/infra/config/README.md
new file mode 100644
index 00000000000..a93b7f2eeae
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/README.md
@@ -0,0 +1 @@
+This directory contains configurations for infra services.
diff --git a/chromium/third_party/dawn/infra/config/branch/cq.cfg b/chromium/third_party/dawn/infra/config/branch/cq.cfg
new file mode 100644
index 00000000000..f0d94a78705
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/branch/cq.cfg
@@ -0,0 +1,34 @@
+# See http://luci-config.appspot.com/schemas/projects/refs:cq.cfg for the
+# documentation of this file format.
+
+version: 1
+cq_status_url: "https://chromium-cq-status.appspot.com"
+git_repo_url: "https://dawn.googlesource.com/dawn"
+
+gerrit {
+}
+
+verifiers {
+ gerrit_cq_ability {
+ committer_list: "project-dawn-committers"
+ dry_run_access_list: "project-dawn-tryjob-access"
+ }
+ try_job {
+ buckets {
+ name: "luci.dawn.try"
+ builders { name: "presubmit" }
+ builders { name: "linux-clang-dbg-x64" }
+ builders { name: "linux-clang-rel-x64" }
+ builders { name: "mac-dbg" }
+ builders { name: "mac-rel" }
+ builders { name: "win-clang-dbg-x64" }
+ builders { name: "win-clang-rel-x64" }
+ }
+ buckets {
+ name: "luci.chromium.try"
+ builders { name: "linux-dawn-rel" }
+ builders { name: "mac-dawn-rel" }
+ builders { name: "win-dawn-rel" }
+ }
+ }
+}
diff --git a/chromium/third_party/dawn/infra/config/global/cr-buildbucket.cfg b/chromium/third_party/dawn/infra/config/global/cr-buildbucket.cfg
new file mode 100644
index 00000000000..1c786121e44
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/global/cr-buildbucket.cfg
@@ -0,0 +1,310 @@
+# Defines buckets on cr-buildbucket.appspot.com, used to schedule builds
+# on buildbot. In particular, CQ uses some of these buckets to schedule tryjobs.
+#
+# See http://luci-config.appspot.com/schemas/projects:cr-buildbucket.cfg for
+# schema of this file and documentation.
+#
+# Please keep this list sorted by bucket name.
+
+acl_sets {
+ name: "ci"
+ acls {
+ role: READER
+ group: "all"
+ }
+ acls {
+ role: SCHEDULER
+ identity: "luci-scheduler@appspot.gserviceaccount.com"
+ }
+}
+
+acl_sets {
+ name: "try"
+ acls {
+ role: READER
+ group: "all"
+ }
+ acls {
+ role: SCHEDULER
+ group: "project-dawn-tryjob-access"
+ }
+ acls {
+ role: SCHEDULER
+ group: "service-account-cq"
+ }
+}
+
+builder_mixins {
+ name: "clang"
+ recipe {
+ properties_j: "clang:true"
+ }
+}
+builder_mixins {
+ name: "no_clang"
+ recipe {
+ properties_j: "clang:false"
+ }
+}
+builder_mixins {
+ name: "release"
+ recipe {
+ properties_j: "debug:false"
+ }
+}
+builder_mixins {
+ name: "debug"
+ recipe {
+ properties_j: "debug:true"
+ }
+}
+builder_mixins {
+ name: "x86"
+ recipe {
+ properties: "target_cpu:x86"
+ }
+}
+builder_mixins {
+ name: "x64"
+ recipe {
+ properties: "target_cpu:x64"
+ }
+}
+
+buckets {
+ name: "luci.dawn.ci"
+ acl_sets: "ci"
+
+ swarming {
+ hostname: "chromium-swarm.appspot.com"
+ builder_defaults {
+ dimensions: "pool:luci.flex.ci"
+ # We have 32bit test configurations but some of our toolchain is 64bit (like CIPD)
+ dimensions: "cpu:x86-64"
+ caches {
+ path: "win_toolchain"
+ name: "win_toolchain"
+ }
+ recipe {
+ cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
+ cipd_version: "refs/heads/master"
+ name: "dawn"
+ }
+ service_account: "dawn-ci-builder@chops-service-accounts.iam.gserviceaccount.com"
+ }
+
+ # Linux: test combinations of {clang}x{release,debug}x{x86,x64}
+ builders {
+ name: "linux-clang-dbg-x64"
+ dimensions: "os:Ubuntu-14.04"
+ mixins: "debug"
+ mixins: "x64"
+ }
+ builders {
+ name: "linux-clang-dbg-x86"
+ dimensions: "os:Ubuntu-14.04"
+ mixins: "debug"
+ mixins: "x86"
+ }
+ builders {
+ name: "linux-clang-rel-x64"
+ dimensions: "os:Ubuntu-14.04"
+ mixins: "release"
+ mixins: "x64"
+ }
+ builders {
+ name: "linux-clang-rel-x86"
+ dimensions: "os:Ubuntu-14.04"
+ mixins: "release"
+ mixins: "x86"
+ }
+
+ # Mac: unlike Linux we only need to test x64 (and only clang too)
+ builders {
+ name: "mac-dbg"
+ dimensions: "os:Mac-10.13"
+ mixins: "debug"
+ }
+ builders {
+ name: "mac-rel"
+ dimensions: "os:Mac-10.13"
+ mixins: "release"
+ }
+
+ # Linux: test combinations of {clang,msvc}x{release,debug}x{x86,x64}
+ # but limit msvc to x64
+ builders {
+ name: "win-clang-dbg-x64"
+ dimensions: "os:Windows"
+ mixins: "clang"
+ mixins: "debug"
+ mixins: "x64"
+ }
+ builders {
+ name: "win-clang-dbg-x86"
+ dimensions: "os:Windows"
+ mixins: "clang"
+ mixins: "debug"
+ mixins: "x86"
+ }
+ builders {
+ name: "win-clang-rel-x64"
+ dimensions: "os:Windows"
+ mixins: "clang"
+ mixins: "release"
+ mixins: "x64"
+ }
+ builders {
+ name: "win-clang-rel-x86"
+ dimensions: "os:Windows"
+ mixins: "clang"
+ mixins: "release"
+ mixins: "x86"
+ }
+ builders {
+ name: "win-msvc-dbg-x64"
+ dimensions: "os:Windows"
+ mixins: "no_clang"
+ mixins: "debug"
+ mixins: "x64"
+ }
+ builders {
+ name: "win-msvc-rel-x64"
+ dimensions: "os:Windows"
+ mixins: "no_clang"
+ mixins: "release"
+ mixins: "x64"
+ }
+ }
+}
+
+buckets: {
+ name: "luci.dawn.try"
+ acl_sets: "try"
+
+ swarming {
+ hostname: "chromium-swarm.appspot.com"
+
+ builder_defaults {
+ dimensions: "pool:luci.flex.try"
+ # We have 32bit test configurations but some of our toolchain is 64bit (like CIPD)
+ dimensions: "cpu:x86-64"
+ caches {
+ path: "win_toolchain"
+ name: "win_toolchain"
+ }
+ recipe {
+ cipd_package: "infra/recipe_bundles/chromium.googlesource.com/chromium/tools/build"
+ cipd_version: "refs/heads/master"
+ name: "dawn"
+ properties_j: "$depot_tools/bot_update:{\"apply_patch_on_gclient\":true}"
+ }
+ service_account: "dawn-try-builder@chops-service-accounts.iam.gserviceaccount.com"
+ }
+
+ builders {
+ name: "presubmit"
+ dimensions: "os:Ubuntu-14.04"
+ recipe {
+ name: "run_presubmit"
+ properties: "repo_name:dawn"
+ properties_j: "runhooks:true"
+ }
+ }
+
+ # A subset of the CI configurations are used for the CQ. We still mirror
+ # the CI builders here so we can trigger tryjobs on their specific
+ # configuration.
+
+ # CI Mirror only
+ builders {
+ name: "linux-clang-dbg-x64"
+ dimensions: "os:Ubuntu-14.04"
+ mixins: "debug"
+ mixins: "x64"
+ }
+ # CI Mirror only
+ builders {
+ name: "linux-clang-dbg-x86"
+ dimensions: "os:Ubuntu-14.04"
+ mixins: "debug"
+ mixins: "x86"
+ }
+ # Actually on the CQ
+ builders {
+ name: "linux-clang-rel-x64"
+ dimensions: "os:Ubuntu-14.04"
+ mixins: "release"
+ mixins: "x64"
+ }
+ # Actually on the CQ
+ builders {
+ name: "linux-clang-rel-x86"
+ dimensions: "os:Ubuntu-14.04"
+ mixins: "release"
+ mixins: "x86"
+ }
+
+ # Actually on the CQ
+ builders {
+ name: "mac-dbg"
+ dimensions: "os:Mac-10.13"
+ mixins: "debug"
+ }
+ # Actually on the CQ
+ builders {
+ name: "mac-rel"
+ dimensions: "os:Mac-10.13"
+ mixins: "release"
+ }
+
+ # Actually on the CQ
+ builders {
+ name: "win-clang-dbg-x64"
+ dimensions: "os:Windows"
+ mixins: "clang"
+ mixins: "debug"
+ mixins: "x64"
+ }
+ # CI Mirror only
+ builders {
+ name: "win-clang-dbg-x86"
+ dimensions: "os:Windows"
+ mixins: "clang"
+ mixins: "debug"
+ mixins: "x86"
+ }
+ # Actually on the CQ
+ builders {
+ name: "win-clang-rel-x64"
+ dimensions: "os:Windows"
+ mixins: "clang"
+ mixins: "release"
+ mixins: "x64"
+ }
+ # CI Mirror only
+ builders {
+ name: "win-clang-rel-x86"
+ dimensions: "os:Windows"
+ mixins: "clang"
+ mixins: "release"
+ mixins: "x86"
+ }
+ # CI Mirror only
+ builders {
+ name: "win-msvc-dbg-x64"
+ dimensions: "os:Windows"
+ mixins: "no_clang"
+ mixins: "debug"
+ mixins: "x64"
+ }
+ # CI Mirror only
+ builders {
+ name: "win-msvc-rel-x64"
+ dimensions: "os:Windows"
+ mixins: "no_clang"
+ mixins: "release"
+ mixins: "x64"
+ }
+ }
+}
diff --git a/chromium/third_party/dawn/infra/config/global/luci-logdog.cfg b/chromium/third_party/dawn/infra/config/global/luci-logdog.cfg
new file mode 100644
index 00000000000..3bd0e960cd7
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/global/luci-logdog.cfg
@@ -0,0 +1,17 @@
+# Copyright (c) 2018 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+#
+# For the schema of this file and documentation, see ProjectConfig message in
+# https://luci-config.appspot.com/schemas/services/luci-logdog:logdog.cfg
+
+# Auth groups who can read log streams.
+reader_auth_groups: "all"
+
+# Auth groups who can register and emit new log streams.
+writer_auth_groups: "luci-logdog-chromium-writers"
+
+# The base Google Storage archival path for this project.
+#
+# Archived LogDog logs will be written to this bucket/path.
+archive_gs_bucket: "chromium-luci-logdog"
diff --git a/chromium/third_party/dawn/infra/config/global/luci-milo.cfg b/chromium/third_party/dawn/infra/config/global/luci-milo.cfg
new file mode 100644
index 00000000000..5e022782b97
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/global/luci-milo.cfg
@@ -0,0 +1,103 @@
+logo_url: "https://storage.googleapis.com/chrome-infra-public/logo/dawn-logo.png"
+consoles {
+ id: "ci"
+ name: "Dawn CI Builders"
+ repo_url: "https://dawn.googlesource.com/dawn"
+ refs: "refs/heads/master"
+ manifest_name: "REVISION"
+
+ builders {
+ name: "buildbucket/luci.dawn.ci/linux-clang-dbg-x64"
+ category: "linux|clang|dbg"
+ short_name: "x64"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/linux-clang-dbg-x86"
+ category: "linux|clang|dbg"
+ short_name: "x86"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/linux-clang-rel-x64"
+ category: "linux|clang|rel"
+ short_name: "x64"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/linux-clang-rel-x86"
+ category: "linux|clang|rel"
+ short_name: "x86"
+ }
+
+ builders {
+ name: "buildbucket/luci.dawn.ci/mac-dbg"
+ category: "mac"
+ short_name: "dbg"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/mac-rel"
+ category: "mac"
+ short_name: "rel"
+ }
+
+ builders {
+ name: "buildbucket/luci.dawn.ci/win-clang-dbg-x64"
+ category: "win|clang|dbg"
+ short_name: "x64"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/win-clang-dbg-x86"
+ category: "win|clang|dbg"
+ short_name: "x86"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/win-clang-rel-x64"
+ category: "win|clang|rel"
+ short_name: "x64"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/win-clang-rel-x86"
+ category: "win|clang|rel"
+ short_name: "x86"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/win-msvc-dbg-x64"
+ category: "win|msvc"
+ short_name: "dbg"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.ci/win-msvc-rel-x64"
+ category: "win|msvc"
+ short_name: "rel"
+ }
+}
+
+consoles {
+ id: "try"
+ name: "Dawn try Builders"
+ manifest_name: "PATCHED"
+ builder_view_only: true
+
+ builders {
+ name: "buildbucket/luci.dawn.try/presubmit"
+ }
+
+ builders {
+ name: "buildbucket/luci.dawn.try/linux-clang-dbg-x64"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.try/linux-clang-rel-x64"
+ }
+
+ builders {
+ name: "buildbucket/luci.dawn.try/mac-dbg"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.try/mac-rel"
+ }
+
+ builders {
+ name: "buildbucket/luci.dawn.try/win-clang-dbg-x64"
+ }
+ builders {
+ name: "buildbucket/luci.dawn.try/win-clang-rel-x64"
+ }
+}
diff --git a/chromium/third_party/dawn/infra/config/global/luci-scheduler.cfg b/chromium/third_party/dawn/infra/config/global/luci-scheduler.cfg
new file mode 100644
index 00000000000..a5e61dc9936
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/global/luci-scheduler.cfg
@@ -0,0 +1,150 @@
+# Defines jobs on luci-scheduler.appspot.com.
+#
+# For schema of this file and documentation see ProjectConfig message in
+#
+# https://chromium.googlesource.com/infra/luci/luci-go/+/master/scheduler/appengine/messages/cron.proto
+
+
+acl_sets {
+ name: "default"
+ acls {
+ role: READER
+ granted_to: "group:all"
+ }
+ acls {
+ role: OWNER
+ granted_to: "group:project-dawn-admins"
+ }
+}
+
+trigger {
+ id: "master-gitiles-trigger"
+ acl_sets: "default"
+ gitiles {
+ repo: "https://dawn.googlesource.com/dawn.git"
+ refs: "refs/heads/master"
+ }
+ triggers: "linux-clang-dbg-x64"
+ triggers: "linux-clang-rel-x64"
+ triggers: "linux-clang-dbg-x86"
+ triggers: "linux-clang-rel-x86"
+ triggers: "mac-dbg"
+ triggers: "mac-rel"
+ triggers: "win-clang-dbg-x64"
+ triggers: "win-clang-rel-x64"
+ triggers: "win-clang-dbg-x86"
+ triggers: "win-clang-rel-x86"
+ triggers: "win-msvc-dbg-x64"
+ triggers: "win-msvc-rel-x64"
+}
+
+job {
+ id: "linux-clang-dbg-x64"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "linux-clang-dbg-x64"
+ }
+}
+job {
+ id: "linux-clang-dbg-x86"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "linux-clang-dbg-x86"
+ }
+}
+job {
+ id: "linux-clang-rel-x64"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "linux-clang-rel-x64"
+ }
+}
+job {
+ id: "linux-clang-rel-x86"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "linux-clang-rel-x86"
+ }
+}
+
+job {
+ id: "mac-dbg"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "mac-dbg"
+ }
+}
+job {
+ id: "mac-rel"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "mac-rel"
+ }
+}
+
+job {
+ id: "win-clang-dbg-x64"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "win-clang-dbg-x64"
+ }
+}
+job {
+ id: "win-clang-dbg-x86"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "win-clang-dbg-x86"
+ }
+}
+job {
+ id: "win-clang-rel-x64"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "win-clang-rel-x64"
+ }
+}
+job {
+ id: "win-clang-rel-x86"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "win-clang-rel-x86"
+ }
+}
+job {
+ id: "win-msvc-dbg-x64"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "win-msvc-dbg-x64"
+ }
+}
+job {
+ id: "win-msvc-rel-x64"
+ acl_sets: "default"
+ buildbucket: {
+ server: "cr-buildbucket.appspot.com"
+ bucket: "luci.dawn.ci"
+ builder: "win-msvc-rel-x64"
+ }
+}
diff --git a/chromium/third_party/dawn/infra/config/global/project.cfg b/chromium/third_party/dawn/infra/config/global/project.cfg
new file mode 100644
index 00000000000..b06b70f02b8
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/global/project.cfg
@@ -0,0 +1,4 @@
+# For the schema of this file and documentation, see ProjectCfg message in
+# https://luci-config.appspot.com/schemas/projects:project.cfg
+name: "dawn"
+access: "group:all" # The project is public, everybody can see build results.
diff --git a/chromium/third_party/dawn/infra/config/global/refs.cfg b/chromium/third_party/dawn/infra/config/global/refs.cfg
new file mode 100644
index 00000000000..b287e225083
--- /dev/null
+++ b/chromium/third_party/dawn/infra/config/global/refs.cfg
@@ -0,0 +1,6 @@
+# Refs configuration file. The documentation of the format can be found
+# at https://luci-config.appspot.com/schemas/projects:refs.cfg.
+refs {
+ name: "refs/heads/master"
+ config_path: "infra/config/branch"
+}
diff --git a/chromium/third_party/dawn/scripts/dawn_features.gni b/chromium/third_party/dawn/scripts/dawn_features.gni
new file mode 100644
index 00000000000..031cdb1739b
--- /dev/null
+++ b/chromium/third_party/dawn/scripts/dawn_features.gni
@@ -0,0 +1,35 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+declare_args() {
+ # Enable Dawn's ASSERTs even in release builds
+ dawn_always_assert = false
+
+ # Enables the compilation of Dawn's D3D12 backend
+ dawn_enable_d3d12 = is_win
+
+ # Enables the compilation of Dawn's Metal backend
+ dawn_enable_metal = is_mac
+
+ # Enables the compilation of Dawn's Null backend
+ # (required for unittests, obviously non-conformant)
+ dawn_enable_null = true
+
+ # Enables the compilation of Dawn's OpenGL backend
+ # (best effort, non-conformant)
+ dawn_enable_opengl = is_linux
+
+ # Enables the compilation of Dawn's Vulkan backend
+ dawn_enable_vulkan = is_linux || is_win
+}
diff --git a/chromium/third_party/dawn/scripts/dawn_overrides_with_defaults.gni b/chromium/third_party/dawn/scripts/dawn_overrides_with_defaults.gni
new file mode 100644
index 00000000000..7c47e0251d7
--- /dev/null
+++ b/chromium/third_party/dawn/scripts/dawn_overrides_with_defaults.gni
@@ -0,0 +1,49 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# This files imports the overrides for Dawn but sets the defaults so that
+# projects including Dawn don't have to set dirs if they happen to use the
+# same.
+# It takes advantage of GN's variable scoping rules to define global variables
+# inside if constructs.
+
+import("//build_overrides/dawn.gni")
+
+if (!defined(dawn_standalone)) {
+ dawn_standalone = false
+}
+
+if (!defined(dawn_jinja2_dir)) {
+ dawn_jinja2_dir = "//third_party/jinja2"
+}
+
+if (!defined(dawn_glfw_dir)) {
+ dawn_glfw_dir = "//third_party/glfw"
+}
+
+if (!defined(dawn_googletest_dir)) {
+ dawn_googletest_dir = "//third_party/googletest"
+}
+
+if (!defined(dawn_shaderc_dir)) {
+ dawn_shaderc_dir = "//third_party/shaderc"
+}
+
+if (!defined(dawn_spirv_cross_dir)) {
+ dawn_spirv_cross_dir = "//third_party/spirv-cross"
+}
+
+if (!defined(dawn_spirv_tools_dir)) {
+ dawn_spirv_tools_dir = "//third_party/SPIRV-Tools"
+}
diff --git a/chromium/third_party/dawn/scripts/git-clang-format b/chromium/third_party/dawn/scripts/git-clang-format
new file mode 100755
index 00000000000..60cd4fb25b6
--- /dev/null
+++ b/chromium/third_party/dawn/scripts/git-clang-format
@@ -0,0 +1,579 @@
+#!/usr/bin/env python
+#
+#===- git-clang-format - ClangFormat Git Integration ---------*- python -*--===#
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+#===------------------------------------------------------------------------===#
+
+r"""
+clang-format git integration
+============================
+
+This file provides a clang-format integration for git. Put it somewhere in your
+path and ensure that it is executable. Then, "git clang-format" will invoke
+clang-format on the changes in current files or a specific commit.
+
+For further details, run:
+git clang-format -h
+
+Requires Python 2.7 or Python 3
+"""
+
+from __future__ import print_function
+import argparse
+import collections
+import contextlib
+import errno
+import os
+import re
+import subprocess
+import sys
+
+usage = 'git clang-format [OPTIONS] [<commit>] [<commit>] [--] [<file>...]'
+
+desc = '''
+If zero or one commits are given, run clang-format on all lines that differ
+between the working directory and <commit>, which defaults to HEAD. Changes are
+only applied to the working directory.
+
+If two commits are given (requires --diff), run clang-format on all lines in the
+second <commit> that differ from the first <commit>.
+
+The following git-config settings set the default of the corresponding option:
+ clangFormat.binary
+ clangFormat.commit
+ clangFormat.extension
+ clangFormat.style
+'''
+
+# Name of the temporary index file in which save the output of clang-format.
+# This file is created within the .git directory.
+temp_index_basename = 'clang-format-index'
+
+
+Range = collections.namedtuple('Range', 'start, count')
+
+
+def main():
+ config = load_git_config()
+
+ # In order to keep '--' yet allow options after positionals, we need to
+ # check for '--' ourselves. (Setting nargs='*' throws away the '--', while
+ # nargs=argparse.REMAINDER disallows options after positionals.)
+ argv = sys.argv[1:]
+ try:
+ idx = argv.index('--')
+ except ValueError:
+ dash_dash = []
+ else:
+ dash_dash = argv[idx:]
+ argv = argv[:idx]
+
+ default_extensions = ','.join([
+ # From clang/lib/Frontend/FrontendOptions.cpp, all lower case
+ 'c', 'h', # C
+ 'm', # ObjC
+ 'mm', # ObjC++
+ 'cc', 'cp', 'cpp', 'c++', 'cxx', 'hpp', # C++
+ # Other languages that clang-format supports
+ 'proto', 'protodevel', # Protocol Buffers
+ 'java', # Java
+ 'js', # JavaScript
+ 'ts', # TypeScript
+ ])
+
+ p = argparse.ArgumentParser(
+ usage=usage, formatter_class=argparse.RawDescriptionHelpFormatter,
+ description=desc)
+ p.add_argument('--binary',
+ default=config.get('clangformat.binary', 'clang-format'),
+ help='path to clang-format'),
+ p.add_argument('--commit',
+ default=config.get('clangformat.commit', 'HEAD'),
+ help='default commit to use if none is specified'),
+ p.add_argument('--diff', action='store_true',
+ help='print a diff instead of applying the changes')
+ p.add_argument('--extensions',
+ default=config.get('clangformat.extensions',
+ default_extensions),
+ help=('comma-separated list of file extensions to format, '
+ 'excluding the period and case-insensitive')),
+ p.add_argument('-f', '--force', action='store_true',
+ help='allow changes to unstaged files')
+ p.add_argument('-p', '--patch', action='store_true',
+ help='select hunks interactively')
+ p.add_argument('-q', '--quiet', action='count', default=0,
+ help='print less information')
+ p.add_argument('--style',
+ default=config.get('clangformat.style', None),
+ help='passed to clang-format'),
+ p.add_argument('-v', '--verbose', action='count', default=0,
+ help='print extra information')
+ # We gather all the remaining positional arguments into 'args' since we need
+ # to use some heuristics to determine whether or not <commit> was present.
+ # However, to print pretty messages, we make use of metavar and help.
+ p.add_argument('args', nargs='*', metavar='<commit>',
+ help='revision from which to compute the diff')
+ p.add_argument('ignored', nargs='*', metavar='<file>...',
+ help='if specified, only consider differences in these files')
+ opts = p.parse_args(argv)
+
+ opts.verbose -= opts.quiet
+ del opts.quiet
+
+ commits, files = interpret_args(opts.args, dash_dash, opts.commit)
+ if len(commits) > 1:
+ if not opts.diff:
+ die('--diff is required when two commits are given')
+ else:
+ if len(commits) > 2:
+ die('at most two commits allowed; %d given' % len(commits))
+ changed_lines = compute_diff_and_extract_lines(commits, files)
+ if opts.verbose >= 1:
+ ignored_files = set(changed_lines)
+ filter_by_extension(changed_lines, opts.extensions.lower().split(','))
+ if opts.verbose >= 1:
+ ignored_files.difference_update(changed_lines)
+ if ignored_files:
+ print('Ignoring changes in the following files (wrong extension):')
+ for filename in ignored_files:
+ print(' %s' % filename)
+ if changed_lines:
+ print('Running clang-format on the following files:')
+ for filename in changed_lines:
+ print(' %s' % filename)
+ if not changed_lines:
+ print('no modified files to format')
+ return
+ # The computed diff outputs absolute paths, so we must cd before accessing
+ # those files.
+ cd_to_toplevel()
+ if len(commits) > 1:
+ old_tree = commits[1]
+ new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ revision=commits[1],
+ binary=opts.binary,
+ style=opts.style)
+ else:
+ old_tree = create_tree_from_workdir(changed_lines)
+ new_tree = run_clang_format_and_save_to_tree(changed_lines,
+ binary=opts.binary,
+ style=opts.style)
+ if opts.verbose >= 1:
+ print('old tree: %s' % old_tree)
+ print('new tree: %s' % new_tree)
+ if old_tree == new_tree:
+ if opts.verbose >= 0:
+ print('clang-format did not modify any files')
+ elif opts.diff:
+ print_diff(old_tree, new_tree)
+ else:
+ changed_files = apply_changes(old_tree, new_tree, force=opts.force,
+ patch_mode=opts.patch)
+ if (opts.verbose >= 0 and not opts.patch) or opts.verbose >= 1:
+ print('changed files:')
+ for filename in changed_files:
+ print(' %s' % filename)
+
+
+def load_git_config(non_string_options=None):
+ """Return the git configuration as a dictionary.
+
+ All options are assumed to be strings unless in `non_string_options`, in which
+ is a dictionary mapping option name (in lower case) to either "--bool" or
+ "--int"."""
+ if non_string_options is None:
+ non_string_options = {}
+ out = {}
+ for entry in run('git', 'config', '--list', '--null').split('\0'):
+ if entry:
+ name, value = entry.split('\n', 1)
+ if name in non_string_options:
+ value = run('git', 'config', non_string_options[name], name)
+ out[name] = value
+ return out
+
+
+def interpret_args(args, dash_dash, default_commit):
+ """Interpret `args` as "[commits] [--] [files]" and return (commits, files).
+
+ It is assumed that "--" and everything that follows has been removed from
+ args and placed in `dash_dash`.
+
+ If "--" is present (i.e., `dash_dash` is non-empty), the arguments to its
+ left (if present) are taken as commits. Otherwise, the arguments are checked
+ from left to right if they are commits or files. If commits are not given,
+ a list with `default_commit` is used."""
+ if dash_dash:
+ if len(args) == 0:
+ commits = [default_commit]
+ else:
+ commits = args
+ for commit in commits:
+ object_type = get_object_type(commit)
+ if object_type not in ('commit', 'tag'):
+ if object_type is None:
+ die("'%s' is not a commit" % commit)
+ else:
+ die("'%s' is a %s, but a commit was expected" % (commit, object_type))
+ files = dash_dash[1:]
+ elif args:
+ commits = []
+ while args:
+ if not disambiguate_revision(args[0]):
+ break
+ commits.append(args.pop(0))
+ if not commits:
+ commits = [default_commit]
+ files = args
+ else:
+ commits = [default_commit]
+ files = []
+ return commits, files
+
+
+def disambiguate_revision(value):
+ """Returns True if `value` is a revision, False if it is a file, or dies."""
+ # If `value` is ambiguous (neither a commit nor a file), the following
+ # command will die with an appropriate error message.
+ run('git', 'rev-parse', value, verbose=False)
+ object_type = get_object_type(value)
+ if object_type is None:
+ return False
+ if object_type in ('commit', 'tag'):
+ return True
+ die('`%s` is a %s, but a commit or filename was expected' %
+ (value, object_type))
+
+
+def get_object_type(value):
+ """Returns a string description of an object's type, or None if it is not
+ a valid git object."""
+ cmd = ['git', 'cat-file', '-t', value]
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout, stderr = p.communicate()
+ if p.returncode != 0:
+ return None
+ return convert_string(stdout.strip())
+
+
+def compute_diff_and_extract_lines(commits, files):
+ """Calls compute_diff() followed by extract_lines()."""
+ diff_process = compute_diff(commits, files)
+ changed_lines = extract_lines(diff_process.stdout)
+ diff_process.stdout.close()
+ diff_process.wait()
+ if diff_process.returncode != 0:
+ # Assume error was already printed to stderr.
+ sys.exit(2)
+ return changed_lines
+
+
+def compute_diff(commits, files):
+ """Return a subprocess object producing the diff from `commits`.
+
+ The return value's `stdin` file object will produce a patch with the
+ differences between the working directory and the first commit if a single
+ one was specified, or the difference between both specified commits, filtered
+ on `files` (if non-empty). Zero context lines are used in the patch."""
+ git_tool = 'diff-index'
+ if len(commits) > 1:
+ git_tool = 'diff-tree'
+ cmd = ['git', git_tool, '-p', '-U0'] + commits + ['--']
+ cmd.extend(files)
+ p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ p.stdin.close()
+ return p
+
+
+def extract_lines(patch_file):
+ """Extract the changed lines in `patch_file`.
+
+ The return value is a dictionary mapping filename to a list of (start_line,
+ line_count) pairs.
+
+ The input must have been produced with ``-U0``, meaning unidiff format with
+ zero lines of context. The return value is a dict mapping filename to a
+ list of line `Range`s."""
+ matches = {}
+ for line in patch_file:
+ line = convert_string(line)
+ match = re.search(r'^\+\+\+\ [^/]+/(.*)', line)
+ if match:
+ filename = match.group(1).rstrip('\r\n')
+ match = re.search(r'^@@ -[0-9,]+ \+(\d+)(,(\d+))?', line)
+ if match:
+ start_line = int(match.group(1))
+ line_count = 1
+ if match.group(3):
+ line_count = int(match.group(3))
+ if line_count > 0:
+ matches.setdefault(filename, []).append(Range(start_line, line_count))
+ return matches
+
+
+def filter_by_extension(dictionary, allowed_extensions):
+ """Delete every key in `dictionary` that doesn't have an allowed extension.
+
+ `allowed_extensions` must be a collection of lowercase file extensions,
+ excluding the period."""
+ allowed_extensions = frozenset(allowed_extensions)
+ for filename in list(dictionary.keys()):
+ base_ext = filename.rsplit('.', 1)
+ if len(base_ext) == 1 and '' in allowed_extensions:
+ continue
+ if len(base_ext) == 1 or base_ext[1].lower() not in allowed_extensions:
+ del dictionary[filename]
+
+
+def cd_to_toplevel():
+ """Change to the top level of the git repository."""
+ toplevel = run('git', 'rev-parse', '--show-toplevel')
+ os.chdir(toplevel)
+
+
+def create_tree_from_workdir(filenames):
+ """Create a new git tree with the given files from the working directory.
+
+ Returns the object ID (SHA-1) of the created tree."""
+ return create_tree(filenames, '--stdin')
+
+
+def run_clang_format_and_save_to_tree(changed_lines, revision=None,
+ binary='clang-format', style=None):
+ """Run clang-format on each file and save the result to a git tree.
+
+ Returns the object ID (SHA-1) of the created tree."""
+ def iteritems(container):
+ try:
+ return container.iteritems() # Python 2
+ except AttributeError:
+ return container.items() # Python 3
+ def index_info_generator():
+ for filename, line_ranges in iteritems(changed_lines):
+ if revision:
+ git_metadata_cmd = ['git', 'ls-tree',
+ '%s:%s' % (revision, os.path.dirname(filename)),
+ os.path.basename(filename)]
+ git_metadata = subprocess.Popen(git_metadata_cmd, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+ stdout = git_metadata.communicate()[0]
+ mode = oct(int(stdout.split()[0], 8))
+ else:
+ mode = oct(os.stat(filename).st_mode)
+ # Adjust python3 octal format so that it matches what git expects
+ if mode.startswith('0o'):
+ mode = '0' + mode[2:]
+ blob_id = clang_format_to_blob(filename, line_ranges,
+ revision=revision,
+ binary=binary,
+ style=style)
+ yield '%s %s\t%s' % (mode, blob_id, filename)
+ return create_tree(index_info_generator(), '--index-info')
+
+
+def create_tree(input_lines, mode):
+ """Create a tree object from the given input.
+
+ If mode is '--stdin', it must be a list of filenames. If mode is
+ '--index-info' is must be a list of values suitable for "git update-index
+ --index-info", such as "<mode> <SP> <sha1> <TAB> <filename>". Any other mode
+ is invalid."""
+ assert mode in ('--stdin', '--index-info')
+ cmd = ['git', 'update-index', '--add', '-z', mode]
+ with temporary_index_file():
+ p = subprocess.Popen(cmd, stdin=subprocess.PIPE)
+ for line in input_lines:
+ p.stdin.write(to_bytes('%s\0' % line))
+ p.stdin.close()
+ if p.wait() != 0:
+ die('`%s` failed' % ' '.join(cmd))
+ tree_id = run('git', 'write-tree')
+ return tree_id
+
+
+def clang_format_to_blob(filename, line_ranges, revision=None,
+ binary='clang-format', style=None):
+ """Run clang-format on the given file and save the result to a git blob.
+
+ Runs on the file in `revision` if not None, or on the file in the working
+ directory if `revision` is None.
+
+ Returns the object ID (SHA-1) of the created blob."""
+ clang_format_cmd = [binary]
+ if style:
+ clang_format_cmd.extend(['-style='+style])
+ clang_format_cmd.extend([
+ '-lines=%s:%s' % (start_line, start_line+line_count-1)
+ for start_line, line_count in line_ranges])
+ if revision:
+ clang_format_cmd.extend(['-assume-filename='+filename])
+ git_show_cmd = ['git', 'cat-file', 'blob', '%s:%s' % (revision, filename)]
+ git_show = subprocess.Popen(git_show_cmd, stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+ git_show.stdin.close()
+ clang_format_stdin = git_show.stdout
+ else:
+ clang_format_cmd.extend([filename])
+ git_show = None
+ clang_format_stdin = subprocess.PIPE
+ try:
+ clang_format = subprocess.Popen(clang_format_cmd, stdin=clang_format_stdin,
+ stdout=subprocess.PIPE)
+ if clang_format_stdin == subprocess.PIPE:
+ clang_format_stdin = clang_format.stdin
+ except OSError as e:
+ if e.errno == errno.ENOENT:
+ die('cannot find executable "%s"' % binary)
+ else:
+ raise
+ clang_format_stdin.close()
+ hash_object_cmd = ['git', 'hash-object', '-w', '--path='+filename, '--stdin']
+ hash_object = subprocess.Popen(hash_object_cmd, stdin=clang_format.stdout,
+ stdout=subprocess.PIPE)
+ clang_format.stdout.close()
+ stdout = hash_object.communicate()[0]
+ if hash_object.returncode != 0:
+ die('`%s` failed' % ' '.join(hash_object_cmd))
+ if clang_format.wait() != 0:
+ die('`%s` failed' % ' '.join(clang_format_cmd))
+ if git_show and git_show.wait() != 0:
+ die('`%s` failed' % ' '.join(git_show_cmd))
+ return convert_string(stdout).rstrip('\r\n')
+
+
+@contextlib.contextmanager
+def temporary_index_file(tree=None):
+ """Context manager for setting GIT_INDEX_FILE to a temporary file and deleting
+ the file afterward."""
+ index_path = create_temporary_index(tree)
+ old_index_path = os.environ.get('GIT_INDEX_FILE')
+ os.environ['GIT_INDEX_FILE'] = index_path
+ try:
+ yield
+ finally:
+ if old_index_path is None:
+ del os.environ['GIT_INDEX_FILE']
+ else:
+ os.environ['GIT_INDEX_FILE'] = old_index_path
+ os.remove(index_path)
+
+
+def create_temporary_index(tree=None):
+ """Create a temporary index file and return the created file's path.
+
+ If `tree` is not None, use that as the tree to read in. Otherwise, an
+ empty index is created."""
+ gitdir = run('git', 'rev-parse', '--git-dir')
+ path = os.path.join(gitdir, temp_index_basename)
+ if tree is None:
+ tree = '--empty'
+ run('git', 'read-tree', '--index-output='+path, tree)
+ return path
+
+
+def print_diff(old_tree, new_tree):
+ """Print the diff between the two trees to stdout."""
+ # We use the porcelain 'diff' and not plumbing 'diff-tree' because the output
+ # is expected to be viewed by the user, and only the former does nice things
+ # like color and pagination.
+ #
+ # We also only print modified files since `new_tree` only contains the files
+ # that were modified, so unmodified files would show as deleted without the
+ # filter.
+ subprocess.check_call(['git', 'diff', '--diff-filter=M', old_tree, new_tree,
+ '--'])
+
+
+def apply_changes(old_tree, new_tree, force=False, patch_mode=False):
+ """Apply the changes in `new_tree` to the working directory.
+
+ Bails if there are local changes in those files and not `force`. If
+ `patch_mode`, runs `git checkout --patch` to select hunks interactively."""
+ changed_files = run('git', 'diff-tree', '--diff-filter=M', '-r', '-z',
+ '--name-only', old_tree,
+ new_tree).rstrip('\0').split('\0')
+ if not force:
+ unstaged_files = run('git', 'diff-files', '--name-status', *changed_files)
+ if unstaged_files:
+ print('The following files would be modified but '
+ 'have unstaged changes:', file=sys.stderr)
+ print(unstaged_files, file=sys.stderr)
+ print('Please commit, stage, or stash them first.', file=sys.stderr)
+ sys.exit(2)
+ if patch_mode:
+ # In patch mode, we could just as well create an index from the new tree
+ # and checkout from that, but then the user will be presented with a
+ # message saying "Discard ... from worktree". Instead, we use the old
+ # tree as the index and checkout from new_tree, which gives the slightly
+ # better message, "Apply ... to index and worktree". This is not quite
+ # right, since it won't be applied to the user's index, but oh well.
+ with temporary_index_file(old_tree):
+ subprocess.check_call(['git', 'checkout', '--patch', new_tree])
+ index_tree = old_tree
+ else:
+ with temporary_index_file(new_tree):
+ run('git', 'checkout-index', '-a', '-f')
+ return changed_files
+
+
+def run(*args, **kwargs):
+ stdin = kwargs.pop('stdin', '')
+ verbose = kwargs.pop('verbose', True)
+ strip = kwargs.pop('strip', True)
+ for name in kwargs:
+ raise TypeError("run() got an unexpected keyword argument '%s'" % name)
+ p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
+ stdin=subprocess.PIPE)
+ stdout, stderr = p.communicate(input=stdin)
+
+ stdout = convert_string(stdout)
+ stderr = convert_string(stderr)
+
+ if p.returncode == 0:
+ if stderr:
+ if verbose:
+ print('`%s` printed to stderr:' % ' '.join(args), file=sys.stderr)
+ print(stderr.rstrip(), file=sys.stderr)
+ if strip:
+ stdout = stdout.rstrip('\r\n')
+ return stdout
+ if verbose:
+ print('`%s` returned %s' % (' '.join(args), p.returncode), file=sys.stderr)
+ if stderr:
+ print(stderr.rstrip(), file=sys.stderr)
+ sys.exit(2)
+
+
+def die(message):
+ print('error:', message, file=sys.stderr)
+ sys.exit(2)
+
+
+def to_bytes(str_input):
+ # Encode to UTF-8 to get binary data.
+ if isinstance(str_input, bytes):
+ return str_input
+ return str_input.encode('utf-8')
+
+
+def to_string(bytes_input):
+ if isinstance(bytes_input, str):
+ return bytes_input
+ return bytes_input.encode('utf-8')
+
+
+def convert_string(bytes_input):
+ try:
+ return to_string(bytes_input.decode('utf-8'))
+ except AttributeError: # 'str' object has no attribute 'decode'.
+ return str(bytes_input)
+ except UnicodeError:
+ return str(bytes_input)
+
+if __name__ == '__main__':
+ main()
diff --git a/chromium/third_party/dawn/scripts/lint_clang_format.sh b/chromium/third_party/dawn/scripts/lint_clang_format.sh
new file mode 100755
index 00000000000..82b572c23cd
--- /dev/null
+++ b/chromium/third_party/dawn/scripts/lint_clang_format.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+clang_format=$1
+base_commit=$2
+
+echo
+skipped_directories="(examples|generator|src/tests/(unittests|end2end)|third_party)"
+# Find the files modified that need formatting
+files_to_check=$(git diff --diff-filter=ACMR --name-only $base_commit | grep -E "*\.(c|cpp|mm|h)$" | grep -vE "^$skipped_directories/*")
+if [ -z "$files_to_check" ]; then
+ echo "No modified files to format."
+ exit 0
+fi
+echo "Checking formatting diff on these files:"
+echo "$files_to_check"
+echo
+files_to_check=$(echo $files_to_check | tr '\n' ' ')
+
+# Run git-clang-format, check if it formatted anything
+format_output=$(scripts/git-clang-format --binary $clang_format --commit $base_commit --diff --style=file $files_to_check)
+if [ "$format_output" == "clang-format did not modify any files" ] || [ "$format_output" == "no modified files to format" ] ; then
+ exit 0
+fi
+
+# clang-format made changes, print them and fail Travis
+echo "Following formatting changes needed:"
+echo
+echo "$format_output"
+echo
+exit 1
diff --git a/chromium/third_party/dawn/scripts/standalone.gclient b/chromium/third_party/dawn/scripts/standalone.gclient
new file mode 100644
index 00000000000..86a7f0ca6d0
--- /dev/null
+++ b/chromium/third_party/dawn/scripts/standalone.gclient
@@ -0,0 +1,10 @@
+# Copy this file to <dawn clone dir>/.gclient to bootstrap gclient in a
+# standalone checkout of Dawn.
+
+solutions = [
+ { "name" : ".",
+ "url" : "https://dawn.googlesource.com/dawn",
+ "deps_file" : "DEPS",
+ "managed" : False,
+ },
+]
diff --git a/chromium/third_party/dawn/scripts/travis_lint_format.sh b/chromium/third_party/dawn/scripts/travis_lint_format.sh
new file mode 100755
index 00000000000..3515d606f64
--- /dev/null
+++ b/chromium/third_party/dawn/scripts/travis_lint_format.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
+ echo "Running outside of pull request isn't supported yet"
+ exit 0
+fi
+
+# Choose the commit against which to format
+base_commit=$(git rev-parse $TRAVIS_BRANCH)
+echo "Formatting against $TRAVIS_BRANCH a.k.a. $base_commit..."
+echo
+
+scripts/lint_clang_format.sh $1 $base_commit
diff --git a/chromium/third_party/dawn/src/common/Assert.cpp b/chromium/third_party/dawn/src/common/Assert.cpp
new file mode 100644
index 00000000000..fc88fd2a8e7
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Assert.cpp
@@ -0,0 +1,26 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "common/Assert.h"
+
+#include <iostream>
+
+void HandleAssertionFailure(const char* file,
+ const char* function,
+ int line,
+ const char* condition) {
+ std::cerr << "Assertion failure at " << file << ":" << line << " (" << function
+ << "): " << condition << std::endl;
+ DAWN_BREAKPOINT();
+}
diff --git a/chromium/third_party/dawn/src/common/Assert.h b/chromium/third_party/dawn/src/common/Assert.h
new file mode 100644
index 00000000000..b9e36ca00bc
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Assert.h
@@ -0,0 +1,80 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_ASSERT_H_
+#define COMMON_ASSERT_H_
+
+#include "common/Compiler.h"
+
+// Dawn asserts to be used instead of the regular C stdlib assert function (if you don't use assert
+// yet, you should start now!). In debug ASSERT(condition) will trigger an error, otherwise in
+// release it does nothing at runtime.
+//
+// In case of name clashes (with for example a testing library), you can define the
+// DAWN_SKIP_ASSERT_SHORTHANDS to only define the DAWN_ prefixed macros.
+//
+// These asserts feature:
+// - Logging of the error with file, line and function information.
+// - Breaking in the debugger when an assert is triggered and a debugger is attached.
+// - Use the assert information to help the compiler optimizer in release builds.
+
+// MSVC triggers a warning in /W4 for do {} while(0). SDL worked around this by using (0,0) and
+// points out that it looks like an owl face.
+#if defined(DAWN_COMPILER_MSVC)
+# define DAWN_ASSERT_LOOP_CONDITION (0, 0)
+#else
+# define DAWN_ASSERT_LOOP_CONDITION (0)
+#endif
+
+// DAWN_ASSERT_CALLSITE_HELPER generates the actual assert code. In Debug it does what you would
+// expect of an assert and in release it tries to give hints to make the compiler generate better
+// code.
+#if defined(DAWN_ENABLE_ASSERTS)
+# define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
+ do { \
+ if (!(condition)) { \
+ HandleAssertionFailure(file, func, line, #condition); \
+ } \
+ } while (DAWN_ASSERT_LOOP_CONDITION)
+#else
+# if defined(DAWN_COMPILER_MSVC)
+# define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __assume(condition)
+# elif defined(DAWN_COMPILER_CLANG) && defined(__builtin_assume)
+# define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) __builtin_assume(condition)
+# else
+# define DAWN_ASSERT_CALLSITE_HELPER(file, func, line, condition) \
+ do { \
+ DAWN_UNUSED(sizeof(condition)); \
+ } while (DAWN_ASSERT_LOOP_CONDITION)
+# endif
+#endif
+
+#define DAWN_ASSERT(condition) DAWN_ASSERT_CALLSITE_HELPER(__FILE__, __func__, __LINE__, condition)
+#define DAWN_UNREACHABLE() \
+ do { \
+ DAWN_ASSERT(DAWN_ASSERT_LOOP_CONDITION && "Unreachable code hit"); \
+ DAWN_BUILTIN_UNREACHABLE(); \
+ } while (DAWN_ASSERT_LOOP_CONDITION)
+
+#if !defined(DAWN_SKIP_ASSERT_SHORTHANDS)
+# define ASSERT DAWN_ASSERT
+# define UNREACHABLE DAWN_UNREACHABLE
+#endif
+
+void HandleAssertionFailure(const char* file,
+ const char* function,
+ int line,
+ const char* condition);
+
+#endif // COMMON_ASSERT_H_
diff --git a/chromium/third_party/dawn/src/common/BitSetIterator.h b/chromium/third_party/dawn/src/common/BitSetIterator.h
new file mode 100644
index 00000000000..432433a9403
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/BitSetIterator.h
@@ -0,0 +1,135 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_BITSETITERATOR_H_
+#define COMMON_BITSETITERATOR_H_
+
+#include "common/Assert.h"
+#include "common/Math.h"
+
+#include <bitset>
+#include <limits>
+
+// This is ANGLE's BitSetIterator class with a customizable return type
+// TODO(cwallez@chromium.org): it could be optimized, in particular when N <= 64
+
+template <typename T>
+T roundUp(const T value, const T alignment) {
+ auto temp = value + alignment - static_cast<T>(1);
+ return temp - temp % alignment;
+}
+
+template <size_t N, typename T>
+class BitSetIterator final {
+ public:
+ BitSetIterator(const std::bitset<N>& bitset);
+ BitSetIterator(const BitSetIterator& other);
+ BitSetIterator& operator=(const BitSetIterator& other);
+
+ class Iterator final {
+ public:
+ Iterator(const std::bitset<N>& bits);
+ Iterator& operator++();
+
+ bool operator==(const Iterator& other) const;
+ bool operator!=(const Iterator& other) const;
+ T operator*() const {
+ return static_cast<T>(mCurrentBit);
+ }
+
+ private:
+ unsigned long getNextBit();
+
+ static const size_t BitsPerWord = sizeof(uint32_t) * 8;
+ std::bitset<N> mBits;
+ unsigned long mCurrentBit;
+ unsigned long mOffset;
+ };
+
+ Iterator begin() const {
+ return Iterator(mBits);
+ }
+ Iterator end() const {
+ return Iterator(std::bitset<N>(0));
+ }
+
+ private:
+ const std::bitset<N> mBits;
+};
+
+template <size_t N, typename T>
+BitSetIterator<N, T>::BitSetIterator(const std::bitset<N>& bitset) : mBits(bitset) {
+}
+
+template <size_t N, typename T>
+BitSetIterator<N, T>::BitSetIterator(const BitSetIterator& other) : mBits(other.mBits) {
+}
+
+template <size_t N, typename T>
+BitSetIterator<N, T>& BitSetIterator<N, T>::operator=(const BitSetIterator& other) {
+ mBits = other.mBits;
+ return *this;
+}
+
+template <size_t N, typename T>
+BitSetIterator<N, T>::Iterator::Iterator(const std::bitset<N>& bits)
+ : mBits(bits), mCurrentBit(0), mOffset(0) {
+ if (bits.any()) {
+ mCurrentBit = getNextBit();
+ } else {
+ mOffset = static_cast<unsigned long>(roundUp(N, BitsPerWord));
+ }
+}
+
+template <size_t N, typename T>
+typename BitSetIterator<N, T>::Iterator& BitSetIterator<N, T>::Iterator::operator++() {
+ DAWN_ASSERT(mBits.any());
+ mBits.set(mCurrentBit - mOffset, 0);
+ mCurrentBit = getNextBit();
+ return *this;
+}
+
+template <size_t N, typename T>
+bool BitSetIterator<N, T>::Iterator::operator==(const Iterator& other) const {
+ return mOffset == other.mOffset && mBits == other.mBits;
+}
+
+template <size_t N, typename T>
+bool BitSetIterator<N, T>::Iterator::operator!=(const Iterator& other) const {
+ return !(*this == other);
+}
+
+template <size_t N, typename T>
+unsigned long BitSetIterator<N, T>::Iterator::getNextBit() {
+ static std::bitset<N> wordMask(std::numeric_limits<uint32_t>::max());
+
+ while (mOffset < N) {
+ uint32_t wordBits = static_cast<uint32_t>((mBits & wordMask).to_ulong());
+ if (wordBits != 0ul) {
+ return ScanForward(wordBits) + mOffset;
+ }
+
+ mBits >>= BitsPerWord;
+ mOffset += BitsPerWord;
+ }
+ return 0;
+}
+
+// Helper to avoid needing to specify the template parameter size
+template <size_t N>
+BitSetIterator<N, uint32_t> IterateBitSet(const std::bitset<N>& bitset) {
+ return BitSetIterator<N, uint32_t>(bitset);
+}
+
+#endif // COMMON_BITSETITERATOR_H_
diff --git a/chromium/third_party/dawn/src/common/Compiler.h b/chromium/third_party/dawn/src/common/Compiler.h
new file mode 100644
index 00000000000..72a8c60c1b6
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Compiler.h
@@ -0,0 +1,94 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_COMPILER_H_
+#define COMMON_COMPILER_H_
+
+// Defines macros for compiler-specific functionality
+// - DAWN_COMPILER_[CLANG|GCC|MSVC]: Compiler detection
+// - DAWN_BREAKPOINT(): Raises an exception and breaks in the debugger
+// - DAWN_BUILTIN_UNREACHABLE(): Hints the compiler that a code path is unreachable
+// - DAWN_NO_DISCARD: An attribute that is C++17 [[nodiscard]] where available
+// - DAWN_(UN)?LIKELY(EXPR): Where available, hints the compiler that the expression will be true
+// (resp. false) to help it generate code that leads to better branch prediction.
+// - DAWN_UNUSED(EXPR): Prevents unused variable/expression warnings on EXPR.
+// - DAWN_UNUSED_FUNC(FUNC): Prevents unused function warnings on FUNC.
+
+// Clang and GCC, check for __clang__ too to catch clang-cl masquarading as MSVC
+#if defined(__GNUC__) || defined(__clang__)
+# if defined(__clang__)
+# define DAWN_COMPILER_CLANG
+# else
+# define DAWN_COMPILER_GCC
+# endif
+
+# if defined(__i386__) || defined(__x86_64__)
+# define DAWN_BREAKPOINT() __asm__ __volatile__("int $3\n\t")
+# else
+// TODO(cwallez@chromium.org): Implement breakpoint on all supported architectures
+# define DAWN_BREAKPOINT()
+# endif
+
+# define DAWN_BUILTIN_UNREACHABLE() __builtin_unreachable()
+# define DAWN_LIKELY(x) __builtin_expect(!!(x), 1)
+# define DAWN_UNLIKELY(x) __builtin_expect(!!(x), 0)
+
+# if !defined(__has_cpp_attribute)
+# define __has_cpp_attribute(name) 0
+# endif
+
+// Use warn_unused_result on clang otherwise we can a c++1z extension warning in C++14 mode
+// Also avoid warn_unused_result with GCC because it is only a function attribute and not a type
+// attribute.
+# if __has_cpp_attribute(warn_unused_result) && defined(__clang__)
+# define DAWN_NO_DISCARD __attribute__((warn_unused_result))
+# elif DAWN_CPP_VERSION >= 17 && __has_cpp_attribute(nodiscard)
+# define DAWN_NO_DISCARD [[nodiscard]]
+# endif
+
+// MSVC
+#elif defined(_MSC_VER)
+# define DAWN_COMPILER_MSVC
+
+extern void __cdecl __debugbreak(void);
+# define DAWN_BREAKPOINT() __debugbreak()
+
+# define DAWN_BUILTIN_UNREACHABLE() __assume(false)
+
+// Visual Studio 2017 15.3 adds support for [[nodiscard]]
+# if _MSC_VER >= 1911 && DAWN_CPP_VERSION >= 17
+# define DAWN_NO_DISCARD [[nodiscard]]
+# endif
+
+#else
+# error "Unsupported compiler"
+#endif
+
+// It seems that (void) EXPR works on all compilers to silence the unused variable warning.
+#define DAWN_UNUSED(EXPR) (void)EXPR
+// Likewise using static asserting on sizeof(&FUNC) seems to make it tagged as used
+#define DAWN_UNUSED_FUNC(FUNC) static_assert(sizeof(&FUNC) == sizeof(void (*)()), "");
+
+// Add noop replacements for macros for features that aren't supported by the compiler.
+#if !defined(DAWN_LIKELY)
+# define DAWN_LIKELY(X) X
+#endif
+#if !defined(DAWN_UNLIKELY)
+# define DAWN_UNLIKELY(X) X
+#endif
+#if !defined(DAWN_NO_DISCARD)
+# define DAWN_NO_DISCARD
+#endif
+
+#endif // COMMON_COMPILER_H_
diff --git a/chromium/third_party/dawn/src/common/Constants.h b/chromium/third_party/dawn/src/common/Constants.h
new file mode 100644
index 00000000000..869cb13654a
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Constants.h
@@ -0,0 +1,30 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_CONSTANTS_H_
+#define COMMON_CONSTANTS_H_
+
+#include <cstdint>
+
+static constexpr uint32_t kMaxPushConstants = 32u;
+static constexpr uint32_t kMaxBindGroups = 4u;
+// TODO(cwallez@chromium.org): investigate bindgroup limits
+static constexpr uint32_t kMaxBindingsPerGroup = 16u;
+static constexpr uint32_t kMaxVertexAttributes = 16u;
+static constexpr uint32_t kMaxVertexInputs = 16u;
+static constexpr uint32_t kNumStages = 3;
+static constexpr uint32_t kMaxColorAttachments = 4u;
+static constexpr uint32_t kTextureRowPitchAlignment = 256u;
+
+#endif // COMMON_CONSTANTS_H_
diff --git a/chromium/third_party/dawn/src/common/DynamicLib.cpp b/chromium/third_party/dawn/src/common/DynamicLib.cpp
new file mode 100644
index 00000000000..6de7ced7f34
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/DynamicLib.cpp
@@ -0,0 +1,100 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "common/DynamicLib.h"
+
+#include "common/Platform.h"
+
+#if DAWN_PLATFORM_WINDOWS
+# include "common/windows_with_undefs.h"
+#elif DAWN_PLATFORM_POSIX
+# include <dlfcn.h>
+#else
+# error "Unsupported platform for DynamicLib"
+#endif
+
+DynamicLib::~DynamicLib() {
+ Close();
+}
+
+DynamicLib::DynamicLib(DynamicLib&& other) {
+ std::swap(mHandle, other.mHandle);
+}
+
+DynamicLib& DynamicLib::operator=(DynamicLib&& other) {
+ std::swap(mHandle, other.mHandle);
+ return *this;
+}
+
+bool DynamicLib::Valid() const {
+ return mHandle != nullptr;
+}
+
+bool DynamicLib::Open(const std::string& filename, std::string* error) {
+#if DAWN_PLATFORM_WINDOWS
+ mHandle = LoadLibraryA(filename.c_str());
+
+ if (mHandle == nullptr && error != nullptr) {
+ *error = "Windows Error: " + std::to_string(GetLastError());
+ }
+#elif DAWN_PLATFORM_POSIX
+ mHandle = dlopen(filename.c_str(), RTLD_NOW);
+
+ if (mHandle == nullptr && error != nullptr) {
+ *error = dlerror();
+ }
+#else
+# error "Unsupported platform for DynamicLib"
+#endif
+
+ return mHandle != nullptr;
+}
+
+void DynamicLib::Close() {
+ if (mHandle == nullptr) {
+ return;
+ }
+
+#if DAWN_PLATFORM_WINDOWS
+ FreeLibrary(static_cast<HMODULE>(mHandle));
+#elif DAWN_PLATFORM_POSIX
+ dlclose(mHandle);
+#else
+# error "Unsupported platform for DynamicLib"
+#endif
+
+ mHandle = nullptr;
+}
+
+void* DynamicLib::GetProc(const std::string& procName, std::string* error) const {
+ void* proc = nullptr;
+
+#if DAWN_PLATFORM_WINDOWS
+ proc = reinterpret_cast<void*>(GetProcAddress(static_cast<HMODULE>(mHandle), procName.c_str()));
+
+ if (proc == nullptr && error != nullptr) {
+ *error = "Windows Error: " + std::to_string(GetLastError());
+ }
+#elif DAWN_PLATFORM_POSIX
+ proc = reinterpret_cast<void*>(dlsym(mHandle, procName.c_str()));
+
+ if (proc == nullptr && error != nullptr) {
+ *error = dlerror();
+ }
+#else
+# error "Unsupported platform for DynamicLib"
+#endif
+
+ return proc;
+}
diff --git a/chromium/third_party/dawn/src/common/DynamicLib.h b/chromium/third_party/dawn/src/common/DynamicLib.h
new file mode 100644
index 00000000000..09a08198f82
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/DynamicLib.h
@@ -0,0 +1,54 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_DYNAMICLIB_H_
+#define COMMON_DYNAMICLIB_H_
+
+#include "common/Assert.h"
+
+#include <string>
+#include <type_traits>
+
+class DynamicLib {
+ public:
+ DynamicLib() = default;
+ ~DynamicLib();
+
+ DynamicLib(const DynamicLib&) = delete;
+ DynamicLib& operator=(const DynamicLib&) = delete;
+
+ DynamicLib(DynamicLib&& other);
+ DynamicLib& operator=(DynamicLib&& other);
+
+ bool Valid() const;
+
+ bool Open(const std::string& filename, std::string* error = nullptr);
+ void Close();
+
+ void* GetProc(const std::string& procName, std::string* error = nullptr) const;
+
+ template <typename T>
+ bool GetProc(T** proc, const std::string& procName, std::string* error = nullptr) const {
+ ASSERT(proc != nullptr);
+ static_assert(std::is_function<T>::value, "");
+
+ *proc = reinterpret_cast<T*>(GetProc(procName, error));
+ return *proc != nullptr;
+ }
+
+ private:
+ void* mHandle = nullptr;
+};
+
+#endif // COMMON_DYNAMICLIB_H_
diff --git a/chromium/third_party/dawn/src/common/HashUtils.h b/chromium/third_party/dawn/src/common/HashUtils.h
new file mode 100644
index 00000000000..e0cd6e7b809
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/HashUtils.h
@@ -0,0 +1,82 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_HASHUTILS_H_
+#define COMMON_HASHUTILS_H_
+
+#include "common/Platform.h"
+
+#include <functional>
+
+// Wrapper around std::hash to make it a templated function instead of a functor. It is marginally
+// nicer, and avoids adding to the std namespace to add hashing of other types.
+template <typename T>
+size_t Hash(const T& value) {
+ return std::hash<T>()(value);
+}
+
+// When hashing sparse structures we want to iteratively build a hash value with only parts of the
+// data. HashCombine "hashes" together an existing hash and hashable values.
+//
+// Example usage to compute the hash of a mask and values corresponding to the mask:
+//
+// size_t hash = Hash(mask):
+// for (uint32_t i : IterateBitSet(mask)) { HashCombine(&hash, hashables[i]); }
+// return hash;
+template <typename T>
+void HashCombine(size_t* hash, const T& value) {
+#if defined(DAWN_PLATFORM_64_BIT)
+ const size_t offset = 0x9e3779b97f4a7c16;
+#elif defined(DAWN_PLATFORM_32_BIT)
+ const size_t offset = 0x9e3779b9;
+#else
+# error "Unsupported platform"
+#endif
+ *hash ^= Hash(value) + offset + (*hash << 6) + (*hash >> 2);
+}
+
+template <typename T, typename... Args>
+void HashCombine(size_t* hash, const T& value, const Args&... args) {
+ HashCombine(hash, value);
+ HashCombine(hash, args...);
+}
+
+// Workaround a bug between clang++ and libstdlibc++ by defining our own hashing for bitsets.
+// When _GLIBCXX_DEBUG is enabled libstdc++ wraps containers into debug containers. For bitset this
+// means what is normally std::bitset is defined as std::__cxx1988::bitset and is replaced by the
+// debug version of bitset.
+// When hashing, std::hash<std::bitset> proxies the call to std::hash<std::__cxx1998::bitset> and
+// fails on clang because the latter tries to access the private _M_getdata member of the bitset.
+// It looks like it should work because the non-debug bitset declares
+//
+// friend struct std::hash<bitset> // bitset is the name of the class itself
+//
+// which should friend std::hash<std::__cxx1998::bitset> but somehow doesn't work on clang.
+#if defined(_GLIBCXX_DEBUG)
+template <size_t N>
+size_t Hash(const std::bitset<N>& value) {
+ constexpr size_t kWindowSize = sizeof(unsigned long long);
+
+ std::bitset<N> bits = value;
+ size_t hash = 0;
+ for (size_t processedBits = 0; processedBits < N; processedBits += kWindowSize) {
+ HashCombine(&hash, bits.to_ullong());
+ bits >>= kWindowSize;
+ }
+
+ return hash;
+}
+#endif
+
+#endif // COMMON_HASHUTILS_H_
diff --git a/chromium/third_party/dawn/src/common/Math.cpp b/chromium/third_party/dawn/src/common/Math.cpp
new file mode 100644
index 00000000000..6aec721a1d2
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Math.cpp
@@ -0,0 +1,79 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "common/Math.h"
+
+#include "common/Assert.h"
+
+#if defined(DAWN_COMPILER_MSVC)
+# include <intrin.h>
+#endif
+
+uint32_t ScanForward(uint32_t bits) {
+ ASSERT(bits != 0);
+#if defined(DAWN_COMPILER_MSVC)
+ unsigned long firstBitIndex = 0ul;
+ unsigned char ret = _BitScanForward(&firstBitIndex, bits);
+ ASSERT(ret != 0);
+ return firstBitIndex;
+#else
+ return static_cast<uint32_t>(__builtin_ctz(bits));
+#endif
+}
+
+uint32_t Log2(uint32_t value) {
+ ASSERT(value != 0);
+#if defined(DAWN_COMPILER_MSVC)
+ unsigned long firstBitIndex = 0ul;
+ unsigned char ret = _BitScanReverse(&firstBitIndex, value);
+ ASSERT(ret != 0);
+ return firstBitIndex;
+#else
+ return 31 - static_cast<uint32_t>(__builtin_clz(value));
+#endif
+}
+
+bool IsPowerOfTwo(size_t n) {
+ ASSERT(n != 0);
+ return (n & (n - 1)) == 0;
+}
+
+bool IsPtrAligned(const void* ptr, size_t alignment) {
+ ASSERT(IsPowerOfTwo(alignment));
+ ASSERT(alignment != 0);
+ return (reinterpret_cast<size_t>(ptr) & (alignment - 1)) == 0;
+}
+
+void* AlignVoidPtr(void* ptr, size_t alignment) {
+ ASSERT(IsPowerOfTwo(alignment));
+ ASSERT(alignment != 0);
+ return reinterpret_cast<void*>((reinterpret_cast<size_t>(ptr) + (alignment - 1)) &
+ ~(alignment - 1));
+}
+
+bool IsAligned(uint32_t value, size_t alignment) {
+ ASSERT(alignment <= UINT32_MAX);
+ ASSERT(IsPowerOfTwo(alignment));
+ ASSERT(alignment != 0);
+ uint32_t alignment32 = static_cast<uint32_t>(alignment);
+ return (value & (alignment32 - 1)) == 0;
+}
+
+uint32_t Align(uint32_t value, size_t alignment) {
+ ASSERT(alignment <= UINT32_MAX);
+ ASSERT(IsPowerOfTwo(alignment));
+ ASSERT(alignment != 0);
+ uint32_t alignment32 = static_cast<uint32_t>(alignment);
+ return (value + (alignment32 - 1)) & ~(alignment32 - 1);
+}
diff --git a/chromium/third_party/dawn/src/common/Math.h b/chromium/third_party/dawn/src/common/Math.h
new file mode 100644
index 00000000000..359d57aa721
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Math.h
@@ -0,0 +1,41 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_MATH_H_
+#define COMMON_MATH_H_
+
+#include <cstddef>
+#include <cstdint>
+
+// The following are not valid for 0
+uint32_t ScanForward(uint32_t bits);
+uint32_t Log2(uint32_t value);
+bool IsPowerOfTwo(size_t n);
+
+bool IsPtrAligned(const void* ptr, size_t alignment);
+void* AlignVoidPtr(void* ptr, size_t alignment);
+bool IsAligned(uint32_t value, size_t alignment);
+uint32_t Align(uint32_t value, size_t alignment);
+
+template <typename T>
+T* AlignPtr(T* ptr, size_t alignment) {
+ return reinterpret_cast<T*>(AlignVoidPtr(ptr, alignment));
+}
+
+template <typename T>
+const T* AlignPtr(const T* ptr, size_t alignment) {
+ return reinterpret_cast<const T*>(AlignVoidPtr(const_cast<T*>(ptr), alignment));
+}
+
+#endif // COMMON_MATH_H_
diff --git a/chromium/third_party/dawn/src/common/Platform.h b/chromium/third_party/dawn/src/common/Platform.h
new file mode 100644
index 00000000000..7e767f1322d
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Platform.h
@@ -0,0 +1,52 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_PLATFORM_H_
+#define COMMON_PLATFORM_H_
+
+#if defined(_WIN32) || defined(_WIN64)
+# define DAWN_PLATFORM_WINDOWS 1
+#elif defined(__linux__)
+# define DAWN_PLATFORM_LINUX 1
+# define DAWN_PLATFORM_POSIX 1
+#elif defined(__APPLE__)
+# define DAWN_PLATFORM_APPLE 1
+# define DAWN_PLATFORM_POSIX 1
+#else
+# error "Unsupported platform."
+#endif
+
+// Distinguish mips32.
+#if defined(__mips__) && (_MIPS_SIM == _ABIO32) && !defined(__mips32__)
+# define __mips32__
+#endif
+
+// Distinguish mips64.
+#if defined(__mips__) && (_MIPS_SIM == _ABI64) && !defined(__mips64__)
+# define __mips64__
+#endif
+
+#if defined(_WIN64) || defined(__aarch64__) || defined(__x86_64__) || defined(__mips64__) || \
+ defined(__s390x__) || defined(__PPC64__)
+# define DAWN_PLATFORM_64_BIT 1
+static_assert(sizeof(sizeof(char)) == 8, "Expect sizeof(size_t) == 8");
+#elif defined(_WIN32) || defined(__arm__) || defined(__i386__) || defined(__mips32__) || \
+ defined(__s390__)
+# define DAWN_PLATFORM_32_BIT 1
+static_assert(sizeof(sizeof(char)) == 4, "Expect sizeof(size_t) == 4");
+#else
+# error "Unsupported platform"
+#endif
+
+#endif // COMMON_PLATFORM_H_
diff --git a/chromium/third_party/dawn/src/common/Result.h b/chromium/third_party/dawn/src/common/Result.h
new file mode 100644
index 00000000000..b5bf5e57827
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Result.h
@@ -0,0 +1,335 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_RESULT_H_
+#define COMMON_RESULT_H_
+
+#include "common/Assert.h"
+#include "common/Compiler.h"
+
+#include <cstddef>
+#include <cstdint>
+#include <utility>
+
+// Result<T, E> is the following sum type (Haskell notation):
+//
+// data Result T E = Success T | Error E | Empty
+//
+// It is meant to be used as the return type of functions that might fail. The reason for the Empty
+// case is that a Result should never be discarded, only destructured (its error or success moved
+// out) or moved into a different Result. The Empty case tags Results that have been moved out and
+// Result's destructor should ASSERT on it being Empty.
+//
+// Since C++ doesn't have efficient sum types for the special cases we care about, we provide
+// template specializations for them.
+
+template <typename T, typename E>
+class Result;
+
+// The interface of Result<T, E> shoud look like the following.
+// public:
+// Result(T&& success);
+// Result(E&& error);
+//
+// Result(Result<T, E>&& other);
+// Result<T, E>& operator=(Result<T, E>&& other);
+//
+// ~Result();
+//
+// bool IsError() const;
+// bool IsSuccess() const;
+//
+// T&& AcquireSuccess();
+// E&& AcquireError();
+
+// Specialization of Result for returning errors only via pointers. It is basically a pointer
+// where nullptr is both Success and Empty.
+template <typename E>
+class DAWN_NO_DISCARD Result<void, E*> {
+ public:
+ Result();
+ Result(E* error);
+
+ Result(Result<void, E*>&& other);
+ Result<void, E*>& operator=(Result<void, E>&& other);
+
+ ~Result();
+
+ bool IsError() const;
+ bool IsSuccess() const;
+
+ void AcquireSuccess();
+ E* AcquireError();
+
+ private:
+ E* mError = nullptr;
+};
+
+// Uses SFINAE to try to get alignof(T) but fallback to Default if T isn't defined.
+template <typename T, size_t Default, typename = size_t>
+constexpr size_t alignof_if_defined_else_default = Default;
+
+template <typename T, size_t Default>
+constexpr size_t alignof_if_defined_else_default<T, Default, decltype(alignof(T))> = alignof(T);
+
+// Specialization of Result when both the error an success are pointers. It is implemented as a
+// tagged pointer. The tag for Success is 0 so that returning the value is fastest.
+template <typename T, typename E>
+class DAWN_NO_DISCARD Result<T*, E*> {
+ public:
+ static_assert(alignof_if_defined_else_default<T, 4> >= 4,
+ "Result<T*, E*> reserves two bits for tagging pointers");
+ static_assert(alignof_if_defined_else_default<E, 4> >= 4,
+ "Result<T*, E*> reserves two bits for tagging pointers");
+
+ Result(T* success);
+ Result(E* error);
+
+ Result(Result<T*, E*>&& other);
+ Result<T*, E*>& operator=(Result<T*, E>&& other);
+
+ ~Result();
+
+ bool IsError() const;
+ bool IsSuccess() const;
+
+ T* AcquireSuccess();
+ E* AcquireError();
+
+ private:
+ enum PayloadType {
+ Success = 0,
+ Error = 1,
+ Empty = 2,
+ };
+
+ // Utility functions to manipulate the tagged pointer. Some of them don't need to be templated
+ // but we really want them inlined so we keep them in the headers
+ static intptr_t MakePayload(void* pointer, PayloadType type);
+ static PayloadType GetPayloadType(intptr_t payload);
+ static T* GetSuccessFromPayload(intptr_t payload);
+ static E* GetErrorFromPayload(intptr_t payload);
+
+ constexpr static intptr_t kEmptyPayload = Empty;
+ intptr_t mPayload = kEmptyPayload;
+};
+
+// Catchall definition of Result<T, E> implemented as a tagged struct. It could be improved to use
+// a tagged union instead if it turns out to be a hotspot. T and E must be movable and default
+// constructible.
+template <typename T, typename E>
+class DAWN_NO_DISCARD Result {
+ public:
+ Result(T&& success);
+ Result(E&& error);
+
+ Result(Result<T, E>&& other);
+ Result<T, E>& operator=(Result<T, E>&& other);
+
+ ~Result();
+
+ bool IsError() const;
+ bool IsSuccess() const;
+
+ T&& AcquireSuccess();
+ E&& AcquireError();
+
+ private:
+ enum PayloadType {
+ Success = 0,
+ Error = 1,
+ Acquired = 2,
+ };
+ PayloadType mType;
+
+ E mError;
+ T mSuccess;
+};
+
+// Implementation of Result<void, E*>
+template <typename E>
+Result<void, E*>::Result() {
+}
+
+template <typename E>
+Result<void, E*>::Result(E* error) : mError(error) {
+}
+
+template <typename E>
+Result<void, E*>::Result(Result<void, E*>&& other) : mError(other.mError) {
+ other.mError = nullptr;
+}
+
+template <typename E>
+Result<void, E*>& Result<void, E*>::operator=(Result<void, E>&& other) {
+ ASSERT(mError == nullptr);
+ mError = other.mError;
+ other.mError = nullptr;
+ return *this;
+}
+
+template <typename E>
+Result<void, E*>::~Result() {
+ ASSERT(mError == nullptr);
+}
+
+template <typename E>
+bool Result<void, E*>::IsError() const {
+ return mError != nullptr;
+}
+
+template <typename E>
+bool Result<void, E*>::IsSuccess() const {
+ return mError == nullptr;
+}
+
+template <typename E>
+void Result<void, E*>::AcquireSuccess() {
+}
+
+template <typename E>
+E* Result<void, E*>::AcquireError() {
+ E* error = mError;
+ mError = nullptr;
+ return error;
+}
+
+// Implementation of Result<T*, E*>
+template <typename T, typename E>
+Result<T*, E*>::Result(T* success) : mPayload(MakePayload(success, Success)) {
+}
+
+template <typename T, typename E>
+Result<T*, E*>::Result(E* error) : mPayload(MakePayload(error, Error)) {
+}
+
+template <typename T, typename E>
+Result<T*, E*>::Result(Result<T*, E*>&& other) : mPayload(other.mPayload) {
+ other.mPayload = kEmptyPayload;
+}
+
+template <typename T, typename E>
+Result<T*, E*>& Result<T*, E*>::operator=(Result<T*, E>&& other) {
+ ASSERT(mPayload == kEmptyPayload);
+ mPayload = other.mPayload;
+ other.mPayload = kEmptyPayload;
+ return *this;
+}
+
+template <typename T, typename E>
+Result<T*, E*>::~Result() {
+ ASSERT(mPayload == kEmptyPayload);
+}
+
+template <typename T, typename E>
+bool Result<T*, E*>::IsError() const {
+ return GetPayloadType(mPayload) == Error;
+}
+
+template <typename T, typename E>
+bool Result<T*, E*>::IsSuccess() const {
+ return GetPayloadType(mPayload) == Success;
+}
+
+template <typename T, typename E>
+T* Result<T*, E*>::AcquireSuccess() {
+ T* success = GetSuccessFromPayload(mPayload);
+ mPayload = kEmptyPayload;
+ return success;
+}
+
+template <typename T, typename E>
+E* Result<T*, E*>::AcquireError() {
+ E* error = GetErrorFromPayload(mPayload);
+ mPayload = kEmptyPayload;
+ return error;
+}
+
+template <typename T, typename E>
+intptr_t Result<T*, E*>::MakePayload(void* pointer, PayloadType type) {
+ intptr_t payload = reinterpret_cast<intptr_t>(pointer);
+ ASSERT((payload & 3) == 0);
+ return payload | type;
+}
+
+template <typename T, typename E>
+typename Result<T*, E*>::PayloadType Result<T*, E*>::GetPayloadType(intptr_t payload) {
+ return static_cast<PayloadType>(payload & 3);
+}
+
+template <typename T, typename E>
+T* Result<T*, E*>::GetSuccessFromPayload(intptr_t payload) {
+ ASSERT(GetPayloadType(payload) == Success);
+ return reinterpret_cast<T*>(payload);
+}
+
+template <typename T, typename E>
+E* Result<T*, E*>::GetErrorFromPayload(intptr_t payload) {
+ ASSERT(GetPayloadType(payload) == Error);
+ return reinterpret_cast<E*>(payload ^ 1);
+}
+
+// Implementation of Result<T, E>
+template <typename T, typename E>
+Result<T, E>::Result(T&& success) : mType(Success), mSuccess(success) {
+}
+
+template <typename T, typename E>
+Result<T, E>::Result(E&& error) : mType(Error), mError(error) {
+}
+
+template <typename T, typename E>
+Result<T, E>::~Result() {
+ ASSERT(mType == Acquired);
+}
+
+template <typename T, typename E>
+Result<T, E>::Result(Result<T, E>&& other)
+ : mType(other.mType), mError(std::move(other.mError)), mSuccess(other.mSuccess) {
+ other.mType = Acquired;
+}
+template <typename T, typename E>
+Result<T, E>& Result<T, E>::operator=(Result<T, E>&& other) {
+ mType = other.mType;
+ mError = std::move(other.mError);
+ mSuccess = std::move(other.mSuccess);
+ other.mType = Acquired;
+ return *this;
+}
+
+template <typename T, typename E>
+bool Result<T, E>::IsError() const {
+ return mType == Error;
+}
+
+template <typename T, typename E>
+bool Result<T, E>::IsSuccess() const {
+ return mType == Success;
+}
+
+template <typename T, typename E>
+T&& Result<T, E>::AcquireSuccess() {
+ ASSERT(mType == Success);
+ mType = Acquired;
+ return std::move(mSuccess);
+}
+
+template <typename T, typename E>
+E&& Result<T, E>::AcquireError() {
+ ASSERT(mType == Error);
+ mType = Acquired;
+ return std::move(mError);
+}
+
+#endif // COMMON_RESULT_H_
diff --git a/chromium/third_party/dawn/src/common/Serial.h b/chromium/third_party/dawn/src/common/Serial.h
new file mode 100644
index 00000000000..e8e1de0b36c
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/Serial.h
@@ -0,0 +1,22 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_SERIAL_H_
+#define COMMON_SERIAL_H_
+
+#include <cstdint>
+
+using Serial = uint64_t;
+
+#endif // COMMON_SERIAL_H_
diff --git a/chromium/third_party/dawn/src/common/SerialMap.h b/chromium/third_party/dawn/src/common/SerialMap.h
new file mode 100644
index 00000000000..93b00197891
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/SerialMap.h
@@ -0,0 +1,75 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_SERIALMAP_H_
+#define COMMON_SERIALMAP_H_
+
+#include "common/SerialStorage.h"
+
+#include <map>
+#include <vector>
+
+template <typename T>
+class SerialMap;
+
+template <typename T>
+struct SerialStorageTraits<SerialMap<T>> {
+ using Value = T;
+ using Storage = std::map<Serial, std::vector<T>>;
+ using StorageIterator = typename Storage::iterator;
+ using ConstStorageIterator = typename Storage::const_iterator;
+};
+
+// SerialMap stores a map from Serial to T.
+// Unlike SerialQueue, items may be enqueued with Serials in any
+// arbitrary order. SerialMap provides useful iterators for iterating
+// through T items in order of increasing Serial.
+template <typename T>
+class SerialMap : public SerialStorage<SerialMap<T>> {
+ public:
+ void Enqueue(const T& value, Serial serial);
+ void Enqueue(T&& value, Serial serial);
+ void Enqueue(const std::vector<T>& values, Serial serial);
+ void Enqueue(std::vector<T>&& values, Serial serial);
+};
+
+// SerialMap
+
+template <typename T>
+void SerialMap<T>::Enqueue(const T& value, Serial serial) {
+ this->mStorage[serial].emplace_back(value);
+}
+
+template <typename T>
+void SerialMap<T>::Enqueue(T&& value, Serial serial) {
+ this->mStorage[serial].emplace_back(value);
+}
+
+template <typename T>
+void SerialMap<T>::Enqueue(const std::vector<T>& values, Serial serial) {
+ DAWN_ASSERT(values.size() > 0);
+ for (const T& value : values) {
+ Enqueue(value, serial);
+ }
+}
+
+template <typename T>
+void SerialMap<T>::Enqueue(std::vector<T>&& values, Serial serial) {
+ DAWN_ASSERT(values.size() > 0);
+ for (const T& value : values) {
+ Enqueue(value, serial);
+ }
+}
+
+#endif // COMMON_SERIALMAP_H_
diff --git a/chromium/third_party/dawn/src/common/SerialQueue.h b/chromium/third_party/dawn/src/common/SerialQueue.h
new file mode 100644
index 00000000000..f5654a98713
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/SerialQueue.h
@@ -0,0 +1,86 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_SERIALQUEUE_H_
+#define COMMON_SERIALQUEUE_H_
+
+#include "common/SerialStorage.h"
+
+#include <vector>
+
+template <typename T>
+class SerialQueue;
+
+template <typename T>
+struct SerialStorageTraits<SerialQueue<T>> {
+ using Value = T;
+ using SerialPair = std::pair<Serial, std::vector<T>>;
+ using Storage = std::vector<SerialPair>;
+ using StorageIterator = typename Storage::iterator;
+ using ConstStorageIterator = typename Storage::const_iterator;
+};
+
+// SerialQueue stores an associative list mapping a Serial to T.
+// It enforces that the Serials enqueued are strictly non-decreasing.
+// This makes it very efficient iterate or clear all items added up
+// to some Serial value because they are stored contiguously in memory.
+template <typename T>
+class SerialQueue : public SerialStorage<SerialQueue<T>> {
+ public:
+ using SerialPair = typename SerialStorageTraits<SerialQueue<T>>::SerialPair;
+
+ // The serial must be given in (not strictly) increasing order.
+ void Enqueue(const T& value, Serial serial);
+ void Enqueue(T&& value, Serial serial);
+ void Enqueue(const std::vector<T>& values, Serial serial);
+ void Enqueue(std::vector<T>&& values, Serial serial);
+};
+
+// SerialQueue
+
+template <typename T>
+void SerialQueue<T>::Enqueue(const T& value, Serial serial) {
+ DAWN_ASSERT(this->Empty() || this->mStorage.back().first <= serial);
+
+ if (this->Empty() || this->mStorage.back().first < serial) {
+ this->mStorage.emplace_back(SerialPair(serial, {}));
+ }
+ this->mStorage.back().second.emplace_back(value);
+}
+
+template <typename T>
+void SerialQueue<T>::Enqueue(T&& value, Serial serial) {
+ DAWN_ASSERT(this->Empty() || this->mStorage.back().first <= serial);
+
+ if (this->Empty() || this->mStorage.back().first < serial) {
+ this->mStorage.emplace_back(SerialPair(serial, {}));
+ }
+ this->mStorage.back().second.emplace_back(value);
+}
+
+template <typename T>
+void SerialQueue<T>::Enqueue(const std::vector<T>& values, Serial serial) {
+ DAWN_ASSERT(values.size() > 0);
+ DAWN_ASSERT(this->Empty() || this->mStorage.back().first <= serial);
+ this->mStorage.emplace_back(SerialPair(serial, {values}));
+}
+
+template <typename T>
+void SerialQueue<T>::Enqueue(std::vector<T>&& values, Serial serial) {
+ DAWN_ASSERT(values.size() > 0);
+ DAWN_ASSERT(this->Empty() || this->mStorage.back().first <= serial);
+ this->mStorage.emplace_back(SerialPair(serial, {values}));
+}
+
+#endif // COMMON_SERIALQUEUE_H_
diff --git a/chromium/third_party/dawn/src/common/SerialStorage.h b/chromium/third_party/dawn/src/common/SerialStorage.h
new file mode 100644
index 00000000000..60fae47b4fc
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/SerialStorage.h
@@ -0,0 +1,315 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_SERIALSTORAGE_H_
+#define COMMON_SERIALSTORAGE_H_
+
+#include "common/Assert.h"
+#include "common/Serial.h"
+
+#include <cstdint>
+#include <utility>
+
+template <typename T>
+struct SerialStorageTraits {};
+
+template <typename Derived>
+class SerialStorage {
+ private:
+ using Value = typename SerialStorageTraits<Derived>::Value;
+ using Storage = typename SerialStorageTraits<Derived>::Storage;
+ using StorageIterator = typename SerialStorageTraits<Derived>::StorageIterator;
+ using ConstStorageIterator = typename SerialStorageTraits<Derived>::ConstStorageIterator;
+
+ public:
+ class Iterator {
+ public:
+ Iterator(StorageIterator start);
+ Iterator& operator++();
+
+ bool operator==(const Iterator& other) const;
+ bool operator!=(const Iterator& other) const;
+ Value& operator*() const;
+
+ private:
+ StorageIterator mStorageIterator;
+ // Special case the mSerialIterator when it should be equal to mStorageIterator.begin()
+ // otherwise we could ask mStorageIterator.begin() when mStorageIterator is mStorage.end()
+ // which is invalid. mStorageIterator.begin() is tagged with a nullptr.
+ Value* mSerialIterator;
+ };
+
+ class ConstIterator {
+ public:
+ ConstIterator(ConstStorageIterator start);
+ ConstIterator& operator++();
+
+ bool operator==(const ConstIterator& other) const;
+ bool operator!=(const ConstIterator& other) const;
+ const Value& operator*() const;
+
+ private:
+ ConstStorageIterator mStorageIterator;
+ const Value* mSerialIterator;
+ };
+
+ class BeginEnd {
+ public:
+ BeginEnd(StorageIterator start, StorageIterator end);
+
+ Iterator begin() const;
+ Iterator end() const;
+
+ private:
+ StorageIterator mStartIt;
+ StorageIterator mEndIt;
+ };
+
+ class ConstBeginEnd {
+ public:
+ ConstBeginEnd(ConstStorageIterator start, ConstStorageIterator end);
+
+ ConstIterator begin() const;
+ ConstIterator end() const;
+
+ private:
+ ConstStorageIterator mStartIt;
+ ConstStorageIterator mEndIt;
+ };
+
+ // Derived classes may specialize constraits for elements stored
+ // Ex.) SerialQueue enforces that the serial must be given in (not strictly)
+ // increasing order
+ template <typename... Params>
+ void Enqueue(Params&&... args, Serial serial) {
+ Derived::Enqueue(std::forward<Params>(args)..., serial);
+ }
+
+ bool Empty() const;
+
+ // The UpTo variants of Iterate and Clear affect all values associated to a serial
+ // that is smaller OR EQUAL to the given serial. Iterating is done like so:
+ // for (const T& value : queue.IterateAll()) { stuff(T); }
+ ConstBeginEnd IterateAll() const;
+ ConstBeginEnd IterateUpTo(Serial serial) const;
+ BeginEnd IterateAll();
+ BeginEnd IterateUpTo(Serial serial);
+
+ void Clear();
+ void ClearUpTo(Serial serial);
+
+ Serial FirstSerial() const;
+
+ protected:
+ // Returns the first StorageIterator that a serial bigger than serial.
+ ConstStorageIterator FindUpTo(Serial serial) const;
+ StorageIterator FindUpTo(Serial serial);
+ Storage mStorage;
+};
+
+// SerialStorage
+
+template <typename Derived>
+bool SerialStorage<Derived>::Empty() const {
+ return mStorage.empty();
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::ConstBeginEnd SerialStorage<Derived>::IterateAll() const {
+ return {mStorage.begin(), mStorage.end()};
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::ConstBeginEnd SerialStorage<Derived>::IterateUpTo(
+ Serial serial) const {
+ return {mStorage.begin(), FindUpTo(serial)};
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::BeginEnd SerialStorage<Derived>::IterateAll() {
+ return {mStorage.begin(), mStorage.end()};
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::BeginEnd SerialStorage<Derived>::IterateUpTo(Serial serial) {
+ return {mStorage.begin(), FindUpTo(serial)};
+}
+
+template <typename Derived>
+void SerialStorage<Derived>::Clear() {
+ mStorage.clear();
+}
+
+template <typename Derived>
+void SerialStorage<Derived>::ClearUpTo(Serial serial) {
+ mStorage.erase(mStorage.begin(), FindUpTo(serial));
+}
+
+template <typename Derived>
+Serial SerialStorage<Derived>::FirstSerial() const {
+ DAWN_ASSERT(!Empty());
+ return mStorage.begin()->first;
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::ConstStorageIterator SerialStorage<Derived>::FindUpTo(
+ Serial serial) const {
+ auto it = mStorage.begin();
+ while (it != mStorage.end() && it->first <= serial) {
+ it++;
+ }
+ return it;
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::StorageIterator SerialStorage<Derived>::FindUpTo(Serial serial) {
+ auto it = mStorage.begin();
+ while (it != mStorage.end() && it->first <= serial) {
+ it++;
+ }
+ return it;
+}
+
+// SerialStorage::BeginEnd
+
+template <typename Derived>
+SerialStorage<Derived>::BeginEnd::BeginEnd(typename SerialStorage<Derived>::StorageIterator start,
+ typename SerialStorage<Derived>::StorageIterator end)
+ : mStartIt(start), mEndIt(end) {
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::Iterator SerialStorage<Derived>::BeginEnd::begin() const {
+ return {mStartIt};
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::Iterator SerialStorage<Derived>::BeginEnd::end() const {
+ return {mEndIt};
+}
+
+// SerialStorage::Iterator
+
+template <typename Derived>
+SerialStorage<Derived>::Iterator::Iterator(typename SerialStorage<Derived>::StorageIterator start)
+ : mStorageIterator(start), mSerialIterator(nullptr) {
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::Iterator& SerialStorage<Derived>::Iterator::operator++() {
+ Value* vectorData = mStorageIterator->second.data();
+
+ if (mSerialIterator == nullptr) {
+ mSerialIterator = vectorData + 1;
+ } else {
+ mSerialIterator++;
+ }
+
+ if (mSerialIterator >= vectorData + mStorageIterator->second.size()) {
+ mSerialIterator = nullptr;
+ mStorageIterator++;
+ }
+
+ return *this;
+}
+
+template <typename Derived>
+bool SerialStorage<Derived>::Iterator::operator==(
+ const typename SerialStorage<Derived>::Iterator& other) const {
+ return other.mStorageIterator == mStorageIterator && other.mSerialIterator == mSerialIterator;
+}
+
+template <typename Derived>
+bool SerialStorage<Derived>::Iterator::operator!=(
+ const typename SerialStorage<Derived>::Iterator& other) const {
+ return !(*this == other);
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::Value& SerialStorage<Derived>::Iterator::operator*() const {
+ if (mSerialIterator == nullptr) {
+ return *mStorageIterator->second.begin();
+ }
+ return *mSerialIterator;
+}
+
+// SerialStorage::ConstBeginEnd
+
+template <typename Derived>
+SerialStorage<Derived>::ConstBeginEnd::ConstBeginEnd(
+ typename SerialStorage<Derived>::ConstStorageIterator start,
+ typename SerialStorage<Derived>::ConstStorageIterator end)
+ : mStartIt(start), mEndIt(end) {
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::ConstIterator SerialStorage<Derived>::ConstBeginEnd::begin()
+ const {
+ return {mStartIt};
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::ConstIterator SerialStorage<Derived>::ConstBeginEnd::end() const {
+ return {mEndIt};
+}
+
+// SerialStorage::ConstIterator
+
+template <typename Derived>
+SerialStorage<Derived>::ConstIterator::ConstIterator(
+ typename SerialStorage<Derived>::ConstStorageIterator start)
+ : mStorageIterator(start), mSerialIterator(nullptr) {
+}
+
+template <typename Derived>
+typename SerialStorage<Derived>::ConstIterator& SerialStorage<Derived>::ConstIterator::
+operator++() {
+ const Value* vectorData = mStorageIterator->second.data();
+
+ if (mSerialIterator == nullptr) {
+ mSerialIterator = vectorData + 1;
+ } else {
+ mSerialIterator++;
+ }
+
+ if (mSerialIterator >= vectorData + mStorageIterator->second.size()) {
+ mSerialIterator = nullptr;
+ mStorageIterator++;
+ }
+
+ return *this;
+}
+
+template <typename Derived>
+bool SerialStorage<Derived>::ConstIterator::operator==(
+ const typename SerialStorage<Derived>::ConstIterator& other) const {
+ return other.mStorageIterator == mStorageIterator && other.mSerialIterator == mSerialIterator;
+}
+
+template <typename Derived>
+bool SerialStorage<Derived>::ConstIterator::operator!=(
+ const typename SerialStorage<Derived>::ConstIterator& other) const {
+ return !(*this == other);
+}
+
+template <typename Derived>
+const typename SerialStorage<Derived>::Value& SerialStorage<Derived>::ConstIterator::operator*()
+ const {
+ if (mSerialIterator == nullptr) {
+ return *mStorageIterator->second.begin();
+ }
+ return *mSerialIterator;
+}
+
+#endif // COMMON_SERIALSTORAGE_H_
diff --git a/chromium/third_party/dawn/src/common/SwapChainUtils.h b/chromium/third_party/dawn/src/common/SwapChainUtils.h
new file mode 100644
index 00000000000..78aa7028469
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/SwapChainUtils.h
@@ -0,0 +1,40 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_SWAPCHAINUTILS_H_
+#define COMMON_SWAPCHAINUTILS_H_
+
+#include "dawn/dawn_wsi.h"
+
+template <typename T>
+dawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
+ dawnSwapChainImplementation impl = {};
+ impl.userData = swapChain;
+ impl.Init = [](void* userData, void* wsiContext) {
+ auto* ctx = reinterpret_cast<typename T::WSIContext*>(wsiContext);
+ reinterpret_cast<T*>(userData)->Init(ctx);
+ };
+ impl.Destroy = [](void* userData) { delete reinterpret_cast<T*>(userData); };
+ impl.Configure = [](void* userData, dawnTextureFormat format, dawnTextureUsageBit allowedUsage,
+ uint32_t width, uint32_t height) {
+ return reinterpret_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
+ };
+ impl.GetNextTexture = [](void* userData, dawnSwapChainNextTexture* nextTexture) {
+ return reinterpret_cast<T*>(userData)->GetNextTexture(nextTexture);
+ };
+ impl.Present = [](void* userData) { return reinterpret_cast<T*>(userData)->Present(); };
+ return impl;
+}
+
+#endif // COMMON_SWAPCHAINUTILS_H_
diff --git a/chromium/third_party/dawn/src/common/vulkan_platform.h b/chromium/third_party/dawn/src/common/vulkan_platform.h
new file mode 100644
index 00000000000..81f0406bc55
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/vulkan_platform.h
@@ -0,0 +1,160 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_VULKANPLATFORM_H_
+#define COMMON_VULKANPLATFORM_H_
+
+#if !defined(DAWN_ENABLE_BACKEND_VULKAN)
+# error "vulkan_platform.h included without the Vulkan backend enabled"
+#endif
+
+#include "common/Platform.h"
+
+#include <cstddef>
+#include <cstdint>
+
+// vulkan.h defines non-dispatchable handles to opaque pointers on 64bit architectures and uint64_t
+// on 32bit architectures. This causes a problem in 32bit where the handles cannot be used to
+// distinguish between overloads of the same function.
+// Change the definition of non-dispatchable handles to be opaque structures containing a uint64_t
+// and overload the comparison operators between themselves and VK_NULL_HANDLE (which will be
+// redefined to be nullptr). This keeps the type-safety of having the handles be different types
+// (like vulkan.h on 64 bit) but makes sure the types are different on 32 bit architectures.
+
+#if defined(DAWN_PLATFORM_64_BIT)
+# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) \
+ using object##Native = struct object##_T*;
+#elif defined(DAWN_PLATFORM_32_BIT)
+# define DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) using object##Native = uint64_t;
+#else
+# error "Unsupported platform"
+#endif
+
+// Define a dummy Vulkan handle for use before we include vulkan.h
+DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(VkSomeHandle)
+
+// Find out the alignment of native handles. Logically we would use alignof(VkSomeHandleNative) so
+// why bother with the wrapper struct? It turns out that on Linux Intel x86 alignof(uint64_t) is 8
+// but alignof(struct{uint64_t a;}) is 4. This is because this Intel ABI doesn't say anything about
+// double-word alignment so for historical reasons compilers violated the standard and use an
+// alignment of 4 for uint64_t (and double) inside structures.
+// See https://stackoverflow.com/questions/44877185
+// One way to get the alignment inside structures of a type is to look at the alignment of it
+// wrapped in a structure. Hence VkSameHandleNativeWrappe
+
+template <typename T>
+struct WrapperStruct {
+ T member;
+};
+
+template <typename T>
+static constexpr size_t AlignOfInStruct = alignof(WrapperStruct<T>);
+
+static constexpr size_t kNativeVkHandleAlignment = AlignOfInStruct<VkSomeHandleNative>;
+static constexpr size_t kUint64Alignment = AlignOfInStruct<VkSomeHandleNative>;
+
+// Simple handle types that supports "nullptr_t" as a 0 value.
+template <typename Tag, typename HandleType>
+class alignas(kNativeVkHandleAlignment) VkNonDispatchableHandle {
+ public:
+ // Default constructor and assigning of VK_NULL_HANDLE
+ VkNonDispatchableHandle() = default;
+ VkNonDispatchableHandle(std::nullptr_t) : mHandle(0) {
+ }
+
+ // Use default copy constructor/assignment
+ VkNonDispatchableHandle(const VkNonDispatchableHandle<Tag, HandleType>& other) = default;
+ VkNonDispatchableHandle& operator=(const VkNonDispatchableHandle<Tag, HandleType>&) = default;
+
+ // Comparisons between handles
+ bool operator==(VkNonDispatchableHandle<Tag, HandleType> other) {
+ return mHandle == other.mHandle;
+ }
+ bool operator!=(VkNonDispatchableHandle<Tag, HandleType> other) {
+ return mHandle != other.mHandle;
+ }
+
+ // Comparisons between handles and VK_NULL_HANDLE
+ bool operator==(std::nullptr_t) {
+ return mHandle == 0;
+ }
+ bool operator!=(std::nullptr_t) {
+ return mHandle != 0;
+ }
+
+ // The regular Vulkan handle type depends on the pointer width but is always 64 bits wide.
+ // - On 64bit it is an opaque pointer type, probably to help with type safety
+ // - On 32bit it is a uint64_t because pointers aren't wide enough (and non dispatchable
+ // handles can be optimized to not be pointer but contain GPU virtual addresses or the
+ // data in a packed form).
+ // Because of this we need two types of conversions from our handle type: to uint64_t and to
+ // the "native" Vulkan type that may not be an uint64_t
+
+ static VkNonDispatchableHandle<Tag, HandleType> CreateFromU64(uint64_t handle) {
+ return {handle};
+ }
+
+ uint64_t GetU64() const {
+ return mHandle;
+ }
+
+#if defined(DAWN_PLATFORM_64_BIT)
+ static VkNonDispatchableHandle<Tag, HandleType> CreateFromHandle(HandleType handle) {
+ return CreateFromU64(static_cast<uint64_t>(reinterpret_cast<intptr_t>(handle)));
+ }
+
+ HandleType GetHandle() const {
+ return mHandle;
+ }
+#elif defined(DAWN_PLATFORM_32_BIT)
+ static VkNonDispatchableHandle<Tag, HandleType> CreateFromHandle(HandleType handle) {
+ return {handle};
+ }
+
+ HandleType GetHandle() const {
+ return mHandle;
+ }
+#else
+# error "Unsupported platform"
+#endif
+
+ private:
+ VkNonDispatchableHandle(uint64_t handle) : mHandle(handle) {
+ }
+
+ uint64_t mHandle = 0;
+};
+
+#define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) \
+ struct VkTag##object; \
+ DAWN_DEFINE_NATIVE_NON_DISPATCHABLE_HANDLE(object) \
+ using object = VkNonDispatchableHandle<VkTag##object, object##Native>; \
+ static_assert(sizeof(object) == sizeof(uint64_t), ""); \
+ static_assert(alignof(object) == kUint64Alignment, ""); \
+ static_assert(sizeof(object) == sizeof(object##Native), ""); \
+ static_assert(alignof(object) == kNativeVkHandleAlignment, "");
+
+# include <vulkan/vulkan.h>
+
+ // VK_NULL_HANDLE is defined to 0 but we don't want our handle type to compare to arbitrary
+ // integers. Redefine VK_NULL_HANDLE to nullptr that has its own type.
+# undef VK_NULL_HANDLE
+# define VK_NULL_HANDLE nullptr
+
+// Remove windows.h macros after vulkan_platform's include of windows.h
+#if defined(DAWN_PLATFORM_WINDOWS)
+# include "common/windows_with_undefs.h"
+#endif
+
+#endif // COMMON_VULKANPLATFORM_H_
diff --git a/chromium/third_party/dawn/src/common/windows_with_undefs.h b/chromium/third_party/dawn/src/common/windows_with_undefs.h
new file mode 100644
index 00000000000..c4815464a62
--- /dev/null
+++ b/chromium/third_party/dawn/src/common/windows_with_undefs.h
@@ -0,0 +1,31 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef COMMON_WINDOWS_WITH_UNDEFS_H_
+#define COMMON_WINDOWS_WITH_UNDEFS_H_
+
+#include "common/Compiler.h"
+
+#if !defined(DAWN_PLATFORM_WINDOWS)
+# error "windows_with_undefs.h included on non-Windows"
+#endif
+
+// This header includes <windows.h> but removes all the extra defines that conflict with identifiers
+// in internal code. It should never be included in something that is part of the public interface.
+#include <windows.h>
+
+// Macros defined for ANSI / Unicode support
+#undef GetMessage
+
+#endif // COMMON_WINDOWS_WITH_UNDEFS_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/BindGroup.cpp b/chromium/third_party/dawn/src/dawn_native/BindGroup.cpp
new file mode 100644
index 00000000000..637b4b2fa40
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/BindGroup.cpp
@@ -0,0 +1,209 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/BindGroup.h"
+
+#include "common/Assert.h"
+#include "common/Math.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/Buffer.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/Texture.h"
+
+namespace dawn_native {
+
+ // BindGroup
+
+ BindGroupBase::BindGroupBase(BindGroupBuilder* builder)
+ : ObjectBase(builder->GetDevice()),
+ mLayout(std::move(builder->mLayout)),
+ mBindings(std::move(builder->mBindings)) {
+ }
+
+ const BindGroupLayoutBase* BindGroupBase::GetLayout() const {
+ return mLayout.Get();
+ }
+
+ BufferViewBase* BindGroupBase::GetBindingAsBufferView(size_t binding) {
+ ASSERT(binding < kMaxBindingsPerGroup);
+ ASSERT(mLayout->GetBindingInfo().mask[binding]);
+ ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::UniformBuffer ||
+ mLayout->GetBindingInfo().types[binding] == dawn::BindingType::StorageBuffer);
+ return reinterpret_cast<BufferViewBase*>(mBindings[binding].Get());
+ }
+
+ SamplerBase* BindGroupBase::GetBindingAsSampler(size_t binding) {
+ ASSERT(binding < kMaxBindingsPerGroup);
+ ASSERT(mLayout->GetBindingInfo().mask[binding]);
+ ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::Sampler);
+ return reinterpret_cast<SamplerBase*>(mBindings[binding].Get());
+ }
+
+ TextureViewBase* BindGroupBase::GetBindingAsTextureView(size_t binding) {
+ ASSERT(binding < kMaxBindingsPerGroup);
+ ASSERT(mLayout->GetBindingInfo().mask[binding]);
+ ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::SampledTexture);
+ return reinterpret_cast<TextureViewBase*>(mBindings[binding].Get());
+ }
+
+ // BindGroupBuilder
+
+ enum BindGroupSetProperties {
+ BINDGROUP_PROPERTY_LAYOUT = 0x1,
+ };
+
+ BindGroupBuilder::BindGroupBuilder(DeviceBase* device) : Builder(device) {
+ }
+
+ BindGroupBase* BindGroupBuilder::GetResultImpl() {
+ constexpr int allProperties = BINDGROUP_PROPERTY_LAYOUT;
+ if ((mPropertiesSet & allProperties) != allProperties) {
+ HandleError("Bindgroup missing properties");
+ return nullptr;
+ }
+
+ if (mSetMask != mLayout->GetBindingInfo().mask) {
+ HandleError("Bindgroup missing bindings");
+ return nullptr;
+ }
+
+ return GetDevice()->CreateBindGroup(this);
+ }
+
+ void BindGroupBuilder::SetLayout(BindGroupLayoutBase* layout) {
+ if ((mPropertiesSet & BINDGROUP_PROPERTY_LAYOUT) != 0) {
+ HandleError("Bindgroup layout property set multiple times");
+ return;
+ }
+
+ mLayout = layout;
+ mPropertiesSet |= BINDGROUP_PROPERTY_LAYOUT;
+ }
+
+ void BindGroupBuilder::SetBufferViews(uint32_t start,
+ uint32_t count,
+ BufferViewBase* const* bufferViews) {
+ if (!SetBindingsValidationBase(start, count)) {
+ return;
+ }
+
+ const auto& layoutInfo = mLayout->GetBindingInfo();
+ for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
+ dawn::BufferUsageBit requiredBit = dawn::BufferUsageBit::None;
+ switch (layoutInfo.types[i]) {
+ case dawn::BindingType::UniformBuffer:
+ requiredBit = dawn::BufferUsageBit::Uniform;
+ break;
+
+ case dawn::BindingType::StorageBuffer:
+ requiredBit = dawn::BufferUsageBit::Storage;
+ break;
+
+ case dawn::BindingType::Sampler:
+ case dawn::BindingType::SampledTexture:
+ HandleError("Setting buffer for a wrong binding type");
+ return;
+ }
+
+ if (!(bufferViews[j]->GetBuffer()->GetUsage() & requiredBit)) {
+ HandleError("Buffer needs to allow the correct usage bit");
+ return;
+ }
+
+ if (!IsAligned(bufferViews[j]->GetOffset(), 256)) {
+ HandleError("Buffer view offset for bind group needs to be 256-byte aligned");
+ return;
+ }
+ }
+
+ SetBindingsBase(start, count, reinterpret_cast<ObjectBase* const*>(bufferViews));
+ }
+
+ void BindGroupBuilder::SetSamplers(uint32_t start,
+ uint32_t count,
+ SamplerBase* const* samplers) {
+ if (!SetBindingsValidationBase(start, count)) {
+ return;
+ }
+
+ const auto& layoutInfo = mLayout->GetBindingInfo();
+ for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
+ if (layoutInfo.types[i] != dawn::BindingType::Sampler) {
+ HandleError("Setting binding for a wrong layout binding type");
+ return;
+ }
+ }
+
+ SetBindingsBase(start, count, reinterpret_cast<ObjectBase* const*>(samplers));
+ }
+
+ void BindGroupBuilder::SetTextureViews(uint32_t start,
+ uint32_t count,
+ TextureViewBase* const* textureViews) {
+ if (!SetBindingsValidationBase(start, count)) {
+ return;
+ }
+
+ const auto& layoutInfo = mLayout->GetBindingInfo();
+ for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
+ if (layoutInfo.types[i] != dawn::BindingType::SampledTexture) {
+ HandleError("Setting binding for a wrong layout binding type");
+ return;
+ }
+
+ if (!(textureViews[j]->GetTexture()->GetUsage() & dawn::TextureUsageBit::Sampled)) {
+ HandleError("Texture needs to allow the sampled usage bit");
+ return;
+ }
+ }
+
+ SetBindingsBase(start, count, reinterpret_cast<ObjectBase* const*>(textureViews));
+ }
+
+ void BindGroupBuilder::SetBindingsBase(uint32_t start,
+ uint32_t count,
+ ObjectBase* const* objects) {
+ for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
+ mSetMask.set(i);
+ mBindings[i] = objects[j];
+ }
+ }
+
+ bool BindGroupBuilder::SetBindingsValidationBase(uint32_t start, uint32_t count) {
+ if (start + count > kMaxBindingsPerGroup) {
+ HandleError("Setting bindings type over maximum number of bindings");
+ return false;
+ }
+
+ if ((mPropertiesSet & BINDGROUP_PROPERTY_LAYOUT) == 0) {
+ HandleError("Bindgroup layout must be set before views");
+ return false;
+ }
+
+ const auto& layoutInfo = mLayout->GetBindingInfo();
+ for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
+ if (mSetMask[i]) {
+ HandleError("Setting already set binding");
+ return false;
+ }
+
+ if (!layoutInfo.mask[i]) {
+ HandleError("Setting binding that isn't present in the layout");
+ return false;
+ }
+ }
+
+ return true;
+ }
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/BindGroup.h b/chromium/third_party/dawn/src/dawn_native/BindGroup.h
new file mode 100644
index 00000000000..115b8256ddf
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/BindGroup.h
@@ -0,0 +1,72 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_BINDGROUP_H_
+#define DAWNNATIVE_BINDGROUP_H_
+
+#include "common/Constants.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/Builder.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+
+namespace dawn_native {
+
+ class BindGroupBase : public ObjectBase {
+ public:
+ BindGroupBase(BindGroupBuilder* builder);
+
+ const BindGroupLayoutBase* GetLayout() const;
+ BufferViewBase* GetBindingAsBufferView(size_t binding);
+ SamplerBase* GetBindingAsSampler(size_t binding);
+ TextureViewBase* GetBindingAsTextureView(size_t binding);
+
+ private:
+ Ref<BindGroupLayoutBase> mLayout;
+ std::array<Ref<ObjectBase>, kMaxBindingsPerGroup> mBindings;
+ };
+
+ class BindGroupBuilder : public Builder<BindGroupBase> {
+ public:
+ BindGroupBuilder(DeviceBase* device);
+
+ // Dawn API
+ void SetLayout(BindGroupLayoutBase* layout);
+
+ void SetBufferViews(uint32_t start, uint32_t count, BufferViewBase* const* bufferViews);
+ void SetSamplers(uint32_t start, uint32_t count, SamplerBase* const* samplers);
+ void SetTextureViews(uint32_t start, uint32_t count, TextureViewBase* const* textureViews);
+
+ private:
+ friend class BindGroupBase;
+
+ BindGroupBase* GetResultImpl() override;
+ void SetBindingsBase(uint32_t start, uint32_t count, ObjectBase* const* objects);
+ bool SetBindingsValidationBase(uint32_t start, uint32_t count);
+
+ std::bitset<kMaxBindingsPerGroup> mSetMask;
+ int mPropertiesSet = 0;
+
+ Ref<BindGroupLayoutBase> mLayout;
+ std::array<Ref<ObjectBase>, kMaxBindingsPerGroup> mBindings;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_BINDGROUP_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/BindGroupLayout.cpp b/chromium/third_party/dawn/src/dawn_native/BindGroupLayout.cpp
new file mode 100644
index 00000000000..0098fa67082
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/BindGroupLayout.cpp
@@ -0,0 +1,117 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/BindGroupLayout.h"
+
+#include "common/BitSetIterator.h"
+#include "common/HashUtils.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/ValidationUtils_autogen.h"
+
+#include <functional>
+
+namespace dawn_native {
+
+ MaybeError ValidateBindGroupLayoutDescriptor(DeviceBase*,
+ const BindGroupLayoutDescriptor* descriptor) {
+ if (descriptor->nextInChain != nullptr) {
+ return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
+ }
+
+ std::bitset<kMaxBindingsPerGroup> bindingsSet;
+ for (uint32_t i = 0; i < descriptor->numBindings; ++i) {
+ auto& binding = descriptor->bindings[i];
+ DAWN_TRY(ValidateShaderStageBit(binding.visibility));
+ DAWN_TRY(ValidateBindingType(binding.type));
+
+ if (binding.binding >= kMaxBindingsPerGroup) {
+ return DAWN_VALIDATION_ERROR("some binding index exceeds the maximum value");
+ }
+ if (bindingsSet[binding.binding]) {
+ return DAWN_VALIDATION_ERROR("some binding index was specified more than once");
+ }
+ bindingsSet.set(binding.binding);
+ }
+ return {};
+ }
+
+ namespace {
+ size_t HashBindingInfo(const BindGroupLayoutBase::LayoutBindingInfo& info) {
+ size_t hash = Hash(info.mask);
+
+ for (uint32_t binding : IterateBitSet(info.mask)) {
+ HashCombine(&hash, info.visibilities[binding], info.types[binding]);
+ }
+
+ return hash;
+ }
+
+ bool operator==(const BindGroupLayoutBase::LayoutBindingInfo& a,
+ const BindGroupLayoutBase::LayoutBindingInfo& b) {
+ if (a.mask != b.mask) {
+ return false;
+ }
+
+ for (uint32_t binding : IterateBitSet(a.mask)) {
+ if ((a.visibilities[binding] != b.visibilities[binding]) ||
+ (a.types[binding] != b.types[binding])) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+ } // namespace
+
+ // BindGroupLayoutBase
+
+ BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device,
+ const BindGroupLayoutDescriptor* descriptor,
+ bool blueprint)
+ : ObjectBase(device), mIsBlueprint(blueprint) {
+ for (uint32_t i = 0; i < descriptor->numBindings; ++i) {
+ auto& binding = descriptor->bindings[i];
+
+ uint32_t index = binding.binding;
+ mBindingInfo.visibilities[index] = binding.visibility;
+ mBindingInfo.types[index] = binding.type;
+
+ ASSERT(!mBindingInfo.mask[index]);
+ mBindingInfo.mask.set(index);
+ }
+ }
+
+ BindGroupLayoutBase::~BindGroupLayoutBase() {
+ // Do not uncache the actual cached object if we are a blueprint
+ if (!mIsBlueprint) {
+ GetDevice()->UncacheBindGroupLayout(this);
+ }
+ }
+
+ const BindGroupLayoutBase::LayoutBindingInfo& BindGroupLayoutBase::GetBindingInfo() const {
+ return mBindingInfo;
+ }
+
+ // BindGroupLayoutCacheFuncs
+
+ size_t BindGroupLayoutCacheFuncs::operator()(const BindGroupLayoutBase* bgl) const {
+ return HashBindingInfo(bgl->GetBindingInfo());
+ }
+
+ bool BindGroupLayoutCacheFuncs::operator()(const BindGroupLayoutBase* a,
+ const BindGroupLayoutBase* b) const {
+ return a->GetBindingInfo() == b->GetBindingInfo();
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/BindGroupLayout.h b/chromium/third_party/dawn/src/dawn_native/BindGroupLayout.h
new file mode 100644
index 00000000000..3a1f4540ac1
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/BindGroupLayout.h
@@ -0,0 +1,63 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_BINDGROUPLAYOUT_H_
+#define DAWNNATIVE_BINDGROUPLAYOUT_H_
+
+#include "common/Constants.h"
+#include "dawn_native/Error.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+
+namespace dawn_native {
+
+ MaybeError ValidateBindGroupLayoutDescriptor(DeviceBase*,
+ const BindGroupLayoutDescriptor* descriptor);
+
+ class BindGroupLayoutBase : public ObjectBase {
+ public:
+ BindGroupLayoutBase(DeviceBase* device,
+ const BindGroupLayoutDescriptor* descriptor,
+ bool blueprint = false);
+ ~BindGroupLayoutBase() override;
+
+ struct LayoutBindingInfo {
+ std::array<dawn::ShaderStageBit, kMaxBindingsPerGroup> visibilities;
+ std::array<dawn::BindingType, kMaxBindingsPerGroup> types;
+ std::bitset<kMaxBindingsPerGroup> mask;
+ };
+ const LayoutBindingInfo& GetBindingInfo() const;
+
+ private:
+ LayoutBindingInfo mBindingInfo;
+ bool mIsBlueprint = false;
+ };
+
+ // Implements the functors necessary for the unordered_set<BGL*>-based cache.
+ struct BindGroupLayoutCacheFuncs {
+ // The hash function
+ size_t operator()(const BindGroupLayoutBase* bgl) const;
+
+ // The equality predicate
+ bool operator()(const BindGroupLayoutBase* a, const BindGroupLayoutBase* b) const;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_BINDGROUPLAYOUT_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/BlendState.cpp b/chromium/third_party/dawn/src/dawn_native/BlendState.cpp
new file mode 100644
index 00000000000..2cf042d23bc
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/BlendState.cpp
@@ -0,0 +1,98 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/BlendState.h"
+
+#include "dawn_native/Device.h"
+
+namespace dawn_native {
+
+ // BlendStateBase
+
+ BlendStateBase::BlendStateBase(BlendStateBuilder* builder)
+ : ObjectBase(builder->GetDevice()), mBlendInfo(builder->mBlendInfo) {
+ }
+
+ const BlendStateBase::BlendInfo& BlendStateBase::GetBlendInfo() const {
+ return mBlendInfo;
+ }
+
+ // BlendStateBuilder
+
+ enum BlendStateSetProperties {
+ BLEND_STATE_PROPERTY_BLEND_ENABLED = 0x1,
+ BLEND_STATE_PROPERTY_ALPHA_BLEND = 0x2,
+ BLEND_STATE_PROPERTY_COLOR_BLEND = 0x4,
+ BLEND_STATE_PROPERTY_COLOR_WRITE_MASK = 0x08,
+ };
+
+ BlendStateBuilder::BlendStateBuilder(DeviceBase* device) : Builder(device) {
+ }
+
+ BlendStateBase* BlendStateBuilder::GetResultImpl() {
+ return GetDevice()->CreateBlendState(this);
+ }
+
+ void BlendStateBuilder::SetBlendEnabled(bool blendEnabled) {
+ if ((mPropertiesSet & BLEND_STATE_PROPERTY_BLEND_ENABLED) != 0) {
+ HandleError("Blend enabled property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= BLEND_STATE_PROPERTY_BLEND_ENABLED;
+
+ mBlendInfo.blendEnabled = blendEnabled;
+ }
+
+ void BlendStateBuilder::SetAlphaBlend(const BlendDescriptor* alphaBlend) {
+ if ((mPropertiesSet & BLEND_STATE_PROPERTY_ALPHA_BLEND) != 0) {
+ HandleError("Alpha blend property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= BLEND_STATE_PROPERTY_ALPHA_BLEND;
+
+ // TODO(yunchao.he@intel.com): validate the enum values in
+ // ValidateBlendStateDescriptor when it is added.
+ mBlendInfo.alphaBlend.operation = alphaBlend->operation;
+ mBlendInfo.alphaBlend.srcFactor = alphaBlend->srcFactor;
+ mBlendInfo.alphaBlend.dstFactor = alphaBlend->dstFactor;
+ }
+
+ void BlendStateBuilder::SetColorBlend(const BlendDescriptor* colorBlend) {
+ if ((mPropertiesSet & BLEND_STATE_PROPERTY_COLOR_BLEND) != 0) {
+ HandleError("Color blend property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= BLEND_STATE_PROPERTY_COLOR_BLEND;
+
+ // TODO(yunchao.he@intel.com): validate the enum values in
+ // ValidateBlendStateDescriptor when it is added.
+ mBlendInfo.colorBlend.operation = colorBlend->operation;
+ mBlendInfo.colorBlend.srcFactor = colorBlend->srcFactor;
+ mBlendInfo.colorBlend.dstFactor = colorBlend->dstFactor;
+ }
+
+ void BlendStateBuilder::SetColorWriteMask(dawn::ColorWriteMask colorWriteMask) {
+ if ((mPropertiesSet & BLEND_STATE_PROPERTY_COLOR_WRITE_MASK) != 0) {
+ HandleError("Color write mask property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= BLEND_STATE_PROPERTY_COLOR_WRITE_MASK;
+
+ mBlendInfo.colorWriteMask = colorWriteMask;
+ }
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/BlendState.h b/chromium/third_party/dawn/src/dawn_native/BlendState.h
new file mode 100644
index 00000000000..72e8821b549
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/BlendState.h
@@ -0,0 +1,67 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_BLENDSTATE_H_
+#define DAWNNATIVE_BLENDSTATE_H_
+
+#include "dawn_native/Builder.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+
+ class BlendStateBase : public ObjectBase {
+ public:
+ BlendStateBase(BlendStateBuilder* builder);
+
+ struct BlendInfo {
+ bool blendEnabled = false;
+ BlendDescriptor alphaBlend = {dawn::BlendOperation::Add, dawn::BlendFactor::One,
+ dawn::BlendFactor::Zero};
+ BlendDescriptor colorBlend = {dawn::BlendOperation::Add, dawn::BlendFactor::One,
+ dawn::BlendFactor::Zero};
+ dawn::ColorWriteMask colorWriteMask = dawn::ColorWriteMask::All;
+ };
+
+ const BlendInfo& GetBlendInfo() const;
+
+ private:
+ BlendInfo mBlendInfo;
+ };
+
+ class BlendStateBuilder : public Builder<BlendStateBase> {
+ public:
+ BlendStateBuilder(DeviceBase* device);
+
+ // Dawn API
+ void SetBlendEnabled(bool blendEnabled);
+ void SetAlphaBlend(const BlendDescriptor* alphaBlend);
+ void SetColorBlend(const BlendDescriptor* colorBlend);
+ void SetColorWriteMask(dawn::ColorWriteMask colorWriteMask);
+
+ private:
+ friend class BlendStateBase;
+
+ BlendStateBase* GetResultImpl() override;
+
+ int mPropertiesSet = 0;
+
+ BlendStateBase::BlendInfo mBlendInfo;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_BLENDSTATE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Buffer.cpp b/chromium/third_party/dawn/src/dawn_native/Buffer.cpp
new file mode 100644
index 00000000000..e073491144c
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Buffer.cpp
@@ -0,0 +1,270 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Buffer.h"
+
+#include "common/Assert.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/ValidationUtils_autogen.h"
+
+#include <cstdio>
+#include <utility>
+
+namespace dawn_native {
+
+ MaybeError ValidateBufferDescriptor(DeviceBase*, const BufferDescriptor* descriptor) {
+ if (descriptor->nextInChain != nullptr) {
+ return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
+ }
+
+ DAWN_TRY(ValidateBufferUsageBit(descriptor->usage));
+
+ dawn::BufferUsageBit usage = descriptor->usage;
+
+ const dawn::BufferUsageBit kMapWriteAllowedUsages =
+ dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc;
+ if (usage & dawn::BufferUsageBit::MapWrite && (usage & kMapWriteAllowedUsages) != usage) {
+ return DAWN_VALIDATION_ERROR("Only TransferSrc is allowed with MapWrite");
+ }
+
+ const dawn::BufferUsageBit kMapReadAllowedUsages =
+ dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst;
+ if (usage & dawn::BufferUsageBit::MapRead && (usage & kMapReadAllowedUsages) != usage) {
+ return DAWN_VALIDATION_ERROR("Only TransferDst is allowed with MapRead");
+ }
+
+ return {};
+ }
+
+ // Buffer
+
+ BufferBase::BufferBase(DeviceBase* device, const BufferDescriptor* descriptor)
+ : ObjectBase(device), mSize(descriptor->size), mUsage(descriptor->usage) {
+ }
+
+ BufferBase::~BufferBase() {
+ if (mIsMapped) {
+ CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
+ CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
+ }
+ }
+
+ BufferViewBuilder* BufferBase::CreateBufferViewBuilder() {
+ return new BufferViewBuilder(GetDevice(), this);
+ }
+
+ uint32_t BufferBase::GetSize() const {
+ return mSize;
+ }
+
+ dawn::BufferUsageBit BufferBase::GetUsage() const {
+ return mUsage;
+ }
+
+ MaybeError BufferBase::ValidateCanUseInSubmitNow() const {
+ if (mIsMapped) {
+ return DAWN_VALIDATION_ERROR("Buffer used in a submit while mapped");
+ }
+ return {};
+ }
+
+ void BufferBase::CallMapReadCallback(uint32_t serial,
+ dawnBufferMapAsyncStatus status,
+ const void* pointer) {
+ if (mMapReadCallback != nullptr && serial == mMapSerial) {
+ ASSERT(mMapWriteCallback == nullptr);
+ // Tag the callback as fired before firing it, otherwise it could fire a second time if
+ // for example buffer.Unmap() is called inside the application-provided callback.
+ dawnBufferMapReadCallback callback = mMapReadCallback;
+ mMapReadCallback = nullptr;
+ callback(status, pointer, mMapUserdata);
+ }
+ }
+
+ void BufferBase::CallMapWriteCallback(uint32_t serial,
+ dawnBufferMapAsyncStatus status,
+ void* pointer) {
+ if (mMapWriteCallback != nullptr && serial == mMapSerial) {
+ ASSERT(mMapReadCallback == nullptr);
+ // Tag the callback as fired before firing it, otherwise it could fire a second time if
+ // for example buffer.Unmap() is called inside the application-provided callback.
+ dawnBufferMapWriteCallback callback = mMapWriteCallback;
+ mMapWriteCallback = nullptr;
+ callback(status, pointer, mMapUserdata);
+ }
+ }
+
+ void BufferBase::SetSubData(uint32_t start, uint32_t count, const uint8_t* data) {
+ if (GetDevice()->ConsumedError(ValidateSetSubData(start, count))) {
+ return;
+ }
+
+ SetSubDataImpl(start, count, data);
+ }
+
+ void BufferBase::MapReadAsync(uint32_t start,
+ uint32_t size,
+ dawnBufferMapReadCallback callback,
+ dawnCallbackUserdata userdata) {
+ if (GetDevice()->ConsumedError(ValidateMap(start, size, dawn::BufferUsageBit::MapRead))) {
+ callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
+ return;
+ }
+
+ ASSERT(mMapWriteCallback == nullptr);
+
+ // TODO(cwallez@chromium.org): what to do on wraparound? Could cause crashes.
+ mMapSerial++;
+ mMapReadCallback = callback;
+ mMapUserdata = userdata;
+ mIsMapped = true;
+
+ MapReadAsyncImpl(mMapSerial, start, size);
+ }
+
+ void BufferBase::MapWriteAsync(uint32_t start,
+ uint32_t size,
+ dawnBufferMapWriteCallback callback,
+ dawnCallbackUserdata userdata) {
+ if (GetDevice()->ConsumedError(ValidateMap(start, size, dawn::BufferUsageBit::MapWrite))) {
+ callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
+ return;
+ }
+
+ ASSERT(mMapReadCallback == nullptr);
+
+ // TODO(cwallez@chromium.org): what to do on wraparound? Could cause crashes.
+ mMapSerial++;
+ mMapWriteCallback = callback;
+ mMapUserdata = userdata;
+ mIsMapped = true;
+
+ MapWriteAsyncImpl(mMapSerial, start, size);
+ }
+
+ void BufferBase::Unmap() {
+ if (GetDevice()->ConsumedError(ValidateUnmap())) {
+ return;
+ }
+
+ // A map request can only be called once, so this will fire only if the request wasn't
+ // completed before the Unmap
+ CallMapReadCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
+ CallMapWriteCallback(mMapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_UNKNOWN, nullptr);
+ UnmapImpl();
+ mIsMapped = false;
+ mMapReadCallback = nullptr;
+ mMapWriteCallback = nullptr;
+ mMapUserdata = 0;
+ }
+
+ MaybeError BufferBase::ValidateSetSubData(uint32_t start, uint32_t count) const {
+ // TODO(cwallez@chromium.org): check for overflows.
+ if (start + count > GetSize()) {
+ return DAWN_VALIDATION_ERROR("Buffer subdata out of range");
+ }
+
+ if (!(mUsage & dawn::BufferUsageBit::TransferDst)) {
+ return DAWN_VALIDATION_ERROR("Buffer needs the transfer dst usage bit");
+ }
+
+ return {};
+ }
+
+ MaybeError BufferBase::ValidateMap(uint32_t start,
+ uint32_t size,
+ dawn::BufferUsageBit requiredUsage) const {
+ // TODO(cwallez@chromium.org): check for overflows.
+ if (start + size > GetSize()) {
+ return DAWN_VALIDATION_ERROR("Buffer map read out of range");
+ }
+
+ if (mIsMapped) {
+ return DAWN_VALIDATION_ERROR("Buffer already mapped");
+ }
+
+ if (!(mUsage & requiredUsage)) {
+ return DAWN_VALIDATION_ERROR("Buffer needs the correct map usage bit");
+ }
+
+ return {};
+ }
+
+ MaybeError BufferBase::ValidateUnmap() const {
+ if (!mIsMapped) {
+ return DAWN_VALIDATION_ERROR("Buffer wasn't mapped");
+ }
+
+ return {};
+ }
+
+ // BufferViewBase
+
+ BufferViewBase::BufferViewBase(BufferViewBuilder* builder)
+ : ObjectBase(builder->GetDevice()),
+ mBuffer(std::move(builder->mBuffer)),
+ mSize(builder->mSize),
+ mOffset(builder->mOffset) {
+ }
+
+ BufferBase* BufferViewBase::GetBuffer() {
+ return mBuffer.Get();
+ }
+
+ uint32_t BufferViewBase::GetSize() const {
+ return mSize;
+ }
+
+ uint32_t BufferViewBase::GetOffset() const {
+ return mOffset;
+ }
+
+ // BufferViewBuilder
+
+ enum BufferViewSetProperties {
+ BUFFER_VIEW_PROPERTY_EXTENT = 0x1,
+ };
+
+ BufferViewBuilder::BufferViewBuilder(DeviceBase* device, BufferBase* buffer)
+ : Builder(device), mBuffer(buffer) {
+ }
+
+ BufferViewBase* BufferViewBuilder::GetResultImpl() {
+ constexpr int allProperties = BUFFER_VIEW_PROPERTY_EXTENT;
+ if ((mPropertiesSet & allProperties) != allProperties) {
+ HandleError("Buffer view missing properties");
+ return nullptr;
+ }
+
+ return GetDevice()->CreateBufferView(this);
+ }
+
+ void BufferViewBuilder::SetExtent(uint32_t offset, uint32_t size) {
+ if ((mPropertiesSet & BUFFER_VIEW_PROPERTY_EXTENT) != 0) {
+ HandleError("Buffer view extent property set multiple times");
+ return;
+ }
+
+ uint64_t viewEnd = static_cast<uint64_t>(offset) + static_cast<uint64_t>(size);
+ if (viewEnd > static_cast<uint64_t>(mBuffer->GetSize())) {
+ HandleError("Buffer view end is OOB");
+ return;
+ }
+
+ mOffset = offset;
+ mSize = size;
+ mPropertiesSet |= BUFFER_VIEW_PROPERTY_EXTENT;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Buffer.h b/chromium/third_party/dawn/src/dawn_native/Buffer.h
new file mode 100644
index 00000000000..ce10ea5b619
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Buffer.h
@@ -0,0 +1,135 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_BUFFER_H_
+#define DAWNNATIVE_BUFFER_H_
+
+#include "dawn_native/Builder.h"
+#include "dawn_native/Error.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+
+ MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* descriptor);
+
+ static constexpr dawn::BufferUsageBit kReadOnlyBufferUsages =
+ dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferSrc |
+ dawn::BufferUsageBit::Index | dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Uniform;
+
+ static constexpr dawn::BufferUsageBit kWritableBufferUsages =
+ dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferDst |
+ dawn::BufferUsageBit::Storage;
+
+ class BufferBase : public ObjectBase {
+ public:
+ BufferBase(DeviceBase* device, const BufferDescriptor* descriptor);
+ ~BufferBase();
+
+ uint32_t GetSize() const;
+ dawn::BufferUsageBit GetUsage() const;
+
+ MaybeError ValidateCanUseInSubmitNow() const;
+
+ // Dawn API
+ BufferViewBuilder* CreateBufferViewBuilder();
+ void SetSubData(uint32_t start, uint32_t count, const uint8_t* data);
+ void MapReadAsync(uint32_t start,
+ uint32_t size,
+ dawnBufferMapReadCallback callback,
+ dawnCallbackUserdata userdata);
+ void MapWriteAsync(uint32_t start,
+ uint32_t size,
+ dawnBufferMapWriteCallback callback,
+ dawnCallbackUserdata userdata);
+ void Unmap();
+
+ protected:
+ void CallMapReadCallback(uint32_t serial,
+ dawnBufferMapAsyncStatus status,
+ const void* pointer);
+ void CallMapWriteCallback(uint32_t serial, dawnBufferMapAsyncStatus status, void* pointer);
+
+ private:
+ virtual void SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) = 0;
+ virtual void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t size) = 0;
+ virtual void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t size) = 0;
+ virtual void UnmapImpl() = 0;
+
+ MaybeError ValidateSetSubData(uint32_t start, uint32_t count) const;
+ MaybeError ValidateMap(uint32_t start,
+ uint32_t size,
+ dawn::BufferUsageBit requiredUsage) const;
+ MaybeError ValidateUnmap() const;
+
+ uint32_t mSize;
+ dawn::BufferUsageBit mUsage = dawn::BufferUsageBit::None;
+
+ dawnBufferMapReadCallback mMapReadCallback = nullptr;
+ dawnBufferMapWriteCallback mMapWriteCallback = nullptr;
+ dawnCallbackUserdata mMapUserdata = 0;
+ uint32_t mMapSerial = 0;
+
+ bool mIsMapped = false;
+ };
+
+ class BufferViewBase : public ObjectBase {
+ public:
+ BufferViewBase(BufferViewBuilder* builder);
+
+ BufferBase* GetBuffer();
+ uint32_t GetSize() const;
+ uint32_t GetOffset() const;
+
+ private:
+ Ref<BufferBase> mBuffer;
+ uint32_t mSize;
+ uint32_t mOffset;
+ };
+
+ class BufferViewBuilder : public Builder<BufferViewBase> {
+ public:
+ BufferViewBuilder(DeviceBase* device, BufferBase* buffer);
+
+ // Dawn API
+ void SetExtent(uint32_t offset, uint32_t size);
+
+ private:
+ friend class BufferViewBase;
+
+ BufferViewBase* GetResultImpl() override;
+
+ Ref<BufferBase> mBuffer;
+ uint32_t mOffset = 0;
+ uint32_t mSize = 0;
+ int mPropertiesSet = 0;
+ };
+
+ // This builder class is kept around purely for testing but should not be used.
+ class BufferBuilder : public Builder<BufferViewBase> {
+ public:
+ BufferBuilder(DeviceBase* device) : Builder(device) {
+ UNREACHABLE();
+ }
+
+ void SetSize(uint32_t) {
+ UNREACHABLE();
+ }
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_BUFFER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Builder.cpp b/chromium/third_party/dawn/src/dawn_native/Builder.cpp
new file mode 100644
index 00000000000..e9deb236a7b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Builder.cpp
@@ -0,0 +1,93 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Builder.h"
+
+#include "common/Assert.h"
+#include "dawn_native/Device.h"
+
+namespace dawn_native {
+
+ bool BuilderBase::CanBeUsed() const {
+ return !mIsConsumed && !mGotStatus;
+ }
+
+ void BuilderBase::HandleError(const char* message) {
+ SetStatus(dawn::BuilderErrorStatus::Error, message);
+ }
+
+ void BuilderBase::SetErrorCallback(dawn::BuilderErrorCallback callback,
+ dawn::CallbackUserdata userdata1,
+ dawn::CallbackUserdata userdata2) {
+ mCallback = callback;
+ mUserdata1 = userdata1;
+ mUserdata2 = userdata2;
+ }
+
+ BuilderBase::BuilderBase(DeviceBase* device) : ObjectBase(device) {
+ }
+
+ BuilderBase::~BuilderBase() {
+ if (!mIsConsumed && mCallback != nullptr) {
+ mCallback(DAWN_BUILDER_ERROR_STATUS_UNKNOWN, "Builder destroyed before GetResult",
+ mUserdata1, mUserdata2);
+ }
+ }
+
+ void BuilderBase::SetStatus(dawn::BuilderErrorStatus status, const char* message) {
+ ASSERT(status != dawn::BuilderErrorStatus::Success);
+ ASSERT(status != dawn::BuilderErrorStatus::Unknown);
+ ASSERT(!mGotStatus); // This is not strictly necessary but something to strive for.
+ mGotStatus = true;
+
+ mStoredStatus = status;
+ mStoredMessage = message;
+ }
+
+ bool BuilderBase::HandleResult(ObjectBase* result) {
+ // GetResult can only be called once.
+ ASSERT(!mIsConsumed);
+ mIsConsumed = true;
+
+ // result == nullptr implies there was an error which implies we should have a status set.
+ ASSERT(result != nullptr || mGotStatus);
+
+ // If we have any error, then we have to return nullptr
+ if (mGotStatus) {
+ ASSERT(mStoredStatus != dawn::BuilderErrorStatus::Success);
+
+ // The application will never see "result" so we need to remove the
+ // external ref here.
+ if (result != nullptr) {
+ result->Release();
+ result = nullptr;
+ }
+
+ // Unhandled builder errors are promoted to device errors
+ if (!mCallback)
+ GetDevice()->HandleError(("Unhandled builder error: " + mStoredMessage).c_str());
+ } else {
+ ASSERT(mStoredStatus == dawn::BuilderErrorStatus::Success);
+ ASSERT(mStoredMessage.empty());
+ }
+
+ if (mCallback != nullptr) {
+ mCallback(static_cast<dawnBuilderErrorStatus>(mStoredStatus), mStoredMessage.c_str(),
+ mUserdata1, mUserdata2);
+ }
+
+ return result != nullptr;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Builder.h b/chromium/third_party/dawn/src/dawn_native/Builder.h
new file mode 100644
index 00000000000..19fef8e2bc1
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Builder.h
@@ -0,0 +1,105 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_BUILDER_H_
+#define DAWNNATIVE_BUILDER_H_
+
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <string>
+
+namespace dawn_native {
+
+ // This class implements behavior shared by all builders:
+ // - Tracking whether GetResult has been called already, needed by the autogenerated code to
+ // prevent operations on "consumed" builders.
+ // - The error status callback of the API. The callback is guaranteed to be called exactly once
+ // with an error, a success, or "unknown" if the builder is destroyed; also the builder
+ // callback cannot be called before either the object is destroyed or GetResult is called.
+ //
+ // It is possible for error to be generated before the error callback is registered when a
+ // builder "set" function performance validation inline. Because of this we have to store the
+ // status in the builder and defer calling the callback to GetResult.
+
+ class BuilderBase : public ObjectBase {
+ public:
+ // Used by the auto-generated validation to prevent usage of the builder
+ // after GetResult or an error.
+ bool CanBeUsed() const;
+
+ // Set the status of the builder to an error.
+ void HandleError(const char* message);
+
+ // Internal API, to be used by builder and BackendProcTable only.
+ // Returns true for success cases, and calls the callback with appropriate status.
+ bool HandleResult(ObjectBase* result);
+
+ // Dawn API
+ void SetErrorCallback(dawn::BuilderErrorCallback callback,
+ dawn::CallbackUserdata userdata1,
+ dawn::CallbackUserdata userdata2);
+
+ protected:
+ BuilderBase(DeviceBase* device);
+ ~BuilderBase();
+
+ bool mGotStatus = false;
+
+ private:
+ void SetStatus(dawn::BuilderErrorStatus status, const char* message);
+
+ dawn::BuilderErrorCallback mCallback = nullptr;
+ dawn::CallbackUserdata mUserdata1 = 0;
+ dawn::CallbackUserdata mUserdata2 = 0;
+
+ dawn::BuilderErrorStatus mStoredStatus = dawn::BuilderErrorStatus::Success;
+ std::string mStoredMessage;
+
+ bool mIsConsumed = false;
+ };
+
+ // This builder base class is used to capture the calls to GetResult and make sure that either:
+ // - There was an error, callback is called with an error and nullptr is returned.
+ // - There was no error, callback is called with success and a non-null T* is returned.
+ template <typename T>
+ class Builder : public BuilderBase {
+ public:
+ // Dawn API
+ T* GetResult();
+
+ protected:
+ using BuilderBase::BuilderBase;
+
+ private:
+ virtual T* GetResultImpl() = 0;
+ };
+
+ template <typename T>
+ T* Builder<T>::GetResult() {
+ T* result = GetResultImpl();
+ // An object can have been returned but failed its initialization, so if an error happened,
+ // return nullptr instead of result.
+ if (HandleResult(result)) {
+ return result;
+ } else {
+ return nullptr;
+ }
+ }
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_BUILDER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/CommandAllocator.cpp b/chromium/third_party/dawn/src/dawn_native/CommandAllocator.cpp
new file mode 100644
index 00000000000..3f90f6f5cb2
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/CommandAllocator.cpp
@@ -0,0 +1,228 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/CommandAllocator.h"
+
+#include "common/Assert.h"
+#include "common/Math.h"
+
+#include <algorithm>
+#include <climits>
+#include <cstdlib>
+
+namespace dawn_native {
+
+ constexpr uint32_t EndOfBlock = UINT_MAX; // std::numeric_limits<uint32_t>::max();
+ constexpr uint32_t AdditionalData = UINT_MAX - 1; // std::numeric_limits<uint32_t>::max() - 1;
+
+ // TODO(cwallez@chromium.org): figure out a way to have more type safety for the iterator
+
+ CommandIterator::CommandIterator() : mEndOfBlock(EndOfBlock) {
+ Reset();
+ }
+
+ CommandIterator::~CommandIterator() {
+ ASSERT(mDataWasDestroyed);
+
+ if (!IsEmpty()) {
+ for (auto& block : mBlocks) {
+ free(block.block);
+ }
+ }
+ }
+
+ CommandIterator::CommandIterator(CommandIterator&& other) : mEndOfBlock(EndOfBlock) {
+ if (!other.IsEmpty()) {
+ mBlocks = std::move(other.mBlocks);
+ other.Reset();
+ }
+ other.DataWasDestroyed();
+ Reset();
+ }
+
+ CommandIterator& CommandIterator::operator=(CommandIterator&& other) {
+ if (!other.IsEmpty()) {
+ mBlocks = std::move(other.mBlocks);
+ other.Reset();
+ } else {
+ mBlocks.clear();
+ }
+ other.DataWasDestroyed();
+ Reset();
+ return *this;
+ }
+
+ CommandIterator::CommandIterator(CommandAllocator&& allocator)
+ : mBlocks(allocator.AcquireBlocks()), mEndOfBlock(EndOfBlock) {
+ Reset();
+ }
+
+ CommandIterator& CommandIterator::operator=(CommandAllocator&& allocator) {
+ mBlocks = allocator.AcquireBlocks();
+ Reset();
+ return *this;
+ }
+
+ void CommandIterator::Reset() {
+ mCurrentBlock = 0;
+
+ if (mBlocks.empty()) {
+ // This will case the first NextCommandId call to try to move to the next block and stop
+ // the iteration immediately, without special casing the initialization.
+ mCurrentPtr = reinterpret_cast<uint8_t*>(&mEndOfBlock);
+ mBlocks.emplace_back();
+ mBlocks[0].size = sizeof(mEndOfBlock);
+ mBlocks[0].block = mCurrentPtr;
+ } else {
+ mCurrentPtr = AlignPtr(mBlocks[0].block, alignof(uint32_t));
+ }
+ }
+
+ void CommandIterator::DataWasDestroyed() {
+ mDataWasDestroyed = true;
+ }
+
+ bool CommandIterator::IsEmpty() const {
+ return mBlocks[0].block == reinterpret_cast<const uint8_t*>(&mEndOfBlock);
+ }
+
+ bool CommandIterator::NextCommandId(uint32_t* commandId) {
+ uint8_t* idPtr = AlignPtr(mCurrentPtr, alignof(uint32_t));
+ ASSERT(idPtr + sizeof(uint32_t) <=
+ mBlocks[mCurrentBlock].block + mBlocks[mCurrentBlock].size);
+
+ uint32_t id = *reinterpret_cast<uint32_t*>(idPtr);
+
+ if (id == EndOfBlock) {
+ mCurrentBlock++;
+ if (mCurrentBlock >= mBlocks.size()) {
+ Reset();
+ *commandId = EndOfBlock;
+ return false;
+ }
+ mCurrentPtr = AlignPtr(mBlocks[mCurrentBlock].block, alignof(uint32_t));
+ return NextCommandId(commandId);
+ }
+
+ mCurrentPtr = idPtr + sizeof(uint32_t);
+ *commandId = id;
+ return true;
+ }
+
+ void* CommandIterator::NextCommand(size_t commandSize, size_t commandAlignment) {
+ uint8_t* commandPtr = AlignPtr(mCurrentPtr, commandAlignment);
+ ASSERT(commandPtr + sizeof(commandSize) <=
+ mBlocks[mCurrentBlock].block + mBlocks[mCurrentBlock].size);
+
+ mCurrentPtr = commandPtr + commandSize;
+ return commandPtr;
+ }
+
+ void* CommandIterator::NextData(size_t dataSize, size_t dataAlignment) {
+ uint32_t id;
+ bool hasId = NextCommandId(&id);
+ ASSERT(hasId);
+ ASSERT(id == AdditionalData);
+
+ return NextCommand(dataSize, dataAlignment);
+ }
+
+ // Potential TODO(cwallez@chromium.org):
+ // - Host the size and pointer to next block in the block itself to avoid having an allocation
+ // in the vector
+ // - Assume T's alignof is, say 64bits, static assert it, and make commandAlignment a constant
+ // in Allocate
+ // - Be able to optimize allocation to one block, for command buffers expected to live long to
+ // avoid cache misses
+ // - Better block allocation, maybe have Dawn API to say command buffer is going to have size
+ // close to another
+
+ CommandAllocator::CommandAllocator()
+ : mCurrentPtr(reinterpret_cast<uint8_t*>(&mDummyEnum[0])),
+ mEndPtr(reinterpret_cast<uint8_t*>(&mDummyEnum[1])) {
+ }
+
+ CommandAllocator::~CommandAllocator() {
+ ASSERT(mBlocks.empty());
+ }
+
+ CommandBlocks&& CommandAllocator::AcquireBlocks() {
+ ASSERT(mCurrentPtr != nullptr && mEndPtr != nullptr);
+ ASSERT(IsPtrAligned(mCurrentPtr, alignof(uint32_t)));
+ ASSERT(mCurrentPtr + sizeof(uint32_t) <= mEndPtr);
+ *reinterpret_cast<uint32_t*>(mCurrentPtr) = EndOfBlock;
+
+ mCurrentPtr = nullptr;
+ mEndPtr = nullptr;
+ return std::move(mBlocks);
+ }
+
+ uint8_t* CommandAllocator::Allocate(uint32_t commandId,
+ size_t commandSize,
+ size_t commandAlignment) {
+ ASSERT(mCurrentPtr != nullptr);
+ ASSERT(mEndPtr != nullptr);
+ ASSERT(commandId != EndOfBlock);
+
+ // It should always be possible to allocate one id, for EndOfBlock tagging,
+ ASSERT(IsPtrAligned(mCurrentPtr, alignof(uint32_t)));
+ ASSERT(mCurrentPtr + sizeof(uint32_t) <= mEndPtr);
+ uint32_t* idAlloc = reinterpret_cast<uint32_t*>(mCurrentPtr);
+
+ uint8_t* commandAlloc = AlignPtr(mCurrentPtr + sizeof(uint32_t), commandAlignment);
+ uint8_t* nextPtr = AlignPtr(commandAlloc + commandSize, alignof(uint32_t));
+
+ // When there is not enough space, we signal the EndOfBlock, so that the iterator nows to
+ // move to the next one. EndOfBlock on the last block means the end of the commands.
+ if (nextPtr + sizeof(uint32_t) > mEndPtr) {
+ // Even if we are not able to get another block, the list of commands will be
+ // well-formed and iterable as this block will be that last one.
+ *idAlloc = EndOfBlock;
+
+ // Make sure we have space for current allocation, plus end of block and alignment
+ // padding for the first id.
+ ASSERT(nextPtr > mCurrentPtr);
+ if (!GetNewBlock(static_cast<size_t>(nextPtr - mCurrentPtr) + sizeof(uint32_t) +
+ alignof(uint32_t))) {
+ return nullptr;
+ }
+ return Allocate(commandId, commandSize, commandAlignment);
+ }
+
+ *idAlloc = commandId;
+ mCurrentPtr = nextPtr;
+ return commandAlloc;
+ }
+
+ uint8_t* CommandAllocator::AllocateData(size_t commandSize, size_t commandAlignment) {
+ return Allocate(AdditionalData, commandSize, commandAlignment);
+ }
+
+ bool CommandAllocator::GetNewBlock(size_t minimumSize) {
+ // Allocate blocks doubling sizes each time, to a maximum of 16k (or at least minimumSize).
+ mLastAllocationSize =
+ std::max(minimumSize, std::min(mLastAllocationSize * 2, size_t(16384)));
+
+ uint8_t* block = reinterpret_cast<uint8_t*>(malloc(mLastAllocationSize));
+ if (block == nullptr) {
+ return false;
+ }
+
+ mBlocks.push_back({mLastAllocationSize, block});
+ mCurrentPtr = AlignPtr(block, alignof(uint32_t));
+ mEndPtr = block + mLastAllocationSize;
+ return true;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/CommandAllocator.h b/chromium/third_party/dawn/src/dawn_native/CommandAllocator.h
new file mode 100644
index 00000000000..06257c6ed4b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/CommandAllocator.h
@@ -0,0 +1,150 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_COMMAND_ALLOCATOR_H_
+#define DAWNNATIVE_COMMAND_ALLOCATOR_H_
+
+#include <cstddef>
+#include <cstdint>
+#include <vector>
+
+namespace dawn_native {
+
+ // Allocation for command buffers should be fast. To avoid doing an allocation per command
+ // or to avoid copying commands when reallocing, we use a linear allocator in a growing set
+ // of large memory blocks. We also use this to have the format to be (u32 commandId, command),
+ // so that iteration over the commands is easy.
+
+ // Usage of the allocator and iterator:
+ // CommandAllocator allocator;
+ // DrawCommand* cmd = allocator.Allocate<DrawCommand>(CommandType::Draw);
+ // // Fill command
+ // // Repeat allocation and filling commands
+ //
+ // CommandIterator commands(allocator);
+ // CommandType type;
+ // void* command;
+ // while(commands.NextCommandId(&e)) {
+ // switch(e) {
+ // case CommandType::Draw:
+ // DrawCommand* draw = commands.NextCommand<DrawCommand>();
+ // // Do the draw
+ // break;
+ // // other cases
+ // }
+ // }
+
+ // Note that you need to extract the commands from the CommandAllocator before destroying it
+ // and must tell the CommandIterator when the allocated commands have been processed for
+ // deletion.
+
+ // These are the lists of blocks, should not be used directly, only through CommandAllocator
+ // and CommandIterator
+ struct BlockDef {
+ size_t size;
+ uint8_t* block;
+ };
+ using CommandBlocks = std::vector<BlockDef>;
+
+ class CommandAllocator;
+
+ // TODO(cwallez@chromium.org): prevent copy for both iterator and allocator
+ class CommandIterator {
+ public:
+ CommandIterator();
+ ~CommandIterator();
+
+ CommandIterator(CommandIterator&& other);
+ CommandIterator& operator=(CommandIterator&& other);
+
+ CommandIterator(CommandAllocator&& allocator);
+ CommandIterator& operator=(CommandAllocator&& allocator);
+
+ template <typename E>
+ bool NextCommandId(E* commandId) {
+ return NextCommandId(reinterpret_cast<uint32_t*>(commandId));
+ }
+ template <typename T>
+ T* NextCommand() {
+ return reinterpret_cast<T*>(NextCommand(sizeof(T), alignof(T)));
+ }
+ template <typename T>
+ T* NextData(size_t count) {
+ return reinterpret_cast<T*>(NextData(sizeof(T) * count, alignof(T)));
+ }
+
+ // Needs to be called if iteration was stopped early.
+ void Reset();
+
+ void DataWasDestroyed();
+
+ private:
+ bool IsEmpty() const;
+
+ bool NextCommandId(uint32_t* commandId);
+ void* NextCommand(size_t commandSize, size_t commandAlignment);
+ void* NextData(size_t dataSize, size_t dataAlignment);
+
+ CommandBlocks mBlocks;
+ uint8_t* mCurrentPtr = nullptr;
+ size_t mCurrentBlock = 0;
+ // Used to avoid a special case for empty iterators.
+ uint32_t mEndOfBlock;
+ bool mDataWasDestroyed = false;
+ };
+
+ class CommandAllocator {
+ public:
+ CommandAllocator();
+ ~CommandAllocator();
+
+ template <typename T, typename E>
+ T* Allocate(E commandId) {
+ static_assert(sizeof(E) == sizeof(uint32_t), "");
+ static_assert(alignof(E) == alignof(uint32_t), "");
+ return reinterpret_cast<T*>(
+ Allocate(static_cast<uint32_t>(commandId), sizeof(T), alignof(T)));
+ }
+
+ template <typename T>
+ T* AllocateData(size_t count) {
+ return reinterpret_cast<T*>(AllocateData(sizeof(T) * count, alignof(T)));
+ }
+
+ private:
+ friend CommandIterator;
+ CommandBlocks&& AcquireBlocks();
+
+ uint8_t* Allocate(uint32_t commandId, size_t commandSize, size_t commandAlignment);
+ uint8_t* AllocateData(size_t dataSize, size_t dataAlignment);
+ bool GetNewBlock(size_t minimumSize);
+
+ CommandBlocks mBlocks;
+ size_t mLastAllocationSize = 2048;
+
+ // Pointers to the current range of allocation in the block. Guaranteed to allow for at
+ // least one uint32_t is not nullptr, so that the special EndOfBlock command id can always
+ // be written. Nullptr iff the blocks were moved out.
+ uint8_t* mCurrentPtr = nullptr;
+ uint8_t* mEndPtr = nullptr;
+
+ // Data used for the block range at initialization so that the first call to Allocate sees
+ // there is not enough space and calls GetNewBlock. This avoids having to special case the
+ // initialization in Allocate.
+ uint32_t mDummyEnum[1] = {0};
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_COMMAND_ALLOCATOR_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/CommandBuffer.cpp b/chromium/third_party/dawn/src/dawn_native/CommandBuffer.cpp
new file mode 100644
index 00000000000..8ddcc15b5c0
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/CommandBuffer.cpp
@@ -0,0 +1,702 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/CommandBuffer.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/Buffer.h"
+#include "dawn_native/CommandBufferStateTracker.h"
+#include "dawn_native/Commands.h"
+#include "dawn_native/ComputePassEncoder.h"
+#include "dawn_native/ComputePipeline.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/ErrorData.h"
+#include "dawn_native/InputState.h"
+#include "dawn_native/PipelineLayout.h"
+#include "dawn_native/RenderPassEncoder.h"
+#include "dawn_native/RenderPipeline.h"
+#include "dawn_native/Texture.h"
+
+#include <cstring>
+#include <map>
+
+namespace dawn_native {
+
+ namespace {
+
+ MaybeError ValidateCopyLocationFitsInTexture(const TextureCopyLocation& location) {
+ const TextureBase* texture = location.texture.Get();
+ if (location.level >= texture->GetNumMipLevels()) {
+ return DAWN_VALIDATION_ERROR("Copy mip-level out of range");
+ }
+
+ if (location.slice >= texture->GetArrayLayers()) {
+ return DAWN_VALIDATION_ERROR("Copy array-layer out of range");
+ }
+
+ // All texture dimensions are in uint32_t so by doing checks in uint64_t we avoid
+ // overflows.
+ uint64_t level = location.level;
+ if (uint64_t(location.x) + uint64_t(location.width) >
+ (static_cast<uint64_t>(texture->GetSize().width) >> level) ||
+ uint64_t(location.y) + uint64_t(location.height) >
+ (static_cast<uint64_t>(texture->GetSize().height) >> level)) {
+ return DAWN_VALIDATION_ERROR("Copy would touch outside of the texture");
+ }
+
+ // TODO(cwallez@chromium.org): Check the depth bound differently for 2D arrays and 3D
+ // textures
+ if (location.z != 0 || location.depth != 1) {
+ return DAWN_VALIDATION_ERROR("No support for z != 0 and depth != 1 for now");
+ }
+
+ return {};
+ }
+
+ bool FitsInBuffer(const BufferBase* buffer, uint32_t offset, uint32_t size) {
+ uint32_t bufferSize = buffer->GetSize();
+ return offset <= bufferSize && (size <= (bufferSize - offset));
+ }
+
+ MaybeError ValidateCopySizeFitsInBuffer(const BufferCopyLocation& location,
+ uint32_t dataSize) {
+ if (!FitsInBuffer(location.buffer.Get(), location.offset, dataSize)) {
+ return DAWN_VALIDATION_ERROR("Copy would overflow the buffer");
+ }
+
+ return {};
+ }
+
+ MaybeError ValidateTexelBufferOffset(TextureBase* texture,
+ const BufferCopyLocation& location) {
+ uint32_t texelSize =
+ static_cast<uint32_t>(TextureFormatPixelSize(texture->GetFormat()));
+ if (location.offset % texelSize != 0) {
+ return DAWN_VALIDATION_ERROR("Buffer offset must be a multiple of the texel size");
+ }
+
+ return {};
+ }
+
+ MaybeError ComputeTextureCopyBufferSize(const TextureCopyLocation& location,
+ uint32_t rowPitch,
+ uint32_t* bufferSize) {
+ // TODO(cwallez@chromium.org): check for overflows
+ *bufferSize = (rowPitch * (location.height - 1) + location.width) * location.depth;
+
+ return {};
+ }
+
+ uint32_t ComputeDefaultRowPitch(TextureBase* texture, uint32_t width) {
+ uint32_t texelSize = TextureFormatPixelSize(texture->GetFormat());
+ return texelSize * width;
+ }
+
+ MaybeError ValidateRowPitch(const TextureCopyLocation& location, uint32_t rowPitch) {
+ if (rowPitch % kTextureRowPitchAlignment != 0) {
+ return DAWN_VALIDATION_ERROR("Row pitch must be a multiple of 256");
+ }
+
+ uint32_t texelSize = TextureFormatPixelSize(location.texture.Get()->GetFormat());
+ if (rowPitch < location.width * texelSize) {
+ return DAWN_VALIDATION_ERROR(
+ "Row pitch must not be less than the number of bytes per row");
+ }
+
+ return {};
+ }
+
+ MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
+ ASSERT(HasZeroOrOneBits(usage));
+ if (!(buffer->GetUsage() & usage)) {
+ return DAWN_VALIDATION_ERROR("buffer doesn't have the required usage.");
+ }
+
+ return {};
+ }
+
+ MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsageBit usage) {
+ ASSERT(HasZeroOrOneBits(usage));
+ if (!(texture->GetUsage() & usage)) {
+ return DAWN_VALIDATION_ERROR("texture doesn't have the required usage.");
+ }
+
+ return {};
+ }
+
+ enum class PassType {
+ Render,
+ Compute,
+ };
+
+ // Helper class to encapsulate the logic of tracking per-resource usage during the
+ // validation of command buffer passes. It is used both to know if there are validation
+ // errors, and to get a list of resources used per pass for backends that need the
+ // information.
+ class PassResourceUsageTracker {
+ public:
+ void BufferUsedAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
+ // std::map's operator[] will create the key and return 0 if the key didn't exist
+ // before.
+ dawn::BufferUsageBit& storedUsage = mBufferUsages[buffer];
+
+ if (usage == dawn::BufferUsageBit::Storage &&
+ storedUsage & dawn::BufferUsageBit::Storage) {
+ mStorageUsedMultipleTimes = true;
+ }
+
+ storedUsage |= usage;
+ }
+
+ void TextureUsedAs(TextureBase* texture, dawn::TextureUsageBit usage) {
+ // std::map's operator[] will create the key and return 0 if the key didn't exist
+ // before.
+ dawn::TextureUsageBit& storedUsage = mTextureUsages[texture];
+
+ if (usage == dawn::TextureUsageBit::Storage &&
+ storedUsage & dawn::TextureUsageBit::Storage) {
+ mStorageUsedMultipleTimes = true;
+ }
+
+ storedUsage |= usage;
+ }
+
+ // Performs the per-pass usage validation checks
+ MaybeError ValidateUsages(PassType pass) const {
+ // Storage resources cannot be used twice in the same compute pass
+ if (pass == PassType::Compute && mStorageUsedMultipleTimes) {
+ return DAWN_VALIDATION_ERROR(
+ "Storage resource used multiple times in compute pass");
+ }
+
+ // Buffers can only be used as single-write or multiple read.
+ for (auto& it : mBufferUsages) {
+ BufferBase* buffer = it.first;
+ dawn::BufferUsageBit usage = it.second;
+
+ if (usage & ~buffer->GetUsage()) {
+ return DAWN_VALIDATION_ERROR("Buffer missing usage for the pass");
+ }
+
+ bool readOnly = (usage & kReadOnlyBufferUsages) == usage;
+ bool singleUse = dawn::HasZeroOrOneBits(usage);
+
+ if (!readOnly && !singleUse) {
+ return DAWN_VALIDATION_ERROR(
+ "Buffer used as writeable usage and another usage in pass");
+ }
+ }
+
+ // Textures can only be used as single-write or multiple read.
+ // TODO(cwallez@chromium.org): implement per-subresource tracking
+ for (auto& it : mTextureUsages) {
+ TextureBase* texture = it.first;
+ dawn::TextureUsageBit usage = it.second;
+
+ if (usage & ~texture->GetUsage()) {
+ return DAWN_VALIDATION_ERROR("Texture missing usage for the pass");
+ }
+
+ // For textures the only read-only usage in a pass is Sampled, so checking the
+ // usage constraint simplifies to checking a single usage bit is set.
+ if (!dawn::HasZeroOrOneBits(it.second)) {
+ return DAWN_VALIDATION_ERROR(
+ "Texture used with more than one usage in pass");
+ }
+ }
+
+ return {};
+ }
+
+ // Returns the per-pass usage for use by backends for APIs with explicit barriers.
+ PassResourceUsage AcquireResourceUsage() {
+ PassResourceUsage result;
+ result.buffers.reserve(mBufferUsages.size());
+ result.bufferUsages.reserve(mBufferUsages.size());
+ result.textures.reserve(mTextureUsages.size());
+ result.textureUsages.reserve(mTextureUsages.size());
+
+ for (auto& it : mBufferUsages) {
+ result.buffers.push_back(it.first);
+ result.bufferUsages.push_back(it.second);
+ }
+
+ for (auto& it : mTextureUsages) {
+ result.textures.push_back(it.first);
+ result.textureUsages.push_back(it.second);
+ }
+
+ return result;
+ }
+
+ private:
+ std::map<BufferBase*, dawn::BufferUsageBit> mBufferUsages;
+ std::map<TextureBase*, dawn::TextureUsageBit> mTextureUsages;
+ bool mStorageUsedMultipleTimes = false;
+ };
+
+ void TrackBindGroupResourceUsage(BindGroupBase* group, PassResourceUsageTracker* tracker) {
+ const auto& layoutInfo = group->GetLayout()->GetBindingInfo();
+
+ for (uint32_t i : IterateBitSet(layoutInfo.mask)) {
+ dawn::BindingType type = layoutInfo.types[i];
+
+ switch (type) {
+ case dawn::BindingType::UniformBuffer: {
+ BufferBase* buffer = group->GetBindingAsBufferView(i)->GetBuffer();
+ tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Uniform);
+ } break;
+
+ case dawn::BindingType::StorageBuffer: {
+ BufferBase* buffer = group->GetBindingAsBufferView(i)->GetBuffer();
+ tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Storage);
+ } break;
+
+ case dawn::BindingType::SampledTexture: {
+ TextureBase* texture = group->GetBindingAsTextureView(i)->GetTexture();
+ tracker->TextureUsedAs(texture, dawn::TextureUsageBit::Sampled);
+ } break;
+
+ case dawn::BindingType::Sampler:
+ break;
+ }
+ }
+ }
+
+ } // namespace
+
+ enum class CommandBufferBuilder::EncodingState : uint8_t {
+ TopLevel,
+ ComputePass,
+ RenderPass,
+ Finished
+ };
+
+ // CommandBuffer
+
+ CommandBufferBase::CommandBufferBase(CommandBufferBuilder* builder)
+ : ObjectBase(builder->GetDevice()), mResourceUsages(builder->AcquireResourceUsages()) {
+ }
+
+ const CommandBufferResourceUsage& CommandBufferBase::GetResourceUsages() const {
+ return mResourceUsages;
+ }
+
+ // CommandBufferBuilder
+
+ CommandBufferBuilder::CommandBufferBuilder(DeviceBase* device)
+ : Builder(device), mEncodingState(EncodingState::TopLevel) {
+ }
+
+ CommandBufferBuilder::~CommandBufferBuilder() {
+ if (!mWereCommandsAcquired) {
+ MoveToIterator();
+ FreeCommands(&mIterator);
+ }
+ }
+
+ CommandIterator CommandBufferBuilder::AcquireCommands() {
+ ASSERT(!mWereCommandsAcquired);
+ mWereCommandsAcquired = true;
+ return std::move(mIterator);
+ }
+
+ CommandBufferResourceUsage CommandBufferBuilder::AcquireResourceUsages() {
+ ASSERT(!mWereResourceUsagesAcquired);
+ mWereResourceUsagesAcquired = true;
+ return std::move(mResourceUsages);
+ }
+
+ CommandBufferBase* CommandBufferBuilder::GetResultImpl() {
+ mEncodingState = EncodingState::Finished;
+
+ MoveToIterator();
+ return GetDevice()->CreateCommandBuffer(this);
+ }
+
+ void CommandBufferBuilder::MoveToIterator() {
+ if (!mWasMovedToIterator) {
+ mIterator = std::move(mAllocator);
+ mWasMovedToIterator = true;
+ }
+ }
+
+ void CommandBufferBuilder::PassEnded() {
+ if (mEncodingState == EncodingState::ComputePass) {
+ mAllocator.Allocate<EndComputePassCmd>(Command::EndComputePass);
+ } else {
+ ASSERT(mEncodingState == EncodingState::RenderPass);
+ mAllocator.Allocate<EndRenderPassCmd>(Command::EndRenderPass);
+ }
+ mEncodingState = EncodingState::TopLevel;
+ }
+
+ void CommandBufferBuilder::ConsumeError(ErrorData* error) {
+ HandleError(error->GetMessage().c_str());
+ delete error;
+ }
+
+ // Implementation of the command buffer validation that can be precomputed before submit
+
+ MaybeError CommandBufferBuilder::ValidateGetResult() {
+ MoveToIterator();
+ mIterator.Reset();
+
+ Command type;
+ while (mIterator.NextCommandId(&type)) {
+ switch (type) {
+ case Command::BeginComputePass: {
+ mIterator.NextCommand<BeginComputePassCmd>();
+ DAWN_TRY(ValidateComputePass());
+ } break;
+
+ case Command::BeginRenderPass: {
+ BeginRenderPassCmd* cmd = mIterator.NextCommand<BeginRenderPassCmd>();
+ DAWN_TRY(ValidateRenderPass(cmd->info.Get()));
+ } break;
+
+ case Command::CopyBufferToBuffer: {
+ CopyBufferToBufferCmd* copy = mIterator.NextCommand<CopyBufferToBufferCmd>();
+
+ DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->source, copy->size));
+ DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->destination, copy->size));
+
+ DAWN_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
+ dawn::BufferUsageBit::TransferSrc));
+ DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
+ dawn::BufferUsageBit::TransferDst));
+
+ mResourceUsages.topLevelBuffers.insert(copy->source.buffer.Get());
+ mResourceUsages.topLevelBuffers.insert(copy->destination.buffer.Get());
+ } break;
+
+ case Command::CopyBufferToTexture: {
+ CopyBufferToTextureCmd* copy = mIterator.NextCommand<CopyBufferToTextureCmd>();
+
+ uint32_t bufferCopySize = 0;
+ DAWN_TRY(ValidateRowPitch(copy->destination, copy->rowPitch));
+ DAWN_TRY(ComputeTextureCopyBufferSize(copy->destination, copy->rowPitch,
+ &bufferCopySize));
+
+ DAWN_TRY(ValidateCopyLocationFitsInTexture(copy->destination));
+ DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->source, bufferCopySize));
+ DAWN_TRY(
+ ValidateTexelBufferOffset(copy->destination.texture.Get(), copy->source));
+
+ DAWN_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
+ dawn::BufferUsageBit::TransferSrc));
+ DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
+ dawn::TextureUsageBit::TransferDst));
+
+ mResourceUsages.topLevelBuffers.insert(copy->source.buffer.Get());
+ mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());
+ } break;
+
+ case Command::CopyTextureToBuffer: {
+ CopyTextureToBufferCmd* copy = mIterator.NextCommand<CopyTextureToBufferCmd>();
+
+ uint32_t bufferCopySize = 0;
+ DAWN_TRY(ValidateRowPitch(copy->source, copy->rowPitch));
+ DAWN_TRY(ComputeTextureCopyBufferSize(copy->source, copy->rowPitch,
+ &bufferCopySize));
+
+ DAWN_TRY(ValidateCopyLocationFitsInTexture(copy->source));
+ DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->destination, bufferCopySize));
+ DAWN_TRY(
+ ValidateTexelBufferOffset(copy->source.texture.Get(), copy->destination));
+
+ DAWN_TRY(ValidateCanUseAs(copy->source.texture.Get(),
+ dawn::TextureUsageBit::TransferSrc));
+ DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
+ dawn::BufferUsageBit::TransferDst));
+
+ mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
+ mResourceUsages.topLevelBuffers.insert(copy->destination.buffer.Get());
+ } break;
+
+ default:
+ return DAWN_VALIDATION_ERROR("Command disallowed outside of a pass");
+ }
+ }
+
+ return {};
+ }
+
+ MaybeError CommandBufferBuilder::ValidateComputePass() {
+ PassResourceUsageTracker usageTracker;
+ CommandBufferStateTracker persistentState;
+
+ Command type;
+ while (mIterator.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndComputePass: {
+ mIterator.NextCommand<EndComputePassCmd>();
+
+ DAWN_TRY(usageTracker.ValidateUsages(PassType::Compute));
+ mResourceUsages.perPass.push_back(usageTracker.AcquireResourceUsage());
+ return {};
+ } break;
+
+ case Command::Dispatch: {
+ mIterator.NextCommand<DispatchCmd>();
+ DAWN_TRY(persistentState.ValidateCanDispatch());
+ } break;
+
+ case Command::SetComputePipeline: {
+ SetComputePipelineCmd* cmd = mIterator.NextCommand<SetComputePipelineCmd>();
+ ComputePipelineBase* pipeline = cmd->pipeline.Get();
+ persistentState.SetComputePipeline(pipeline);
+ } break;
+
+ case Command::SetPushConstants: {
+ SetPushConstantsCmd* cmd = mIterator.NextCommand<SetPushConstantsCmd>();
+ mIterator.NextData<uint32_t>(cmd->count);
+ // Validation of count and offset has already been done when the command was
+ // recorded because it impacts the size of an allocation in the
+ // CommandAllocator.
+ if (cmd->stages & ~dawn::ShaderStageBit::Compute) {
+ return DAWN_VALIDATION_ERROR(
+ "SetPushConstants stage must be compute or 0 in compute passes");
+ }
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mIterator.NextCommand<SetBindGroupCmd>();
+
+ TrackBindGroupResourceUsage(cmd->group.Get(), &usageTracker);
+ persistentState.SetBindGroup(cmd->index, cmd->group.Get());
+ } break;
+
+ default:
+ return DAWN_VALIDATION_ERROR("Command disallowed inside a compute pass");
+ }
+ }
+
+ return DAWN_VALIDATION_ERROR("Unfinished compute pass");
+ }
+
+ MaybeError CommandBufferBuilder::ValidateRenderPass(RenderPassDescriptorBase* renderPass) {
+ PassResourceUsageTracker usageTracker;
+ CommandBufferStateTracker persistentState;
+
+ // Track usage of the render pass attachments
+ for (uint32_t i : IterateBitSet(renderPass->GetColorAttachmentMask())) {
+ TextureBase* texture = renderPass->GetColorAttachment(i).view->GetTexture();
+ usageTracker.TextureUsedAs(texture, dawn::TextureUsageBit::OutputAttachment);
+ }
+
+ if (renderPass->HasDepthStencilAttachment()) {
+ TextureBase* texture = renderPass->GetDepthStencilAttachment().view->GetTexture();
+ usageTracker.TextureUsedAs(texture, dawn::TextureUsageBit::OutputAttachment);
+ }
+
+ Command type;
+ while (mIterator.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndRenderPass: {
+ mIterator.NextCommand<EndRenderPassCmd>();
+
+ DAWN_TRY(usageTracker.ValidateUsages(PassType::Render));
+ mResourceUsages.perPass.push_back(usageTracker.AcquireResourceUsage());
+ return {};
+ } break;
+
+ case Command::DrawArrays: {
+ mIterator.NextCommand<DrawArraysCmd>();
+ DAWN_TRY(persistentState.ValidateCanDrawArrays());
+ } break;
+
+ case Command::DrawElements: {
+ mIterator.NextCommand<DrawElementsCmd>();
+ DAWN_TRY(persistentState.ValidateCanDrawElements());
+ } break;
+
+ case Command::SetRenderPipeline: {
+ SetRenderPipelineCmd* cmd = mIterator.NextCommand<SetRenderPipelineCmd>();
+ RenderPipelineBase* pipeline = cmd->pipeline.Get();
+
+ if (!pipeline->IsCompatibleWith(renderPass)) {
+ return DAWN_VALIDATION_ERROR(
+ "Pipeline is incompatible with this render pass");
+ }
+
+ persistentState.SetRenderPipeline(pipeline);
+ } break;
+
+ case Command::SetPushConstants: {
+ SetPushConstantsCmd* cmd = mIterator.NextCommand<SetPushConstantsCmd>();
+ mIterator.NextData<uint32_t>(cmd->count);
+ // Validation of count and offset has already been done when the command was
+ // recorded because it impacts the size of an allocation in the
+ // CommandAllocator.
+ if (cmd->stages &
+ ~(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment)) {
+ return DAWN_VALIDATION_ERROR(
+ "SetPushConstants stage must be a subset of (vertex|fragment) in "
+ "render passes");
+ }
+ } break;
+
+ case Command::SetStencilReference: {
+ mIterator.NextCommand<SetStencilReferenceCmd>();
+ } break;
+
+ case Command::SetBlendColor: {
+ mIterator.NextCommand<SetBlendColorCmd>();
+ } break;
+
+ case Command::SetScissorRect: {
+ mIterator.NextCommand<SetScissorRectCmd>();
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mIterator.NextCommand<SetBindGroupCmd>();
+
+ TrackBindGroupResourceUsage(cmd->group.Get(), &usageTracker);
+ persistentState.SetBindGroup(cmd->index, cmd->group.Get());
+ } break;
+
+ case Command::SetIndexBuffer: {
+ SetIndexBufferCmd* cmd = mIterator.NextCommand<SetIndexBufferCmd>();
+
+ usageTracker.BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsageBit::Index);
+ persistentState.SetIndexBuffer();
+ } break;
+
+ case Command::SetVertexBuffers: {
+ SetVertexBuffersCmd* cmd = mIterator.NextCommand<SetVertexBuffersCmd>();
+ auto buffers = mIterator.NextData<Ref<BufferBase>>(cmd->count);
+ mIterator.NextData<uint32_t>(cmd->count);
+
+ for (uint32_t i = 0; i < cmd->count; ++i) {
+ usageTracker.BufferUsedAs(buffers[i].Get(), dawn::BufferUsageBit::Vertex);
+ }
+ persistentState.SetVertexBuffer(cmd->startSlot, cmd->count);
+ } break;
+
+ default:
+ return DAWN_VALIDATION_ERROR("Command disallowed inside a render pass");
+ }
+ }
+
+ return DAWN_VALIDATION_ERROR("Unfinished render pass");
+ }
+
+ MaybeError CommandBufferBuilder::ValidateCanRecordTopLevelCommands() const {
+ if (mEncodingState != EncodingState::TopLevel) {
+ return DAWN_VALIDATION_ERROR("Command cannot be recorded inside a pass");
+ }
+ return {};
+ }
+
+ // Implementation of the API's command recording methods
+
+ ComputePassEncoderBase* CommandBufferBuilder::BeginComputePass() {
+ if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
+ return nullptr;
+ }
+
+ mAllocator.Allocate<BeginComputePassCmd>(Command::BeginComputePass);
+
+ mEncodingState = EncodingState::ComputePass;
+ return new ComputePassEncoderBase(GetDevice(), this, &mAllocator);
+ }
+
+ RenderPassEncoderBase* CommandBufferBuilder::BeginRenderPass(RenderPassDescriptorBase* info) {
+ if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
+ return nullptr;
+ }
+
+ BeginRenderPassCmd* cmd = mAllocator.Allocate<BeginRenderPassCmd>(Command::BeginRenderPass);
+ new (cmd) BeginRenderPassCmd;
+ cmd->info = info;
+
+ mEncodingState = EncodingState::RenderPass;
+ return new RenderPassEncoderBase(GetDevice(), this, &mAllocator);
+ }
+
+ void CommandBufferBuilder::CopyBufferToBuffer(BufferBase* source,
+ uint32_t sourceOffset,
+ BufferBase* destination,
+ uint32_t destinationOffset,
+ uint32_t size) {
+ if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
+ return;
+ }
+
+ CopyBufferToBufferCmd* copy =
+ mAllocator.Allocate<CopyBufferToBufferCmd>(Command::CopyBufferToBuffer);
+ new (copy) CopyBufferToBufferCmd;
+ copy->source.buffer = source;
+ copy->source.offset = sourceOffset;
+ copy->destination.buffer = destination;
+ copy->destination.offset = destinationOffset;
+ copy->size = size;
+ }
+
+ void CommandBufferBuilder::CopyBufferToTexture(const BufferCopyView* source,
+ const TextureCopyView* destination,
+ const Extent3D* copySize) {
+ if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
+ return;
+ }
+ CopyBufferToTextureCmd* copy =
+ mAllocator.Allocate<CopyBufferToTextureCmd>(Command::CopyBufferToTexture);
+ new (copy) CopyBufferToTextureCmd;
+ copy->source.buffer = source->buffer;
+ copy->source.offset = source->offset;
+ copy->destination.texture = destination->texture;
+ copy->destination.x = destination->origin.x;
+ copy->destination.y = destination->origin.y;
+ copy->destination.z = destination->origin.z;
+ copy->destination.width = copySize->width;
+ copy->destination.height = copySize->height;
+ copy->destination.depth = copySize->depth;
+ copy->destination.level = destination->level;
+ copy->destination.slice = destination->slice;
+ if (source->rowPitch == 0) {
+ copy->rowPitch = ComputeDefaultRowPitch(destination->texture, copySize->width);
+ } else {
+ copy->rowPitch = source->rowPitch;
+ }
+ }
+
+ void CommandBufferBuilder::CopyTextureToBuffer(const TextureCopyView* source,
+ const BufferCopyView* destination,
+ const Extent3D* copySize) {
+ if (ConsumedError(ValidateCanRecordTopLevelCommands())) {
+ return;
+ }
+ CopyTextureToBufferCmd* copy =
+ mAllocator.Allocate<CopyTextureToBufferCmd>(Command::CopyTextureToBuffer);
+ new (copy) CopyTextureToBufferCmd;
+ copy->source.texture = source->texture;
+ copy->source.x = source->origin.x;
+ copy->source.y = source->origin.y;
+ copy->source.z = source->origin.z;
+ copy->source.width = copySize->width;
+ copy->source.height = copySize->height;
+ copy->source.depth = copySize->depth;
+ copy->source.level = source->level;
+ copy->source.slice = source->slice;
+ copy->destination.buffer = destination->buffer;
+ copy->destination.offset = destination->offset;
+ if (destination->rowPitch == 0) {
+ copy->rowPitch = ComputeDefaultRowPitch(source->texture, copySize->width);
+ } else {
+ copy->rowPitch = destination->rowPitch;
+ }
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/CommandBuffer.h b/chromium/third_party/dawn/src/dawn_native/CommandBuffer.h
new file mode 100644
index 00000000000..27f126a7466
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/CommandBuffer.h
@@ -0,0 +1,115 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_COMMANDBUFFER_H_
+#define DAWNNATIVE_COMMANDBUFFER_H_
+
+#include "dawn_native/dawn_platform.h"
+
+#include "dawn_native/Builder.h"
+#include "dawn_native/CommandAllocator.h"
+#include "dawn_native/Error.h"
+#include "dawn_native/ObjectBase.h"
+#include "dawn_native/PassResourceUsage.h"
+
+#include <memory>
+#include <set>
+#include <utility>
+
+namespace dawn_native {
+
+ class BindGroupBase;
+ class BufferBase;
+ class FramebufferBase;
+ class DeviceBase;
+ class PipelineBase;
+ class RenderPassBase;
+ class TextureBase;
+
+ class CommandBufferBuilder;
+
+ class CommandBufferBase : public ObjectBase {
+ public:
+ CommandBufferBase(CommandBufferBuilder* builder);
+
+ const CommandBufferResourceUsage& GetResourceUsages() const;
+
+ private:
+ CommandBufferResourceUsage mResourceUsages;
+ };
+
+ class CommandBufferBuilder : public Builder<CommandBufferBase> {
+ public:
+ CommandBufferBuilder(DeviceBase* device);
+ ~CommandBufferBuilder();
+
+ MaybeError ValidateGetResult();
+
+ CommandIterator AcquireCommands();
+ CommandBufferResourceUsage AcquireResourceUsages();
+
+ // Dawn API
+ ComputePassEncoderBase* BeginComputePass();
+ RenderPassEncoderBase* BeginRenderPass(RenderPassDescriptorBase* info);
+ void CopyBufferToBuffer(BufferBase* source,
+ uint32_t sourceOffset,
+ BufferBase* destination,
+ uint32_t destinationOffset,
+ uint32_t size);
+ void CopyBufferToTexture(const BufferCopyView* source,
+ const TextureCopyView* destination,
+ const Extent3D* copySize);
+ void CopyTextureToBuffer(const TextureCopyView* source,
+ const BufferCopyView* destination,
+ const Extent3D* copySize);
+
+ // Functions to interact with the encoders
+ bool ConsumedError(MaybeError maybeError) {
+ if (DAWN_UNLIKELY(maybeError.IsError())) {
+ ConsumeError(maybeError.AcquireError());
+ return true;
+ }
+ return false;
+ }
+
+ void PassEnded();
+
+ private:
+ friend class CommandBufferBase;
+
+ enum class EncodingState : uint8_t;
+ EncodingState mEncodingState;
+
+ CommandBufferBase* GetResultImpl() override;
+ void MoveToIterator();
+
+ MaybeError ValidateComputePass();
+ MaybeError ValidateRenderPass(RenderPassDescriptorBase* renderPass);
+
+ MaybeError ValidateCanRecordTopLevelCommands() const;
+
+ void ConsumeError(ErrorData* error);
+
+ CommandAllocator mAllocator;
+ CommandIterator mIterator;
+ bool mWasMovedToIterator = false;
+ bool mWereCommandsAcquired = false;
+
+ bool mWereResourceUsagesAcquired = false;
+ CommandBufferResourceUsage mResourceUsages;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_COMMANDBUFFER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/CommandBufferStateTracker.cpp b/chromium/third_party/dawn/src/dawn_native/CommandBufferStateTracker.cpp
new file mode 100644
index 00000000000..44799ac1091
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/CommandBufferStateTracker.cpp
@@ -0,0 +1,170 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/CommandBufferStateTracker.h"
+
+#include "common/Assert.h"
+#include "common/BitSetIterator.h"
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/ComputePipeline.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/InputState.h"
+#include "dawn_native/PipelineLayout.h"
+#include "dawn_native/RenderPipeline.h"
+
+namespace dawn_native {
+
+ enum ValidationAspect {
+ VALIDATION_ASPECT_PIPELINE,
+ VALIDATION_ASPECT_BIND_GROUPS,
+ VALIDATION_ASPECT_VERTEX_BUFFERS,
+ VALIDATION_ASPECT_INDEX_BUFFER,
+
+ VALIDATION_ASPECT_COUNT
+ };
+ static_assert(VALIDATION_ASPECT_COUNT == CommandBufferStateTracker::kNumAspects, "");
+
+ static constexpr CommandBufferStateTracker::ValidationAspects kDispatchAspects =
+ 1 << VALIDATION_ASPECT_PIPELINE | 1 << VALIDATION_ASPECT_BIND_GROUPS;
+
+ static constexpr CommandBufferStateTracker::ValidationAspects kDrawArraysAspects =
+ 1 << VALIDATION_ASPECT_PIPELINE | 1 << VALIDATION_ASPECT_BIND_GROUPS |
+ 1 << VALIDATION_ASPECT_VERTEX_BUFFERS;
+
+ static constexpr CommandBufferStateTracker::ValidationAspects kDrawElementsAspects =
+ 1 << VALIDATION_ASPECT_PIPELINE | 1 << VALIDATION_ASPECT_BIND_GROUPS |
+ 1 << VALIDATION_ASPECT_VERTEX_BUFFERS | 1 << VALIDATION_ASPECT_INDEX_BUFFER;
+
+ static constexpr CommandBufferStateTracker::ValidationAspects kLazyAspects =
+ 1 << VALIDATION_ASPECT_BIND_GROUPS | 1 << VALIDATION_ASPECT_VERTEX_BUFFERS;
+
+ MaybeError CommandBufferStateTracker::ValidateCanDispatch() {
+ return ValidateOperation(kDispatchAspects);
+ }
+
+ MaybeError CommandBufferStateTracker::ValidateCanDrawArrays() {
+ return ValidateOperation(kDrawArraysAspects);
+ }
+
+ MaybeError CommandBufferStateTracker::ValidateCanDrawElements() {
+ return ValidateOperation(kDrawElementsAspects);
+ }
+
+ MaybeError CommandBufferStateTracker::ValidateOperation(ValidationAspects requiredAspects) {
+ // Fast return-true path if everything is good
+ ValidationAspects missingAspects = requiredAspects & ~mAspects;
+ if (missingAspects.none()) {
+ return {};
+ }
+
+ // Generate an error immediately if a non-lazy aspect is missing as computing lazy aspects
+ // requires the pipeline to be set.
+ if ((missingAspects & ~kLazyAspects).any()) {
+ return GenerateAspectError(missingAspects);
+ }
+
+ RecomputeLazyAspects(missingAspects);
+
+ missingAspects = requiredAspects & ~mAspects;
+ if (missingAspects.any()) {
+ return GenerateAspectError(missingAspects);
+ }
+
+ return {};
+ }
+
+ void CommandBufferStateTracker::RecomputeLazyAspects(ValidationAspects aspects) {
+ ASSERT(mAspects[VALIDATION_ASPECT_PIPELINE]);
+ ASSERT((aspects & ~kLazyAspects).none());
+
+ if (aspects[VALIDATION_ASPECT_BIND_GROUPS]) {
+ bool matches = true;
+
+ for (uint32_t i : IterateBitSet(mLastPipelineLayout->GetBindGroupLayoutsMask())) {
+ if (mLastPipelineLayout->GetBindGroupLayout(i) != mBindgroups[i]->GetLayout()) {
+ matches = false;
+ break;
+ }
+ }
+
+ if (matches) {
+ mAspects.set(VALIDATION_ASPECT_BIND_GROUPS);
+ }
+ }
+
+ if (aspects[VALIDATION_ASPECT_VERTEX_BUFFERS]) {
+ ASSERT(mLastRenderPipeline != nullptr);
+
+ auto requiredInputs = mLastRenderPipeline->GetInputState()->GetInputsSetMask();
+ if ((mInputsSet & requiredInputs) == requiredInputs) {
+ mAspects.set(VALIDATION_ASPECT_VERTEX_BUFFERS);
+ }
+ }
+ }
+
+ MaybeError CommandBufferStateTracker::GenerateAspectError(ValidationAspects aspects) {
+ ASSERT(aspects.any());
+
+ if (aspects[VALIDATION_ASPECT_INDEX_BUFFER]) {
+ return DAWN_VALIDATION_ERROR("Missing index buffer");
+ }
+
+ if (aspects[VALIDATION_ASPECT_VERTEX_BUFFERS]) {
+ return DAWN_VALIDATION_ERROR("Missing vertex buffer");
+ }
+
+ if (aspects[VALIDATION_ASPECT_BIND_GROUPS]) {
+ return DAWN_VALIDATION_ERROR("Missing bind group");
+ }
+
+ if (aspects[VALIDATION_ASPECT_PIPELINE]) {
+ return DAWN_VALIDATION_ERROR("Missing pipeline");
+ }
+
+ UNREACHABLE();
+ }
+
+ void CommandBufferStateTracker::SetComputePipeline(ComputePipelineBase* pipeline) {
+ SetPipelineCommon(pipeline);
+ }
+
+ void CommandBufferStateTracker::SetRenderPipeline(RenderPipelineBase* pipeline) {
+ mLastRenderPipeline = pipeline;
+ SetPipelineCommon(pipeline);
+ }
+
+ void CommandBufferStateTracker::SetBindGroup(uint32_t index, BindGroupBase* bindgroup) {
+ mBindgroups[index] = bindgroup;
+ }
+
+ void CommandBufferStateTracker::SetIndexBuffer() {
+ mAspects.set(VALIDATION_ASPECT_INDEX_BUFFER);
+ }
+
+ void CommandBufferStateTracker::SetVertexBuffer(uint32_t start, uint32_t count) {
+ for (uint32_t i = 0; i < count; ++i) {
+ mInputsSet.set(start + i);
+ }
+ }
+
+ void CommandBufferStateTracker::SetPipelineCommon(PipelineBase* pipeline) {
+ mLastPipelineLayout = pipeline->GetLayout();
+
+ mAspects.set(VALIDATION_ASPECT_PIPELINE);
+
+ // Reset lazy aspects so they get recomputed on the next operation.
+ mAspects &= ~kLazyAspects;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/CommandBufferStateTracker.h b/chromium/third_party/dawn/src/dawn_native/CommandBufferStateTracker.h
new file mode 100644
index 00000000000..9dd1edbac6d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/CommandBufferStateTracker.h
@@ -0,0 +1,63 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_COMMANDBUFFERSTATETRACKER_H
+#define DAWNNATIVE_COMMANDBUFFERSTATETRACKER_H
+
+#include "common/Constants.h"
+#include "dawn_native/CommandBuffer.h"
+
+#include <array>
+#include <bitset>
+#include <map>
+#include <set>
+
+namespace dawn_native {
+
+ class CommandBufferStateTracker {
+ public:
+ // Non-state-modifying validation functions
+ MaybeError ValidateCanDispatch();
+ MaybeError ValidateCanDrawArrays();
+ MaybeError ValidateCanDrawElements();
+
+ // State-modifying methods
+ void SetComputePipeline(ComputePipelineBase* pipeline);
+ void SetRenderPipeline(RenderPipelineBase* pipeline);
+ void SetBindGroup(uint32_t index, BindGroupBase* bindgroup);
+ void SetIndexBuffer();
+ void SetVertexBuffer(uint32_t start, uint32_t count);
+
+ static constexpr size_t kNumAspects = 4;
+ using ValidationAspects = std::bitset<kNumAspects>;
+
+ private:
+ MaybeError ValidateOperation(ValidationAspects requiredAspects);
+ void RecomputeLazyAspects(ValidationAspects aspects);
+ MaybeError GenerateAspectError(ValidationAspects aspects);
+
+ void SetPipelineCommon(PipelineBase* pipeline);
+
+ ValidationAspects mAspects;
+
+ std::array<BindGroupBase*, kMaxBindGroups> mBindgroups = {};
+ std::bitset<kMaxVertexInputs> mInputsSet;
+
+ PipelineLayoutBase* mLastPipelineLayout = nullptr;
+ RenderPipelineBase* mLastRenderPipeline = nullptr;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_COMMANDBUFFERSTATETRACKER_H
diff --git a/chromium/third_party/dawn/src/dawn_native/Commands.cpp b/chromium/third_party/dawn/src/dawn_native/Commands.cpp
new file mode 100644
index 00000000000..455675a5b6e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Commands.cpp
@@ -0,0 +1,202 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Commands.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/Buffer.h"
+#include "dawn_native/CommandAllocator.h"
+#include "dawn_native/ComputePipeline.h"
+#include "dawn_native/RenderPipeline.h"
+#include "dawn_native/Texture.h"
+
+namespace dawn_native {
+
+ void FreeCommands(CommandIterator* commands) {
+ commands->Reset();
+
+ Command type;
+ while (commands->NextCommandId(&type)) {
+ switch (type) {
+ case Command::BeginComputePass: {
+ BeginComputePassCmd* begin = commands->NextCommand<BeginComputePassCmd>();
+ begin->~BeginComputePassCmd();
+ } break;
+ case Command::BeginRenderPass: {
+ BeginRenderPassCmd* begin = commands->NextCommand<BeginRenderPassCmd>();
+ begin->~BeginRenderPassCmd();
+ } break;
+ case Command::CopyBufferToBuffer: {
+ CopyBufferToBufferCmd* copy = commands->NextCommand<CopyBufferToBufferCmd>();
+ copy->~CopyBufferToBufferCmd();
+ } break;
+ case Command::CopyBufferToTexture: {
+ CopyBufferToTextureCmd* copy = commands->NextCommand<CopyBufferToTextureCmd>();
+ copy->~CopyBufferToTextureCmd();
+ } break;
+ case Command::CopyTextureToBuffer: {
+ CopyTextureToBufferCmd* copy = commands->NextCommand<CopyTextureToBufferCmd>();
+ copy->~CopyTextureToBufferCmd();
+ } break;
+ case Command::Dispatch: {
+ DispatchCmd* dispatch = commands->NextCommand<DispatchCmd>();
+ dispatch->~DispatchCmd();
+ } break;
+ case Command::DrawArrays: {
+ DrawArraysCmd* draw = commands->NextCommand<DrawArraysCmd>();
+ draw->~DrawArraysCmd();
+ } break;
+ case Command::DrawElements: {
+ DrawElementsCmd* draw = commands->NextCommand<DrawElementsCmd>();
+ draw->~DrawElementsCmd();
+ } break;
+ case Command::EndComputePass: {
+ EndComputePassCmd* cmd = commands->NextCommand<EndComputePassCmd>();
+ cmd->~EndComputePassCmd();
+ } break;
+ case Command::EndRenderPass: {
+ EndRenderPassCmd* cmd = commands->NextCommand<EndRenderPassCmd>();
+ cmd->~EndRenderPassCmd();
+ } break;
+ case Command::SetComputePipeline: {
+ SetComputePipelineCmd* cmd = commands->NextCommand<SetComputePipelineCmd>();
+ cmd->~SetComputePipelineCmd();
+ } break;
+ case Command::SetRenderPipeline: {
+ SetRenderPipelineCmd* cmd = commands->NextCommand<SetRenderPipelineCmd>();
+ cmd->~SetRenderPipelineCmd();
+ } break;
+ case Command::SetPushConstants: {
+ SetPushConstantsCmd* cmd = commands->NextCommand<SetPushConstantsCmd>();
+ commands->NextData<uint32_t>(cmd->count);
+ cmd->~SetPushConstantsCmd();
+ } break;
+ case Command::SetStencilReference: {
+ SetStencilReferenceCmd* cmd = commands->NextCommand<SetStencilReferenceCmd>();
+ cmd->~SetStencilReferenceCmd();
+ } break;
+ case Command::SetScissorRect: {
+ SetScissorRectCmd* cmd = commands->NextCommand<SetScissorRectCmd>();
+ cmd->~SetScissorRectCmd();
+ } break;
+ case Command::SetBlendColor: {
+ SetBlendColorCmd* cmd = commands->NextCommand<SetBlendColorCmd>();
+ cmd->~SetBlendColorCmd();
+ } break;
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>();
+ cmd->~SetBindGroupCmd();
+ } break;
+ case Command::SetIndexBuffer: {
+ SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>();
+ cmd->~SetIndexBufferCmd();
+ } break;
+ case Command::SetVertexBuffers: {
+ SetVertexBuffersCmd* cmd = commands->NextCommand<SetVertexBuffersCmd>();
+ auto buffers = commands->NextData<Ref<BufferBase>>(cmd->count);
+ for (size_t i = 0; i < cmd->count; ++i) {
+ (&buffers[i])->~Ref<BufferBase>();
+ }
+ commands->NextData<uint32_t>(cmd->count);
+ cmd->~SetVertexBuffersCmd();
+ } break;
+ }
+ }
+ commands->DataWasDestroyed();
+ }
+
+ void SkipCommand(CommandIterator* commands, Command type) {
+ switch (type) {
+ case Command::BeginComputePass:
+ commands->NextCommand<BeginComputePassCmd>();
+ break;
+
+ case Command::BeginRenderPass:
+ commands->NextCommand<BeginRenderPassCmd>();
+ break;
+
+ case Command::CopyBufferToBuffer:
+ commands->NextCommand<CopyBufferToBufferCmd>();
+ break;
+
+ case Command::CopyBufferToTexture:
+ commands->NextCommand<CopyBufferToTextureCmd>();
+ break;
+
+ case Command::CopyTextureToBuffer:
+ commands->NextCommand<CopyTextureToBufferCmd>();
+ break;
+
+ case Command::Dispatch:
+ commands->NextCommand<DispatchCmd>();
+ break;
+
+ case Command::DrawArrays:
+ commands->NextCommand<DrawArraysCmd>();
+ break;
+
+ case Command::DrawElements:
+ commands->NextCommand<DrawElementsCmd>();
+ break;
+
+ case Command::EndComputePass:
+ commands->NextCommand<EndComputePassCmd>();
+ break;
+
+ case Command::EndRenderPass:
+ commands->NextCommand<EndRenderPassCmd>();
+ break;
+
+ case Command::SetComputePipeline:
+ commands->NextCommand<SetComputePipelineCmd>();
+ break;
+
+ case Command::SetRenderPipeline:
+ commands->NextCommand<SetRenderPipelineCmd>();
+ break;
+
+ case Command::SetPushConstants: {
+ auto* cmd = commands->NextCommand<SetPushConstantsCmd>();
+ commands->NextData<uint32_t>(cmd->count);
+ } break;
+
+ case Command::SetStencilReference:
+ commands->NextCommand<SetStencilReferenceCmd>();
+ break;
+
+ case Command::SetScissorRect:
+ commands->NextCommand<SetScissorRectCmd>();
+ break;
+
+ case Command::SetBlendColor:
+ commands->NextCommand<SetBlendColorCmd>();
+ break;
+
+ case Command::SetBindGroup:
+ commands->NextCommand<SetBindGroupCmd>();
+ break;
+
+ case Command::SetIndexBuffer:
+ commands->NextCommand<SetIndexBufferCmd>();
+ break;
+
+ case Command::SetVertexBuffers: {
+ auto* cmd = commands->NextCommand<SetVertexBuffersCmd>();
+ commands->NextData<Ref<BufferBase>>(cmd->count);
+ commands->NextData<uint32_t>(cmd->count);
+ } break;
+ }
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Commands.h b/chromium/third_party/dawn/src/dawn_native/Commands.h
new file mode 100644
index 00000000000..e4598ad6a89
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Commands.h
@@ -0,0 +1,164 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_COMMANDS_H_
+#define DAWNNATIVE_COMMANDS_H_
+
+#include "dawn_native/RenderPassDescriptor.h"
+#include "dawn_native/Texture.h"
+
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+
+ // Definition of the commands that are present in the CommandIterator given by the
+ // CommandBufferBuilder. There are not defined in CommandBuffer.h to break some header
+ // dependencies: Ref<Object> needs Object to be defined.
+
+ enum class Command {
+ BeginComputePass,
+ BeginRenderPass,
+ CopyBufferToBuffer,
+ CopyBufferToTexture,
+ CopyTextureToBuffer,
+ Dispatch,
+ DrawArrays,
+ DrawElements,
+ EndComputePass,
+ EndRenderPass,
+ SetComputePipeline,
+ SetRenderPipeline,
+ SetPushConstants,
+ SetStencilReference,
+ SetScissorRect,
+ SetBlendColor,
+ SetBindGroup,
+ SetIndexBuffer,
+ SetVertexBuffers,
+ };
+
+ struct BeginComputePassCmd {};
+
+ struct BeginRenderPassCmd {
+ Ref<RenderPassDescriptorBase> info;
+ };
+
+ struct BufferCopyLocation {
+ Ref<BufferBase> buffer;
+ uint32_t offset;
+ };
+
+ struct TextureCopyLocation {
+ Ref<TextureBase> texture;
+ uint32_t x, y, z;
+ uint32_t width, height, depth;
+ uint32_t level;
+ uint32_t slice;
+ };
+
+ struct CopyBufferToBufferCmd {
+ BufferCopyLocation source;
+ BufferCopyLocation destination;
+ uint32_t size;
+ };
+
+ struct CopyBufferToTextureCmd {
+ BufferCopyLocation source;
+ TextureCopyLocation destination;
+ uint32_t rowPitch;
+ };
+
+ struct CopyTextureToBufferCmd {
+ TextureCopyLocation source;
+ BufferCopyLocation destination;
+ uint32_t rowPitch;
+ };
+
+ struct DispatchCmd {
+ uint32_t x;
+ uint32_t y;
+ uint32_t z;
+ };
+
+ struct DrawArraysCmd {
+ uint32_t vertexCount;
+ uint32_t instanceCount;
+ uint32_t firstVertex;
+ uint32_t firstInstance;
+ };
+
+ struct DrawElementsCmd {
+ uint32_t indexCount;
+ uint32_t instanceCount;
+ uint32_t firstIndex;
+ uint32_t firstInstance;
+ };
+
+ struct EndComputePassCmd {};
+
+ struct EndRenderPassCmd {};
+
+ struct SetComputePipelineCmd {
+ Ref<ComputePipelineBase> pipeline;
+ };
+
+ struct SetRenderPipelineCmd {
+ Ref<RenderPipelineBase> pipeline;
+ };
+
+ struct SetPushConstantsCmd {
+ dawn::ShaderStageBit stages;
+ uint32_t offset;
+ uint32_t count;
+ };
+
+ struct SetStencilReferenceCmd {
+ uint32_t reference;
+ };
+
+ struct SetScissorRectCmd {
+ uint32_t x, y, width, height;
+ };
+
+ struct SetBlendColorCmd {
+ float r, g, b, a;
+ };
+
+ struct SetBindGroupCmd {
+ uint32_t index;
+ Ref<BindGroupBase> group;
+ };
+
+ struct SetIndexBufferCmd {
+ Ref<BufferBase> buffer;
+ uint32_t offset;
+ };
+
+ struct SetVertexBuffersCmd {
+ uint32_t startSlot;
+ uint32_t count;
+ };
+
+ // This needs to be called before the CommandIterator is freed so that the Ref<> present in
+ // the commands have a chance to run their destructor and remove internal references.
+ class CommandIterator;
+ void FreeCommands(CommandIterator* commands);
+
+ // Helper function to allow skipping over a command when it is unimplemented, while still
+ // consuming the correct amount of data from the command iterator.
+ void SkipCommand(CommandIterator* commands, Command type);
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_COMMANDS_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/ComputePassEncoder.cpp b/chromium/third_party/dawn/src/dawn_native/ComputePassEncoder.cpp
new file mode 100644
index 00000000000..77774db3d5d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ComputePassEncoder.cpp
@@ -0,0 +1,52 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/ComputePassEncoder.h"
+
+#include "dawn_native/CommandBuffer.h"
+#include "dawn_native/Commands.h"
+#include "dawn_native/ComputePipeline.h"
+
+namespace dawn_native {
+
+ ComputePassEncoderBase::ComputePassEncoderBase(DeviceBase* device,
+ CommandBufferBuilder* topLevelBuilder,
+ CommandAllocator* allocator)
+ : ProgrammablePassEncoder(device, topLevelBuilder, allocator) {
+ }
+
+ void ComputePassEncoderBase::Dispatch(uint32_t x, uint32_t y, uint32_t z) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ DispatchCmd* dispatch = mAllocator->Allocate<DispatchCmd>(Command::Dispatch);
+ new (dispatch) DispatchCmd;
+ dispatch->x = x;
+ dispatch->y = y;
+ dispatch->z = z;
+ }
+
+ void ComputePassEncoderBase::SetComputePipeline(ComputePipelineBase* pipeline) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ SetComputePipelineCmd* cmd =
+ mAllocator->Allocate<SetComputePipelineCmd>(Command::SetComputePipeline);
+ new (cmd) SetComputePipelineCmd;
+ cmd->pipeline = pipeline;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/ComputePassEncoder.h b/chromium/third_party/dawn/src/dawn_native/ComputePassEncoder.h
new file mode 100644
index 00000000000..79c8f63c044
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ComputePassEncoder.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_COMPUTEPASSENCODER_H_
+#define DAWNNATIVE_COMPUTEPASSENCODER_H_
+
+#include "dawn_native/Error.h"
+#include "dawn_native/ProgrammablePassEncoder.h"
+
+namespace dawn_native {
+
+ // This is called ComputePassEncoderBase to match the code generator expectations. Note that it
+ // is a pure frontend type to record in its parent CommandBufferBuilder and never has a backend
+ // implementation.
+ // TODO(cwallez@chromium.org): Remove that generator limitation and rename to ComputePassEncoder
+ class ComputePassEncoderBase : public ProgrammablePassEncoder {
+ public:
+ ComputePassEncoderBase(DeviceBase* device,
+ CommandBufferBuilder* topLevelBuilder,
+ CommandAllocator* allocator);
+
+ void Dispatch(uint32_t x, uint32_t y, uint32_t z);
+ void SetComputePipeline(ComputePipelineBase* pipeline);
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_COMPUTEPASSENCODER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/ComputePipeline.cpp b/chromium/third_party/dawn/src/dawn_native/ComputePipeline.cpp
new file mode 100644
index 00000000000..6e961f19f0d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ComputePipeline.cpp
@@ -0,0 +1,50 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/ComputePipeline.h"
+
+#include "dawn_native/Device.h"
+
+namespace dawn_native {
+
+ MaybeError ValidateComputePipelineDescriptor(DeviceBase*,
+ const ComputePipelineDescriptor* descriptor) {
+ if (descriptor->nextInChain != nullptr) {
+ return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
+ }
+
+ if (descriptor->entryPoint != std::string("main")) {
+ return DAWN_VALIDATION_ERROR("Currently the entry point has to be main()");
+ }
+
+ if (descriptor->module->GetExecutionModel() != dawn::ShaderStage::Compute) {
+ return DAWN_VALIDATION_ERROR("Setting module with wrong execution model");
+ }
+
+ if (!descriptor->module->IsCompatibleWithPipelineLayout(descriptor->layout)) {
+ return DAWN_VALIDATION_ERROR("Stage not compatible with layout");
+ }
+
+ return {};
+ }
+
+ // ComputePipelineBase
+
+ ComputePipelineBase::ComputePipelineBase(DeviceBase* device,
+ const ComputePipelineDescriptor* descriptor)
+ : PipelineBase(device, descriptor->layout, dawn::ShaderStageBit::Compute) {
+ ExtractModuleData(dawn::ShaderStage::Compute, descriptor->module);
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/ComputePipeline.h b/chromium/third_party/dawn/src/dawn_native/ComputePipeline.h
new file mode 100644
index 00000000000..1cea676af88
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ComputePipeline.h
@@ -0,0 +1,34 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_COMPUTEPIPELINE_H_
+#define DAWNNATIVE_COMPUTEPIPELINE_H_
+
+#include "dawn_native/Pipeline.h"
+
+namespace dawn_native {
+
+ class DeviceBase;
+
+ MaybeError ValidateComputePipelineDescriptor(DeviceBase* device,
+ const ComputePipelineDescriptor* descriptor);
+
+ class ComputePipelineBase : public PipelineBase {
+ public:
+ ComputePipelineBase(DeviceBase* device, const ComputePipelineDescriptor* descriptor);
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_COMPUTEPIPELINE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/DawnNative.cpp b/chromium/third_party/dawn/src/dawn_native/DawnNative.cpp
new file mode 100644
index 00000000000..f1dd1aa423a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/DawnNative.cpp
@@ -0,0 +1,33 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/DawnNative.h"
+#include "dawn_native/Device.h"
+
+// Contains the entry-points into dawn_native
+
+namespace dawn_native {
+
+ dawnProcTable GetProcsAutogen();
+
+ dawnProcTable GetProcs() {
+ return GetProcsAutogen();
+ }
+
+ const PCIInfo& GetPCIInfo(dawnDevice device) {
+ DeviceBase* deviceBase = reinterpret_cast<DeviceBase*>(device);
+ return deviceBase->GetPCIInfo();
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/DepthStencilState.cpp b/chromium/third_party/dawn/src/dawn_native/DepthStencilState.cpp
new file mode 100644
index 00000000000..9405cfab955
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/DepthStencilState.cpp
@@ -0,0 +1,137 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/DepthStencilState.h"
+
+#include "dawn_native/Device.h"
+
+namespace dawn_native {
+
+ // DepthStencilStateBase
+
+ DepthStencilStateBase::DepthStencilStateBase(DepthStencilStateBuilder* builder)
+ : ObjectBase(builder->GetDevice()),
+ mDepthInfo(builder->mDepthInfo),
+ mStencilInfo(builder->mStencilInfo) {
+ }
+
+ bool DepthStencilStateBase::StencilTestEnabled() const {
+ return mStencilInfo.back.compareFunction != dawn::CompareFunction::Always ||
+ mStencilInfo.back.stencilFail != dawn::StencilOperation::Keep ||
+ mStencilInfo.back.depthFail != dawn::StencilOperation::Keep ||
+ mStencilInfo.back.depthStencilPass != dawn::StencilOperation::Keep ||
+ mStencilInfo.front.compareFunction != dawn::CompareFunction::Always ||
+ mStencilInfo.front.stencilFail != dawn::StencilOperation::Keep ||
+ mStencilInfo.front.depthFail != dawn::StencilOperation::Keep ||
+ mStencilInfo.front.depthStencilPass != dawn::StencilOperation::Keep;
+ }
+
+ const DepthStencilStateBase::DepthInfo& DepthStencilStateBase::GetDepth() const {
+ return mDepthInfo;
+ }
+
+ const DepthStencilStateBase::StencilInfo& DepthStencilStateBase::GetStencil() const {
+ return mStencilInfo;
+ }
+
+ // DepthStencilStateBuilder
+
+ enum DepthStencilStateSetProperties {
+ DEPTH_STENCIL_STATE_PROPERTY_DEPTH_COMPARE_FUNCTION = 0x1,
+ DEPTH_STENCIL_STATE_PROPERTY_DEPTH_WRITE_ENABLED = 0x2,
+ DEPTH_STENCIL_STATE_PROPERTY_STENCIL_BACK_FUNCTION = 0x4,
+ DEPTH_STENCIL_STATE_PROPERTY_STENCIL_FRONT_FUNCTION = 0x08,
+ DEPTH_STENCIL_STATE_PROPERTY_STENCIL_MASK = 0x10,
+ };
+
+ DepthStencilStateBuilder::DepthStencilStateBuilder(DeviceBase* device) : Builder(device) {
+ }
+
+ DepthStencilStateBase* DepthStencilStateBuilder::GetResultImpl() {
+ return GetDevice()->CreateDepthStencilState(this);
+ }
+
+ void DepthStencilStateBuilder::SetDepthCompareFunction(
+ dawn::CompareFunction depthCompareFunction) {
+ if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_DEPTH_COMPARE_FUNCTION) != 0) {
+ HandleError("Depth compare property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_DEPTH_COMPARE_FUNCTION;
+
+ mDepthInfo.compareFunction = depthCompareFunction;
+ }
+
+ void DepthStencilStateBuilder::SetDepthWriteEnabled(bool enabled) {
+ if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_DEPTH_WRITE_ENABLED) != 0) {
+ HandleError("Depth write enabled property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_DEPTH_WRITE_ENABLED;
+
+ mDepthInfo.depthWriteEnabled = enabled;
+ }
+
+ void DepthStencilStateBuilder::SetStencilFunction(dawn::Face face,
+ dawn::CompareFunction stencilCompareFunction,
+ dawn::StencilOperation stencilFail,
+ dawn::StencilOperation depthFail,
+ dawn::StencilOperation depthStencilPass) {
+ if (face == dawn::Face::None) {
+ HandleError("Can't set stencil function of None face");
+ return;
+ }
+
+ if (face & dawn::Face::Back) {
+ if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_STENCIL_BACK_FUNCTION) != 0) {
+ HandleError("Stencil back function property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_STENCIL_BACK_FUNCTION;
+
+ mStencilInfo.back.compareFunction = stencilCompareFunction;
+ mStencilInfo.back.stencilFail = stencilFail;
+ mStencilInfo.back.depthFail = depthFail;
+ mStencilInfo.back.depthStencilPass = depthStencilPass;
+ }
+ if (face & dawn::Face::Front) {
+ if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_STENCIL_FRONT_FUNCTION) != 0) {
+ HandleError("Stencil front function property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_STENCIL_FRONT_FUNCTION;
+
+ mStencilInfo.front.compareFunction = stencilCompareFunction;
+ mStencilInfo.front.stencilFail = stencilFail;
+ mStencilInfo.front.depthFail = depthFail;
+ mStencilInfo.front.depthStencilPass = depthStencilPass;
+ }
+ }
+
+ void DepthStencilStateBuilder::SetStencilMask(uint32_t readMask, uint32_t writeMask) {
+ if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_STENCIL_MASK) != 0) {
+ HandleError("Stencilmask property set multiple times");
+ return;
+ }
+
+ mPropertiesSet |= DEPTH_STENCIL_STATE_PROPERTY_STENCIL_MASK;
+ mStencilInfo.readMask = readMask;
+ mStencilInfo.writeMask = writeMask;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/DepthStencilState.h b/chromium/third_party/dawn/src/dawn_native/DepthStencilState.h
new file mode 100644
index 00000000000..87a8952b79e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/DepthStencilState.h
@@ -0,0 +1,85 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_DEPTHSTENCILSTATE_H_
+#define DAWNNATIVE_DEPTHSTENCILSTATE_H_
+
+#include "dawn_native/Builder.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+
+ class DepthStencilStateBase : public ObjectBase {
+ public:
+ DepthStencilStateBase(DepthStencilStateBuilder* builder);
+
+ struct DepthInfo {
+ dawn::CompareFunction compareFunction = dawn::CompareFunction::Always;
+ bool depthWriteEnabled = false;
+ };
+
+ struct StencilFaceInfo {
+ dawn::CompareFunction compareFunction = dawn::CompareFunction::Always;
+ dawn::StencilOperation stencilFail = dawn::StencilOperation::Keep;
+ dawn::StencilOperation depthFail = dawn::StencilOperation::Keep;
+ dawn::StencilOperation depthStencilPass = dawn::StencilOperation::Keep;
+ };
+
+ struct StencilInfo {
+ StencilFaceInfo back;
+ StencilFaceInfo front;
+ uint32_t readMask = 0xff;
+ uint32_t writeMask = 0xff;
+ };
+
+ bool StencilTestEnabled() const;
+ const DepthInfo& GetDepth() const;
+ const StencilInfo& GetStencil() const;
+
+ private:
+ DepthInfo mDepthInfo;
+ StencilInfo mStencilInfo;
+ };
+
+ class DepthStencilStateBuilder : public Builder<DepthStencilStateBase> {
+ public:
+ DepthStencilStateBuilder(DeviceBase* device);
+
+ // Dawn API
+ void SetDepthCompareFunction(dawn::CompareFunction depthCompareFunction);
+ void SetDepthWriteEnabled(bool enabled);
+ void SetStencilFunction(dawn::Face face,
+ dawn::CompareFunction stencilCompareFunction,
+ dawn::StencilOperation stencilFail,
+ dawn::StencilOperation depthFail,
+ dawn::StencilOperation depthStencilPass);
+ void SetStencilMask(uint32_t readMask, uint32_t writeMask);
+
+ private:
+ friend class DepthStencilStateBase;
+
+ DepthStencilStateBase* GetResultImpl() override;
+
+ int mPropertiesSet = 0;
+
+ DepthStencilStateBase::DepthInfo mDepthInfo;
+ DepthStencilStateBase::StencilInfo mStencilInfo;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_DEPTHSTENCILSTATE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Device.cpp b/chromium/third_party/dawn/src/dawn_native/Device.cpp
new file mode 100644
index 00000000000..f2581cd03f6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Device.cpp
@@ -0,0 +1,299 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Device.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/BlendState.h"
+#include "dawn_native/Buffer.h"
+#include "dawn_native/CommandBuffer.h"
+#include "dawn_native/ComputePipeline.h"
+#include "dawn_native/DepthStencilState.h"
+#include "dawn_native/ErrorData.h"
+#include "dawn_native/InputState.h"
+#include "dawn_native/PipelineLayout.h"
+#include "dawn_native/Queue.h"
+#include "dawn_native/RenderPassDescriptor.h"
+#include "dawn_native/RenderPipeline.h"
+#include "dawn_native/Sampler.h"
+#include "dawn_native/ShaderModule.h"
+#include "dawn_native/SwapChain.h"
+#include "dawn_native/Texture.h"
+
+#include <unordered_set>
+
+namespace dawn_native {
+
+ // DeviceBase::Caches
+
+ // The caches are unordered_sets of pointers with special hash and compare functions
+ // to compare the value of the objects, instead of the pointers.
+ using BindGroupLayoutCache = std::
+ unordered_set<BindGroupLayoutBase*, BindGroupLayoutCacheFuncs, BindGroupLayoutCacheFuncs>;
+
+ struct DeviceBase::Caches {
+ BindGroupLayoutCache bindGroupLayouts;
+ };
+
+ // DeviceBase
+
+ DeviceBase::DeviceBase() {
+ mCaches = std::make_unique<DeviceBase::Caches>();
+ }
+
+ DeviceBase::~DeviceBase() {
+ }
+
+ void DeviceBase::HandleError(const char* message) {
+ if (mErrorCallback) {
+ mErrorCallback(message, mErrorUserdata);
+ }
+ }
+
+ void DeviceBase::SetErrorCallback(dawn::DeviceErrorCallback callback,
+ dawn::CallbackUserdata userdata) {
+ mErrorCallback = callback;
+ mErrorUserdata = userdata;
+ }
+
+ DeviceBase* DeviceBase::GetDevice() {
+ return this;
+ }
+
+ ResultOrError<BindGroupLayoutBase*> DeviceBase::GetOrCreateBindGroupLayout(
+ const BindGroupLayoutDescriptor* descriptor) {
+ BindGroupLayoutBase blueprint(this, descriptor, true);
+
+ auto iter = mCaches->bindGroupLayouts.find(&blueprint);
+ if (iter != mCaches->bindGroupLayouts.end()) {
+ (*iter)->Reference();
+ return *iter;
+ }
+
+ BindGroupLayoutBase* backendObj;
+ DAWN_TRY_ASSIGN(backendObj, CreateBindGroupLayoutImpl(descriptor));
+ mCaches->bindGroupLayouts.insert(backendObj);
+ return backendObj;
+ }
+
+ void DeviceBase::UncacheBindGroupLayout(BindGroupLayoutBase* obj) {
+ mCaches->bindGroupLayouts.erase(obj);
+ }
+
+ // Object creation API methods
+
+ BindGroupBuilder* DeviceBase::CreateBindGroupBuilder() {
+ return new BindGroupBuilder(this);
+ }
+ BindGroupLayoutBase* DeviceBase::CreateBindGroupLayout(
+ const BindGroupLayoutDescriptor* descriptor) {
+ BindGroupLayoutBase* result = nullptr;
+
+ if (ConsumedError(CreateBindGroupLayoutInternal(&result, descriptor))) {
+ return nullptr;
+ }
+
+ return result;
+ }
+ BlendStateBuilder* DeviceBase::CreateBlendStateBuilder() {
+ return new BlendStateBuilder(this);
+ }
+ BufferBase* DeviceBase::CreateBuffer(const BufferDescriptor* descriptor) {
+ BufferBase* result = nullptr;
+
+ if (ConsumedError(CreateBufferInternal(&result, descriptor))) {
+ return nullptr;
+ }
+
+ return result;
+ }
+ CommandBufferBuilder* DeviceBase::CreateCommandBufferBuilder() {
+ return new CommandBufferBuilder(this);
+ }
+ ComputePipelineBase* DeviceBase::CreateComputePipeline(
+ const ComputePipelineDescriptor* descriptor) {
+ ComputePipelineBase* result = nullptr;
+
+ if (ConsumedError(CreateComputePipelineInternal(&result, descriptor))) {
+ return nullptr;
+ }
+
+ return result;
+ }
+ DepthStencilStateBuilder* DeviceBase::CreateDepthStencilStateBuilder() {
+ return new DepthStencilStateBuilder(this);
+ }
+ InputStateBuilder* DeviceBase::CreateInputStateBuilder() {
+ return new InputStateBuilder(this);
+ }
+ PipelineLayoutBase* DeviceBase::CreatePipelineLayout(
+ const PipelineLayoutDescriptor* descriptor) {
+ PipelineLayoutBase* result = nullptr;
+
+ if (ConsumedError(CreatePipelineLayoutInternal(&result, descriptor))) {
+ return nullptr;
+ }
+
+ return result;
+ }
+ QueueBase* DeviceBase::CreateQueue() {
+ QueueBase* result = nullptr;
+
+ if (ConsumedError(CreateQueueInternal(&result))) {
+ return nullptr;
+ }
+
+ return result;
+ }
+ RenderPassDescriptorBuilder* DeviceBase::CreateRenderPassDescriptorBuilder() {
+ return new RenderPassDescriptorBuilder(this);
+ }
+ RenderPipelineBuilder* DeviceBase::CreateRenderPipelineBuilder() {
+ return new RenderPipelineBuilder(this);
+ }
+ SamplerBase* DeviceBase::CreateSampler(const SamplerDescriptor* descriptor) {
+ SamplerBase* result = nullptr;
+
+ if (ConsumedError(CreateSamplerInternal(&result, descriptor))) {
+ return nullptr;
+ }
+
+ return result;
+ }
+ ShaderModuleBase* DeviceBase::CreateShaderModule(const ShaderModuleDescriptor* descriptor) {
+ ShaderModuleBase* result = nullptr;
+
+ if (ConsumedError(CreateShaderModuleInternal(&result, descriptor))) {
+ return nullptr;
+ }
+
+ return result;
+ }
+ SwapChainBuilder* DeviceBase::CreateSwapChainBuilder() {
+ return new SwapChainBuilder(this);
+ }
+ TextureBase* DeviceBase::CreateTexture(const TextureDescriptor* descriptor) {
+ TextureBase* result = nullptr;
+
+ if (ConsumedError(CreateTextureInternal(&result, descriptor))) {
+ return nullptr;
+ }
+ return result;
+ }
+ TextureViewBase* DeviceBase::CreateTextureView(TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ TextureViewBase* result = nullptr;
+
+ if (ConsumedError(CreateTextureViewInternal(&result, texture, descriptor))) {
+ return nullptr;
+ }
+ return result;
+ }
+
+ // Other Device API methods
+
+ void DeviceBase::Tick() {
+ TickImpl();
+ }
+
+ void DeviceBase::Reference() {
+ ASSERT(mRefCount != 0);
+ mRefCount++;
+ }
+
+ void DeviceBase::Release() {
+ ASSERT(mRefCount != 0);
+ mRefCount--;
+ if (mRefCount == 0) {
+ delete this;
+ }
+ }
+
+ // Implementation details of object creation
+
+ MaybeError DeviceBase::CreateBindGroupLayoutInternal(
+ BindGroupLayoutBase** result,
+ const BindGroupLayoutDescriptor* descriptor) {
+ DAWN_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor));
+ DAWN_TRY_ASSIGN(*result, GetOrCreateBindGroupLayout(descriptor));
+ return {};
+ }
+
+ MaybeError DeviceBase::CreateBufferInternal(BufferBase** result,
+ const BufferDescriptor* descriptor) {
+ DAWN_TRY(ValidateBufferDescriptor(this, descriptor));
+ DAWN_TRY_ASSIGN(*result, CreateBufferImpl(descriptor));
+ return {};
+ }
+
+ MaybeError DeviceBase::CreateComputePipelineInternal(
+ ComputePipelineBase** result,
+ const ComputePipelineDescriptor* descriptor) {
+ DAWN_TRY(ValidateComputePipelineDescriptor(this, descriptor));
+ DAWN_TRY_ASSIGN(*result, CreateComputePipelineImpl(descriptor));
+ return {};
+ }
+
+ MaybeError DeviceBase::CreatePipelineLayoutInternal(
+ PipelineLayoutBase** result,
+ const PipelineLayoutDescriptor* descriptor) {
+ DAWN_TRY(ValidatePipelineLayoutDescriptor(this, descriptor));
+ DAWN_TRY_ASSIGN(*result, CreatePipelineLayoutImpl(descriptor));
+ return {};
+ }
+
+ MaybeError DeviceBase::CreateQueueInternal(QueueBase** result) {
+ DAWN_TRY_ASSIGN(*result, CreateQueueImpl());
+ return {};
+ }
+
+ MaybeError DeviceBase::CreateSamplerInternal(SamplerBase** result,
+ const SamplerDescriptor* descriptor) {
+ DAWN_TRY(ValidateSamplerDescriptor(this, descriptor));
+ DAWN_TRY_ASSIGN(*result, CreateSamplerImpl(descriptor));
+ return {};
+ }
+
+ MaybeError DeviceBase::CreateShaderModuleInternal(ShaderModuleBase** result,
+ const ShaderModuleDescriptor* descriptor) {
+ DAWN_TRY(ValidateShaderModuleDescriptor(this, descriptor));
+ DAWN_TRY_ASSIGN(*result, CreateShaderModuleImpl(descriptor));
+ return {};
+ }
+
+ MaybeError DeviceBase::CreateTextureInternal(TextureBase** result,
+ const TextureDescriptor* descriptor) {
+ DAWN_TRY(ValidateTextureDescriptor(this, descriptor));
+ DAWN_TRY_ASSIGN(*result, CreateTextureImpl(descriptor));
+ return {};
+ }
+
+ MaybeError DeviceBase::CreateTextureViewInternal(TextureViewBase** result,
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ DAWN_TRY(ValidateTextureViewDescriptor(this, texture, descriptor));
+ DAWN_TRY_ASSIGN(*result, CreateTextureViewImpl(texture, descriptor));
+ return {};
+ }
+
+ // Other implementation details
+
+ void DeviceBase::ConsumeError(ErrorData* error) {
+ ASSERT(error != nullptr);
+ HandleError(error->GetMessage().c_str());
+ delete error;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Device.h b/chromium/third_party/dawn/src/dawn_native/Device.h
new file mode 100644
index 00000000000..59c027212ab
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Device.h
@@ -0,0 +1,161 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_DEVICEBASE_H_
+#define DAWNNATIVE_DEVICEBASE_H_
+
+#include "dawn_native/Error.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/DawnNative.h"
+#include "dawn_native/dawn_platform.h"
+
+#include <memory>
+
+namespace dawn_native {
+
+ using ErrorCallback = void (*)(const char* errorMessage, void* userData);
+
+ class DeviceBase {
+ public:
+ DeviceBase();
+ virtual ~DeviceBase();
+
+ void HandleError(const char* message);
+
+ bool ConsumedError(MaybeError maybeError) {
+ if (DAWN_UNLIKELY(maybeError.IsError())) {
+ ConsumeError(maybeError.AcquireError());
+ return true;
+ }
+ return false;
+ }
+
+ // Used by autogenerated code, returns itself
+ DeviceBase* GetDevice();
+
+ virtual BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) = 0;
+ virtual BlendStateBase* CreateBlendState(BlendStateBuilder* builder) = 0;
+ virtual BufferViewBase* CreateBufferView(BufferViewBuilder* builder) = 0;
+ virtual CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) = 0;
+ virtual DepthStencilStateBase* CreateDepthStencilState(
+ DepthStencilStateBuilder* builder) = 0;
+ virtual InputStateBase* CreateInputState(InputStateBuilder* builder) = 0;
+ virtual RenderPassDescriptorBase* CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) = 0;
+ virtual RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) = 0;
+ virtual SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) = 0;
+
+ virtual void TickImpl() = 0;
+
+ // Many Dawn objects are completely immutable once created which means that if two
+ // builders are given the same arguments, they can return the same object. Reusing
+ // objects will help make comparisons between objects by a single pointer comparison.
+ //
+ // Technically no object is immutable as they have a reference count, and an
+ // application with reference-counting issues could "see" that objects are reused.
+ // This is solved by automatic-reference counting, and also the fact that when using
+ // the client-server wire every creation will get a different proxy object, with a
+ // different reference count.
+ //
+ // When trying to create an object, we give both the builder and an example of what
+ // the built object will be, the "blueprint". The blueprint is just a FooBase object
+ // instead of a backend Foo object. If the blueprint doesn't match an object in the
+ // cache, then the builder is used to make a new object.
+ ResultOrError<BindGroupLayoutBase*> GetOrCreateBindGroupLayout(
+ const BindGroupLayoutDescriptor* descriptor);
+ void UncacheBindGroupLayout(BindGroupLayoutBase* obj);
+
+ // Dawn API
+ BindGroupBuilder* CreateBindGroupBuilder();
+ BindGroupLayoutBase* CreateBindGroupLayout(const BindGroupLayoutDescriptor* descriptor);
+ BlendStateBuilder* CreateBlendStateBuilder();
+ BufferBase* CreateBuffer(const BufferDescriptor* descriptor);
+ CommandBufferBuilder* CreateCommandBufferBuilder();
+ ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
+ DepthStencilStateBuilder* CreateDepthStencilStateBuilder();
+ InputStateBuilder* CreateInputStateBuilder();
+ PipelineLayoutBase* CreatePipelineLayout(const PipelineLayoutDescriptor* descriptor);
+ QueueBase* CreateQueue();
+ RenderPassDescriptorBuilder* CreateRenderPassDescriptorBuilder();
+ RenderPipelineBuilder* CreateRenderPipelineBuilder();
+ SamplerBase* CreateSampler(const SamplerDescriptor* descriptor);
+ ShaderModuleBase* CreateShaderModule(const ShaderModuleDescriptor* descriptor);
+ SwapChainBuilder* CreateSwapChainBuilder();
+ TextureBase* CreateTexture(const TextureDescriptor* descriptor);
+ TextureViewBase* CreateTextureView(TextureBase* texture,
+ const TextureViewDescriptor* descriptor);
+
+ void Tick();
+ void SetErrorCallback(dawn::DeviceErrorCallback callback, dawn::CallbackUserdata userdata);
+ void Reference();
+ void Release();
+
+ BufferBuilder* CreateBufferBuilderForTesting() {
+ return nullptr;
+ }
+
+ virtual const PCIInfo& GetPCIInfo() const = 0;
+
+ private:
+ virtual ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) = 0;
+ virtual ResultOrError<BufferBase*> CreateBufferImpl(const BufferDescriptor* descriptor) = 0;
+ virtual ResultOrError<ComputePipelineBase*> CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) = 0;
+ virtual ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) = 0;
+ virtual ResultOrError<QueueBase*> CreateQueueImpl() = 0;
+ virtual ResultOrError<SamplerBase*> CreateSamplerImpl(
+ const SamplerDescriptor* descriptor) = 0;
+ virtual ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) = 0;
+ virtual ResultOrError<TextureBase*> CreateTextureImpl(
+ const TextureDescriptor* descriptor) = 0;
+ virtual ResultOrError<TextureViewBase*> CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) = 0;
+
+ MaybeError CreateBindGroupLayoutInternal(BindGroupLayoutBase** result,
+ const BindGroupLayoutDescriptor* descriptor);
+ MaybeError CreateBufferInternal(BufferBase** result, const BufferDescriptor* descriptor);
+ MaybeError CreateComputePipelineInternal(ComputePipelineBase** result,
+ const ComputePipelineDescriptor* descriptor);
+ MaybeError CreatePipelineLayoutInternal(PipelineLayoutBase** result,
+ const PipelineLayoutDescriptor* descriptor);
+ MaybeError CreateQueueInternal(QueueBase** result);
+ MaybeError CreateSamplerInternal(SamplerBase** result, const SamplerDescriptor* descriptor);
+ MaybeError CreateShaderModuleInternal(ShaderModuleBase** result,
+ const ShaderModuleDescriptor* descriptor);
+ MaybeError CreateTextureInternal(TextureBase** result, const TextureDescriptor* descriptor);
+ MaybeError CreateTextureViewInternal(TextureViewBase** result,
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor);
+
+ void ConsumeError(ErrorData* error);
+
+ // The object caches aren't exposed in the header as they would require a lot of
+ // additional includes.
+ struct Caches;
+ std::unique_ptr<Caches> mCaches;
+
+ dawn::DeviceErrorCallback mErrorCallback = nullptr;
+ dawn::CallbackUserdata mErrorUserdata = 0;
+ uint32_t mRefCount = 1;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_DEVICEBASE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Error.cpp b/chromium/third_party/dawn/src/dawn_native/Error.cpp
new file mode 100644
index 00000000000..9467c3a0395
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Error.cpp
@@ -0,0 +1,35 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Error.h"
+
+#include "dawn_native/ErrorData.h"
+
+namespace dawn_native {
+
+ ErrorData* MakeError(ErrorType type,
+ const char* message,
+ const char* file,
+ const char* function,
+ int line) {
+ ErrorData* error = new ErrorData(type, message);
+ error->AppendBacktrace(file, function, line);
+ return error;
+ }
+
+ void AppendBacktrace(ErrorData* error, const char* file, const char* function, int line) {
+ error->AppendBacktrace(file, function, line);
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Error.h b/chromium/third_party/dawn/src/dawn_native/Error.h
new file mode 100644
index 00000000000..7f202f70590
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Error.h
@@ -0,0 +1,95 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_ERROR_H_
+#define DAWNNATIVE_ERROR_H_
+
+#include "common/Result.h"
+
+namespace dawn_native {
+
+ // This is the content of an error value for MaybeError or ResultOrError, split off to its own
+ // file to avoid having all files including headers like <string> and <vector>
+ class ErrorData;
+
+ enum class ErrorType : uint32_t { Validation, ContextLost, Unimplemented };
+
+ // MaybeError and ResultOrError are meant to be used as return value for function that are not
+ // expected to, but might fail. The handling of error is potentially much slower than successes.
+ using MaybeError = Result<void, ErrorData*>;
+
+ template <typename T>
+ using ResultOrError = Result<T, ErrorData*>;
+
+ // Returning a success is done like so:
+ // return {}; // for Error
+ // return SomethingOfTypeT; // for ResultOrError<T>
+ //
+ // Returning an error is done via:
+ // return DAWN_MAKE_ERROR(errorType, "My error message");
+ //
+ // but shorthand version for specific error types are preferred:
+ // return DAWN_VALIDATION_ERROR("My error message");
+#define DAWN_MAKE_ERROR(TYPE, MESSAGE) MakeError(TYPE, MESSAGE, __FILE__, __func__, __LINE__)
+#define DAWN_VALIDATION_ERROR(MESSAGE) DAWN_MAKE_ERROR(ErrorType::Validation, MESSAGE)
+#define DAWN_CONTEXT_LOST_ERROR(MESSAGE) DAWN_MAKE_ERROR(ErrorType::ContextLost, MESSAGE)
+#define DAWN_UNIMPLEMENTED_ERROR(MESSAGE) DAWN_MAKE_ERROR(ErrorType::Unimplemented, MESSAGE)
+
+#define DAWN_CONCAT1(x, y) x##y
+#define DAWN_CONCAT2(x, y) DAWN_CONCAT1(x, y)
+#define DAWN_LOCAL_VAR DAWN_CONCAT2(_localVar, __LINE__)
+
+ // When Errors aren't handled explicitly, calls to functions returning errors should be
+ // wrapped in an DAWN_TRY. It will return the error if any, otherwise keep executing
+ // the current function.
+#define DAWN_TRY(EXPR) \
+ { \
+ auto DAWN_LOCAL_VAR = EXPR; \
+ if (DAWN_UNLIKELY(DAWN_LOCAL_VAR.IsError())) { \
+ ErrorData* error = DAWN_LOCAL_VAR.AcquireError(); \
+ AppendBacktrace(error, __FILE__, __func__, __LINE__); \
+ return {error}; \
+ } \
+ } \
+ for (;;) \
+ break
+
+ // DAWN_TRY_ASSIGN is the same as DAWN_TRY for ResultOrError and assigns the success value, if
+ // any, to VAR.
+#define DAWN_TRY_ASSIGN(VAR, EXPR) \
+ { \
+ auto DAWN_LOCAL_VAR = EXPR; \
+ if (DAWN_UNLIKELY(DAWN_LOCAL_VAR.IsError())) { \
+ ErrorData* error = DAWN_LOCAL_VAR.AcquireError(); \
+ AppendBacktrace(error, __FILE__, __func__, __LINE__); \
+ return {error}; \
+ } \
+ VAR = DAWN_LOCAL_VAR.AcquireSuccess(); \
+ } \
+ for (;;) \
+ break
+
+ // Implementation detail of DAWN_TRY and DAWN_TRY_ASSIGN's adding to the Error's backtrace.
+ void AppendBacktrace(ErrorData* error, const char* file, const char* function, int line);
+
+ // Implementation detail of DAWN_MAKE_ERROR
+ ErrorData* MakeError(ErrorType type,
+ const char* message,
+ const char* file,
+ const char* function,
+ int line);
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_ERROR_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/ErrorData.cpp b/chromium/third_party/dawn/src/dawn_native/ErrorData.cpp
new file mode 100644
index 00000000000..77a0e3f9dc1
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ErrorData.cpp
@@ -0,0 +1,46 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/ErrorData.h"
+
+namespace dawn_native {
+
+ ErrorData::ErrorData() = default;
+
+ ErrorData::ErrorData(ErrorType type, std::string message)
+ : mType(type), mMessage(std::move(message)) {
+ }
+
+ void ErrorData::AppendBacktrace(const char* file, const char* function, int line) {
+ BacktraceRecord record;
+ record.file = file;
+ record.function = function;
+ record.line = line;
+
+ mBacktrace.push_back(std::move(record));
+ }
+
+ ErrorType ErrorData::GetType() const {
+ return mType;
+ }
+
+ const std::string& ErrorData::GetMessage() const {
+ return mMessage;
+ }
+
+ const std::vector<ErrorData::BacktraceRecord>& ErrorData::GetBacktrace() const {
+ return mBacktrace;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/ErrorData.h b/chromium/third_party/dawn/src/dawn_native/ErrorData.h
new file mode 100644
index 00000000000..01520034838
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ErrorData.h
@@ -0,0 +1,50 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_ERRORDATA_H_
+#define DAWNNATIVE_ERRORDATA_H_
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+namespace dawn_native {
+
+ enum class ErrorType : uint32_t;
+
+ class ErrorData {
+ public:
+ ErrorData();
+ ErrorData(ErrorType type, std::string message);
+
+ struct BacktraceRecord {
+ const char* file;
+ const char* function;
+ int line;
+ };
+ void AppendBacktrace(const char* file, const char* function, int line);
+
+ ErrorType GetType() const;
+ const std::string& GetMessage() const;
+ const std::vector<BacktraceRecord>& GetBacktrace() const;
+
+ private:
+ ErrorType mType;
+ std::string mMessage;
+ std::vector<BacktraceRecord> mBacktrace;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_ERRORDATA_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Forward.h b/chromium/third_party/dawn/src/dawn_native/Forward.h
new file mode 100644
index 00000000000..a5ac6e4a3fb
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Forward.h
@@ -0,0 +1,69 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_FORWARD_H_
+#define DAWNNATIVE_FORWARD_H_
+
+#include <cstdint>
+
+namespace dawn_native {
+
+ class BindGroupBase;
+ class BindGroupBuilder;
+ class BindGroupLayoutBase;
+ class BindGroupLayoutBuilder;
+ class BlendStateBase;
+ class BlendStateBuilder;
+ class BufferBase;
+ class BufferBuilder;
+ class BufferViewBase;
+ class BufferViewBuilder;
+ class ComputePipelineBase;
+ class ComputePipelineBuilder;
+ class CommandBufferBase;
+ class CommandBufferBuilder;
+ class ComputePassEncoderBase;
+ class DepthStencilStateBase;
+ class DepthStencilStateBuilder;
+ class InputStateBase;
+ class InputStateBuilder;
+ class PipelineLayoutBase;
+ class PipelineLayoutBuilder;
+ class QueueBase;
+ class RenderPassDescriptorBase;
+ class RenderPassDescriptorBuilder;
+ class RenderPassEncoderBase;
+ class RenderPipelineBase;
+ class RenderPipelineBuilder;
+ class SamplerBase;
+ class ShaderModuleBase;
+ class ShaderModuleBuilder;
+ class SwapChainBase;
+ class SwapChainBuilder;
+ class TextureBase;
+ class TextureViewBase;
+ class TextureViewBuilder;
+
+ class DeviceBase;
+
+ template <typename T>
+ class Ref;
+
+ template <typename T>
+ class PerStage;
+
+ enum PushConstantType : uint8_t;
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_FORWARD_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/InputState.cpp b/chromium/third_party/dawn/src/dawn_native/InputState.cpp
new file mode 100644
index 00000000000..6e818f916cc
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/InputState.cpp
@@ -0,0 +1,171 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/InputState.h"
+
+#include "common/Assert.h"
+#include "dawn_native/Device.h"
+
+namespace dawn_native {
+
+ // InputState helpers
+
+ size_t IndexFormatSize(dawn::IndexFormat format) {
+ switch (format) {
+ case dawn::IndexFormat::Uint16:
+ return sizeof(uint16_t);
+ case dawn::IndexFormat::Uint32:
+ return sizeof(uint32_t);
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ uint32_t VertexFormatNumComponents(dawn::VertexFormat format) {
+ switch (format) {
+ case dawn::VertexFormat::FloatR32G32B32A32:
+ case dawn::VertexFormat::IntR32G32B32A32:
+ case dawn::VertexFormat::UshortR16G16B16A16:
+ case dawn::VertexFormat::UnormR8G8B8A8:
+ return 4;
+ case dawn::VertexFormat::FloatR32G32B32:
+ case dawn::VertexFormat::IntR32G32B32:
+ return 3;
+ case dawn::VertexFormat::FloatR32G32:
+ case dawn::VertexFormat::IntR32G32:
+ case dawn::VertexFormat::UshortR16G16:
+ case dawn::VertexFormat::UnormR8G8:
+ return 2;
+ case dawn::VertexFormat::FloatR32:
+ case dawn::VertexFormat::IntR32:
+ return 1;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ size_t VertexFormatComponentSize(dawn::VertexFormat format) {
+ switch (format) {
+ case dawn::VertexFormat::FloatR32G32B32A32:
+ case dawn::VertexFormat::FloatR32G32B32:
+ case dawn::VertexFormat::FloatR32G32:
+ case dawn::VertexFormat::FloatR32:
+ return sizeof(float);
+ case dawn::VertexFormat::IntR32G32B32A32:
+ case dawn::VertexFormat::IntR32G32B32:
+ case dawn::VertexFormat::IntR32G32:
+ case dawn::VertexFormat::IntR32:
+ return sizeof(int32_t);
+ case dawn::VertexFormat::UshortR16G16B16A16:
+ case dawn::VertexFormat::UshortR16G16:
+ return sizeof(uint16_t);
+ case dawn::VertexFormat::UnormR8G8B8A8:
+ case dawn::VertexFormat::UnormR8G8:
+ return sizeof(uint8_t);
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ size_t VertexFormatSize(dawn::VertexFormat format) {
+ return VertexFormatNumComponents(format) * VertexFormatComponentSize(format);
+ }
+
+ // InputStateBase
+
+ InputStateBase::InputStateBase(InputStateBuilder* builder) : ObjectBase(builder->GetDevice()) {
+ mAttributesSetMask = builder->mAttributesSetMask;
+ mAttributeInfos = builder->mAttributeInfos;
+ mInputsSetMask = builder->mInputsSetMask;
+ mInputInfos = builder->mInputInfos;
+ }
+
+ const std::bitset<kMaxVertexAttributes>& InputStateBase::GetAttributesSetMask() const {
+ return mAttributesSetMask;
+ }
+
+ const InputStateBase::AttributeInfo& InputStateBase::GetAttribute(uint32_t location) const {
+ ASSERT(mAttributesSetMask[location]);
+ return mAttributeInfos[location];
+ }
+
+ const std::bitset<kMaxVertexInputs>& InputStateBase::GetInputsSetMask() const {
+ return mInputsSetMask;
+ }
+
+ const InputStateBase::InputInfo& InputStateBase::GetInput(uint32_t slot) const {
+ ASSERT(mInputsSetMask[slot]);
+ return mInputInfos[slot];
+ }
+
+ // InputStateBuilder
+
+ InputStateBuilder::InputStateBuilder(DeviceBase* device) : Builder(device) {
+ }
+
+ InputStateBase* InputStateBuilder::GetResultImpl() {
+ for (uint32_t location = 0; location < kMaxVertexAttributes; ++location) {
+ if (mAttributesSetMask[location] &&
+ !mInputsSetMask[mAttributeInfos[location].bindingSlot]) {
+ HandleError("Attribute uses unset input");
+ return nullptr;
+ }
+ }
+
+ return GetDevice()->CreateInputState(this);
+ }
+
+ void InputStateBuilder::SetAttribute(uint32_t shaderLocation,
+ uint32_t bindingSlot,
+ dawn::VertexFormat format,
+ uint32_t offset) {
+ if (shaderLocation >= kMaxVertexAttributes) {
+ HandleError("Setting attribute out of bounds");
+ return;
+ }
+ if (bindingSlot >= kMaxVertexInputs) {
+ HandleError("Binding slot out of bounds");
+ return;
+ }
+ if (mAttributesSetMask[shaderLocation]) {
+ HandleError("Setting already set attribute");
+ return;
+ }
+
+ mAttributesSetMask.set(shaderLocation);
+ auto& info = mAttributeInfos[shaderLocation];
+ info.bindingSlot = bindingSlot;
+ info.format = format;
+ info.offset = offset;
+ }
+
+ void InputStateBuilder::SetInput(uint32_t bindingSlot,
+ uint32_t stride,
+ dawn::InputStepMode stepMode) {
+ if (bindingSlot >= kMaxVertexInputs) {
+ HandleError("Setting input out of bounds");
+ return;
+ }
+ if (mInputsSetMask[bindingSlot]) {
+ HandleError("Setting already set input");
+ return;
+ }
+
+ mInputsSetMask.set(bindingSlot);
+ auto& info = mInputInfos[bindingSlot];
+ info.stride = stride;
+ info.stepMode = stepMode;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/InputState.h b/chromium/third_party/dawn/src/dawn_native/InputState.h
new file mode 100644
index 00000000000..05519b21053
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/InputState.h
@@ -0,0 +1,86 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_INPUTSTATE_H_
+#define DAWNNATIVE_INPUTSTATE_H_
+
+#include "common/Constants.h"
+#include "dawn_native/Builder.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+
+namespace dawn_native {
+
+ size_t IndexFormatSize(dawn::IndexFormat format);
+ uint32_t VertexFormatNumComponents(dawn::VertexFormat format);
+ size_t VertexFormatComponentSize(dawn::VertexFormat format);
+ size_t VertexFormatSize(dawn::VertexFormat format);
+
+ class InputStateBase : public ObjectBase {
+ public:
+ InputStateBase(InputStateBuilder* builder);
+
+ struct AttributeInfo {
+ uint32_t bindingSlot;
+ dawn::VertexFormat format;
+ uint32_t offset;
+ };
+
+ struct InputInfo {
+ uint32_t stride;
+ dawn::InputStepMode stepMode;
+ };
+
+ const std::bitset<kMaxVertexAttributes>& GetAttributesSetMask() const;
+ const AttributeInfo& GetAttribute(uint32_t location) const;
+ const std::bitset<kMaxVertexInputs>& GetInputsSetMask() const;
+ const InputInfo& GetInput(uint32_t slot) const;
+
+ private:
+ std::bitset<kMaxVertexAttributes> mAttributesSetMask;
+ std::array<AttributeInfo, kMaxVertexAttributes> mAttributeInfos;
+ std::bitset<kMaxVertexInputs> mInputsSetMask;
+ std::array<InputInfo, kMaxVertexInputs> mInputInfos;
+ };
+
+ class InputStateBuilder : public Builder<InputStateBase> {
+ public:
+ InputStateBuilder(DeviceBase* device);
+
+ // Dawn API
+ void SetAttribute(uint32_t shaderLocation,
+ uint32_t bindingSlot,
+ dawn::VertexFormat format,
+ uint32_t offset);
+ void SetInput(uint32_t bindingSlot, uint32_t stride, dawn::InputStepMode stepMode);
+
+ private:
+ friend class InputStateBase;
+
+ InputStateBase* GetResultImpl() override;
+
+ std::bitset<kMaxVertexAttributes> mAttributesSetMask;
+ std::array<InputStateBase::AttributeInfo, kMaxVertexAttributes> mAttributeInfos;
+ std::bitset<kMaxVertexInputs> mInputsSetMask;
+ std::array<InputStateBase::InputInfo, kMaxVertexInputs> mInputInfos;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_INPUTSTATE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/ObjectBase.cpp b/chromium/third_party/dawn/src/dawn_native/ObjectBase.cpp
new file mode 100644
index 00000000000..2d6b56f9222
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ObjectBase.cpp
@@ -0,0 +1,29 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/ObjectBase.h"
+
+namespace dawn_native {
+
+ ObjectBase::ObjectBase(DeviceBase* device) : mDevice(device) {
+ }
+
+ ObjectBase::~ObjectBase() {
+ }
+
+ DeviceBase* ObjectBase::GetDevice() const {
+ return mDevice;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/ObjectBase.h b/chromium/third_party/dawn/src/dawn_native/ObjectBase.h
new file mode 100644
index 00000000000..019938a2c9e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ObjectBase.h
@@ -0,0 +1,37 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OBJECTBASE_H_
+#define DAWNNATIVE_OBJECTBASE_H_
+
+#include "dawn_native/RefCounted.h"
+
+namespace dawn_native {
+
+ class DeviceBase;
+
+ class ObjectBase : public RefCounted {
+ public:
+ ObjectBase(DeviceBase* device);
+ virtual ~ObjectBase();
+
+ DeviceBase* GetDevice() const;
+
+ private:
+ DeviceBase* mDevice;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_OBJECTBASE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/PassResourceUsage.h b/chromium/third_party/dawn/src/dawn_native/PassResourceUsage.h
new file mode 100644
index 00000000000..9a8c2b07db4
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/PassResourceUsage.h
@@ -0,0 +1,47 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_PASSRESOURCEUSAGE_H
+#define DAWNNATIVE_PASSRESOURCEUSAGE_H
+
+#include "dawn_native/dawn_platform.h"
+
+#include <set>
+#include <vector>
+
+namespace dawn_native {
+
+ class BufferBase;
+ class TextureBase;
+
+ // Which resources are used by pass and how they are used. The command buffer validation
+ // pre-computes this information so that backends with explicit barriers don't have to
+ // re-compute it.
+ struct PassResourceUsage {
+ std::vector<BufferBase*> buffers;
+ std::vector<dawn::BufferUsageBit> bufferUsages;
+
+ std::vector<TextureBase*> textures;
+ std::vector<dawn::TextureUsageBit> textureUsages;
+ };
+
+ struct CommandBufferResourceUsage {
+ std::vector<PassResourceUsage> perPass;
+ std::set<BufferBase*> topLevelBuffers;
+ std::set<TextureBase*> topLevelTextures;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_PASSRESOURCEUSAGE_H
diff --git a/chromium/third_party/dawn/src/dawn_native/PerStage.cpp b/chromium/third_party/dawn/src/dawn_native/PerStage.cpp
new file mode 100644
index 00000000000..b29ede1c33b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/PerStage.cpp
@@ -0,0 +1,29 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/PerStage.h"
+
+namespace dawn_native {
+
+ BitSetIterator<kNumStages, dawn::ShaderStage> IterateStages(dawn::ShaderStageBit stages) {
+ std::bitset<kNumStages> bits(static_cast<uint32_t>(stages));
+ return BitSetIterator<kNumStages, dawn::ShaderStage>(bits);
+ }
+
+ dawn::ShaderStageBit StageBit(dawn::ShaderStage stage) {
+ ASSERT(static_cast<uint32_t>(stage) < kNumStages);
+ return static_cast<dawn::ShaderStageBit>(1 << static_cast<uint32_t>(stage));
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/PerStage.h b/chromium/third_party/dawn/src/dawn_native/PerStage.h
new file mode 100644
index 00000000000..b1b67af5fa2
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/PerStage.h
@@ -0,0 +1,82 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_PERSTAGE_H_
+#define DAWNNATIVE_PERSTAGE_H_
+
+#include "common/Assert.h"
+#include "common/BitSetIterator.h"
+#include "common/Constants.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+
+namespace dawn_native {
+
+ static_assert(static_cast<uint32_t>(dawn::ShaderStage::Vertex) < kNumStages, "");
+ static_assert(static_cast<uint32_t>(dawn::ShaderStage::Fragment) < kNumStages, "");
+ static_assert(static_cast<uint32_t>(dawn::ShaderStage::Compute) < kNumStages, "");
+
+ static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Vertex) ==
+ (1 << static_cast<uint32_t>(dawn::ShaderStage::Vertex)),
+ "");
+ static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Fragment) ==
+ (1 << static_cast<uint32_t>(dawn::ShaderStage::Fragment)),
+ "");
+ static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Compute) ==
+ (1 << static_cast<uint32_t>(dawn::ShaderStage::Compute)),
+ "");
+
+ BitSetIterator<kNumStages, dawn::ShaderStage> IterateStages(dawn::ShaderStageBit stages);
+ dawn::ShaderStageBit StageBit(dawn::ShaderStage stage);
+
+ static constexpr dawn::ShaderStageBit kAllStages =
+ static_cast<dawn::ShaderStageBit>((1 << kNumStages) - 1);
+
+ template <typename T>
+ class PerStage {
+ public:
+ PerStage() = default;
+ PerStage(const T& initialValue) {
+ mData.fill(initialValue);
+ }
+
+ T& operator[](dawn::ShaderStage stage) {
+ DAWN_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
+ return mData[static_cast<uint32_t>(stage)];
+ }
+ const T& operator[](dawn::ShaderStage stage) const {
+ DAWN_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
+ return mData[static_cast<uint32_t>(stage)];
+ }
+
+ T& operator[](dawn::ShaderStageBit stageBit) {
+ uint32_t bit = static_cast<uint32_t>(stageBit);
+ DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
+ return mData[Log2(bit)];
+ }
+ const T& operator[](dawn::ShaderStageBit stageBit) const {
+ uint32_t bit = static_cast<uint32_t>(stageBit);
+ DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
+ return mData[Log2(bit)];
+ }
+
+ private:
+ std::array<T, kNumStages> mData;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_PERSTAGE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Pipeline.cpp b/chromium/third_party/dawn/src/dawn_native/Pipeline.cpp
new file mode 100644
index 00000000000..301ef0f6f37
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Pipeline.cpp
@@ -0,0 +1,136 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Pipeline.h"
+
+#include "dawn_native/DepthStencilState.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/InputState.h"
+#include "dawn_native/PipelineLayout.h"
+#include "dawn_native/ShaderModule.h"
+
+namespace dawn_native {
+
+ // PipelineBase
+
+ PipelineBase::PipelineBase(DeviceBase* device,
+ PipelineLayoutBase* layout,
+ dawn::ShaderStageBit stages)
+ : ObjectBase(device), mStageMask(stages), mLayout(layout), mDevice(device) {
+ }
+
+ PipelineBase::PipelineBase(DeviceBase* device, PipelineBuilder* builder)
+ : ObjectBase(device),
+ mStageMask(builder->mStageMask),
+ mLayout(std::move(builder->mLayout)),
+ mDevice(device) {
+ if (!mLayout) {
+ PipelineLayoutDescriptor descriptor;
+ descriptor.numBindGroupLayouts = 0;
+ descriptor.bindGroupLayouts = nullptr;
+ mLayout = device->CreatePipelineLayout(&descriptor);
+ // Remove the external ref objects are created with
+ mLayout->Release();
+ }
+
+ for (auto stage : IterateStages(builder->mStageMask)) {
+ if (!builder->mStages[stage].module->IsCompatibleWithPipelineLayout(mLayout.Get())) {
+ builder->GetParentBuilder()->HandleError("Stage not compatible with layout");
+ return;
+ }
+
+ ExtractModuleData(stage, builder->mStages[stage].module.Get());
+ }
+ }
+
+ void PipelineBase::ExtractModuleData(dawn::ShaderStage stage, ShaderModuleBase* module) {
+ PushConstantInfo* info = &mPushConstants[stage];
+
+ const auto& moduleInfo = module->GetPushConstants();
+ info->mask = moduleInfo.mask;
+
+ for (uint32_t i = 0; i < moduleInfo.names.size(); i++) {
+ uint32_t size = moduleInfo.sizes[i];
+ if (size == 0) {
+ continue;
+ }
+
+ for (uint32_t offset = 0; offset < size; offset++) {
+ info->types[i + offset] = moduleInfo.types[i];
+ }
+ i += size - 1;
+ }
+ }
+
+ const PipelineBase::PushConstantInfo& PipelineBase::GetPushConstants(
+ dawn::ShaderStage stage) const {
+ return mPushConstants[stage];
+ }
+
+ dawn::ShaderStageBit PipelineBase::GetStageMask() const {
+ return mStageMask;
+ }
+
+ PipelineLayoutBase* PipelineBase::GetLayout() {
+ return mLayout.Get();
+ }
+
+ DeviceBase* PipelineBase::GetDevice() const {
+ return mDevice;
+ }
+
+ // PipelineBuilder
+
+ PipelineBuilder::PipelineBuilder(BuilderBase* parentBuilder)
+ : mParentBuilder(parentBuilder), mStageMask(static_cast<dawn::ShaderStageBit>(0)) {
+ }
+
+ const PipelineBuilder::StageInfo& PipelineBuilder::GetStageInfo(dawn::ShaderStage stage) const {
+ ASSERT(mStageMask & StageBit(stage));
+ return mStages[stage];
+ }
+
+ BuilderBase* PipelineBuilder::GetParentBuilder() const {
+ return mParentBuilder;
+ }
+
+ void PipelineBuilder::SetLayout(PipelineLayoutBase* layout) {
+ mLayout = layout;
+ }
+
+ void PipelineBuilder::SetStage(dawn::ShaderStage stage,
+ ShaderModuleBase* module,
+ const char* entryPoint) {
+ if (entryPoint != std::string("main")) {
+ mParentBuilder->HandleError("Currently the entry point has to be main()");
+ return;
+ }
+
+ if (stage != module->GetExecutionModel()) {
+ mParentBuilder->HandleError("Setting module with wrong execution model");
+ return;
+ }
+
+ dawn::ShaderStageBit bit = StageBit(stage);
+ if (mStageMask & bit) {
+ mParentBuilder->HandleError("Setting already set stage");
+ return;
+ }
+ mStageMask |= bit;
+
+ mStages[stage].module = module;
+ mStages[stage].entryPoint = entryPoint;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Pipeline.h b/chromium/third_party/dawn/src/dawn_native/Pipeline.h
new file mode 100644
index 00000000000..d91dc5bde94
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Pipeline.h
@@ -0,0 +1,91 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_PIPELINE_H_
+#define DAWNNATIVE_PIPELINE_H_
+
+#include "dawn_native/Builder.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+#include "dawn_native/PerStage.h"
+#include "dawn_native/PipelineLayout.h"
+#include "dawn_native/ShaderModule.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+
+namespace dawn_native {
+
+ enum PushConstantType : uint8_t {
+ Int,
+ UInt,
+ Float,
+ };
+
+ class PipelineBuilder;
+
+ class PipelineBase : public ObjectBase {
+ public:
+ PipelineBase(DeviceBase* device, PipelineLayoutBase* layout, dawn::ShaderStageBit stages);
+ PipelineBase(DeviceBase* device, PipelineBuilder* builder);
+
+ struct PushConstantInfo {
+ std::bitset<kMaxPushConstants> mask;
+ std::array<PushConstantType, kMaxPushConstants> types;
+ };
+ const PushConstantInfo& GetPushConstants(dawn::ShaderStage stage) const;
+ dawn::ShaderStageBit GetStageMask() const;
+
+ PipelineLayoutBase* GetLayout();
+ DeviceBase* GetDevice() const;
+
+ protected:
+ void ExtractModuleData(dawn::ShaderStage stage, ShaderModuleBase* module);
+
+ private:
+ dawn::ShaderStageBit mStageMask;
+ Ref<PipelineLayoutBase> mLayout;
+ PerStage<PushConstantInfo> mPushConstants;
+ DeviceBase* mDevice;
+ };
+
+ class PipelineBuilder {
+ public:
+ PipelineBuilder(BuilderBase* parentBuilder);
+
+ struct StageInfo {
+ std::string entryPoint;
+ Ref<ShaderModuleBase> module;
+ };
+ const StageInfo& GetStageInfo(dawn::ShaderStage stage) const;
+ BuilderBase* GetParentBuilder() const;
+
+ // Dawn API
+ void SetLayout(PipelineLayoutBase* layout);
+ void SetStage(dawn::ShaderStage stage, ShaderModuleBase* module, const char* entryPoint);
+
+ private:
+ friend class PipelineBase;
+
+ BuilderBase* mParentBuilder;
+ Ref<PipelineLayoutBase> mLayout;
+ dawn::ShaderStageBit mStageMask;
+ PerStage<StageInfo> mStages;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_PIPELINE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/PipelineLayout.cpp b/chromium/third_party/dawn/src/dawn_native/PipelineLayout.cpp
new file mode 100644
index 00000000000..1ccb386733f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/PipelineLayout.cpp
@@ -0,0 +1,76 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/PipelineLayout.h"
+
+#include "common/Assert.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/Device.h"
+
+namespace dawn_native {
+
+ MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*,
+ const PipelineLayoutDescriptor* descriptor) {
+ if (descriptor->nextInChain != nullptr) {
+ return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
+ }
+
+ if (descriptor->numBindGroupLayouts > kMaxBindGroups) {
+ return DAWN_VALIDATION_ERROR("too many bind group layouts");
+ }
+
+ for (uint32_t i = 0; i < descriptor->numBindGroupLayouts; ++i) {
+ if (descriptor->bindGroupLayouts[i] == nullptr) {
+ return DAWN_VALIDATION_ERROR("bind group layouts may not be null");
+ }
+ }
+ return {};
+ }
+
+ // PipelineLayoutBase
+
+ PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
+ const PipelineLayoutDescriptor* descriptor)
+ : ObjectBase(device) {
+ ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups);
+ for (uint32_t group = 0; group < descriptor->numBindGroupLayouts; ++group) {
+ mBindGroupLayouts[group] = descriptor->bindGroupLayouts[group];
+ mMask.set(group);
+ }
+ }
+
+ const BindGroupLayoutBase* PipelineLayoutBase::GetBindGroupLayout(size_t group) const {
+ ASSERT(group < kMaxBindGroups);
+ return mBindGroupLayouts[group].Get();
+ }
+
+ const std::bitset<kMaxBindGroups> PipelineLayoutBase::GetBindGroupLayoutsMask() const {
+ return mMask;
+ }
+
+ std::bitset<kMaxBindGroups> PipelineLayoutBase::InheritedGroupsMask(
+ const PipelineLayoutBase* other) const {
+ return {(1 << GroupsInheritUpTo(other)) - 1u};
+ }
+
+ uint32_t PipelineLayoutBase::GroupsInheritUpTo(const PipelineLayoutBase* other) const {
+ for (uint32_t i = 0; i < kMaxBindGroups; ++i) {
+ if (!mMask[i] || mBindGroupLayouts[i].Get() != other->mBindGroupLayouts[i].Get()) {
+ return i;
+ }
+ }
+ return kMaxBindGroups + 1;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/PipelineLayout.h b/chromium/third_party/dawn/src/dawn_native/PipelineLayout.h
new file mode 100644
index 00000000000..0d5e932d199
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/PipelineLayout.h
@@ -0,0 +1,57 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_PIPELINELAYOUT_H_
+#define DAWNNATIVE_PIPELINELAYOUT_H_
+
+#include "common/Constants.h"
+#include "dawn_native/Error.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+
+namespace dawn_native {
+
+ MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*,
+ const PipelineLayoutDescriptor* descriptor);
+
+ using BindGroupLayoutArray = std::array<Ref<BindGroupLayoutBase>, kMaxBindGroups>;
+
+ class PipelineLayoutBase : public ObjectBase {
+ public:
+ PipelineLayoutBase(DeviceBase* device, const PipelineLayoutDescriptor* descriptor);
+
+ const BindGroupLayoutBase* GetBindGroupLayout(size_t group) const;
+ const std::bitset<kMaxBindGroups> GetBindGroupLayoutsMask() const;
+
+ // Utility functions to compute inherited bind groups.
+ // Returns the inherited bind groups as a mask.
+ std::bitset<kMaxBindGroups> InheritedGroupsMask(const PipelineLayoutBase* other) const;
+
+ // Returns the index of the first incompatible bind group in the range
+ // [1, kMaxBindGroups + 1]
+ uint32_t GroupsInheritUpTo(const PipelineLayoutBase* other) const;
+
+ protected:
+ BindGroupLayoutArray mBindGroupLayouts;
+ std::bitset<kMaxBindGroups> mMask;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_PIPELINELAYOUT_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/ProgrammablePassEncoder.cpp b/chromium/third_party/dawn/src/dawn_native/ProgrammablePassEncoder.cpp
new file mode 100644
index 00000000000..2f042f80a8f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ProgrammablePassEncoder.cpp
@@ -0,0 +1,83 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/ProgrammablePassEncoder.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/CommandBuffer.h"
+#include "dawn_native/Commands.h"
+
+namespace dawn_native {
+
+ ProgrammablePassEncoder::ProgrammablePassEncoder(DeviceBase* device,
+ CommandBufferBuilder* topLevelBuilder,
+ CommandAllocator* allocator)
+ : ObjectBase(device), mTopLevelBuilder(topLevelBuilder), mAllocator(allocator) {
+ }
+
+ void ProgrammablePassEncoder::EndPass() {
+ mTopLevelBuilder->PassEnded();
+ mAllocator = nullptr;
+ }
+
+ void ProgrammablePassEncoder::SetBindGroup(uint32_t groupIndex, BindGroupBase* group) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ if (groupIndex >= kMaxBindGroups) {
+ mTopLevelBuilder->HandleError("Setting bind group over the max");
+ return;
+ }
+
+ SetBindGroupCmd* cmd = mAllocator->Allocate<SetBindGroupCmd>(Command::SetBindGroup);
+ new (cmd) SetBindGroupCmd;
+ cmd->index = groupIndex;
+ cmd->group = group;
+ }
+
+ void ProgrammablePassEncoder::SetPushConstants(dawn::ShaderStageBit stages,
+ uint32_t offset,
+ uint32_t count,
+ const void* data) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ // TODO(cwallez@chromium.org): check for overflows
+ if (offset + count > kMaxPushConstants) {
+ mTopLevelBuilder->HandleError("Setting too many push constants");
+ return;
+ }
+
+ SetPushConstantsCmd* cmd =
+ mAllocator->Allocate<SetPushConstantsCmd>(Command::SetPushConstants);
+ new (cmd) SetPushConstantsCmd;
+ cmd->stages = stages;
+ cmd->offset = offset;
+ cmd->count = count;
+
+ uint32_t* values = mAllocator->AllocateData<uint32_t>(count);
+ memcpy(values, data, count * sizeof(uint32_t));
+ }
+
+ MaybeError ProgrammablePassEncoder::ValidateCanRecordCommands() const {
+ if (mAllocator == nullptr) {
+ return DAWN_VALIDATION_ERROR("Recording in an already ended pass encoder");
+ }
+
+ return nullptr;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/ProgrammablePassEncoder.h b/chromium/third_party/dawn/src/dawn_native/ProgrammablePassEncoder.h
new file mode 100644
index 00000000000..2606096d515
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ProgrammablePassEncoder.h
@@ -0,0 +1,55 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_PROGRAMMABLEPASSENCODER_H_
+#define DAWNNATIVE_PROGRAMMABLEPASSENCODER_H_
+
+#include "dawn_native/Error.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+
+ class CommandAllocator;
+ class DeviceBase;
+
+ // Base class for shared functionality between ComputePassEncoder and RenderPassEncoder.
+ class ProgrammablePassEncoder : public ObjectBase {
+ public:
+ ProgrammablePassEncoder(DeviceBase* device,
+ CommandBufferBuilder* topLevelBuilder,
+ CommandAllocator* allocator);
+
+ void EndPass();
+
+ void SetBindGroup(uint32_t groupIndex, BindGroupBase* group);
+ void SetPushConstants(dawn::ShaderStageBit stages,
+ uint32_t offset,
+ uint32_t count,
+ const void* data);
+
+ protected:
+ MaybeError ValidateCanRecordCommands() const;
+
+ // The allocator is borrowed from the top level builder. Keep a reference to the builder
+ // to make sure the allocator isn't freed.
+ Ref<CommandBufferBuilder> mTopLevelBuilder = nullptr;
+ // mAllocator is cleared at the end of the pass so it acts as a tag that EndPass was called
+ CommandAllocator* mAllocator = nullptr;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_PROGRAMMABLEPASSENCODER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Queue.cpp b/chromium/third_party/dawn/src/dawn_native/Queue.cpp
new file mode 100644
index 00000000000..021a095da53
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Queue.cpp
@@ -0,0 +1,61 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Queue.h"
+
+#include "dawn_native/Buffer.h"
+#include "dawn_native/CommandBuffer.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/Texture.h"
+
+namespace dawn_native {
+
+ // QueueBase
+
+ QueueBase::QueueBase(DeviceBase* device) : ObjectBase(device) {
+ }
+
+ void QueueBase::Submit(uint32_t numCommands, CommandBufferBase* const* commands) {
+ if (GetDevice()->ConsumedError(ValidateSubmit(numCommands, commands))) {
+ return;
+ }
+
+ SubmitImpl(numCommands, commands);
+ }
+
+ MaybeError QueueBase::ValidateSubmit(uint32_t numCommands, CommandBufferBase* const* commands) {
+ for (uint32_t i = 0; i < numCommands; ++i) {
+ const CommandBufferResourceUsage& usages = commands[i]->GetResourceUsages();
+
+ for (const PassResourceUsage& passUsages : usages.perPass) {
+ for (const BufferBase* buffer : passUsages.buffers) {
+ DAWN_TRY(buffer->ValidateCanUseInSubmitNow());
+ }
+ for (const TextureBase* texture : passUsages.textures) {
+ DAWN_TRY(texture->ValidateCanUseInSubmitNow());
+ }
+ }
+
+ for (const BufferBase* buffer : usages.topLevelBuffers) {
+ DAWN_TRY(buffer->ValidateCanUseInSubmitNow());
+ }
+ for (const TextureBase* texture : usages.topLevelTextures) {
+ DAWN_TRY(texture->ValidateCanUseInSubmitNow());
+ }
+ }
+
+ return {};
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Queue.h b/chromium/third_party/dawn/src/dawn_native/Queue.h
new file mode 100644
index 00000000000..a9655f2d81f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Queue.h
@@ -0,0 +1,42 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_QUEUE_H_
+#define DAWNNATIVE_QUEUE_H_
+
+#include "dawn_native/Builder.h"
+#include "dawn_native/Error.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+
+ class QueueBase : public ObjectBase {
+ public:
+ QueueBase(DeviceBase* device);
+
+ // Dawn API
+ void Submit(uint32_t numCommands, CommandBufferBase* const* commands);
+
+ private:
+ virtual void SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) = 0;
+
+ MaybeError ValidateSubmit(uint32_t numCommands, CommandBufferBase* const* commands);
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_QUEUE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/RefCounted.cpp b/chromium/third_party/dawn/src/dawn_native/RefCounted.cpp
new file mode 100644
index 00000000000..64a4817b047
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/RefCounted.cpp
@@ -0,0 +1,77 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/RefCounted.h"
+
+#include "common/Assert.h"
+
+namespace dawn_native {
+
+ RefCounted::RefCounted() {
+ }
+
+ RefCounted::~RefCounted() {
+ }
+
+ void RefCounted::ReferenceInternal() {
+ ASSERT(mInternalRefs != 0);
+
+ // TODO(cwallez@chromium.org): what to do on overflow?
+ mInternalRefs++;
+ }
+
+ void RefCounted::ReleaseInternal() {
+ ASSERT(mInternalRefs != 0);
+
+ mInternalRefs--;
+
+ if (mInternalRefs == 0) {
+ ASSERT(mExternalRefs == 0);
+ // TODO(cwallez@chromium.org): would this work with custom allocators?
+ delete this;
+ }
+ }
+
+ uint32_t RefCounted::GetExternalRefs() const {
+ return mExternalRefs;
+ }
+
+ uint32_t RefCounted::GetInternalRefs() const {
+ return mInternalRefs;
+ }
+
+ void RefCounted::Reference() {
+ ASSERT(mInternalRefs != 0);
+
+ // mExternalRefs != 0 counts as one internal ref.
+ if (mExternalRefs == 0) {
+ ReferenceInternal();
+ }
+
+ // TODO(cwallez@chromium.org): what to do on overflow?
+ mExternalRefs++;
+ }
+
+ void RefCounted::Release() {
+ ASSERT(mInternalRefs != 0);
+ ASSERT(mExternalRefs != 0);
+
+ mExternalRefs--;
+ // mExternalRefs != 0 counts as one internal ref.
+ if (mExternalRefs == 0) {
+ ReleaseInternal();
+ }
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/RefCounted.h b/chromium/third_party/dawn/src/dawn_native/RefCounted.h
new file mode 100644
index 00000000000..ccc63f9344d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/RefCounted.h
@@ -0,0 +1,129 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_REFCOUNTED_H_
+#define DAWNNATIVE_REFCOUNTED_H_
+
+#include <cstdint>
+
+namespace dawn_native {
+
+ class RefCounted {
+ public:
+ RefCounted();
+ virtual ~RefCounted();
+
+ void ReferenceInternal();
+ void ReleaseInternal();
+
+ uint32_t GetExternalRefs() const;
+ uint32_t GetInternalRefs() const;
+
+ // Dawn API
+ void Reference();
+ void Release();
+
+ protected:
+ uint32_t mExternalRefs = 1;
+ uint32_t mInternalRefs = 1;
+ };
+
+ template <typename T>
+ class Ref {
+ public:
+ Ref() {
+ }
+
+ Ref(T* p) : mPointee(p) {
+ Reference();
+ }
+
+ Ref(const Ref<T>& other) : mPointee(other.mPointee) {
+ Reference();
+ }
+ Ref<T>& operator=(const Ref<T>& other) {
+ if (&other == this)
+ return *this;
+
+ other.Reference();
+ Release();
+ mPointee = other.mPointee;
+
+ return *this;
+ }
+
+ Ref(Ref<T>&& other) {
+ mPointee = other.mPointee;
+ other.mPointee = nullptr;
+ }
+ Ref<T>& operator=(Ref<T>&& other) {
+ if (&other == this)
+ return *this;
+
+ Release();
+ mPointee = other.mPointee;
+ other.mPointee = nullptr;
+
+ return *this;
+ }
+
+ ~Ref() {
+ Release();
+ mPointee = nullptr;
+ }
+
+ operator bool() {
+ return mPointee != nullptr;
+ }
+
+ const T& operator*() const {
+ return *mPointee;
+ }
+ T& operator*() {
+ return *mPointee;
+ }
+
+ const T* operator->() const {
+ return mPointee;
+ }
+ T* operator->() {
+ return mPointee;
+ }
+
+ const T* Get() const {
+ return mPointee;
+ }
+ T* Get() {
+ return mPointee;
+ }
+
+ private:
+ void Reference() const {
+ if (mPointee != nullptr) {
+ mPointee->ReferenceInternal();
+ }
+ }
+ void Release() const {
+ if (mPointee != nullptr) {
+ mPointee->ReleaseInternal();
+ }
+ }
+
+ // static_assert(std::is_base_of<RefCounted, T>::value, "");
+ T* mPointee = nullptr;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_REFCOUNTED_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/RenderPassDescriptor.cpp b/chromium/third_party/dawn/src/dawn_native/RenderPassDescriptor.cpp
new file mode 100644
index 00000000000..1426095021b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/RenderPassDescriptor.cpp
@@ -0,0 +1,211 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/RenderPassDescriptor.h"
+
+#include "common/Assert.h"
+#include "common/BitSetIterator.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/Texture.h"
+
+namespace dawn_native {
+
+ // RenderPassDescriptor
+
+ RenderPassDescriptorBase::RenderPassDescriptorBase(RenderPassDescriptorBuilder* builder)
+ : ObjectBase(builder->GetDevice()),
+ mColorAttachmentsSet(builder->mColorAttachmentsSet),
+ mColorAttachments(builder->mColorAttachments),
+ mDepthStencilAttachmentSet(builder->mDepthStencilAttachmentSet),
+ mDepthStencilAttachment(builder->mDepthStencilAttachment),
+ mWidth(builder->mWidth),
+ mHeight(builder->mHeight) {
+ }
+
+ std::bitset<kMaxColorAttachments> RenderPassDescriptorBase::GetColorAttachmentMask() const {
+ return mColorAttachmentsSet;
+ }
+
+ bool RenderPassDescriptorBase::HasDepthStencilAttachment() const {
+ return mDepthStencilAttachmentSet;
+ }
+
+ const RenderPassColorAttachmentInfo& RenderPassDescriptorBase::GetColorAttachment(
+ uint32_t attachment) const {
+ ASSERT(attachment < kMaxColorAttachments);
+ ASSERT(mColorAttachmentsSet[attachment]);
+
+ return mColorAttachments[attachment];
+ }
+
+ RenderPassColorAttachmentInfo& RenderPassDescriptorBase::GetColorAttachment(
+ uint32_t attachment) {
+ ASSERT(attachment < kMaxColorAttachments);
+ ASSERT(mColorAttachmentsSet[attachment]);
+
+ return mColorAttachments[attachment];
+ }
+
+ const RenderPassDepthStencilAttachmentInfo&
+ RenderPassDescriptorBase::GetDepthStencilAttachment() const {
+ ASSERT(mDepthStencilAttachmentSet);
+
+ return mDepthStencilAttachment;
+ }
+
+ RenderPassDepthStencilAttachmentInfo& RenderPassDescriptorBase::GetDepthStencilAttachment() {
+ ASSERT(mDepthStencilAttachmentSet);
+
+ return mDepthStencilAttachment;
+ }
+
+ uint32_t RenderPassDescriptorBase::GetWidth() const {
+ return mWidth;
+ }
+
+ uint32_t RenderPassDescriptorBase::GetHeight() const {
+ return mHeight;
+ }
+
+ // RenderPassDescriptorBuilder
+
+ RenderPassDescriptorBuilder::RenderPassDescriptorBuilder(DeviceBase* device) : Builder(device) {
+ }
+
+ bool RenderPassDescriptorBuilder::CheckArrayLayersAndLevelCountForAttachment(
+ const TextureViewBase* textureView) {
+ // Currently we do not support layered rendering.
+ if (textureView->GetLayerCount() > 1) {
+ HandleError(
+ "The layer count of the texture view used as attachment cannot be greater than 1");
+ return false;
+ }
+
+ if (textureView->GetLevelCount() > 1) {
+ HandleError(
+ "The mipmap level count of the texture view used as attachment cannot be greater "
+ "than 1");
+ return false;
+ }
+ return true;
+ }
+
+ RenderPassDescriptorBase* RenderPassDescriptorBuilder::GetResultImpl() {
+ auto CheckOrSetSize = [this](const TextureViewBase* attachment) -> bool {
+ if (this->mWidth == 0) {
+ ASSERT(this->mHeight == 0);
+
+ this->mWidth = attachment->GetTexture()->GetSize().width;
+ this->mHeight = attachment->GetTexture()->GetSize().height;
+ ASSERT(this->mWidth != 0 && this->mHeight != 0);
+
+ return true;
+ }
+
+ ASSERT(this->mWidth != 0 && this->mHeight != 0);
+ return this->mWidth == attachment->GetTexture()->GetSize().width &&
+ this->mHeight == attachment->GetTexture()->GetSize().height;
+ };
+
+ uint32_t attachmentCount = 0;
+ for (uint32_t i : IterateBitSet(mColorAttachmentsSet)) {
+ attachmentCount++;
+ if (!CheckOrSetSize(mColorAttachments[i].view.Get())) {
+ HandleError("Attachment size mismatch");
+ return nullptr;
+ }
+ }
+
+ if (mDepthStencilAttachmentSet) {
+ attachmentCount++;
+ if (!CheckOrSetSize(mDepthStencilAttachment.view.Get())) {
+ HandleError("Attachment size mismatch");
+ return nullptr;
+ }
+ }
+
+ if (attachmentCount == 0) {
+ HandleError("Should have at least one attachment");
+ return nullptr;
+ }
+
+ return GetDevice()->CreateRenderPassDescriptor(this);
+ }
+
+ void RenderPassDescriptorBuilder::SetColorAttachment(uint32_t attachment,
+ TextureViewBase* textureView,
+ dawn::LoadOp loadOp) {
+ if (attachment >= kMaxColorAttachments) {
+ HandleError("Setting color attachment out of bounds");
+ return;
+ }
+
+ if (!IsColorRenderableTextureFormat(textureView->GetFormat())) {
+ HandleError(
+ "The format of the texture view used as color attachment is not color renderable");
+ return;
+ }
+
+ if (!CheckArrayLayersAndLevelCountForAttachment(textureView)) {
+ return;
+ }
+
+ mColorAttachmentsSet.set(attachment);
+ mColorAttachments[attachment].loadOp = loadOp;
+ mColorAttachments[attachment].view = textureView;
+ }
+
+ void RenderPassDescriptorBuilder::SetColorAttachmentClearColor(uint32_t attachment,
+ float clearR,
+ float clearG,
+ float clearB,
+ float clearA) {
+ if (attachment >= kMaxColorAttachments) {
+ HandleError("Setting color attachment out of bounds");
+ return;
+ }
+
+ mColorAttachments[attachment].clearColor[0] = clearR;
+ mColorAttachments[attachment].clearColor[1] = clearG;
+ mColorAttachments[attachment].clearColor[2] = clearB;
+ mColorAttachments[attachment].clearColor[3] = clearA;
+ }
+
+ void RenderPassDescriptorBuilder::SetDepthStencilAttachment(TextureViewBase* textureView,
+ dawn::LoadOp depthLoadOp,
+ dawn::LoadOp stencilLoadOp) {
+ if (!TextureFormatHasDepthOrStencil(textureView->GetFormat())) {
+ HandleError(
+ "The format of the texture view used as depth stencil attachment is not a depth "
+ "stencil format");
+ return;
+ }
+
+ if (!CheckArrayLayersAndLevelCountForAttachment(textureView)) {
+ return;
+ }
+
+ mDepthStencilAttachmentSet = true;
+ mDepthStencilAttachment.depthLoadOp = depthLoadOp;
+ mDepthStencilAttachment.stencilLoadOp = stencilLoadOp;
+ mDepthStencilAttachment.view = textureView;
+ }
+
+ void RenderPassDescriptorBuilder::SetDepthStencilAttachmentClearValue(float clearDepth,
+ uint32_t clearStencil) {
+ mDepthStencilAttachment.clearDepth = clearDepth;
+ mDepthStencilAttachment.clearStencil = clearStencil;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/RenderPassDescriptor.h b/chromium/third_party/dawn/src/dawn_native/RenderPassDescriptor.h
new file mode 100644
index 00000000000..9ee4cd0263f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/RenderPassDescriptor.h
@@ -0,0 +1,111 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_RENDERPASSDESCRIPTOR_H_
+#define DAWNNATIVE_RENDERPASSDESCRIPTOR_H_
+
+#include "common/Constants.h"
+#include "dawn_native/Builder.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+#include <vector>
+
+namespace dawn_native {
+
+ struct RenderPassColorAttachmentInfo {
+ dawn::LoadOp loadOp;
+ std::array<float, 4> clearColor = {{0.0f, 0.0f, 0.0f, 0.0f}};
+ Ref<TextureViewBase> view;
+ };
+
+ struct RenderPassDepthStencilAttachmentInfo {
+ dawn::LoadOp depthLoadOp;
+ dawn::LoadOp stencilLoadOp;
+ float clearDepth = 1.0f;
+ uint32_t clearStencil = 0;
+ Ref<TextureViewBase> view;
+ };
+
+ // RenderPassDescriptor contains the list of attachments for a renderpass along with data such
+ // as the load operation and the clear values for the attachments.
+
+ class RenderPassDescriptorBase : public ObjectBase {
+ public:
+ RenderPassDescriptorBase(RenderPassDescriptorBuilder* builder);
+
+ std::bitset<kMaxColorAttachments> GetColorAttachmentMask() const;
+ bool HasDepthStencilAttachment() const;
+
+ const RenderPassColorAttachmentInfo& GetColorAttachment(uint32_t attachment) const;
+ RenderPassColorAttachmentInfo& GetColorAttachment(uint32_t attachment);
+ const RenderPassDepthStencilAttachmentInfo& GetDepthStencilAttachment() const;
+ RenderPassDepthStencilAttachmentInfo& GetDepthStencilAttachment();
+
+ // All attachments of the render pass have the same size, these return that size.
+ uint32_t GetWidth() const;
+ uint32_t GetHeight() const;
+
+ private:
+ std::bitset<kMaxColorAttachments> mColorAttachmentsSet;
+ std::array<RenderPassColorAttachmentInfo, kMaxColorAttachments> mColorAttachments;
+
+ bool mDepthStencilAttachmentSet;
+ RenderPassDepthStencilAttachmentInfo mDepthStencilAttachment;
+
+ uint32_t mWidth;
+ uint32_t mHeight;
+ };
+
+ class RenderPassDescriptorBuilder : public Builder<RenderPassDescriptorBase> {
+ public:
+ RenderPassDescriptorBuilder(DeviceBase* device);
+
+ // Dawn API
+ RenderPassDescriptorBase* GetResultImpl() override;
+ void SetColorAttachment(uint32_t attachment,
+ TextureViewBase* textureView,
+ dawn::LoadOp loadOp);
+ void SetColorAttachmentClearColor(uint32_t attachment,
+ float clearR,
+ float clearG,
+ float clearB,
+ float clearA);
+ void SetDepthStencilAttachment(TextureViewBase* textureView,
+ dawn::LoadOp depthLoadOp,
+ dawn::LoadOp stencilLoadOp);
+ void SetDepthStencilAttachmentClearValue(float clearDepth, uint32_t clearStencil);
+
+ private:
+ friend class RenderPassDescriptorBase;
+
+ bool CheckArrayLayersAndLevelCountForAttachment(const TextureViewBase* textureView);
+
+ std::bitset<kMaxColorAttachments> mColorAttachmentsSet;
+ std::array<RenderPassColorAttachmentInfo, kMaxColorAttachments> mColorAttachments;
+
+ bool mDepthStencilAttachmentSet = false;
+ RenderPassDepthStencilAttachmentInfo mDepthStencilAttachment;
+
+ uint32_t mWidth = 0;
+ uint32_t mHeight = 0;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_RENDERPASS_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/RenderPassEncoder.cpp b/chromium/third_party/dawn/src/dawn_native/RenderPassEncoder.cpp
new file mode 100644
index 00000000000..6e4ec813762
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/RenderPassEncoder.cpp
@@ -0,0 +1,147 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/RenderPassEncoder.h"
+
+#include "dawn_native/Buffer.h"
+#include "dawn_native/CommandBuffer.h"
+#include "dawn_native/Commands.h"
+#include "dawn_native/RenderPipeline.h"
+
+namespace dawn_native {
+
+ RenderPassEncoderBase::RenderPassEncoderBase(DeviceBase* device,
+ CommandBufferBuilder* topLevelBuilder,
+ CommandAllocator* allocator)
+ : ProgrammablePassEncoder(device, topLevelBuilder, allocator) {
+ }
+
+ void RenderPassEncoderBase::DrawArrays(uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t firstVertex,
+ uint32_t firstInstance) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ DrawArraysCmd* draw = mAllocator->Allocate<DrawArraysCmd>(Command::DrawArrays);
+ new (draw) DrawArraysCmd;
+ draw->vertexCount = vertexCount;
+ draw->instanceCount = instanceCount;
+ draw->firstVertex = firstVertex;
+ draw->firstInstance = firstInstance;
+ }
+
+ void RenderPassEncoderBase::DrawElements(uint32_t indexCount,
+ uint32_t instanceCount,
+ uint32_t firstIndex,
+ uint32_t firstInstance) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ DrawElementsCmd* draw = mAllocator->Allocate<DrawElementsCmd>(Command::DrawElements);
+ new (draw) DrawElementsCmd;
+ draw->indexCount = indexCount;
+ draw->instanceCount = instanceCount;
+ draw->firstIndex = firstIndex;
+ draw->firstInstance = firstInstance;
+ }
+
+ void RenderPassEncoderBase::SetRenderPipeline(RenderPipelineBase* pipeline) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ SetRenderPipelineCmd* cmd =
+ mAllocator->Allocate<SetRenderPipelineCmd>(Command::SetRenderPipeline);
+ new (cmd) SetRenderPipelineCmd;
+ cmd->pipeline = pipeline;
+ }
+
+ void RenderPassEncoderBase::SetStencilReference(uint32_t reference) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ SetStencilReferenceCmd* cmd =
+ mAllocator->Allocate<SetStencilReferenceCmd>(Command::SetStencilReference);
+ new (cmd) SetStencilReferenceCmd;
+ cmd->reference = reference;
+ }
+
+ void RenderPassEncoderBase::SetBlendColor(float r, float g, float b, float a) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ SetBlendColorCmd* cmd = mAllocator->Allocate<SetBlendColorCmd>(Command::SetBlendColor);
+ new (cmd) SetBlendColorCmd;
+ cmd->r = r;
+ cmd->g = g;
+ cmd->b = b;
+ cmd->a = a;
+ }
+
+ void RenderPassEncoderBase::SetScissorRect(uint32_t x,
+ uint32_t y,
+ uint32_t width,
+ uint32_t height) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ SetScissorRectCmd* cmd = mAllocator->Allocate<SetScissorRectCmd>(Command::SetScissorRect);
+ new (cmd) SetScissorRectCmd;
+ cmd->x = x;
+ cmd->y = y;
+ cmd->width = width;
+ cmd->height = height;
+ }
+
+ void RenderPassEncoderBase::SetIndexBuffer(BufferBase* buffer, uint32_t offset) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ SetIndexBufferCmd* cmd = mAllocator->Allocate<SetIndexBufferCmd>(Command::SetIndexBuffer);
+ new (cmd) SetIndexBufferCmd;
+ cmd->buffer = buffer;
+ cmd->offset = offset;
+ }
+
+ void RenderPassEncoderBase::SetVertexBuffers(uint32_t startSlot,
+ uint32_t count,
+ BufferBase* const* buffers,
+ uint32_t const* offsets) {
+ if (mTopLevelBuilder->ConsumedError(ValidateCanRecordCommands())) {
+ return;
+ }
+
+ SetVertexBuffersCmd* cmd =
+ mAllocator->Allocate<SetVertexBuffersCmd>(Command::SetVertexBuffers);
+ new (cmd) SetVertexBuffersCmd;
+ cmd->startSlot = startSlot;
+ cmd->count = count;
+
+ Ref<BufferBase>* cmdBuffers = mAllocator->AllocateData<Ref<BufferBase>>(count);
+ for (size_t i = 0; i < count; ++i) {
+ new (&cmdBuffers[i]) Ref<BufferBase>(buffers[i]);
+ }
+
+ uint32_t* cmdOffsets = mAllocator->AllocateData<uint32_t>(count);
+ memcpy(cmdOffsets, offsets, count * sizeof(uint32_t));
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/RenderPassEncoder.h b/chromium/third_party/dawn/src/dawn_native/RenderPassEncoder.h
new file mode 100644
index 00000000000..c2bdad8a9ae
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/RenderPassEncoder.h
@@ -0,0 +1,66 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_RENDERPASSENCODER_H_
+#define DAWNNATIVE_RENDERPASSENCODER_H_
+
+#include "dawn_native/Error.h"
+#include "dawn_native/ProgrammablePassEncoder.h"
+
+namespace dawn_native {
+
+ // This is called RenderPassEncoderBase to match the code generator expectations. Note that it
+ // is a pure frontend type to record in its parent CommandBufferBuilder and never has a backend
+ // implementation.
+ // TODO(cwallez@chromium.org): Remove that generator limitation and rename to ComputePassEncoder
+ class RenderPassEncoderBase : public ProgrammablePassEncoder {
+ public:
+ RenderPassEncoderBase(DeviceBase* device,
+ CommandBufferBuilder* topLevelBuilder,
+ CommandAllocator* allocator);
+
+ void DrawArrays(uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t firstVertex,
+ uint32_t firstInstance);
+ void DrawElements(uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t firstIndex,
+ uint32_t firstInstance);
+
+ void SetRenderPipeline(RenderPipelineBase* pipeline);
+
+ void SetStencilReference(uint32_t reference);
+ void SetBlendColor(float r, float g, float b, float a);
+ void SetScissorRect(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
+
+ template <typename T>
+ void SetVertexBuffers(uint32_t startSlot,
+ uint32_t count,
+ T* const* buffers,
+ uint32_t const* offsets) {
+ static_assert(std::is_base_of<BufferBase, T>::value, "");
+ SetVertexBuffers(startSlot, count, reinterpret_cast<BufferBase* const*>(buffers),
+ offsets);
+ }
+ void SetVertexBuffers(uint32_t startSlot,
+ uint32_t count,
+ BufferBase* const* buffers,
+ uint32_t const* offsets);
+ void SetIndexBuffer(BufferBase* buffer, uint32_t offset);
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_RENDERPASSENCODER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/RenderPipeline.cpp b/chromium/third_party/dawn/src/dawn_native/RenderPipeline.cpp
new file mode 100644
index 00000000000..047ad2570b0
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/RenderPipeline.cpp
@@ -0,0 +1,222 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/RenderPipeline.h"
+
+#include "common/BitSetIterator.h"
+#include "dawn_native/BlendState.h"
+#include "dawn_native/DepthStencilState.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/InputState.h"
+#include "dawn_native/RenderPassDescriptor.h"
+#include "dawn_native/Texture.h"
+
+namespace dawn_native {
+
+ // RenderPipelineBase
+
+ RenderPipelineBase::RenderPipelineBase(RenderPipelineBuilder* builder)
+ : PipelineBase(builder->GetDevice(), builder),
+ mDepthStencilState(std::move(builder->mDepthStencilState)),
+ mIndexFormat(builder->mIndexFormat),
+ mInputState(std::move(builder->mInputState)),
+ mPrimitiveTopology(builder->mPrimitiveTopology),
+ mBlendStates(builder->mBlendStates),
+ mColorAttachmentsSet(builder->mColorAttachmentsSet),
+ mColorAttachmentFormats(builder->mColorAttachmentFormats),
+ mDepthStencilFormatSet(builder->mDepthStencilFormatSet),
+ mDepthStencilFormat(builder->mDepthStencilFormat) {
+ if (GetStageMask() != (dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment)) {
+ builder->HandleError("Render pipeline should have exactly a vertex and fragment stage");
+ return;
+ }
+
+ // TODO(kainino@chromium.org): Need to verify the pipeline against its render subpass.
+
+ if ((builder->GetStageInfo(dawn::ShaderStage::Vertex).module->GetUsedVertexAttributes() &
+ ~mInputState->GetAttributesSetMask())
+ .any()) {
+ builder->HandleError("Pipeline vertex stage uses inputs not in the input state");
+ return;
+ }
+
+ // TODO(cwallez@chromium.org): Check against the shader module that the correct color
+ // attachment are set?
+
+ size_t attachmentCount = mColorAttachmentsSet.count();
+ if (mDepthStencilFormatSet) {
+ attachmentCount++;
+ }
+
+ if (attachmentCount == 0) {
+ builder->HandleError("Should have at least one attachment");
+ return;
+ }
+ }
+
+ BlendStateBase* RenderPipelineBase::GetBlendState(uint32_t attachmentSlot) {
+ ASSERT(attachmentSlot < mBlendStates.size());
+ return mBlendStates[attachmentSlot].Get();
+ }
+
+ DepthStencilStateBase* RenderPipelineBase::GetDepthStencilState() {
+ return mDepthStencilState.Get();
+ }
+
+ dawn::IndexFormat RenderPipelineBase::GetIndexFormat() const {
+ return mIndexFormat;
+ }
+
+ InputStateBase* RenderPipelineBase::GetInputState() {
+ return mInputState.Get();
+ }
+
+ dawn::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const {
+ return mPrimitiveTopology;
+ }
+
+ std::bitset<kMaxColorAttachments> RenderPipelineBase::GetColorAttachmentsMask() const {
+ return mColorAttachmentsSet;
+ }
+
+ bool RenderPipelineBase::HasDepthStencilAttachment() const {
+ return mDepthStencilFormatSet;
+ }
+
+ dawn::TextureFormat RenderPipelineBase::GetColorAttachmentFormat(uint32_t attachment) const {
+ return mColorAttachmentFormats[attachment];
+ }
+
+ dawn::TextureFormat RenderPipelineBase::GetDepthStencilFormat() const {
+ return mDepthStencilFormat;
+ }
+
+ bool RenderPipelineBase::IsCompatibleWith(const RenderPassDescriptorBase* renderPass) const {
+ // TODO(cwallez@chromium.org): This is called on every SetPipeline command. Optimize it for
+ // example by caching some "attachment compatibility" object that would make the
+ // compatibility check a single pointer comparison.
+
+ if (renderPass->GetColorAttachmentMask() != mColorAttachmentsSet) {
+ return false;
+ }
+
+ for (uint32_t i : IterateBitSet(mColorAttachmentsSet)) {
+ if (renderPass->GetColorAttachment(i).view->GetTexture()->GetFormat() !=
+ mColorAttachmentFormats[i]) {
+ return false;
+ }
+ }
+
+ if (renderPass->HasDepthStencilAttachment() != mDepthStencilFormatSet) {
+ return false;
+ }
+
+ if (mDepthStencilFormatSet &&
+ (renderPass->GetDepthStencilAttachment().view->GetTexture()->GetFormat() !=
+ mDepthStencilFormat)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ // RenderPipelineBuilder
+
+ RenderPipelineBuilder::RenderPipelineBuilder(DeviceBase* device)
+ : Builder(device), PipelineBuilder(this) {
+ }
+
+ RenderPipelineBase* RenderPipelineBuilder::GetResultImpl() {
+ DeviceBase* device = GetDevice();
+ // TODO(cwallez@chromium.org): the layout should be required, and put the default objects in
+ // the device
+ if (!mInputState) {
+ auto builder = device->CreateInputStateBuilder();
+ mInputState = builder->GetResult();
+ // Remove the external ref objects are created with
+ mInputState->Release();
+ builder->Release();
+ }
+ if (!mDepthStencilState) {
+ auto builder = device->CreateDepthStencilStateBuilder();
+ mDepthStencilState = builder->GetResult();
+ // Remove the external ref objects are created with
+ mDepthStencilState->Release();
+ builder->Release();
+ }
+
+ if ((mBlendStatesSet | mColorAttachmentsSet) != mColorAttachmentsSet) {
+ HandleError("Blend state set on unset color attachment");
+ return nullptr;
+ }
+
+ // Assign all color attachments without a blend state the default state
+ // TODO(enga@google.com): Put the default objects in the device
+ for (uint32_t attachmentSlot : IterateBitSet(mColorAttachmentsSet & ~mBlendStatesSet)) {
+ mBlendStates[attachmentSlot] = device->CreateBlendStateBuilder()->GetResult();
+ // Remove the external ref objects are created with
+ mBlendStates[attachmentSlot]->Release();
+ }
+
+ return device->CreateRenderPipeline(this);
+ }
+
+ void RenderPipelineBuilder::SetColorAttachmentFormat(uint32_t attachmentSlot,
+ dawn::TextureFormat format) {
+ if (attachmentSlot >= kMaxColorAttachments) {
+ HandleError("Attachment index out of bounds");
+ return;
+ }
+
+ mColorAttachmentsSet.set(attachmentSlot);
+ mColorAttachmentFormats[attachmentSlot] = format;
+ }
+
+ void RenderPipelineBuilder::SetColorAttachmentBlendState(uint32_t attachmentSlot,
+ BlendStateBase* blendState) {
+ if (attachmentSlot >= kMaxColorAttachments) {
+ HandleError("Attachment index out of bounds");
+ return;
+ }
+ if (mBlendStatesSet[attachmentSlot]) {
+ HandleError("Attachment blend state already set");
+ return;
+ }
+
+ mBlendStatesSet.set(attachmentSlot);
+ mBlendStates[attachmentSlot] = blendState;
+ }
+
+ void RenderPipelineBuilder::SetDepthStencilState(DepthStencilStateBase* depthStencilState) {
+ mDepthStencilState = depthStencilState;
+ }
+
+ void RenderPipelineBuilder::SetDepthStencilAttachmentFormat(dawn::TextureFormat format) {
+ mDepthStencilFormatSet = true;
+ mDepthStencilFormat = format;
+ }
+
+ void RenderPipelineBuilder::SetIndexFormat(dawn::IndexFormat format) {
+ mIndexFormat = format;
+ }
+
+ void RenderPipelineBuilder::SetInputState(InputStateBase* inputState) {
+ mInputState = inputState;
+ }
+
+ void RenderPipelineBuilder::SetPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
+ mPrimitiveTopology = primitiveTopology;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/RenderPipeline.h b/chromium/third_party/dawn/src/dawn_native/RenderPipeline.h
new file mode 100644
index 00000000000..73362e7268e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/RenderPipeline.h
@@ -0,0 +1,96 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_RENDERPIPELINE_H_
+#define DAWNNATIVE_RENDERPIPELINE_H_
+
+#include "dawn_native/BlendState.h"
+#include "dawn_native/DepthStencilState.h"
+#include "dawn_native/InputState.h"
+#include "dawn_native/Pipeline.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+
+namespace dawn_native {
+
+ class RenderPipelineBase : public PipelineBase {
+ public:
+ RenderPipelineBase(RenderPipelineBuilder* builder);
+
+ BlendStateBase* GetBlendState(uint32_t attachmentSlot);
+ DepthStencilStateBase* GetDepthStencilState();
+ dawn::IndexFormat GetIndexFormat() const;
+ InputStateBase* GetInputState();
+ dawn::PrimitiveTopology GetPrimitiveTopology() const;
+
+ std::bitset<kMaxColorAttachments> GetColorAttachmentsMask() const;
+ bool HasDepthStencilAttachment() const;
+ dawn::TextureFormat GetColorAttachmentFormat(uint32_t attachment) const;
+ dawn::TextureFormat GetDepthStencilFormat() const;
+
+ // A pipeline can be used in a render pass if its attachment info matches the actual
+ // attachments in the render pass. This returns whether it is the case.
+ bool IsCompatibleWith(const RenderPassDescriptorBase* renderPass) const;
+
+ private:
+ Ref<DepthStencilStateBase> mDepthStencilState;
+ dawn::IndexFormat mIndexFormat;
+ Ref<InputStateBase> mInputState;
+ dawn::PrimitiveTopology mPrimitiveTopology;
+ std::array<Ref<BlendStateBase>, kMaxColorAttachments> mBlendStates;
+
+ std::bitset<kMaxColorAttachments> mColorAttachmentsSet;
+ std::array<dawn::TextureFormat, kMaxColorAttachments> mColorAttachmentFormats;
+ bool mDepthStencilFormatSet = false;
+ dawn::TextureFormat mDepthStencilFormat;
+ };
+
+ class RenderPipelineBuilder : public Builder<RenderPipelineBase>, public PipelineBuilder {
+ public:
+ RenderPipelineBuilder(DeviceBase* device);
+
+ // Dawn API
+ void SetColorAttachmentFormat(uint32_t attachmentSlot, dawn::TextureFormat format);
+ void SetColorAttachmentBlendState(uint32_t attachmentSlot, BlendStateBase* blendState);
+ void SetDepthStencilAttachmentFormat(dawn::TextureFormat format);
+ void SetDepthStencilState(DepthStencilStateBase* depthStencilState);
+ void SetPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology);
+ void SetIndexFormat(dawn::IndexFormat format);
+ void SetInputState(InputStateBase* inputState);
+
+ private:
+ friend class RenderPipelineBase;
+
+ RenderPipelineBase* GetResultImpl() override;
+
+ Ref<DepthStencilStateBase> mDepthStencilState;
+ Ref<InputStateBase> mInputState;
+ // TODO(enga@google.com): Remove default when we validate that all required properties are
+ // set
+ dawn::PrimitiveTopology mPrimitiveTopology = dawn::PrimitiveTopology::TriangleList;
+ dawn::IndexFormat mIndexFormat = dawn::IndexFormat::Uint32;
+ std::bitset<kMaxColorAttachments> mBlendStatesSet;
+ std::array<Ref<BlendStateBase>, kMaxColorAttachments> mBlendStates;
+ std::bitset<kMaxColorAttachments> mColorAttachmentsSet;
+ std::array<dawn::TextureFormat, kMaxColorAttachments> mColorAttachmentFormats;
+ bool mDepthStencilFormatSet = false;
+ dawn::TextureFormat mDepthStencilFormat;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_RENDERPIPELINE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Sampler.cpp b/chromium/third_party/dawn/src/dawn_native/Sampler.cpp
new file mode 100644
index 00000000000..71cca99b4c3
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Sampler.cpp
@@ -0,0 +1,40 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Sampler.h"
+
+#include "dawn_native/Device.h"
+#include "dawn_native/ValidationUtils_autogen.h"
+
+namespace dawn_native {
+
+ MaybeError ValidateSamplerDescriptor(DeviceBase*, const SamplerDescriptor* descriptor) {
+ if (descriptor->nextInChain != nullptr) {
+ return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
+ }
+ DAWN_TRY(ValidateFilterMode(descriptor->minFilter));
+ DAWN_TRY(ValidateFilterMode(descriptor->magFilter));
+ DAWN_TRY(ValidateFilterMode(descriptor->mipmapFilter));
+ DAWN_TRY(ValidateAddressMode(descriptor->addressModeU));
+ DAWN_TRY(ValidateAddressMode(descriptor->addressModeV));
+ DAWN_TRY(ValidateAddressMode(descriptor->addressModeW));
+ return {};
+ }
+
+ // SamplerBase
+
+ SamplerBase::SamplerBase(DeviceBase* device, const SamplerDescriptor*) : ObjectBase(device) {
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Sampler.h b/chromium/third_party/dawn/src/dawn_native/Sampler.h
new file mode 100644
index 00000000000..a9d547a63ca
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Sampler.h
@@ -0,0 +1,36 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_SAMPLER_H_
+#define DAWNNATIVE_SAMPLER_H_
+
+#include "dawn_native/Error.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+
+ class DeviceBase;
+
+ MaybeError ValidateSamplerDescriptor(DeviceBase* device, const SamplerDescriptor* descriptor);
+
+ class SamplerBase : public ObjectBase {
+ public:
+ SamplerBase(DeviceBase* device, const SamplerDescriptor* descriptor);
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_SAMPLER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/ShaderModule.cpp b/chromium/third_party/dawn/src/dawn_native/ShaderModule.cpp
new file mode 100644
index 00000000000..d7867a3ec3b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ShaderModule.cpp
@@ -0,0 +1,259 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/ShaderModule.h"
+
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/Pipeline.h"
+#include "dawn_native/PipelineLayout.h"
+
+#include <spirv-cross/spirv_cross.hpp>
+#include <spirv-tools/libspirv.hpp>
+
+namespace dawn_native {
+
+ MaybeError ValidateShaderModuleDescriptor(DeviceBase*,
+ const ShaderModuleDescriptor* descriptor) {
+ if (descriptor->nextInChain != nullptr) {
+ return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
+ }
+
+ spvtools::SpirvTools spirvTools(SPV_ENV_VULKAN_1_1);
+
+ std::ostringstream errorStream;
+ errorStream << "SPIRV Validation failure:" << std::endl;
+
+ spirvTools.SetMessageConsumer([&errorStream](spv_message_level_t level, const char*,
+ const spv_position_t& position,
+ const char* message) {
+ switch (level) {
+ case SPV_MSG_FATAL:
+ case SPV_MSG_INTERNAL_ERROR:
+ case SPV_MSG_ERROR:
+ errorStream << "error: line " << position.index << ": " << message << std::endl;
+ break;
+ case SPV_MSG_WARNING:
+ errorStream << "warning: line " << position.index << ": " << message
+ << std::endl;
+ break;
+ case SPV_MSG_INFO:
+ errorStream << "info: line " << position.index << ": " << message << std::endl;
+ break;
+ default:
+ break;
+ }
+ });
+
+ if (!spirvTools.Validate(descriptor->code, descriptor->codeSize)) {
+ return DAWN_VALIDATION_ERROR(errorStream.str().c_str());
+ }
+
+ return {};
+ }
+
+ // ShaderModuleBase
+
+ ShaderModuleBase::ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor*)
+ : ObjectBase(device) {
+ }
+
+ void ShaderModuleBase::ExtractSpirvInfo(const spirv_cross::Compiler& compiler) {
+ DeviceBase* device = GetDevice();
+ // TODO(cwallez@chromium.org): make errors here builder-level
+ // currently errors here do not prevent the shadermodule from being used
+ const auto& resources = compiler.get_shader_resources();
+
+ switch (compiler.get_execution_model()) {
+ case spv::ExecutionModelVertex:
+ mExecutionModel = dawn::ShaderStage::Vertex;
+ break;
+ case spv::ExecutionModelFragment:
+ mExecutionModel = dawn::ShaderStage::Fragment;
+ break;
+ case spv::ExecutionModelGLCompute:
+ mExecutionModel = dawn::ShaderStage::Compute;
+ break;
+ default:
+ UNREACHABLE();
+ }
+
+ // Extract push constants
+ mPushConstants.mask.reset();
+ mPushConstants.sizes.fill(0);
+ mPushConstants.types.fill(PushConstantType::Int);
+
+ if (resources.push_constant_buffers.size() > 0) {
+ auto interfaceBlock = resources.push_constant_buffers[0];
+
+ const auto& blockType = compiler.get_type(interfaceBlock.type_id);
+ ASSERT(blockType.basetype == spirv_cross::SPIRType::Struct);
+
+ for (uint32_t i = 0; i < blockType.member_types.size(); i++) {
+ ASSERT(compiler.get_member_decoration_bitset(blockType.self, i)
+ .get(spv::DecorationOffset));
+
+ uint32_t offset =
+ compiler.get_member_decoration(blockType.self, i, spv::DecorationOffset);
+ ASSERT(offset % 4 == 0);
+ offset /= 4;
+
+ auto memberType = compiler.get_type(blockType.member_types[i]);
+ PushConstantType constantType;
+ if (memberType.basetype == spirv_cross::SPIRType::Int) {
+ constantType = PushConstantType::Int;
+ } else if (memberType.basetype == spirv_cross::SPIRType::UInt) {
+ constantType = PushConstantType::UInt;
+ } else {
+ ASSERT(memberType.basetype == spirv_cross::SPIRType::Float);
+ constantType = PushConstantType::Float;
+ }
+
+ // TODO(cwallez@chromium.org): check for overflows and make the logic better take
+ // into account things like the array of types with padding.
+ uint32_t size = memberType.vecsize * memberType.columns;
+ // Handle unidimensional arrays
+ if (!memberType.array.empty()) {
+ size *= memberType.array[0];
+ }
+
+ if (offset + size > kMaxPushConstants) {
+ device->HandleError("Push constant block too big in the SPIRV");
+ return;
+ }
+
+ mPushConstants.mask.set(offset);
+ mPushConstants.names[offset] =
+ interfaceBlock.name + "." + compiler.get_member_name(blockType.self, i);
+ mPushConstants.sizes[offset] = size;
+ mPushConstants.types[offset] = constantType;
+ }
+ }
+
+ // Fill in bindingInfo with the SPIRV bindings
+ auto ExtractResourcesBinding = [this](const std::vector<spirv_cross::Resource>& resources,
+ const spirv_cross::Compiler& compiler,
+ dawn::BindingType bindingType) {
+ for (const auto& resource : resources) {
+ ASSERT(compiler.get_decoration_bitset(resource.id).get(spv::DecorationBinding));
+ ASSERT(
+ compiler.get_decoration_bitset(resource.id).get(spv::DecorationDescriptorSet));
+
+ uint32_t binding = compiler.get_decoration(resource.id, spv::DecorationBinding);
+ uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
+
+ if (binding >= kMaxBindingsPerGroup || set >= kMaxBindGroups) {
+ GetDevice()->HandleError("Binding over limits in the SPIRV");
+ continue;
+ }
+
+ auto& info = mBindingInfo[set][binding];
+ info.used = true;
+ info.id = resource.id;
+ info.base_type_id = resource.base_type_id;
+ info.type = bindingType;
+ }
+ };
+
+ ExtractResourcesBinding(resources.uniform_buffers, compiler,
+ dawn::BindingType::UniformBuffer);
+ ExtractResourcesBinding(resources.separate_images, compiler,
+ dawn::BindingType::SampledTexture);
+ ExtractResourcesBinding(resources.separate_samplers, compiler, dawn::BindingType::Sampler);
+ ExtractResourcesBinding(resources.storage_buffers, compiler,
+ dawn::BindingType::StorageBuffer);
+
+ // Extract the vertex attributes
+ if (mExecutionModel == dawn::ShaderStage::Vertex) {
+ for (const auto& attrib : resources.stage_inputs) {
+ ASSERT(compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation));
+ uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation);
+
+ if (location >= kMaxVertexAttributes) {
+ device->HandleError("Attribute location over limits in the SPIRV");
+ return;
+ }
+
+ mUsedVertexAttributes.set(location);
+ }
+
+ // Without a location qualifier on vertex outputs, spirv_cross::CompilerMSL gives them
+ // all the location 0, causing a compile error.
+ for (const auto& attrib : resources.stage_outputs) {
+ if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) {
+ device->HandleError("Need location qualifier on vertex output");
+ return;
+ }
+ }
+ }
+
+ if (mExecutionModel == dawn::ShaderStage::Fragment) {
+ // Without a location qualifier on vertex inputs, spirv_cross::CompilerMSL gives them
+ // all the location 0, causing a compile error.
+ for (const auto& attrib : resources.stage_inputs) {
+ if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) {
+ device->HandleError("Need location qualifier on fragment input");
+ return;
+ }
+ }
+ }
+ }
+
+ const ShaderModuleBase::PushConstantInfo& ShaderModuleBase::GetPushConstants() const {
+ return mPushConstants;
+ }
+
+ const ShaderModuleBase::ModuleBindingInfo& ShaderModuleBase::GetBindingInfo() const {
+ return mBindingInfo;
+ }
+
+ const std::bitset<kMaxVertexAttributes>& ShaderModuleBase::GetUsedVertexAttributes() const {
+ return mUsedVertexAttributes;
+ }
+
+ dawn::ShaderStage ShaderModuleBase::GetExecutionModel() const {
+ return mExecutionModel;
+ }
+
+ bool ShaderModuleBase::IsCompatibleWithPipelineLayout(const PipelineLayoutBase* layout) {
+ for (size_t group = 0; group < kMaxBindGroups; ++group) {
+ if (!IsCompatibleWithBindGroupLayout(group, layout->GetBindGroupLayout(group))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ bool ShaderModuleBase::IsCompatibleWithBindGroupLayout(size_t group,
+ const BindGroupLayoutBase* layout) {
+ const auto& layoutInfo = layout->GetBindingInfo();
+ for (size_t i = 0; i < kMaxBindingsPerGroup; ++i) {
+ const auto& moduleInfo = mBindingInfo[group][i];
+
+ if (!moduleInfo.used) {
+ continue;
+ }
+
+ if (moduleInfo.type != layoutInfo.types[i]) {
+ return false;
+ }
+ if ((layoutInfo.visibilities[i] & StageBit(mExecutionModel)) == 0) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/ShaderModule.h b/chromium/third_party/dawn/src/dawn_native/ShaderModule.h
new file mode 100644
index 00000000000..1d0fcf186d5
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ShaderModule.h
@@ -0,0 +1,81 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_SHADERMODULE_H_
+#define DAWNNATIVE_SHADERMODULE_H_
+
+#include "common/Constants.h"
+#include "dawn_native/Builder.h"
+#include "dawn_native/Error.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+#include <vector>
+
+namespace spirv_cross {
+ class Compiler;
+}
+
+namespace dawn_native {
+
+ MaybeError ValidateShaderModuleDescriptor(DeviceBase* device,
+ const ShaderModuleDescriptor* descriptor);
+
+ class ShaderModuleBase : public ObjectBase {
+ public:
+ ShaderModuleBase(DeviceBase* device, const ShaderModuleDescriptor* descriptor);
+
+ void ExtractSpirvInfo(const spirv_cross::Compiler& compiler);
+
+ struct PushConstantInfo {
+ std::bitset<kMaxPushConstants> mask;
+
+ std::array<std::string, kMaxPushConstants> names;
+ std::array<uint32_t, kMaxPushConstants> sizes;
+ std::array<PushConstantType, kMaxPushConstants> types;
+ };
+
+ struct BindingInfo {
+ // The SPIRV ID of the resource.
+ uint32_t id;
+ uint32_t base_type_id;
+ dawn::BindingType type;
+ bool used = false;
+ };
+ using ModuleBindingInfo =
+ std::array<std::array<BindingInfo, kMaxBindingsPerGroup>, kMaxBindGroups>;
+
+ const PushConstantInfo& GetPushConstants() const;
+ const ModuleBindingInfo& GetBindingInfo() const;
+ const std::bitset<kMaxVertexAttributes>& GetUsedVertexAttributes() const;
+ dawn::ShaderStage GetExecutionModel() const;
+
+ bool IsCompatibleWithPipelineLayout(const PipelineLayoutBase* layout);
+
+ private:
+ bool IsCompatibleWithBindGroupLayout(size_t group, const BindGroupLayoutBase* layout);
+
+ PushConstantInfo mPushConstants = {};
+ ModuleBindingInfo mBindingInfo;
+ std::bitset<kMaxVertexAttributes> mUsedVertexAttributes;
+ dawn::ShaderStage mExecutionModel;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_SHADERMODULE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/SwapChain.cpp b/chromium/third_party/dawn/src/dawn_native/SwapChain.cpp
new file mode 100644
index 00000000000..6314a0da0f4
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/SwapChain.cpp
@@ -0,0 +1,118 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/SwapChain.h"
+
+#include "dawn_native/Device.h"
+#include "dawn_native/Texture.h"
+
+namespace dawn_native {
+
+ // SwapChain
+
+ SwapChainBase::SwapChainBase(SwapChainBuilder* builder)
+ : ObjectBase(builder->GetDevice()), mImplementation(builder->mImplementation) {
+ }
+
+ SwapChainBase::~SwapChainBase() {
+ const auto& im = GetImplementation();
+ im.Destroy(im.userData);
+ }
+
+ void SwapChainBase::Configure(dawn::TextureFormat format,
+ dawn::TextureUsageBit allowedUsage,
+ uint32_t width,
+ uint32_t height) {
+ if (width == 0 || height == 0) {
+ GetDevice()->HandleError("Swap chain cannot be configured to zero size");
+ return;
+ }
+ allowedUsage |= dawn::TextureUsageBit::Present;
+
+ mFormat = format;
+ mAllowedUsage = allowedUsage;
+ mWidth = width;
+ mHeight = height;
+ mImplementation.Configure(mImplementation.userData, static_cast<dawnTextureFormat>(format),
+ static_cast<dawnTextureUsageBit>(allowedUsage), width, height);
+ }
+
+ TextureBase* SwapChainBase::GetNextTexture() {
+ if (mWidth == 0) {
+ // If width is 0, it implies swap chain has never been configured
+ GetDevice()->HandleError("Swap chain needs to be configured before GetNextTexture");
+ return nullptr;
+ }
+
+ TextureDescriptor descriptor;
+ descriptor.dimension = dawn::TextureDimension::e2D;
+ descriptor.size.width = mWidth;
+ descriptor.size.height = mHeight;
+ descriptor.size.depth = 1;
+ descriptor.arrayLayer = 1;
+ descriptor.format = mFormat;
+ descriptor.levelCount = 1;
+ descriptor.usage = mAllowedUsage;
+
+ auto* texture = GetNextTextureImpl(&descriptor);
+ mLastNextTexture = texture;
+ return texture;
+ }
+
+ void SwapChainBase::Present(TextureBase* texture) {
+ if (texture != mLastNextTexture) {
+ GetDevice()->HandleError("Tried to present something other than the last NextTexture");
+ return;
+ }
+
+ OnBeforePresent(texture);
+
+ mImplementation.Present(mImplementation.userData);
+ }
+
+ const dawnSwapChainImplementation& SwapChainBase::GetImplementation() {
+ return mImplementation;
+ }
+
+ // SwapChain Builder
+
+ SwapChainBuilder::SwapChainBuilder(DeviceBase* device) : Builder(device) {
+ }
+
+ SwapChainBase* SwapChainBuilder::GetResultImpl() {
+ if (!mImplementation.Init) {
+ HandleError("Implementation not set");
+ return nullptr;
+ }
+ return GetDevice()->CreateSwapChain(this);
+ }
+
+ void SwapChainBuilder::SetImplementation(uint64_t implementation) {
+ if (!implementation) {
+ HandleError("Implementation pointer is invalid");
+ return;
+ }
+
+ dawnSwapChainImplementation& impl =
+ *reinterpret_cast<dawnSwapChainImplementation*>(implementation);
+
+ if (!impl.Init || !impl.Destroy || !impl.Configure || !impl.GetNextTexture ||
+ !impl.Present) {
+ HandleError("Implementation is incomplete");
+ return;
+ }
+
+ mImplementation = impl;
+ }
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/SwapChain.h b/chromium/third_party/dawn/src/dawn_native/SwapChain.h
new file mode 100644
index 00000000000..de51a0a6164
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/SwapChain.h
@@ -0,0 +1,70 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_SWAPCHAIN_H_
+#define DAWNNATIVE_SWAPCHAIN_H_
+
+#include "dawn_native/Builder.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn/dawn_wsi.h"
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+
+ class SwapChainBase : public ObjectBase {
+ public:
+ SwapChainBase(SwapChainBuilder* builder);
+ ~SwapChainBase();
+
+ // Dawn API
+ void Configure(dawn::TextureFormat format,
+ dawn::TextureUsageBit allowedUsage,
+ uint32_t width,
+ uint32_t height);
+ TextureBase* GetNextTexture();
+ void Present(TextureBase* texture);
+
+ protected:
+ const dawnSwapChainImplementation& GetImplementation();
+ virtual TextureBase* GetNextTextureImpl(const TextureDescriptor*) = 0;
+ virtual void OnBeforePresent(TextureBase* texture) = 0;
+
+ private:
+ dawnSwapChainImplementation mImplementation = {};
+ dawn::TextureFormat mFormat = {};
+ dawn::TextureUsageBit mAllowedUsage;
+ uint32_t mWidth = 0;
+ uint32_t mHeight = 0;
+ TextureBase* mLastNextTexture = nullptr;
+ };
+
+ class SwapChainBuilder : public Builder<SwapChainBase> {
+ public:
+ SwapChainBuilder(DeviceBase* device);
+
+ // Dawn API
+ SwapChainBase* GetResultImpl() override;
+ void SetImplementation(uint64_t implementation);
+
+ private:
+ friend class SwapChainBase;
+
+ dawnSwapChainImplementation mImplementation = {};
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_SWAPCHAIN_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/Texture.cpp b/chromium/third_party/dawn/src/dawn_native/Texture.cpp
new file mode 100644
index 00000000000..0923fccb79b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Texture.cpp
@@ -0,0 +1,326 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/Texture.h"
+
+#include "common/Assert.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/ValidationUtils_autogen.h"
+
+namespace dawn_native {
+ namespace {
+ // TODO(jiawei.shao@intel.com): implement texture view format compatibility rule
+ MaybeError ValidateTextureViewFormatCompatibility(const TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ if (texture->GetFormat() != descriptor->format) {
+ return DAWN_VALIDATION_ERROR(
+ "The format of texture view is not compatible to the original texture");
+ }
+
+ return {};
+ }
+
+ // TODO(jiawei.shao@intel.com): support validation on all texture view dimensions
+ bool IsTextureViewDimensionCompatibleWithTextureDimension(
+ dawn::TextureViewDimension textureViewDimension,
+ dawn::TextureDimension textureDimension) {
+ switch (textureViewDimension) {
+ case dawn::TextureViewDimension::e2D:
+ case dawn::TextureViewDimension::e2DArray:
+ case dawn::TextureViewDimension::Cube:
+ case dawn::TextureViewDimension::CubeArray:
+ return textureDimension == dawn::TextureDimension::e2D;
+ default:
+ UNREACHABLE();
+ return false;
+ }
+ }
+
+ // TODO(jiawei.shao@intel.com): support validation on all texture view dimensions
+ bool IsArrayLayerValidForTextureViewDimension(
+ dawn::TextureViewDimension textureViewDimension,
+ uint32_t textureViewArrayLayer) {
+ switch (textureViewDimension) {
+ case dawn::TextureViewDimension::e2D:
+ return textureViewArrayLayer == 1u;
+ case dawn::TextureViewDimension::e2DArray:
+ return true;
+ case dawn::TextureViewDimension::Cube:
+ return textureViewArrayLayer == 6u;
+ case dawn::TextureViewDimension::CubeArray:
+ return textureViewArrayLayer % 6 == 0;
+ default:
+ UNREACHABLE();
+ return false;
+ }
+ }
+
+ bool IsTextureSizeValidForTextureViewDimension(
+ dawn::TextureViewDimension textureViewDimension,
+ const Extent3D& textureSize) {
+ switch (textureViewDimension) {
+ case dawn::TextureViewDimension::Cube:
+ case dawn::TextureViewDimension::CubeArray:
+ return textureSize.width == textureSize.height;
+ case dawn::TextureViewDimension::e2D:
+ case dawn::TextureViewDimension::e2DArray:
+ return true;
+ default:
+ UNREACHABLE();
+ return false;
+ }
+ }
+
+ MaybeError ValidateTextureViewDimensionCompatibility(
+ const TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ if (!IsArrayLayerValidForTextureViewDimension(descriptor->dimension,
+ descriptor->layerCount)) {
+ return DAWN_VALIDATION_ERROR(
+ "The dimension of the texture view is not compatible with the layer count");
+ }
+
+ if (!IsTextureViewDimensionCompatibleWithTextureDimension(descriptor->dimension,
+ texture->GetDimension())) {
+ return DAWN_VALIDATION_ERROR(
+ "The dimension of the texture view is not compatible with the dimension of the"
+ "original texture");
+ }
+
+ if (!IsTextureSizeValidForTextureViewDimension(descriptor->dimension,
+ texture->GetSize())) {
+ return DAWN_VALIDATION_ERROR(
+ "The dimension of the texture view is not compatible with the size of the"
+ "original texture");
+ }
+
+ return {};
+ }
+
+ TextureViewDescriptor MakeDefaultTextureViewDescriptor(const TextureBase* texture) {
+ TextureViewDescriptor descriptor;
+ descriptor.format = texture->GetFormat();
+ descriptor.baseArrayLayer = 0;
+ descriptor.layerCount = texture->GetArrayLayers();
+ descriptor.baseMipLevel = 0;
+ descriptor.levelCount = texture->GetNumMipLevels();
+
+ // TODO(jiawei.shao@intel.com): support all texture dimensions.
+ switch (texture->GetDimension()) {
+ case dawn::TextureDimension::e2D:
+ if (texture->GetArrayLayers() == 1u) {
+ descriptor.dimension = dawn::TextureViewDimension::e2D;
+ } else {
+ descriptor.dimension = dawn::TextureViewDimension::e2DArray;
+ }
+ break;
+ default:
+ UNREACHABLE();
+ }
+
+ return descriptor;
+ }
+
+ } // anonymous namespace
+
+ MaybeError ValidateTextureDescriptor(DeviceBase*, const TextureDescriptor* descriptor) {
+ if (descriptor->nextInChain != nullptr) {
+ return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
+ }
+
+ DAWN_TRY(ValidateTextureUsageBit(descriptor->usage));
+ DAWN_TRY(ValidateTextureDimension(descriptor->dimension));
+ DAWN_TRY(ValidateTextureFormat(descriptor->format));
+
+ // TODO(jiawei.shao@intel.com): check stuff based on the dimension
+ if (descriptor->size.width == 0 || descriptor->size.height == 0 ||
+ descriptor->size.depth == 0 || descriptor->arrayLayer == 0 ||
+ descriptor->levelCount == 0) {
+ return DAWN_VALIDATION_ERROR("Cannot create an empty texture");
+ }
+
+ return {};
+ }
+
+ MaybeError ValidateTextureViewDescriptor(const DeviceBase*,
+ const TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ if (descriptor->nextInChain != nullptr) {
+ return DAWN_VALIDATION_ERROR("nextInChain must be nullptr");
+ }
+
+ DAWN_TRY(ValidateTextureViewDimension(descriptor->dimension));
+ DAWN_TRY(ValidateTextureFormat(descriptor->format));
+
+ // TODO(jiawei.shao@intel.com): check stuff based on resource limits
+ if (descriptor->layerCount == 0 || descriptor->levelCount == 0) {
+ return DAWN_VALIDATION_ERROR("Cannot create an empty texture view");
+ }
+
+ if (uint64_t(descriptor->baseArrayLayer) + uint64_t(descriptor->layerCount) >
+ uint64_t(texture->GetArrayLayers())) {
+ return DAWN_VALIDATION_ERROR("Texture view array-layer out of range");
+ }
+
+ if (uint64_t(descriptor->baseMipLevel) + uint64_t(descriptor->levelCount) >
+ uint64_t(texture->GetNumMipLevels())) {
+ return DAWN_VALIDATION_ERROR("Texture view mip-level out of range");
+ }
+
+ DAWN_TRY(ValidateTextureViewFormatCompatibility(texture, descriptor));
+ DAWN_TRY(ValidateTextureViewDimensionCompatibility(texture, descriptor));
+
+ return {};
+ }
+
+ uint32_t TextureFormatPixelSize(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::R8Unorm:
+ case dawn::TextureFormat::R8Uint:
+ return 1;
+ case dawn::TextureFormat::R8G8Unorm:
+ case dawn::TextureFormat::R8G8Uint:
+ return 2;
+ case dawn::TextureFormat::R8G8B8A8Unorm:
+ case dawn::TextureFormat::R8G8B8A8Uint:
+ case dawn::TextureFormat::B8G8R8A8Unorm:
+ return 4;
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return 8;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ bool TextureFormatHasDepth(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ bool TextureFormatHasStencil(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ bool TextureFormatHasDepthOrStencil(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ bool IsColorRenderableTextureFormat(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::B8G8R8A8Unorm:
+ case dawn::TextureFormat::R8G8B8A8Uint:
+ case dawn::TextureFormat::R8G8B8A8Unorm:
+ case dawn::TextureFormat::R8G8Uint:
+ case dawn::TextureFormat::R8G8Unorm:
+ case dawn::TextureFormat::R8Uint:
+ case dawn::TextureFormat::R8Unorm:
+ return true;
+
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return false;
+
+ default:
+ UNREACHABLE();
+ return false;
+ }
+ }
+
+ // TextureBase
+
+ TextureBase::TextureBase(DeviceBase* device, const TextureDescriptor* descriptor)
+ : ObjectBase(device),
+ mDimension(descriptor->dimension),
+ mFormat(descriptor->format),
+ mSize(descriptor->size),
+ mArrayLayers(descriptor->arrayLayer),
+ mNumMipLevels(descriptor->levelCount),
+ mUsage(descriptor->usage) {
+ }
+
+ dawn::TextureDimension TextureBase::GetDimension() const {
+ return mDimension;
+ }
+ dawn::TextureFormat TextureBase::GetFormat() const {
+ return mFormat;
+ }
+ const Extent3D& TextureBase::GetSize() const {
+ return mSize;
+ }
+ uint32_t TextureBase::GetArrayLayers() const {
+ return mArrayLayers;
+ }
+ uint32_t TextureBase::GetNumMipLevels() const {
+ return mNumMipLevels;
+ }
+ dawn::TextureUsageBit TextureBase::GetUsage() const {
+ return mUsage;
+ }
+
+ MaybeError TextureBase::ValidateCanUseInSubmitNow() const {
+ return {};
+ }
+
+ TextureViewBase* TextureBase::CreateDefaultTextureView() {
+ TextureViewDescriptor descriptor = MakeDefaultTextureViewDescriptor(this);
+ return GetDevice()->CreateTextureView(this, &descriptor);
+ }
+
+ TextureViewBase* TextureBase::CreateTextureView(const TextureViewDescriptor* descriptor) {
+ return GetDevice()->CreateTextureView(this, descriptor);
+ }
+
+ // TextureViewBase
+
+ TextureViewBase::TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor)
+ : ObjectBase(texture->GetDevice()),
+ mTexture(texture),
+ mFormat(descriptor->format),
+ mLevelCount(descriptor->levelCount),
+ mLayerCount(descriptor->layerCount) {
+ }
+
+ const TextureBase* TextureViewBase::GetTexture() const {
+ return mTexture.Get();
+ }
+
+ TextureBase* TextureViewBase::GetTexture() {
+ return mTexture.Get();
+ }
+
+ dawn::TextureFormat TextureViewBase::GetFormat() const {
+ return mFormat;
+ }
+
+ uint32_t TextureViewBase::GetLevelCount() const {
+ return mLevelCount;
+ }
+
+ uint32_t TextureViewBase::GetLayerCount() const {
+ return mLayerCount;
+ }
+} // namespace dawn_native
diff --git a/chromium/third_party/dawn/src/dawn_native/Texture.h b/chromium/third_party/dawn/src/dawn_native/Texture.h
new file mode 100644
index 00000000000..f1194f05b22
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/Texture.h
@@ -0,0 +1,92 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_TEXTURE_H_
+#define DAWNNATIVE_TEXTURE_H_
+
+#include "dawn_native/Builder.h"
+#include "dawn_native/Error.h"
+#include "dawn_native/Forward.h"
+#include "dawn_native/ObjectBase.h"
+
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native {
+ MaybeError ValidateTextureDescriptor(DeviceBase* device, const TextureDescriptor* descriptor);
+ MaybeError ValidateTextureViewDescriptor(const DeviceBase* device,
+ const TextureBase* texture,
+ const TextureViewDescriptor* descriptor);
+
+ uint32_t TextureFormatPixelSize(dawn::TextureFormat format);
+ bool TextureFormatHasDepth(dawn::TextureFormat format);
+ bool TextureFormatHasStencil(dawn::TextureFormat format);
+ bool TextureFormatHasDepthOrStencil(dawn::TextureFormat format);
+ bool IsColorRenderableTextureFormat(dawn::TextureFormat format);
+
+ static constexpr dawn::TextureUsageBit kReadOnlyTextureUsages =
+ dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::Sampled |
+ dawn::TextureUsageBit::Present;
+
+ static constexpr dawn::TextureUsageBit kWritableTextureUsages =
+ dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Storage |
+ dawn::TextureUsageBit::OutputAttachment;
+
+ class TextureBase : public ObjectBase {
+ public:
+ TextureBase(DeviceBase* device, const TextureDescriptor* descriptor);
+
+ dawn::TextureDimension GetDimension() const;
+ dawn::TextureFormat GetFormat() const;
+ const Extent3D& GetSize() const;
+ uint32_t GetArrayLayers() const;
+ uint32_t GetNumMipLevels() const;
+ dawn::TextureUsageBit GetUsage() const;
+
+ MaybeError ValidateCanUseInSubmitNow() const;
+
+ // Dawn API
+ TextureViewBase* CreateDefaultTextureView();
+ TextureViewBase* CreateTextureView(const TextureViewDescriptor* descriptor);
+
+ private:
+ dawn::TextureDimension mDimension;
+ dawn::TextureFormat mFormat;
+ Extent3D mSize;
+ uint32_t mArrayLayers;
+ uint32_t mNumMipLevels;
+ dawn::TextureUsageBit mUsage = dawn::TextureUsageBit::None;
+ };
+
+ class TextureViewBase : public ObjectBase {
+ public:
+ TextureViewBase(TextureBase* texture, const TextureViewDescriptor* descriptor);
+
+ const TextureBase* GetTexture() const;
+ TextureBase* GetTexture();
+
+ dawn::TextureFormat GetFormat() const;
+ uint32_t GetLevelCount() const;
+ uint32_t GetLayerCount() const;
+
+ private:
+ Ref<TextureBase> mTexture;
+
+ dawn::TextureFormat mFormat;
+ uint32_t mLevelCount;
+ uint32_t mLayerCount;
+ };
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_TEXTURE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/ToBackend.h b/chromium/third_party/dawn/src/dawn_native/ToBackend.h
new file mode 100644
index 00000000000..1e64f2c80c1
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/ToBackend.h
@@ -0,0 +1,154 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_TOBACKEND_H_
+#define DAWNNATIVE_TOBACKEND_H_
+
+#include "dawn_native/Forward.h"
+
+namespace dawn_native {
+
+ // ToBackendTraits implements the mapping from base type to member type of BackendTraits
+ template <typename T, typename BackendTraits>
+ struct ToBackendTraits;
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<BindGroupBase, BackendTraits> {
+ using BackendType = typename BackendTraits::BindGroupType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<BindGroupLayoutBase, BackendTraits> {
+ using BackendType = typename BackendTraits::BindGroupLayoutType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<BlendStateBase, BackendTraits> {
+ using BackendType = typename BackendTraits::BlendStateType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<BufferBase, BackendTraits> {
+ using BackendType = typename BackendTraits::BufferType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<BufferViewBase, BackendTraits> {
+ using BackendType = typename BackendTraits::BufferViewType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<CommandBufferBase, BackendTraits> {
+ using BackendType = typename BackendTraits::CommandBufferType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<ComputePipelineBase, BackendTraits> {
+ using BackendType = typename BackendTraits::ComputePipelineType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<DepthStencilStateBase, BackendTraits> {
+ using BackendType = typename BackendTraits::DepthStencilStateType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<DeviceBase, BackendTraits> {
+ using BackendType = typename BackendTraits::DeviceType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<InputStateBase, BackendTraits> {
+ using BackendType = typename BackendTraits::InputStateType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<PipelineLayoutBase, BackendTraits> {
+ using BackendType = typename BackendTraits::PipelineLayoutType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<QueueBase, BackendTraits> {
+ using BackendType = typename BackendTraits::QueueType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<RenderPassDescriptorBase, BackendTraits> {
+ using BackendType = typename BackendTraits::RenderPassDescriptorType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<RenderPipelineBase, BackendTraits> {
+ using BackendType = typename BackendTraits::RenderPipelineType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<SamplerBase, BackendTraits> {
+ using BackendType = typename BackendTraits::SamplerType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<ShaderModuleBase, BackendTraits> {
+ using BackendType = typename BackendTraits::ShaderModuleType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<TextureBase, BackendTraits> {
+ using BackendType = typename BackendTraits::TextureType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<SwapChainBase, BackendTraits> {
+ using BackendType = typename BackendTraits::SwapChainType;
+ };
+
+ template <typename BackendTraits>
+ struct ToBackendTraits<TextureViewBase, BackendTraits> {
+ using BackendType = typename BackendTraits::TextureViewType;
+ };
+
+ // ToBackendBase implements conversion to the given BackendTraits
+ // To use it in a backend, use the following:
+ // template<typename T>
+ // auto ToBackend(T&& common) -> decltype(ToBackendBase<MyBackendTraits>(common)) {
+ // return ToBackendBase<MyBackendTraits>(common);
+ // }
+
+ template <typename BackendTraits, typename T>
+ Ref<typename ToBackendTraits<T, BackendTraits>::BackendType>& ToBackendBase(Ref<T>& common) {
+ return reinterpret_cast<Ref<typename ToBackendTraits<T, BackendTraits>::BackendType>&>(
+ common);
+ }
+
+ template <typename BackendTraits, typename T>
+ const Ref<typename ToBackendTraits<T, BackendTraits>::BackendType>& ToBackendBase(
+ const Ref<T>& common) {
+ return reinterpret_cast<
+ const Ref<typename ToBackendTraits<T, BackendTraits>::BackendType>&>(common);
+ }
+
+ template <typename BackendTraits, typename T>
+ typename ToBackendTraits<T, BackendTraits>::BackendType* ToBackendBase(T* common) {
+ return reinterpret_cast<typename ToBackendTraits<T, BackendTraits>::BackendType*>(common);
+ }
+
+ template <typename BackendTraits, typename T>
+ const typename ToBackendTraits<T, BackendTraits>::BackendType* ToBackendBase(const T* common) {
+ return reinterpret_cast<const typename ToBackendTraits<T, BackendTraits>::BackendType*>(
+ common);
+ }
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_TOBACKEND_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupD3D12.cpp
new file mode 100644
index 00000000000..c013d80d30d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupD3D12.cpp
@@ -0,0 +1,103 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/BindGroupD3D12.h"
+#include "common/BitSetIterator.h"
+#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
+#include "dawn_native/d3d12/BufferD3D12.h"
+#include "dawn_native/d3d12/SamplerD3D12.h"
+#include "dawn_native/d3d12/TextureD3D12.h"
+
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ BindGroup::BindGroup(BindGroupBuilder* builder) : BindGroupBase(builder) {
+ }
+
+ void BindGroup::RecordDescriptors(const DescriptorHeapHandle& cbvUavSrvHeapStart,
+ uint32_t* cbvUavSrvHeapOffset,
+ const DescriptorHeapHandle& samplerHeapStart,
+ uint32_t* samplerHeapOffset,
+ uint64_t serial,
+ uint32_t indexInSubmit) {
+ mHeapSerial = serial;
+ mIndexInSubmit = indexInSubmit;
+
+ const auto* bgl = ToBackend(GetLayout());
+ const auto& layout = bgl->GetBindingInfo();
+
+ // Save the offset to the start of the descriptor table in the heap
+ mCbvUavSrvHeapOffset = *cbvUavSrvHeapOffset;
+ mSamplerHeapOffset = *samplerHeapOffset;
+
+ const auto& bindingOffsets = bgl->GetBindingOffsets();
+
+ auto d3d12Device = ToBackend(GetDevice())->GetD3D12Device();
+ for (uint32_t binding : IterateBitSet(layout.mask)) {
+ switch (layout.types[binding]) {
+ case dawn::BindingType::UniformBuffer: {
+ auto* view = ToBackend(GetBindingAsBufferView(binding));
+ auto& cbv = view->GetCBVDescriptor();
+ d3d12Device->CreateConstantBufferView(
+ &cbv, cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
+ bindingOffsets[binding]));
+ } break;
+ case dawn::BindingType::StorageBuffer: {
+ auto* view = ToBackend(GetBindingAsBufferView(binding));
+ auto& uav = view->GetUAVDescriptor();
+ d3d12Device->CreateUnorderedAccessView(
+ ToBackend(view->GetBuffer())->GetD3D12Resource().Get(), nullptr, &uav,
+ cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
+ bindingOffsets[binding]));
+ } break;
+ case dawn::BindingType::SampledTexture: {
+ auto* view = ToBackend(GetBindingAsTextureView(binding));
+ auto& srv = view->GetSRVDescriptor();
+ d3d12Device->CreateShaderResourceView(
+ ToBackend(view->GetTexture())->GetD3D12Resource(), &srv,
+ cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
+ bindingOffsets[binding]));
+ } break;
+ case dawn::BindingType::Sampler: {
+ auto* sampler = ToBackend(GetBindingAsSampler(binding));
+ auto& samplerDesc = sampler->GetSamplerDescriptor();
+ d3d12Device->CreateSampler(
+ &samplerDesc, samplerHeapStart.GetCPUHandle(*samplerHeapOffset +
+ bindingOffsets[binding]));
+ } break;
+ }
+ }
+
+ // Offset by the number of descriptors created
+ *cbvUavSrvHeapOffset += bgl->GetCbvUavSrvDescriptorCount();
+ *samplerHeapOffset += bgl->GetSamplerDescriptorCount();
+ }
+
+ uint32_t BindGroup::GetCbvUavSrvHeapOffset() const {
+ return mCbvUavSrvHeapOffset;
+ }
+
+ uint32_t BindGroup::GetSamplerHeapOffset() const {
+ return mSamplerHeapOffset;
+ }
+
+ uint64_t BindGroup::GetHeapSerial() const {
+ return mHeapSerial;
+ }
+ uint32_t BindGroup::GetIndexInSubmit() const {
+ return mIndexInSubmit;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupD3D12.h
new file mode 100644
index 00000000000..b5779391275
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupD3D12.h
@@ -0,0 +1,52 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_BINDGROUPD3D12_H_
+#define DAWNNATIVE_D3D12_BINDGROUPD3D12_H_
+
+#include "dawn_native/BindGroup.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include "dawn_native/d3d12/DescriptorHeapAllocator.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class BindGroup : public BindGroupBase {
+ public:
+ BindGroup(BindGroupBuilder* builder);
+
+ void RecordDescriptors(const DescriptorHeapHandle& cbvSrvUavHeapStart,
+ uint32_t* cbvUavSrvHeapOffset,
+ const DescriptorHeapHandle& samplerHeapStart,
+ uint32_t* samplerHeapOffset,
+ uint64_t serial,
+ uint32_t indexInSubmit);
+ uint32_t GetCbvUavSrvHeapOffset() const;
+ uint32_t GetSamplerHeapOffset() const;
+ uint64_t GetHeapSerial() const;
+ uint32_t GetIndexInSubmit() const;
+
+ private:
+ uint32_t mCbvUavSrvHeapOffset;
+ uint32_t mSamplerHeapOffset;
+ uint64_t mHeapSerial = 0;
+ uint32_t mIndexInSubmit;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_BINDGROUPD3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp
new file mode 100644
index 00000000000..7477e3fbf05
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp
@@ -0,0 +1,132 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
+
+#include "common/BitSetIterator.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ BindGroupLayout::BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor)
+ : BindGroupLayoutBase(device, descriptor), mDescriptorCounts{} {
+ const auto& groupInfo = GetBindingInfo();
+
+ for (uint32_t binding : IterateBitSet(groupInfo.mask)) {
+ switch (groupInfo.types[binding]) {
+ case dawn::BindingType::UniformBuffer:
+ mBindingOffsets[binding] = mDescriptorCounts[CBV]++;
+ break;
+ case dawn::BindingType::StorageBuffer:
+ mBindingOffsets[binding] = mDescriptorCounts[UAV]++;
+ break;
+ case dawn::BindingType::SampledTexture:
+ mBindingOffsets[binding] = mDescriptorCounts[SRV]++;
+ break;
+ case dawn::BindingType::Sampler:
+ mBindingOffsets[binding] = mDescriptorCounts[Sampler]++;
+ break;
+ }
+ }
+
+ auto SetDescriptorRange = [&](uint32_t index, uint32_t count, uint32_t* baseRegister,
+ D3D12_DESCRIPTOR_RANGE_TYPE type) -> bool {
+ if (count == 0) {
+ return false;
+ }
+
+ auto& range = mRanges[index];
+ range.RangeType = type;
+ range.NumDescriptors = count;
+ range.RegisterSpace = 0;
+ range.OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
+ range.BaseShaderRegister = *baseRegister;
+ *baseRegister += count;
+ // These ranges will be copied and range.BaseShaderRegister will be set in
+ // d3d12::PipelineLayout to account for bind group register offsets
+ return true;
+ };
+
+ uint32_t rangeIndex = 0;
+ uint32_t baseRegister = 0;
+
+ std::array<uint32_t, DescriptorType::Count> descriptorOffsets;
+ // Ranges 0-2 contain the CBV, UAV, and SRV ranges, if they exist, tightly packed
+ // Range 3 contains the Sampler range, if there is one
+ if (SetDescriptorRange(rangeIndex, mDescriptorCounts[CBV], &baseRegister,
+ D3D12_DESCRIPTOR_RANGE_TYPE_CBV)) {
+ descriptorOffsets[CBV] = mRanges[rangeIndex++].BaseShaderRegister;
+ }
+ if (SetDescriptorRange(rangeIndex, mDescriptorCounts[UAV], &baseRegister,
+ D3D12_DESCRIPTOR_RANGE_TYPE_UAV)) {
+ descriptorOffsets[UAV] = mRanges[rangeIndex++].BaseShaderRegister;
+ }
+ if (SetDescriptorRange(rangeIndex, mDescriptorCounts[SRV], &baseRegister,
+ D3D12_DESCRIPTOR_RANGE_TYPE_SRV)) {
+ descriptorOffsets[SRV] = mRanges[rangeIndex++].BaseShaderRegister;
+ }
+ uint32_t zero = 0;
+ SetDescriptorRange(Sampler, mDescriptorCounts[Sampler], &zero,
+ D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER);
+ descriptorOffsets[Sampler] = 0;
+
+ for (uint32_t binding : IterateBitSet(groupInfo.mask)) {
+ switch (groupInfo.types[binding]) {
+ case dawn::BindingType::UniformBuffer:
+ mBindingOffsets[binding] += descriptorOffsets[CBV];
+ break;
+ case dawn::BindingType::StorageBuffer:
+ mBindingOffsets[binding] += descriptorOffsets[UAV];
+ break;
+ case dawn::BindingType::SampledTexture:
+ mBindingOffsets[binding] += descriptorOffsets[SRV];
+ break;
+ case dawn::BindingType::Sampler:
+ mBindingOffsets[binding] += descriptorOffsets[Sampler];
+ break;
+ }
+ }
+ }
+
+ const std::array<uint32_t, kMaxBindingsPerGroup>& BindGroupLayout::GetBindingOffsets() const {
+ return mBindingOffsets;
+ }
+
+ uint32_t BindGroupLayout::GetCbvUavSrvDescriptorTableSize() const {
+ return (static_cast<uint32_t>(mDescriptorCounts[CBV] > 0) +
+ static_cast<uint32_t>(mDescriptorCounts[UAV] > 0) +
+ static_cast<uint32_t>(mDescriptorCounts[SRV] > 0));
+ }
+
+ uint32_t BindGroupLayout::GetSamplerDescriptorTableSize() const {
+ return mDescriptorCounts[Sampler] > 0;
+ }
+
+ uint32_t BindGroupLayout::GetCbvUavSrvDescriptorCount() const {
+ return mDescriptorCounts[CBV] + mDescriptorCounts[UAV] + mDescriptorCounts[SRV];
+ }
+
+ uint32_t BindGroupLayout::GetSamplerDescriptorCount() const {
+ return mDescriptorCounts[Sampler];
+ }
+
+ const D3D12_DESCRIPTOR_RANGE* BindGroupLayout::GetCbvUavSrvDescriptorRanges() const {
+ return mRanges;
+ }
+
+ const D3D12_DESCRIPTOR_RANGE* BindGroupLayout::GetSamplerDescriptorRanges() const {
+ return &mRanges[Sampler];
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupLayoutD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupLayoutD3D12.h
new file mode 100644
index 00000000000..e5766e635d2
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/BindGroupLayoutD3D12.h
@@ -0,0 +1,54 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_BINDGROUPLAYOUTD3D12_H_
+#define DAWNNATIVE_D3D12_BINDGROUPLAYOUTD3D12_H_
+
+#include "dawn_native/BindGroupLayout.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class BindGroupLayout : public BindGroupLayoutBase {
+ public:
+ BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor);
+
+ enum DescriptorType {
+ CBV,
+ UAV,
+ SRV,
+ Sampler,
+ Count,
+ };
+
+ const std::array<uint32_t, kMaxBindingsPerGroup>& GetBindingOffsets() const;
+ uint32_t GetCbvUavSrvDescriptorTableSize() const;
+ uint32_t GetSamplerDescriptorTableSize() const;
+ uint32_t GetCbvUavSrvDescriptorCount() const;
+ uint32_t GetSamplerDescriptorCount() const;
+ const D3D12_DESCRIPTOR_RANGE* GetCbvUavSrvDescriptorRanges() const;
+ const D3D12_DESCRIPTOR_RANGE* GetSamplerDescriptorRanges() const;
+
+ private:
+ std::array<uint32_t, kMaxBindingsPerGroup> mBindingOffsets;
+ std::array<uint32_t, DescriptorType::Count> mDescriptorCounts;
+ D3D12_DESCRIPTOR_RANGE mRanges[DescriptorType::Count];
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_BINDGROUPLAYOUTD3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/BlendStateD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/BlendStateD3D12.cpp
new file mode 100644
index 00000000000..862315eb0c6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/BlendStateD3D12.cpp
@@ -0,0 +1,108 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/BlendStateD3D12.h"
+
+#include "common/Assert.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ D3D12_BLEND D3D12Blend(dawn::BlendFactor factor) {
+ switch (factor) {
+ case dawn::BlendFactor::Zero:
+ return D3D12_BLEND_ZERO;
+ case dawn::BlendFactor::One:
+ return D3D12_BLEND_ONE;
+ case dawn::BlendFactor::SrcColor:
+ return D3D12_BLEND_SRC_COLOR;
+ case dawn::BlendFactor::OneMinusSrcColor:
+ return D3D12_BLEND_INV_SRC_COLOR;
+ case dawn::BlendFactor::SrcAlpha:
+ return D3D12_BLEND_SRC_ALPHA;
+ case dawn::BlendFactor::OneMinusSrcAlpha:
+ return D3D12_BLEND_INV_SRC_ALPHA;
+ case dawn::BlendFactor::DstColor:
+ return D3D12_BLEND_DEST_COLOR;
+ case dawn::BlendFactor::OneMinusDstColor:
+ return D3D12_BLEND_INV_DEST_COLOR;
+ case dawn::BlendFactor::DstAlpha:
+ return D3D12_BLEND_DEST_ALPHA;
+ case dawn::BlendFactor::OneMinusDstAlpha:
+ return D3D12_BLEND_INV_DEST_ALPHA;
+ case dawn::BlendFactor::SrcAlphaSaturated:
+ return D3D12_BLEND_SRC_ALPHA_SAT;
+ case dawn::BlendFactor::BlendColor:
+ return D3D12_BLEND_BLEND_FACTOR;
+ case dawn::BlendFactor::OneMinusBlendColor:
+ return D3D12_BLEND_INV_BLEND_FACTOR;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ D3D12_BLEND_OP D3D12BlendOperation(dawn::BlendOperation operation) {
+ switch (operation) {
+ case dawn::BlendOperation::Add:
+ return D3D12_BLEND_OP_ADD;
+ case dawn::BlendOperation::Subtract:
+ return D3D12_BLEND_OP_SUBTRACT;
+ case dawn::BlendOperation::ReverseSubtract:
+ return D3D12_BLEND_OP_REV_SUBTRACT;
+ case dawn::BlendOperation::Min:
+ return D3D12_BLEND_OP_MIN;
+ case dawn::BlendOperation::Max:
+ return D3D12_BLEND_OP_MAX;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ uint8_t D3D12RenderTargetWriteMask(dawn::ColorWriteMask colorWriteMask) {
+ static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Red) ==
+ D3D12_COLOR_WRITE_ENABLE_RED,
+ "ColorWriteMask values must match");
+ static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Green) ==
+ D3D12_COLOR_WRITE_ENABLE_GREEN,
+ "ColorWriteMask values must match");
+ static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Blue) ==
+ D3D12_COLOR_WRITE_ENABLE_BLUE,
+ "ColorWriteMask values must match");
+ static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Alpha) ==
+ D3D12_COLOR_WRITE_ENABLE_ALPHA,
+ "ColorWriteMask values must match");
+ return static_cast<uint8_t>(colorWriteMask);
+ }
+ } // namespace
+
+ BlendState::BlendState(BlendStateBuilder* builder) : BlendStateBase(builder) {
+ auto& info = GetBlendInfo();
+ mBlendDesc.BlendEnable = info.blendEnabled;
+ mBlendDesc.SrcBlend = D3D12Blend(info.colorBlend.srcFactor);
+ mBlendDesc.DestBlend = D3D12Blend(info.colorBlend.dstFactor);
+ mBlendDesc.BlendOp = D3D12BlendOperation(info.colorBlend.operation);
+ mBlendDesc.SrcBlendAlpha = D3D12Blend(info.alphaBlend.srcFactor);
+ mBlendDesc.DestBlendAlpha = D3D12Blend(info.alphaBlend.dstFactor);
+ mBlendDesc.BlendOpAlpha = D3D12BlendOperation(info.alphaBlend.operation);
+ mBlendDesc.RenderTargetWriteMask = D3D12RenderTargetWriteMask(info.colorWriteMask);
+ mBlendDesc.LogicOpEnable = false;
+ mBlendDesc.LogicOp = D3D12_LOGIC_OP_NOOP;
+ }
+
+ const D3D12_RENDER_TARGET_BLEND_DESC& BlendState::GetD3D12BlendDesc() const {
+ return mBlendDesc;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/BlendStateD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/BlendStateD3D12.h
new file mode 100644
index 00000000000..ea1a32da071
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/BlendStateD3D12.h
@@ -0,0 +1,36 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_BLENDSTATED3D12_H_
+#define DAWNNATIVE_D3D12_BLENDSTATED3D12_H_
+
+#include "dawn_native/BlendState.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class BlendState : public BlendStateBase {
+ public:
+ BlendState(BlendStateBuilder* builder);
+
+ const D3D12_RENDER_TARGET_BLEND_DESC& GetD3D12BlendDesc() const;
+
+ private:
+ D3D12_RENDER_TARGET_BLEND_DESC mBlendDesc;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_BLENDSTATED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/BufferD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/BufferD3D12.cpp
new file mode 100644
index 00000000000..71b6b400e5e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/BufferD3D12.cpp
@@ -0,0 +1,251 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/BufferD3D12.h"
+
+#include "common/Assert.h"
+#include "common/Constants.h"
+#include "common/Math.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/ResourceAllocator.h"
+#include "dawn_native/d3d12/ResourceUploader.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::BufferUsageBit usage) {
+ D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
+
+ if (usage & dawn::BufferUsageBit::Storage) {
+ flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
+ }
+
+ return flags;
+ }
+
+ D3D12_RESOURCE_STATES D3D12BufferUsage(dawn::BufferUsageBit usage) {
+ D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
+
+ if (usage & dawn::BufferUsageBit::TransferSrc) {
+ resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
+ }
+ if (usage & dawn::BufferUsageBit::TransferDst) {
+ resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
+ }
+ if (usage & (dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Uniform)) {
+ resourceState |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER;
+ }
+ if (usage & dawn::BufferUsageBit::Index) {
+ resourceState |= D3D12_RESOURCE_STATE_INDEX_BUFFER;
+ }
+ if (usage & dawn::BufferUsageBit::Storage) {
+ resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
+ }
+
+ return resourceState;
+ }
+
+ D3D12_HEAP_TYPE D3D12HeapType(dawn::BufferUsageBit allowedUsage) {
+ if (allowedUsage & dawn::BufferUsageBit::MapRead) {
+ return D3D12_HEAP_TYPE_READBACK;
+ } else if (allowedUsage & dawn::BufferUsageBit::MapWrite) {
+ return D3D12_HEAP_TYPE_UPLOAD;
+ } else {
+ return D3D12_HEAP_TYPE_DEFAULT;
+ }
+ }
+ } // namespace
+
+ Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
+ : BufferBase(device, descriptor) {
+ D3D12_RESOURCE_DESC resourceDescriptor;
+ resourceDescriptor.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
+ resourceDescriptor.Alignment = 0;
+ resourceDescriptor.Width = GetD3D12Size();
+ resourceDescriptor.Height = 1;
+ resourceDescriptor.DepthOrArraySize = 1;
+ resourceDescriptor.MipLevels = 1;
+ resourceDescriptor.Format = DXGI_FORMAT_UNKNOWN;
+ resourceDescriptor.SampleDesc.Count = 1;
+ resourceDescriptor.SampleDesc.Quality = 0;
+ resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
+ resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage());
+
+ auto heapType = D3D12HeapType(GetUsage());
+ auto bufferUsage = D3D12_RESOURCE_STATE_COMMON;
+
+ // D3D12 requires buffers on the READBACK heap to have the D3D12_RESOURCE_STATE_COPY_DEST
+ // state
+ if (heapType == D3D12_HEAP_TYPE_READBACK) {
+ bufferUsage |= D3D12_RESOURCE_STATE_COPY_DEST;
+ mFixedResourceState = true;
+ mLastUsage = dawn::BufferUsageBit::TransferDst;
+ }
+
+ // D3D12 requires buffers on the UPLOAD heap to have the D3D12_RESOURCE_STATE_GENERIC_READ
+ // state
+ if (heapType == D3D12_HEAP_TYPE_UPLOAD) {
+ bufferUsage |= D3D12_RESOURCE_STATE_GENERIC_READ;
+ mFixedResourceState = true;
+ mLastUsage = dawn::BufferUsageBit::TransferSrc;
+ }
+
+ mResource =
+ device->GetResourceAllocator()->Allocate(heapType, resourceDescriptor, bufferUsage);
+ }
+
+ Buffer::~Buffer() {
+ ToBackend(GetDevice())->GetResourceAllocator()->Release(mResource);
+ }
+
+ uint32_t Buffer::GetD3D12Size() const {
+ // TODO(enga@google.com): TODO investigate if this needs to be a constraint at the API level
+ return Align(GetSize(), 256);
+ }
+
+ ComPtr<ID3D12Resource> Buffer::GetD3D12Resource() {
+ return mResource;
+ }
+
+ void Buffer::TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
+ dawn::BufferUsageBit usage) {
+ // Resources in upload and readback heaps must be kept in the COPY_SOURCE/DEST state
+ if (mFixedResourceState) {
+ ASSERT(usage == mLastUsage);
+ return;
+ }
+
+ // We can skip transitions to already current usages.
+ // TODO(cwallez@chromium.org): Need some form of UAV barriers at some point.
+ bool lastIncludesTarget = (mLastUsage & usage) == usage;
+ if (lastIncludesTarget) {
+ return;
+ }
+
+ D3D12_RESOURCE_STATES lastState = D3D12BufferUsage(mLastUsage);
+ D3D12_RESOURCE_STATES newState = D3D12BufferUsage(usage);
+
+ D3D12_RESOURCE_BARRIER barrier;
+ barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
+ barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
+ barrier.Transition.pResource = mResource.Get();
+ barrier.Transition.StateBefore = lastState;
+ barrier.Transition.StateAfter = newState;
+ barrier.Transition.Subresource = 0;
+
+ commandList->ResourceBarrier(1, &barrier);
+
+ mLastUsage = usage;
+ }
+
+ D3D12_GPU_VIRTUAL_ADDRESS Buffer::GetVA() const {
+ return mResource->GetGPUVirtualAddress();
+ }
+
+ void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite) {
+ if (isWrite) {
+ CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
+ } else {
+ CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
+ }
+ }
+
+ void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) {
+ Device* device = ToBackend(GetDevice());
+
+ TransitionUsageNow(device->GetPendingCommandList(), dawn::BufferUsageBit::TransferDst);
+ device->GetResourceUploader()->BufferSubData(mResource, start, count, data);
+ }
+
+ void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
+ mWrittenMappedRange = {};
+ D3D12_RANGE readRange = {start, start + count};
+ char* data = nullptr;
+ ASSERT_SUCCESS(mResource->Map(0, &readRange, reinterpret_cast<void**>(&data)));
+
+ // There is no need to transition the resource to a new state: D3D12 seems to make the GPU
+ // writes available when the fence is passed.
+ MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
+ tracker->Track(this, serial, data + start, false);
+ }
+
+ void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
+ mWrittenMappedRange = {start, start + count};
+ char* data = nullptr;
+ ASSERT_SUCCESS(mResource->Map(0, &mWrittenMappedRange, reinterpret_cast<void**>(&data)));
+
+ // There is no need to transition the resource to a new state: D3D12 seems to make the CPU
+ // writes available on queue submission.
+ MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapRequestTracker();
+ tracker->Track(this, serial, data + start, true);
+ }
+
+ void Buffer::UnmapImpl() {
+ mResource->Unmap(0, &mWrittenMappedRange);
+ ToBackend(GetDevice())->GetResourceAllocator()->Release(mResource);
+ mWrittenMappedRange = {};
+ }
+
+ BufferView::BufferView(BufferViewBuilder* builder) : BufferViewBase(builder) {
+ mCbvDesc.BufferLocation = ToBackend(GetBuffer())->GetVA() + GetOffset();
+ mCbvDesc.SizeInBytes = GetD3D12Size();
+
+ mUavDesc.Format = DXGI_FORMAT_UNKNOWN;
+ mUavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
+ mUavDesc.Buffer.FirstElement = GetOffset();
+ mUavDesc.Buffer.NumElements = GetD3D12Size();
+ mUavDesc.Buffer.StructureByteStride = 1;
+ mUavDesc.Buffer.CounterOffsetInBytes = 0;
+ mUavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_NONE;
+ }
+
+ uint32_t BufferView::GetD3D12Size() const {
+ // TODO(enga@google.com): TODO investigate if this needs to be a constraint at the API level
+ return Align(GetSize(), 256);
+ }
+
+ const D3D12_CONSTANT_BUFFER_VIEW_DESC& BufferView::GetCBVDescriptor() const {
+ return mCbvDesc;
+ }
+
+ const D3D12_UNORDERED_ACCESS_VIEW_DESC& BufferView::GetUAVDescriptor() const {
+ return mUavDesc;
+ }
+
+ MapRequestTracker::MapRequestTracker(Device* device) : mDevice(device) {
+ }
+
+ MapRequestTracker::~MapRequestTracker() {
+ ASSERT(mInflightRequests.Empty());
+ }
+
+ void MapRequestTracker::Track(Buffer* buffer, uint32_t mapSerial, void* data, bool isWrite) {
+ Request request;
+ request.buffer = buffer;
+ request.mapSerial = mapSerial;
+ request.data = data;
+ request.isWrite = isWrite;
+
+ mInflightRequests.Enqueue(std::move(request), mDevice->GetSerial());
+ }
+
+ void MapRequestTracker::Tick(Serial finishedSerial) {
+ for (auto& request : mInflightRequests.IterateUpTo(finishedSerial)) {
+ request.buffer->OnMapCommandSerialFinished(request.mapSerial, request.data,
+ request.isWrite);
+ }
+ mInflightRequests.ClearUpTo(finishedSerial);
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/BufferD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/BufferD3D12.h
new file mode 100644
index 00000000000..9965d49e771
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/BufferD3D12.h
@@ -0,0 +1,88 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_BUFFERD3D12_H_
+#define DAWNNATIVE_D3D12_BUFFERD3D12_H_
+
+#include "common/SerialQueue.h"
+#include "dawn_native/Buffer.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class Buffer : public BufferBase {
+ public:
+ Buffer(Device* device, const BufferDescriptor* descriptor);
+ ~Buffer();
+
+ uint32_t GetD3D12Size() const;
+ ComPtr<ID3D12Resource> GetD3D12Resource();
+ D3D12_GPU_VIRTUAL_ADDRESS GetVA() const;
+ void OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite);
+
+ void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
+ dawn::BufferUsageBit usage);
+
+ private:
+ // Dawn API
+ void SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
+ void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void UnmapImpl() override;
+
+ ComPtr<ID3D12Resource> mResource;
+ bool mFixedResourceState = false;
+ dawn::BufferUsageBit mLastUsage = dawn::BufferUsageBit::None;
+ D3D12_RANGE mWrittenMappedRange;
+ };
+
+ class BufferView : public BufferViewBase {
+ public:
+ BufferView(BufferViewBuilder* builder);
+
+ uint32_t GetD3D12Size() const;
+ const D3D12_CONSTANT_BUFFER_VIEW_DESC& GetCBVDescriptor() const;
+ const D3D12_UNORDERED_ACCESS_VIEW_DESC& GetUAVDescriptor() const;
+
+ private:
+ D3D12_CONSTANT_BUFFER_VIEW_DESC mCbvDesc;
+ D3D12_UNORDERED_ACCESS_VIEW_DESC mUavDesc;
+ };
+
+ class MapRequestTracker {
+ public:
+ MapRequestTracker(Device* device);
+ ~MapRequestTracker();
+
+ void Track(Buffer* buffer, uint32_t mapSerial, void* data, bool isWrite);
+ void Tick(Serial finishedSerial);
+
+ private:
+ Device* mDevice;
+
+ struct Request {
+ Ref<Buffer> buffer;
+ uint32_t mapSerial;
+ void* data;
+ bool isWrite;
+ };
+ SerialQueue<Request> mInflightRequests;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_BUFFERD3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/CommandAllocatorManager.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/CommandAllocatorManager.cpp
new file mode 100644
index 00000000000..47072fcf6ce
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/CommandAllocatorManager.cpp
@@ -0,0 +1,69 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/CommandAllocatorManager.h"
+
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+#include "common/Assert.h"
+#include "common/BitSetIterator.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ CommandAllocatorManager::CommandAllocatorManager(Device* device)
+ : device(device), mAllocatorCount(0) {
+ mFreeAllocators.set();
+ }
+
+ ComPtr<ID3D12CommandAllocator> CommandAllocatorManager::ReserveCommandAllocator() {
+ // If there are no free allocators, get the oldest serial in flight and wait on it
+ if (mFreeAllocators.none()) {
+ const uint64_t firstSerial = mInFlightCommandAllocators.FirstSerial();
+ device->WaitForSerial(firstSerial);
+ Tick(firstSerial);
+ }
+
+ ASSERT(mFreeAllocators.any());
+
+ // Get the index of the first free allocator from the bitset
+ unsigned int firstFreeIndex = *(IterateBitSet(mFreeAllocators).begin());
+
+ if (firstFreeIndex >= mAllocatorCount) {
+ ASSERT(firstFreeIndex == mAllocatorCount);
+ mAllocatorCount++;
+ ASSERT_SUCCESS(device->GetD3D12Device()->CreateCommandAllocator(
+ D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&mCommandAllocators[firstFreeIndex])));
+ }
+
+ // Mark the command allocator as used
+ mFreeAllocators.reset(firstFreeIndex);
+
+ // Enqueue the command allocator. It will be scheduled for reset after the next
+ // ExecuteCommandLists
+ mInFlightCommandAllocators.Enqueue({mCommandAllocators[firstFreeIndex], firstFreeIndex},
+ device->GetSerial());
+
+ return mCommandAllocators[firstFreeIndex];
+ }
+
+ void CommandAllocatorManager::Tick(uint64_t lastCompletedSerial) {
+ // Reset all command allocators that are no longer in flight
+ for (auto it : mInFlightCommandAllocators.IterateUpTo(lastCompletedSerial)) {
+ ASSERT_SUCCESS(it.commandAllocator->Reset());
+ mFreeAllocators.set(it.index);
+ }
+ mInFlightCommandAllocators.ClearUpTo(lastCompletedSerial);
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/CommandAllocatorManager.h b/chromium/third_party/dawn/src/dawn_native/d3d12/CommandAllocatorManager.h
new file mode 100644
index 00000000000..fd7c8ce27dd
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/CommandAllocatorManager.h
@@ -0,0 +1,56 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_COMMANDALLOCATORMANAGER_H_
+#define DAWNNATIVE_D3D12_COMMANDALLOCATORMANAGER_H_
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include "common/SerialQueue.h"
+
+#include <bitset>
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class CommandAllocatorManager {
+ public:
+ CommandAllocatorManager(Device* device);
+
+ // A CommandAllocator that is reserved must be used on the next ExecuteCommandLists
+ // otherwise its commands may be reset before execution has completed on the GPU
+ ComPtr<ID3D12CommandAllocator> ReserveCommandAllocator();
+ void Tick(uint64_t lastCompletedSerial);
+
+ private:
+ Device* device;
+
+ // This must be at least 2 because the Device and Queue use separate command allocators
+ static constexpr unsigned int kMaxCommandAllocators = 32;
+ unsigned int mAllocatorCount;
+
+ struct IndexedCommandAllocator {
+ ComPtr<ID3D12CommandAllocator> commandAllocator;
+ unsigned int index;
+ };
+
+ ComPtr<ID3D12CommandAllocator> mCommandAllocators[kMaxCommandAllocators];
+ std::bitset<kMaxCommandAllocators> mFreeAllocators;
+ SerialQueue<IndexedCommandAllocator> mInFlightCommandAllocators;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_COMMANDALLOCATORMANAGER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/CommandBufferD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/CommandBufferD3D12.cpp
new file mode 100644
index 00000000000..65e7d6cec3d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/CommandBufferD3D12.cpp
@@ -0,0 +1,639 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/CommandBufferD3D12.h"
+
+#include "common/Assert.h"
+#include "dawn_native/Commands.h"
+#include "dawn_native/d3d12/BindGroupD3D12.h"
+#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
+#include "dawn_native/d3d12/BufferD3D12.h"
+#include "dawn_native/d3d12/ComputePipelineD3D12.h"
+#include "dawn_native/d3d12/DescriptorHeapAllocator.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/InputStateD3D12.h"
+#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
+#include "dawn_native/d3d12/RenderPassDescriptorD3D12.h"
+#include "dawn_native/d3d12/RenderPipelineD3D12.h"
+#include "dawn_native/d3d12/ResourceAllocator.h"
+#include "dawn_native/d3d12/SamplerD3D12.h"
+#include "dawn_native/d3d12/TextureCopySplitter.h"
+#include "dawn_native/d3d12/TextureD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ DXGI_FORMAT DXGIIndexFormat(dawn::IndexFormat format) {
+ switch (format) {
+ case dawn::IndexFormat::Uint16:
+ return DXGI_FORMAT_R16_UINT;
+ case dawn::IndexFormat::Uint32:
+ return DXGI_FORMAT_R32_UINT;
+ default:
+ UNREACHABLE();
+ }
+ }
+ } // anonymous namespace
+
+ struct BindGroupStateTracker {
+ uint32_t cbvSrvUavDescriptorIndex = 0;
+ uint32_t samplerDescriptorIndex = 0;
+ DescriptorHeapHandle cbvSrvUavCPUDescriptorHeap = {};
+ DescriptorHeapHandle samplerCPUDescriptorHeap = {};
+ DescriptorHeapHandle cbvSrvUavGPUDescriptorHeap = {};
+ DescriptorHeapHandle samplerGPUDescriptorHeap = {};
+ std::array<BindGroup*, kMaxBindGroups> bindGroups = {};
+ bool inCompute = false;
+
+ Device* device;
+
+ BindGroupStateTracker(Device* device) : device(device) {
+ }
+
+ void SetInComputePass(bool inCompute_) {
+ inCompute = inCompute_;
+ }
+
+ void TrackSetBindGroup(BindGroup* group, uint32_t index, uint32_t indexInSubmit) {
+ if (bindGroups[index] != group) {
+ bindGroups[index] = group;
+
+ // Descriptors don't need to be recorded if they have already been recorded in
+ // the heap. Indices are only updated when descriptors are recorded
+ const uint64_t serial = device->GetSerial();
+ if (group->GetHeapSerial() != serial ||
+ group->GetIndexInSubmit() != indexInSubmit) {
+ group->RecordDescriptors(cbvSrvUavCPUDescriptorHeap, &cbvSrvUavDescriptorIndex,
+ samplerCPUDescriptorHeap, &samplerDescriptorIndex,
+ serial, indexInSubmit);
+ }
+ }
+ }
+
+ void TrackInheritedGroups(PipelineLayout* oldLayout,
+ PipelineLayout* newLayout,
+ uint32_t indexInSubmit) {
+ if (oldLayout == nullptr) {
+ return;
+ }
+
+ uint32_t inheritUntil = oldLayout->GroupsInheritUpTo(newLayout);
+ for (uint32_t i = 0; i < inheritUntil; ++i) {
+ TrackSetBindGroup(bindGroups[i], i, indexInSubmit);
+ }
+ }
+
+ void SetBindGroup(ComPtr<ID3D12GraphicsCommandList> commandList,
+ PipelineLayout* pipelineLayout,
+ BindGroup* group,
+ uint32_t index,
+ bool force = false) {
+ if (bindGroups[index] != group || force) {
+ bindGroups[index] = group;
+
+ uint32_t cbvUavSrvCount =
+ ToBackend(group->GetLayout())->GetCbvUavSrvDescriptorCount();
+ uint32_t samplerCount = ToBackend(group->GetLayout())->GetSamplerDescriptorCount();
+
+ if (cbvUavSrvCount > 0) {
+ uint32_t parameterIndex = pipelineLayout->GetCbvUavSrvRootParameterIndex(index);
+
+ if (inCompute) {
+ commandList->SetComputeRootDescriptorTable(
+ parameterIndex, cbvSrvUavGPUDescriptorHeap.GetGPUHandle(
+ group->GetCbvUavSrvHeapOffset()));
+ } else {
+ commandList->SetGraphicsRootDescriptorTable(
+ parameterIndex, cbvSrvUavGPUDescriptorHeap.GetGPUHandle(
+ group->GetCbvUavSrvHeapOffset()));
+ }
+ }
+
+ if (samplerCount > 0) {
+ uint32_t parameterIndex = pipelineLayout->GetSamplerRootParameterIndex(index);
+
+ if (inCompute) {
+ commandList->SetComputeRootDescriptorTable(
+ parameterIndex,
+ samplerGPUDescriptorHeap.GetGPUHandle(group->GetSamplerHeapOffset()));
+ } else {
+ commandList->SetGraphicsRootDescriptorTable(
+ parameterIndex,
+ samplerGPUDescriptorHeap.GetGPUHandle(group->GetSamplerHeapOffset()));
+ }
+ }
+ }
+ }
+
+ void SetInheritedBindGroups(ComPtr<ID3D12GraphicsCommandList> commandList,
+ PipelineLayout* oldLayout,
+ PipelineLayout* newLayout) {
+ if (oldLayout == nullptr) {
+ return;
+ }
+
+ uint32_t inheritUntil = oldLayout->GroupsInheritUpTo(newLayout);
+ for (uint32_t i = 0; i < inheritUntil; ++i) {
+ SetBindGroup(commandList, newLayout, bindGroups[i], i, true);
+ }
+ }
+
+ void Reset() {
+ for (uint32_t i = 0; i < kMaxBindGroups; ++i) {
+ bindGroups[i] = nullptr;
+ }
+ }
+ };
+
+ namespace {
+
+ void AllocateAndSetDescriptorHeaps(Device* device,
+ BindGroupStateTracker* bindingTracker,
+ CommandIterator* commands,
+ int indexInSubmit) {
+ auto* descriptorHeapAllocator = device->GetDescriptorHeapAllocator();
+
+ // TODO(enga@google.com): This currently allocates CPU heaps of arbitrarily chosen sizes
+ // This will not work if there are too many descriptors
+ bindingTracker->cbvSrvUavCPUDescriptorHeap = descriptorHeapAllocator->AllocateCPUHeap(
+ D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, 8192);
+ bindingTracker->samplerCPUDescriptorHeap =
+ descriptorHeapAllocator->AllocateCPUHeap(D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, 2048);
+
+ {
+ Command type;
+ PipelineLayout* lastLayout = nullptr;
+
+ while (commands->NextCommandId(&type)) {
+ switch (type) {
+ case Command::SetComputePipeline: {
+ SetComputePipelineCmd* cmd =
+ commands->NextCommand<SetComputePipelineCmd>();
+ PipelineLayout* layout = ToBackend(cmd->pipeline->GetLayout());
+ bindingTracker->TrackInheritedGroups(lastLayout, layout, indexInSubmit);
+ lastLayout = layout;
+ } break;
+
+ case Command::SetRenderPipeline: {
+ SetRenderPipelineCmd* cmd =
+ commands->NextCommand<SetRenderPipelineCmd>();
+ PipelineLayout* layout = ToBackend(cmd->pipeline->GetLayout());
+ bindingTracker->TrackInheritedGroups(lastLayout, layout, indexInSubmit);
+ lastLayout = layout;
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>();
+ BindGroup* group = ToBackend(cmd->group.Get());
+ bindingTracker->TrackSetBindGroup(group, cmd->index, indexInSubmit);
+ } break;
+ default:
+ SkipCommand(commands, type);
+ }
+ }
+
+ commands->Reset();
+ }
+
+ if (bindingTracker->cbvSrvUavDescriptorIndex > 0) {
+ // Allocate a GPU-visible heap and copy from the CPU-only heap to the GPU-visible
+ // heap
+ bindingTracker->cbvSrvUavGPUDescriptorHeap =
+ descriptorHeapAllocator->AllocateGPUHeap(
+ D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
+ bindingTracker->cbvSrvUavDescriptorIndex);
+ device->GetD3D12Device()->CopyDescriptorsSimple(
+ bindingTracker->cbvSrvUavDescriptorIndex,
+ bindingTracker->cbvSrvUavGPUDescriptorHeap.GetCPUHandle(0),
+ bindingTracker->cbvSrvUavCPUDescriptorHeap.GetCPUHandle(0),
+ D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
+ }
+
+ if (bindingTracker->samplerDescriptorIndex > 0) {
+ bindingTracker->samplerGPUDescriptorHeap = descriptorHeapAllocator->AllocateGPUHeap(
+ D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, bindingTracker->samplerDescriptorIndex);
+ device->GetD3D12Device()->CopyDescriptorsSimple(
+ bindingTracker->samplerDescriptorIndex,
+ bindingTracker->samplerGPUDescriptorHeap.GetCPUHandle(0),
+ bindingTracker->samplerCPUDescriptorHeap.GetCPUHandle(0),
+ D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
+ }
+ }
+
+ } // anonymous namespace
+
+ CommandBuffer::CommandBuffer(CommandBufferBuilder* builder)
+ : CommandBufferBase(builder), mCommands(builder->AcquireCommands()) {
+ }
+
+ CommandBuffer::~CommandBuffer() {
+ FreeCommands(&mCommands);
+ }
+
+ void CommandBuffer::RecordCommands(ComPtr<ID3D12GraphicsCommandList> commandList,
+ uint32_t indexInSubmit) {
+ Device* device = ToBackend(GetDevice());
+ BindGroupStateTracker bindingTracker(device);
+
+ // Precompute the allocation of bindgroups in descriptor heaps
+ // TODO(cwallez@chromium.org): Iterating over all the commands here is inefficient. We
+ // should have a system where commands and descriptors are recorded in parallel then the
+ // heaps set using a small CommandList inserted just before the main CommandList.
+ {
+ AllocateAndSetDescriptorHeaps(device, &bindingTracker, &mCommands, indexInSubmit);
+ bindingTracker.Reset();
+
+ ID3D12DescriptorHeap* descriptorHeaps[2] = {
+ bindingTracker.cbvSrvUavGPUDescriptorHeap.Get(),
+ bindingTracker.samplerGPUDescriptorHeap.Get()};
+ if (descriptorHeaps[0] && descriptorHeaps[1]) {
+ commandList->SetDescriptorHeaps(2, descriptorHeaps);
+ } else if (descriptorHeaps[0]) {
+ commandList->SetDescriptorHeaps(1, descriptorHeaps);
+ } else if (descriptorHeaps[1]) {
+ commandList->SetDescriptorHeaps(1, &descriptorHeaps[1]);
+ }
+ }
+
+ // Records the necessary barriers for the resource usage pre-computed by the frontend
+ auto TransitionForPass = [](ComPtr<ID3D12GraphicsCommandList> commandList,
+ const PassResourceUsage& usages) {
+ for (size_t i = 0; i < usages.buffers.size(); ++i) {
+ Buffer* buffer = ToBackend(usages.buffers[i]);
+ buffer->TransitionUsageNow(commandList, usages.bufferUsages[i]);
+ }
+ for (size_t i = 0; i < usages.textures.size(); ++i) {
+ Texture* texture = ToBackend(usages.textures[i]);
+ texture->TransitionUsageNow(commandList, usages.textureUsages[i]);
+ }
+ };
+
+ const std::vector<PassResourceUsage>& passResourceUsages = GetResourceUsages().perPass;
+ uint32_t nextPassNumber = 0;
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::BeginComputePass: {
+ mCommands.NextCommand<BeginComputePassCmd>();
+
+ TransitionForPass(commandList, passResourceUsages[nextPassNumber]);
+ bindingTracker.SetInComputePass(true);
+ RecordComputePass(commandList, &bindingTracker);
+
+ nextPassNumber++;
+ } break;
+
+ case Command::BeginRenderPass: {
+ BeginRenderPassCmd* beginRenderPassCmd =
+ mCommands.NextCommand<BeginRenderPassCmd>();
+
+ TransitionForPass(commandList, passResourceUsages[nextPassNumber]);
+ bindingTracker.SetInComputePass(false);
+ RecordRenderPass(commandList, &bindingTracker,
+ ToBackend(beginRenderPassCmd->info.Get()));
+
+ nextPassNumber++;
+ } break;
+
+ case Command::CopyBufferToBuffer: {
+ CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
+ Buffer* srcBuffer = ToBackend(copy->source.buffer.Get());
+ Buffer* dstBuffer = ToBackend(copy->destination.buffer.Get());
+
+ srcBuffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::TransferSrc);
+ dstBuffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::TransferDst);
+
+ commandList->CopyBufferRegion(
+ dstBuffer->GetD3D12Resource().Get(), copy->destination.offset,
+ srcBuffer->GetD3D12Resource().Get(), copy->source.offset, copy->size);
+ } break;
+
+ case Command::CopyBufferToTexture: {
+ CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
+ Buffer* buffer = ToBackend(copy->source.buffer.Get());
+ Texture* texture = ToBackend(copy->destination.texture.Get());
+
+ buffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::TransferSrc);
+ texture->TransitionUsageNow(commandList, dawn::TextureUsageBit::TransferDst);
+
+ auto copySplit = ComputeTextureCopySplit(
+ copy->destination.x, copy->destination.y, copy->destination.z,
+ copy->destination.width, copy->destination.height, copy->destination.depth,
+ static_cast<uint32_t>(TextureFormatPixelSize(texture->GetFormat())),
+ copy->source.offset, copy->rowPitch);
+
+ D3D12_TEXTURE_COPY_LOCATION textureLocation;
+ textureLocation.pResource = texture->GetD3D12Resource();
+ textureLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
+ textureLocation.SubresourceIndex =
+ texture->GetNumMipLevels() * copy->destination.slice +
+ copy->destination.level;
+
+ for (uint32_t i = 0; i < copySplit.count; ++i) {
+ auto& info = copySplit.copies[i];
+
+ D3D12_TEXTURE_COPY_LOCATION bufferLocation;
+ bufferLocation.pResource = buffer->GetD3D12Resource().Get();
+ bufferLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
+ bufferLocation.PlacedFootprint.Offset = copySplit.offset;
+ bufferLocation.PlacedFootprint.Footprint.Format = texture->GetD3D12Format();
+ bufferLocation.PlacedFootprint.Footprint.Width = info.bufferSize.width;
+ bufferLocation.PlacedFootprint.Footprint.Height = info.bufferSize.height;
+ bufferLocation.PlacedFootprint.Footprint.Depth = info.bufferSize.depth;
+ bufferLocation.PlacedFootprint.Footprint.RowPitch = copy->rowPitch;
+
+ D3D12_BOX sourceRegion;
+ sourceRegion.left = info.bufferOffset.x;
+ sourceRegion.top = info.bufferOffset.y;
+ sourceRegion.front = info.bufferOffset.z;
+ sourceRegion.right = info.bufferOffset.x + info.copySize.width;
+ sourceRegion.bottom = info.bufferOffset.y + info.copySize.height;
+ sourceRegion.back = info.bufferOffset.z + info.copySize.depth;
+
+ commandList->CopyTextureRegion(&textureLocation, info.textureOffset.x,
+ info.textureOffset.y, info.textureOffset.z,
+ &bufferLocation, &sourceRegion);
+ }
+ } break;
+
+ case Command::CopyTextureToBuffer: {
+ CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
+ Texture* texture = ToBackend(copy->source.texture.Get());
+ Buffer* buffer = ToBackend(copy->destination.buffer.Get());
+
+ texture->TransitionUsageNow(commandList, dawn::TextureUsageBit::TransferSrc);
+ buffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::TransferDst);
+
+ auto copySplit = ComputeTextureCopySplit(
+ copy->source.x, copy->source.y, copy->source.z, copy->source.width,
+ copy->source.height, copy->source.depth,
+ static_cast<uint32_t>(TextureFormatPixelSize(texture->GetFormat())),
+ copy->destination.offset, copy->rowPitch);
+
+ D3D12_TEXTURE_COPY_LOCATION textureLocation;
+ textureLocation.pResource = texture->GetD3D12Resource();
+ textureLocation.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX;
+ textureLocation.SubresourceIndex =
+ texture->GetNumMipLevels() * copy->source.slice + copy->source.level;
+
+ for (uint32_t i = 0; i < copySplit.count; ++i) {
+ auto& info = copySplit.copies[i];
+
+ D3D12_TEXTURE_COPY_LOCATION bufferLocation;
+ bufferLocation.pResource = buffer->GetD3D12Resource().Get();
+ bufferLocation.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
+ bufferLocation.PlacedFootprint.Offset = copySplit.offset;
+ bufferLocation.PlacedFootprint.Footprint.Format = texture->GetD3D12Format();
+ bufferLocation.PlacedFootprint.Footprint.Width = info.bufferSize.width;
+ bufferLocation.PlacedFootprint.Footprint.Height = info.bufferSize.height;
+ bufferLocation.PlacedFootprint.Footprint.Depth = info.bufferSize.depth;
+ bufferLocation.PlacedFootprint.Footprint.RowPitch = copy->rowPitch;
+
+ D3D12_BOX sourceRegion;
+ sourceRegion.left = info.textureOffset.x;
+ sourceRegion.top = info.textureOffset.y;
+ sourceRegion.front = info.textureOffset.z;
+ sourceRegion.right = info.textureOffset.x + info.copySize.width;
+ sourceRegion.bottom = info.textureOffset.y + info.copySize.height;
+ sourceRegion.back = info.textureOffset.z + info.copySize.depth;
+
+ commandList->CopyTextureRegion(&bufferLocation, info.bufferOffset.x,
+ info.bufferOffset.y, info.bufferOffset.z,
+ &textureLocation, &sourceRegion);
+ }
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+ }
+
+ void CommandBuffer::RecordComputePass(ComPtr<ID3D12GraphicsCommandList> commandList,
+ BindGroupStateTracker* bindingTracker) {
+ PipelineLayout* lastLayout = nullptr;
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::Dispatch: {
+ DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
+ commandList->Dispatch(dispatch->x, dispatch->y, dispatch->z);
+ } break;
+
+ case Command::EndComputePass: {
+ mCommands.NextCommand<EndComputePassCmd>();
+ return;
+ } break;
+
+ case Command::SetComputePipeline: {
+ SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
+ ComputePipeline* pipeline = ToBackend(cmd->pipeline).Get();
+ PipelineLayout* layout = ToBackend(pipeline->GetLayout());
+
+ commandList->SetComputeRootSignature(layout->GetRootSignature().Get());
+ commandList->SetPipelineState(pipeline->GetPipelineState().Get());
+
+ bindingTracker->SetInheritedBindGroups(commandList, lastLayout, layout);
+ lastLayout = layout;
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
+ BindGroup* group = ToBackend(cmd->group.Get());
+ bindingTracker->SetBindGroup(commandList, lastLayout, group, cmd->index);
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+ }
+
+ void CommandBuffer::RecordRenderPass(ComPtr<ID3D12GraphicsCommandList> commandList,
+ BindGroupStateTracker* bindingTracker,
+ RenderPassDescriptor* renderPass) {
+ // Clear framebuffer attachments as needed and transition to render target
+ {
+ for (uint32_t i : IterateBitSet(renderPass->GetColorAttachmentMask())) {
+ auto& attachmentInfo = renderPass->GetColorAttachment(i);
+
+ // Load op - color
+ if (attachmentInfo.loadOp == dawn::LoadOp::Clear) {
+ D3D12_CPU_DESCRIPTOR_HANDLE handle = renderPass->GetRTVDescriptor(i);
+ commandList->ClearRenderTargetView(handle, attachmentInfo.clearColor.data(), 0,
+ nullptr);
+ }
+ }
+
+ if (renderPass->HasDepthStencilAttachment()) {
+ auto& attachmentInfo = renderPass->GetDepthStencilAttachment();
+ Texture* texture = ToBackend(attachmentInfo.view->GetTexture());
+
+ // Load op - depth/stencil
+ bool doDepthClear = TextureFormatHasDepth(texture->GetFormat()) &&
+ (attachmentInfo.depthLoadOp == dawn::LoadOp::Clear);
+ bool doStencilClear = TextureFormatHasStencil(texture->GetFormat()) &&
+ (attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear);
+
+ D3D12_CLEAR_FLAGS clearFlags = {};
+ if (doDepthClear) {
+ clearFlags |= D3D12_CLEAR_FLAG_DEPTH;
+ }
+ if (doStencilClear) {
+ clearFlags |= D3D12_CLEAR_FLAG_STENCIL;
+ }
+
+ if (clearFlags) {
+ auto handle = renderPass->GetDSVDescriptor();
+ // TODO(kainino@chromium.org): investigate: should the Dawn clear
+ // stencil type be uint8_t?
+ uint8_t clearStencil = static_cast<uint8_t>(attachmentInfo.clearStencil);
+ commandList->ClearDepthStencilView(
+ handle, clearFlags, attachmentInfo.clearDepth, clearStencil, 0, nullptr);
+ }
+ }
+ }
+
+ // Set up render targets
+ {
+ RenderPassDescriptor::OMSetRenderTargetArgs args =
+ renderPass->GetSubpassOMSetRenderTargetArgs();
+ if (args.dsv.ptr) {
+ commandList->OMSetRenderTargets(args.numRTVs, args.RTVs.data(), FALSE, &args.dsv);
+ } else {
+ commandList->OMSetRenderTargets(args.numRTVs, args.RTVs.data(), FALSE, nullptr);
+ }
+ }
+
+ // Set up default dynamic state
+ {
+ uint32_t width = renderPass->GetWidth();
+ uint32_t height = renderPass->GetHeight();
+ D3D12_VIEWPORT viewport = {
+ 0.f, 0.f, static_cast<float>(width), static_cast<float>(height), 0.f, 1.f};
+ D3D12_RECT scissorRect = {0, 0, static_cast<long>(width), static_cast<long>(height)};
+ commandList->RSSetViewports(1, &viewport);
+ commandList->RSSetScissorRects(1, &scissorRect);
+
+ static constexpr std::array<float, 4> defaultBlendFactor = {0, 0, 0, 0};
+ commandList->OMSetBlendFactor(&defaultBlendFactor[0]);
+ }
+
+ RenderPipeline* lastPipeline = nullptr;
+ PipelineLayout* lastLayout = nullptr;
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndRenderPass: {
+ mCommands.NextCommand<EndRenderPassCmd>();
+ return;
+ } break;
+
+ case Command::DrawArrays: {
+ DrawArraysCmd* draw = mCommands.NextCommand<DrawArraysCmd>();
+ commandList->DrawInstanced(draw->vertexCount, draw->instanceCount,
+ draw->firstVertex, draw->firstInstance);
+ } break;
+
+ case Command::DrawElements: {
+ DrawElementsCmd* draw = mCommands.NextCommand<DrawElementsCmd>();
+ commandList->DrawIndexedInstanced(draw->indexCount, draw->instanceCount,
+ draw->firstIndex, 0, draw->firstInstance);
+ } break;
+
+ case Command::SetRenderPipeline: {
+ SetRenderPipelineCmd* cmd = mCommands.NextCommand<SetRenderPipelineCmd>();
+ RenderPipeline* pipeline = ToBackend(cmd->pipeline).Get();
+ PipelineLayout* layout = ToBackend(pipeline->GetLayout());
+
+ commandList->SetGraphicsRootSignature(layout->GetRootSignature().Get());
+ commandList->SetPipelineState(pipeline->GetPipelineState().Get());
+ commandList->IASetPrimitiveTopology(pipeline->GetD3D12PrimitiveTopology());
+
+ bindingTracker->SetInheritedBindGroups(commandList, lastLayout, layout);
+
+ lastPipeline = pipeline;
+ lastLayout = layout;
+ } break;
+
+ case Command::SetStencilReference: {
+ SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
+
+ commandList->OMSetStencilRef(cmd->reference);
+ } break;
+
+ case Command::SetScissorRect: {
+ SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
+ D3D12_RECT rect;
+ rect.left = cmd->x;
+ rect.top = cmd->y;
+ rect.right = cmd->x + cmd->width;
+ rect.bottom = cmd->y + cmd->height;
+
+ commandList->RSSetScissorRects(1, &rect);
+ } break;
+
+ case Command::SetBlendColor: {
+ SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
+ commandList->OMSetBlendFactor(static_cast<const FLOAT*>(&cmd->r));
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
+ BindGroup* group = ToBackend(cmd->group.Get());
+ bindingTracker->SetBindGroup(commandList, lastLayout, group, cmd->index);
+ } break;
+
+ case Command::SetIndexBuffer: {
+ SetIndexBufferCmd* cmd = mCommands.NextCommand<SetIndexBufferCmd>();
+
+ Buffer* buffer = ToBackend(cmd->buffer.Get());
+ D3D12_INDEX_BUFFER_VIEW bufferView;
+ bufferView.BufferLocation = buffer->GetVA() + cmd->offset;
+ bufferView.SizeInBytes = buffer->GetSize() - cmd->offset;
+ // TODO(cwallez@chromium.org): Make index buffers lazily applied, right now
+ // this will break if the pipeline is changed for one with a different index
+ // format after SetIndexBuffer
+ bufferView.Format = DXGIIndexFormat(lastPipeline->GetIndexFormat());
+
+ commandList->IASetIndexBuffer(&bufferView);
+ } break;
+
+ case Command::SetVertexBuffers: {
+ SetVertexBuffersCmd* cmd = mCommands.NextCommand<SetVertexBuffersCmd>();
+ auto buffers = mCommands.NextData<Ref<BufferBase>>(cmd->count);
+ auto offsets = mCommands.NextData<uint32_t>(cmd->count);
+
+ auto inputState = ToBackend(lastPipeline->GetInputState());
+
+ std::array<D3D12_VERTEX_BUFFER_VIEW, kMaxVertexInputs> d3d12BufferViews;
+ for (uint32_t i = 0; i < cmd->count; ++i) {
+ auto input = inputState->GetInput(cmd->startSlot + i);
+ Buffer* buffer = ToBackend(buffers[i].Get());
+ d3d12BufferViews[i].BufferLocation = buffer->GetVA() + offsets[i];
+ d3d12BufferViews[i].StrideInBytes = input.stride;
+ d3d12BufferViews[i].SizeInBytes = buffer->GetSize() - offsets[i];
+ }
+
+ commandList->IASetVertexBuffers(cmd->startSlot, cmd->count,
+ d3d12BufferViews.data());
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/CommandBufferD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/CommandBufferD3D12.h
new file mode 100644
index 00000000000..95ac8bd1422
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/CommandBufferD3D12.h
@@ -0,0 +1,49 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_COMMANDBUFFERD3D12_H_
+#define DAWNNATIVE_D3D12_COMMANDBUFFERD3D12_H_
+
+#include "dawn_native/CommandAllocator.h"
+#include "dawn_native/CommandBuffer.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+ class RenderPassDescriptor;
+
+ struct BindGroupStateTracker;
+
+ class CommandBuffer : public CommandBufferBase {
+ public:
+ CommandBuffer(CommandBufferBuilder* builder);
+ ~CommandBuffer();
+
+ void RecordCommands(ComPtr<ID3D12GraphicsCommandList> commandList, uint32_t indexInSubmit);
+
+ private:
+ void RecordComputePass(ComPtr<ID3D12GraphicsCommandList> commandList,
+ BindGroupStateTracker* bindingTracker);
+ void RecordRenderPass(ComPtr<ID3D12GraphicsCommandList> commandList,
+ BindGroupStateTracker* bindingTracker,
+ RenderPassDescriptor* renderPass);
+
+ CommandIterator mCommands;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_COMMANDBUFFERD3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/ComputePipelineD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/ComputePipelineD3D12.cpp
new file mode 100644
index 00000000000..67f4cbc4748
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/ComputePipelineD3D12.cpp
@@ -0,0 +1,66 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/ComputePipelineD3D12.h"
+
+#include "common/Assert.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
+#include "dawn_native/d3d12/PlatformFunctions.h"
+#include "dawn_native/d3d12/ShaderModuleD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ ComputePipeline::ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor)
+ : ComputePipelineBase(device, descriptor) {
+ uint32_t compileFlags = 0;
+#if defined(_DEBUG)
+ // Enable better shader debugging with the graphics debugging tools.
+ compileFlags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
+#endif
+ // SPRIV-cross does matrix multiplication expecting row major matrices
+ compileFlags |= D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
+
+ const ShaderModule* module = ToBackend(descriptor->module);
+ const std::string& hlslSource = module->GetHLSLSource(ToBackend(GetLayout()));
+
+ ComPtr<ID3DBlob> compiledShader;
+ ComPtr<ID3DBlob> errors;
+
+ const PlatformFunctions* functions = device->GetFunctions();
+ if (FAILED(functions->d3dCompile(hlslSource.c_str(), hlslSource.length(), nullptr, nullptr,
+ nullptr, descriptor->entryPoint, "cs_5_1", compileFlags, 0,
+ &compiledShader, &errors))) {
+ printf("%s\n", reinterpret_cast<char*>(errors->GetBufferPointer()));
+ ASSERT(false);
+ }
+
+ D3D12_COMPUTE_PIPELINE_STATE_DESC d3dDesc = {};
+ d3dDesc.pRootSignature = ToBackend(GetLayout())->GetRootSignature().Get();
+ d3dDesc.CS.pShaderBytecode = compiledShader->GetBufferPointer();
+ d3dDesc.CS.BytecodeLength = compiledShader->GetBufferSize();
+
+ device->GetD3D12Device()->CreateComputePipelineState(&d3dDesc,
+ IID_PPV_ARGS(&mPipelineState));
+ }
+
+ ComputePipeline::~ComputePipeline() {
+ ToBackend(GetDevice())->ReferenceUntilUnused(mPipelineState);
+ }
+
+ ComPtr<ID3D12PipelineState> ComputePipeline::GetPipelineState() {
+ return mPipelineState;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/ComputePipelineD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/ComputePipelineD3D12.h
new file mode 100644
index 00000000000..7b1af9f6705
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/ComputePipelineD3D12.h
@@ -0,0 +1,39 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_COMPUTEPIPELINED3D12_H_
+#define DAWNNATIVE_D3D12_COMPUTEPIPELINED3D12_H_
+
+#include "dawn_native/ComputePipeline.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class ComputePipeline : public ComputePipelineBase {
+ public:
+ ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor);
+ ~ComputePipeline();
+
+ ComPtr<ID3D12PipelineState> GetPipelineState();
+
+ private:
+ ComPtr<ID3D12PipelineState> mPipelineState;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_COMPUTEPIPELINED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/DepthStencilStateD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/DepthStencilStateD3D12.cpp
new file mode 100644
index 00000000000..9b202c8d439
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/DepthStencilStateD3D12.cpp
@@ -0,0 +1,98 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/DepthStencilStateD3D12.h"
+
+#include "common/BitSetIterator.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ static D3D12_STENCIL_OP StencilOp(dawn::StencilOperation op) {
+ switch (op) {
+ case dawn::StencilOperation::Keep:
+ return D3D12_STENCIL_OP_KEEP;
+ case dawn::StencilOperation::Zero:
+ return D3D12_STENCIL_OP_ZERO;
+ case dawn::StencilOperation::Replace:
+ return D3D12_STENCIL_OP_REPLACE;
+ case dawn::StencilOperation::IncrementClamp:
+ return D3D12_STENCIL_OP_INCR_SAT;
+ case dawn::StencilOperation::DecrementClamp:
+ return D3D12_STENCIL_OP_DECR_SAT;
+ case dawn::StencilOperation::Invert:
+ return D3D12_STENCIL_OP_INVERT;
+ case dawn::StencilOperation::IncrementWrap:
+ return D3D12_STENCIL_OP_INCR;
+ case dawn::StencilOperation::DecrementWrap:
+ return D3D12_STENCIL_OP_DECR;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ static D3D12_COMPARISON_FUNC ComparisonFunc(dawn::CompareFunction func) {
+ switch (func) {
+ case dawn::CompareFunction::Always:
+ return D3D12_COMPARISON_FUNC_ALWAYS;
+ case dawn::CompareFunction::Equal:
+ return D3D12_COMPARISON_FUNC_EQUAL;
+ case dawn::CompareFunction::Greater:
+ return D3D12_COMPARISON_FUNC_GREATER;
+ case dawn::CompareFunction::GreaterEqual:
+ return D3D12_COMPARISON_FUNC_GREATER_EQUAL;
+ case dawn::CompareFunction::Less:
+ return D3D12_COMPARISON_FUNC_LESS;
+ case dawn::CompareFunction::LessEqual:
+ return D3D12_COMPARISON_FUNC_LESS_EQUAL;
+ case dawn::CompareFunction::Never:
+ return D3D12_COMPARISON_FUNC_NEVER;
+ case dawn::CompareFunction::NotEqual:
+ return D3D12_COMPARISON_FUNC_NOT_EQUAL;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ static D3D12_DEPTH_STENCILOP_DESC StencilOpDesc(
+ DepthStencilStateBase::StencilFaceInfo faceInfo) {
+ D3D12_DEPTH_STENCILOP_DESC desc;
+
+ desc.StencilFailOp = StencilOp(faceInfo.stencilFail);
+ desc.StencilDepthFailOp = StencilOp(faceInfo.depthFail);
+ desc.StencilPassOp = StencilOp(faceInfo.depthStencilPass);
+ desc.StencilFunc = ComparisonFunc(faceInfo.compareFunction);
+
+ return desc;
+ }
+
+ DepthStencilState::DepthStencilState(DepthStencilStateBuilder* builder)
+ : DepthStencilStateBase(builder) {
+ mDepthStencilDescriptor.DepthEnable = TRUE;
+ mDepthStencilDescriptor.DepthWriteMask =
+ GetDepth().depthWriteEnabled ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO;
+ mDepthStencilDescriptor.DepthFunc = ComparisonFunc(GetDepth().compareFunction);
+
+ mDepthStencilDescriptor.StencilEnable = StencilTestEnabled() ? TRUE : FALSE;
+ mDepthStencilDescriptor.StencilReadMask = static_cast<UINT8>(GetStencil().readMask);
+ mDepthStencilDescriptor.StencilWriteMask = static_cast<UINT8>(GetStencil().writeMask);
+
+ mDepthStencilDescriptor.FrontFace = StencilOpDesc(GetStencil().front);
+ mDepthStencilDescriptor.BackFace = StencilOpDesc(GetStencil().back);
+ }
+
+ const D3D12_DEPTH_STENCIL_DESC& DepthStencilState::GetD3D12DepthStencilDescriptor() const {
+ return mDepthStencilDescriptor;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/DepthStencilStateD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/DepthStencilStateD3D12.h
new file mode 100644
index 00000000000..e7041b77664
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/DepthStencilStateD3D12.h
@@ -0,0 +1,38 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_DEPTHSTENCILSTATED3D12_H_
+#define DAWNNATIVE_D3D12_DEPTHSTENCILSTATED3D12_H_
+
+#include "dawn_native/DepthStencilState.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class DepthStencilState : public DepthStencilStateBase {
+ public:
+ DepthStencilState(DepthStencilStateBuilder* builder);
+
+ const D3D12_DEPTH_STENCIL_DESC& GetD3D12DepthStencilDescriptor() const;
+
+ private:
+ D3D12_DEPTH_STENCIL_DESC mDepthStencilDescriptor;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_DEPTHSTENCILSTATED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/DescriptorHeapAllocator.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/DescriptorHeapAllocator.cpp
new file mode 100644
index 00000000000..9374dae33dd
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/DescriptorHeapAllocator.cpp
@@ -0,0 +1,132 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/DescriptorHeapAllocator.h"
+
+#include "common/Assert.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ DescriptorHeapHandle::DescriptorHeapHandle()
+ : mDescriptorHeap(nullptr), mSizeIncrement(0), mOffset(0) {
+ }
+
+ DescriptorHeapHandle::DescriptorHeapHandle(ComPtr<ID3D12DescriptorHeap> descriptorHeap,
+ uint32_t sizeIncrement,
+ uint32_t offset)
+ : mDescriptorHeap(descriptorHeap), mSizeIncrement(sizeIncrement), mOffset(offset) {
+ }
+
+ ID3D12DescriptorHeap* DescriptorHeapHandle::Get() const {
+ return mDescriptorHeap.Get();
+ }
+
+ D3D12_CPU_DESCRIPTOR_HANDLE DescriptorHeapHandle::GetCPUHandle(uint32_t index) const {
+ ASSERT(mDescriptorHeap);
+ auto handle = mDescriptorHeap->GetCPUDescriptorHandleForHeapStart();
+ handle.ptr += mSizeIncrement * (index + mOffset);
+ return handle;
+ }
+
+ D3D12_GPU_DESCRIPTOR_HANDLE DescriptorHeapHandle::GetGPUHandle(uint32_t index) const {
+ ASSERT(mDescriptorHeap);
+ auto handle = mDescriptorHeap->GetGPUDescriptorHandleForHeapStart();
+ handle.ptr += mSizeIncrement * (index + mOffset);
+ return handle;
+ }
+
+ DescriptorHeapAllocator::DescriptorHeapAllocator(Device* device)
+ : mDevice(device),
+ mSizeIncrements{
+ device->GetD3D12Device()->GetDescriptorHandleIncrementSize(
+ D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV),
+ device->GetD3D12Device()->GetDescriptorHandleIncrementSize(
+ D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER),
+ device->GetD3D12Device()->GetDescriptorHandleIncrementSize(
+ D3D12_DESCRIPTOR_HEAP_TYPE_RTV),
+ device->GetD3D12Device()->GetDescriptorHandleIncrementSize(
+ D3D12_DESCRIPTOR_HEAP_TYPE_DSV),
+ } {
+ }
+
+ DescriptorHeapHandle DescriptorHeapAllocator::Allocate(D3D12_DESCRIPTOR_HEAP_TYPE type,
+ uint32_t count,
+ uint32_t allocationSize,
+ DescriptorHeapInfo* heapInfo,
+ D3D12_DESCRIPTOR_HEAP_FLAGS flags) {
+ // TODO(enga@google.com): This is just a linear allocator so the heap will quickly run out
+ // of space causing a new one to be allocated We should reuse heap subranges that have been
+ // released
+ if (count == 0) {
+ return DescriptorHeapHandle();
+ }
+
+ {
+ // If the current pool for this type has space, linearly allocate count bytes in the
+ // pool
+ auto& allocationInfo = heapInfo->second;
+ if (allocationInfo.remaining >= count) {
+ DescriptorHeapHandle handle(heapInfo->first, mSizeIncrements[type],
+ allocationInfo.size - allocationInfo.remaining);
+ allocationInfo.remaining -= count;
+ Release(handle);
+ return handle;
+ }
+ }
+
+ // If the pool has no more space, replace the pool with a new one of the specified size
+
+ D3D12_DESCRIPTOR_HEAP_DESC heapDescriptor;
+ heapDescriptor.Type = type;
+ heapDescriptor.NumDescriptors = allocationSize;
+ heapDescriptor.Flags = flags;
+ heapDescriptor.NodeMask = 0;
+ ComPtr<ID3D12DescriptorHeap> heap;
+ ASSERT_SUCCESS(
+ mDevice->GetD3D12Device()->CreateDescriptorHeap(&heapDescriptor, IID_PPV_ARGS(&heap)));
+
+ AllocationInfo allocationInfo = {allocationSize, allocationSize - count};
+ *heapInfo = std::make_pair(heap, allocationInfo);
+
+ DescriptorHeapHandle handle(heap, mSizeIncrements[type], 0);
+ Release(handle);
+ return handle;
+ }
+
+ DescriptorHeapHandle DescriptorHeapAllocator::AllocateCPUHeap(D3D12_DESCRIPTOR_HEAP_TYPE type,
+ uint32_t count) {
+ return Allocate(type, count, count, &mCpuDescriptorHeapInfos[type],
+ D3D12_DESCRIPTOR_HEAP_FLAG_NONE);
+ }
+
+ DescriptorHeapHandle DescriptorHeapAllocator::AllocateGPUHeap(D3D12_DESCRIPTOR_HEAP_TYPE type,
+ uint32_t count) {
+ ASSERT(type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ||
+ type == D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER);
+ unsigned int heapSize =
+ (type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ? kMaxCbvUavSrvHeapSize
+ : kMaxSamplerHeapSize);
+ return Allocate(type, count, heapSize, &mGpuDescriptorHeapInfos[type],
+ D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE);
+ }
+
+ void DescriptorHeapAllocator::Tick(uint64_t lastCompletedSerial) {
+ mReleasedHandles.ClearUpTo(lastCompletedSerial);
+ }
+
+ void DescriptorHeapAllocator::Release(DescriptorHeapHandle handle) {
+ mReleasedHandles.Enqueue(handle, mDevice->GetSerial());
+ }
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/DescriptorHeapAllocator.h b/chromium/third_party/dawn/src/dawn_native/d3d12/DescriptorHeapAllocator.h
new file mode 100644
index 00000000000..f1ba5029f87
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/DescriptorHeapAllocator.h
@@ -0,0 +1,83 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_DESCRIPTORHEAPALLOCATOR_H_
+#define DAWNNATIVE_D3D12_DESCRIPTORHEAPALLOCATOR_H_
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include <array>
+#include <vector>
+#include "common/SerialQueue.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class DescriptorHeapHandle {
+ public:
+ DescriptorHeapHandle();
+ DescriptorHeapHandle(ComPtr<ID3D12DescriptorHeap> descriptorHeap,
+ uint32_t sizeIncrement,
+ uint32_t offset);
+
+ ID3D12DescriptorHeap* Get() const;
+ D3D12_CPU_DESCRIPTOR_HANDLE GetCPUHandle(uint32_t index) const;
+ D3D12_GPU_DESCRIPTOR_HANDLE GetGPUHandle(uint32_t index) const;
+
+ private:
+ ComPtr<ID3D12DescriptorHeap> mDescriptorHeap;
+ uint32_t mSizeIncrement;
+ uint32_t mOffset;
+ };
+
+ class DescriptorHeapAllocator {
+ public:
+ DescriptorHeapAllocator(Device* device);
+
+ DescriptorHeapHandle AllocateGPUHeap(D3D12_DESCRIPTOR_HEAP_TYPE type, uint32_t count);
+ DescriptorHeapHandle AllocateCPUHeap(D3D12_DESCRIPTOR_HEAP_TYPE type, uint32_t count);
+ void Tick(uint64_t lastCompletedSerial);
+
+ private:
+ static constexpr unsigned int kMaxCbvUavSrvHeapSize = 1000000;
+ static constexpr unsigned int kMaxSamplerHeapSize = 2048;
+ static constexpr unsigned int kDescriptorHeapTypes =
+ D3D12_DESCRIPTOR_HEAP_TYPE::D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES;
+
+ struct AllocationInfo {
+ uint32_t size = 0;
+ uint32_t remaining = 0;
+ };
+
+ using DescriptorHeapInfo = std::pair<ComPtr<ID3D12DescriptorHeap>, AllocationInfo>;
+
+ DescriptorHeapHandle Allocate(D3D12_DESCRIPTOR_HEAP_TYPE type,
+ uint32_t count,
+ uint32_t allocationSize,
+ DescriptorHeapInfo* heapInfo,
+ D3D12_DESCRIPTOR_HEAP_FLAGS flags);
+ void Release(DescriptorHeapHandle handle);
+
+ Device* mDevice;
+
+ std::array<uint32_t, kDescriptorHeapTypes> mSizeIncrements;
+ std::array<DescriptorHeapInfo, kDescriptorHeapTypes> mCpuDescriptorHeapInfos;
+ std::array<DescriptorHeapInfo, kDescriptorHeapTypes> mGpuDescriptorHeapInfos;
+ SerialQueue<DescriptorHeapHandle> mReleasedHandles;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_DESCRIPTORHEAPALLOCATOR_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/DeviceD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/DeviceD3D12.cpp
new file mode 100644
index 00000000000..1d1f7415093
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/DeviceD3D12.cpp
@@ -0,0 +1,357 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+#include "common/Assert.h"
+#include "common/SwapChainUtils.h"
+#include "dawn_native/D3D12Backend.h"
+#include "dawn_native/d3d12/BindGroupD3D12.h"
+#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
+#include "dawn_native/d3d12/BlendStateD3D12.h"
+#include "dawn_native/d3d12/BufferD3D12.h"
+#include "dawn_native/d3d12/CommandAllocatorManager.h"
+#include "dawn_native/d3d12/CommandBufferD3D12.h"
+#include "dawn_native/d3d12/ComputePipelineD3D12.h"
+#include "dawn_native/d3d12/DepthStencilStateD3D12.h"
+#include "dawn_native/d3d12/DescriptorHeapAllocator.h"
+#include "dawn_native/d3d12/InputStateD3D12.h"
+#include "dawn_native/d3d12/NativeSwapChainImplD3D12.h"
+#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
+#include "dawn_native/d3d12/PlatformFunctions.h"
+#include "dawn_native/d3d12/QueueD3D12.h"
+#include "dawn_native/d3d12/RenderPassDescriptorD3D12.h"
+#include "dawn_native/d3d12/RenderPipelineD3D12.h"
+#include "dawn_native/d3d12/ResourceAllocator.h"
+#include "dawn_native/d3d12/ResourceUploader.h"
+#include "dawn_native/d3d12/SamplerD3D12.h"
+#include "dawn_native/d3d12/ShaderModuleD3D12.h"
+#include "dawn_native/d3d12/SwapChainD3D12.h"
+#include "dawn_native/d3d12/TextureD3D12.h"
+
+#include <locale>
+
+namespace dawn_native { namespace d3d12 {
+
+ dawnDevice CreateDevice() {
+ return reinterpret_cast<dawnDevice>(new Device());
+ }
+
+ dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, HWND window) {
+ Device* backendDevice = reinterpret_cast<Device*>(device);
+
+ dawnSwapChainImplementation impl;
+ impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
+ impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
+
+ return impl;
+ }
+
+ dawnTextureFormat GetNativeSwapChainPreferredFormat(
+ const dawnSwapChainImplementation* swapChain) {
+ NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
+ return static_cast<dawnTextureFormat>(impl->GetPreferredFormat());
+ }
+
+ void ASSERT_SUCCESS(HRESULT hr) {
+ ASSERT(SUCCEEDED(hr));
+ }
+
+ namespace {
+ ComPtr<IDXGIFactory4> CreateFactory(const PlatformFunctions* functions) {
+ ComPtr<IDXGIFactory4> factory;
+
+ uint32_t dxgiFactoryFlags = 0;
+#if defined(DAWN_ENABLE_ASSERTS)
+ // Enable the debug layer (requires the Graphics Tools "optional feature").
+ {
+ ComPtr<ID3D12Debug> debugController;
+ if (SUCCEEDED(functions->d3d12GetDebugInterface(IID_PPV_ARGS(&debugController)))) {
+ debugController->EnableDebugLayer();
+
+ // Enable additional debug layers.
+ dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG;
+ }
+
+ ComPtr<IDXGIDebug1> dxgiDebug;
+ if (SUCCEEDED(functions->dxgiGetDebugInterface1(0, IID_PPV_ARGS(&dxgiDebug)))) {
+ dxgiDebug->ReportLiveObjects(DXGI_DEBUG_ALL,
+ DXGI_DEBUG_RLO_FLAGS(DXGI_DEBUG_RLO_ALL));
+ }
+ }
+#endif // defined(DAWN_ENABLE_ASSERTS)
+
+ ASSERT_SUCCESS(functions->createDxgiFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&factory)));
+ return factory;
+ }
+
+ ComPtr<IDXGIAdapter1> GetHardwareAdapter(ComPtr<IDXGIFactory4> factory,
+ const PlatformFunctions* functions) {
+ for (uint32_t adapterIndex = 0;; ++adapterIndex) {
+ IDXGIAdapter1* adapter = nullptr;
+ if (factory->EnumAdapters1(adapterIndex, &adapter) == DXGI_ERROR_NOT_FOUND) {
+ break; // No more adapters to enumerate.
+ }
+
+ // Check to see if the adapter supports Direct3D 12, but don't create the actual
+ // device yet.
+ if (SUCCEEDED(functions->d3d12CreateDevice(adapter, D3D_FEATURE_LEVEL_11_0,
+ _uuidof(ID3D12Device), nullptr))) {
+ return adapter;
+ }
+ adapter->Release();
+ }
+ return nullptr;
+ }
+
+ } // anonymous namespace
+
+ Device::Device() {
+ mFunctions = std::make_unique<PlatformFunctions>();
+
+ {
+ MaybeError status = mFunctions->LoadFunctions();
+ ASSERT(status.IsSuccess());
+ }
+
+ // Create the connection to DXGI and the D3D12 device
+ mFactory = CreateFactory(mFunctions.get());
+ ASSERT(mFactory.Get() != nullptr);
+
+ mHardwareAdapter = GetHardwareAdapter(mFactory, mFunctions.get());
+ ASSERT(mHardwareAdapter.Get() != nullptr);
+
+ ASSERT_SUCCESS(mFunctions->d3d12CreateDevice(mHardwareAdapter.Get(), D3D_FEATURE_LEVEL_11_0,
+ IID_PPV_ARGS(&mD3d12Device)));
+
+ // Collect GPU information
+ CollectPCIInfo();
+
+ // Create device-global objects
+ D3D12_COMMAND_QUEUE_DESC queueDesc = {};
+ queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE;
+ queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT;
+ ASSERT_SUCCESS(mD3d12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&mCommandQueue)));
+
+ ASSERT_SUCCESS(
+ mD3d12Device->CreateFence(mSerial, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(&mFence)));
+ mFenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr);
+ ASSERT(mFenceEvent != nullptr);
+
+ // Initialize backend services
+ mCommandAllocatorManager = std::make_unique<CommandAllocatorManager>(this);
+ mDescriptorHeapAllocator = std::make_unique<DescriptorHeapAllocator>(this);
+ mMapRequestTracker = std::make_unique<MapRequestTracker>(this);
+ mResourceAllocator = std::make_unique<ResourceAllocator>(this);
+ mResourceUploader = std::make_unique<ResourceUploader>(this);
+
+ NextSerial();
+ }
+
+ Device::~Device() {
+ const uint64_t currentSerial = GetSerial();
+ NextSerial();
+ WaitForSerial(currentSerial); // Wait for all in-flight commands to finish executing
+ TickImpl(); // Call tick one last time so resources are cleaned up
+
+ ASSERT(mUsedComObjectRefs.Empty());
+ ASSERT(mPendingCommands.commandList == nullptr);
+ }
+
+ ComPtr<IDXGIFactory4> Device::GetFactory() {
+ return mFactory;
+ }
+
+ ComPtr<ID3D12Device> Device::GetD3D12Device() {
+ return mD3d12Device;
+ }
+
+ ComPtr<ID3D12CommandQueue> Device::GetCommandQueue() {
+ return mCommandQueue;
+ }
+
+ DescriptorHeapAllocator* Device::GetDescriptorHeapAllocator() {
+ return mDescriptorHeapAllocator.get();
+ }
+
+ const PlatformFunctions* Device::GetFunctions() {
+ return mFunctions.get();
+ }
+
+ MapRequestTracker* Device::GetMapRequestTracker() const {
+ return mMapRequestTracker.get();
+ }
+
+ ResourceAllocator* Device::GetResourceAllocator() {
+ return mResourceAllocator.get();
+ }
+
+ ResourceUploader* Device::GetResourceUploader() {
+ return mResourceUploader.get();
+ }
+
+ void Device::OpenCommandList(ComPtr<ID3D12GraphicsCommandList>* commandList) {
+ ComPtr<ID3D12GraphicsCommandList>& cmdList = *commandList;
+ if (!cmdList) {
+ ASSERT_SUCCESS(mD3d12Device->CreateCommandList(
+ 0, D3D12_COMMAND_LIST_TYPE_DIRECT,
+ mCommandAllocatorManager->ReserveCommandAllocator().Get(), nullptr,
+ IID_PPV_ARGS(&cmdList)));
+ } else {
+ ASSERT_SUCCESS(
+ cmdList->Reset(mCommandAllocatorManager->ReserveCommandAllocator().Get(), nullptr));
+ }
+ }
+
+ ComPtr<ID3D12GraphicsCommandList> Device::GetPendingCommandList() {
+ // Callers of GetPendingCommandList do so to record commands. Only reserve a command
+ // allocator when it is needed so we don't submit empty command lists
+ if (!mPendingCommands.open) {
+ OpenCommandList(&mPendingCommands.commandList);
+ mPendingCommands.open = true;
+ }
+ return mPendingCommands.commandList;
+ }
+
+ void Device::TickImpl() {
+ // Perform cleanup operations to free unused objects
+ const uint64_t lastCompletedSerial = mFence->GetCompletedValue();
+ mResourceAllocator->Tick(lastCompletedSerial);
+ mCommandAllocatorManager->Tick(lastCompletedSerial);
+ mDescriptorHeapAllocator->Tick(lastCompletedSerial);
+ mMapRequestTracker->Tick(lastCompletedSerial);
+ mUsedComObjectRefs.ClearUpTo(lastCompletedSerial);
+ ExecuteCommandLists({});
+ NextSerial();
+ }
+
+ const dawn_native::PCIInfo& Device::GetPCIInfo() const {
+ return mPCIInfo;
+ }
+
+ uint64_t Device::GetSerial() const {
+ return mSerial;
+ }
+
+ void Device::NextSerial() {
+ ASSERT_SUCCESS(mCommandQueue->Signal(mFence.Get(), mSerial++));
+ }
+
+ void Device::WaitForSerial(uint64_t serial) {
+ const uint64_t lastCompletedSerial = mFence->GetCompletedValue();
+ if (lastCompletedSerial < serial) {
+ ASSERT_SUCCESS(mFence->SetEventOnCompletion(serial, mFenceEvent));
+ WaitForSingleObject(mFenceEvent, INFINITE);
+ }
+ }
+
+ void Device::ReferenceUntilUnused(ComPtr<IUnknown> object) {
+ mUsedComObjectRefs.Enqueue(object, mSerial);
+ }
+
+ void Device::ExecuteCommandLists(std::initializer_list<ID3D12CommandList*> commandLists) {
+ // If there are pending commands, prepend them to ExecuteCommandLists
+ if (mPendingCommands.open) {
+ std::vector<ID3D12CommandList*> lists(commandLists.size() + 1);
+ mPendingCommands.commandList->Close();
+ mPendingCommands.open = false;
+ lists[0] = mPendingCommands.commandList.Get();
+ std::copy(commandLists.begin(), commandLists.end(), lists.begin() + 1);
+ mCommandQueue->ExecuteCommandLists(static_cast<UINT>(commandLists.size() + 1),
+ lists.data());
+ mPendingCommands.commandList = nullptr;
+ } else {
+ std::vector<ID3D12CommandList*> lists(commandLists);
+ mCommandQueue->ExecuteCommandLists(static_cast<UINT>(commandLists.size()),
+ lists.data());
+ }
+ }
+
+ BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
+ return new BindGroup(builder);
+ }
+ ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) {
+ return new BindGroupLayout(this, descriptor);
+ }
+ BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
+ return new BlendState(builder);
+ }
+ ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
+ return new Buffer(this, descriptor);
+ }
+ BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
+ return new BufferView(builder);
+ }
+ CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
+ return new CommandBuffer(builder);
+ }
+ ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) {
+ return new ComputePipeline(this, descriptor);
+ }
+ DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
+ return new DepthStencilState(builder);
+ }
+ InputStateBase* Device::CreateInputState(InputStateBuilder* builder) {
+ return new InputState(builder);
+ }
+ ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) {
+ return new PipelineLayout(this, descriptor);
+ }
+ ResultOrError<QueueBase*> Device::CreateQueueImpl() {
+ return new Queue(this);
+ }
+ RenderPassDescriptorBase* Device::CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) {
+ return new RenderPassDescriptor(builder);
+ }
+ RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
+ return new RenderPipeline(builder);
+ }
+ ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
+ return new Sampler(this, descriptor);
+ }
+ ResultOrError<ShaderModuleBase*> Device::CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) {
+ return new ShaderModule(this, descriptor);
+ }
+ SwapChainBase* Device::CreateSwapChain(SwapChainBuilder* builder) {
+ return new SwapChain(builder);
+ }
+ ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
+ return new Texture(this, descriptor);
+ }
+ ResultOrError<TextureViewBase*> Device::CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ return new TextureView(texture, descriptor);
+ }
+
+ void Device::CollectPCIInfo() {
+ memset(&mPCIInfo, 0, sizeof(mPCIInfo));
+
+ DXGI_ADAPTER_DESC1 adapterDesc;
+ mHardwareAdapter->GetDesc1(&adapterDesc);
+
+ mPCIInfo.deviceId = adapterDesc.DeviceId;
+ mPCIInfo.vendorId = adapterDesc.VendorId;
+
+ std::wstring_convert<std::codecvt<wchar_t, char, std::mbstate_t>> converter(
+ "Error converting");
+ mPCIInfo.name = converter.to_bytes(adapterDesc.Description);
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/DeviceD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/DeviceD3D12.h
new file mode 100644
index 00000000000..3717e2453e2
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/DeviceD3D12.h
@@ -0,0 +1,129 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_DEVICED3D12_H_
+#define DAWNNATIVE_D3D12_DEVICED3D12_H_
+
+#include "dawn_native/dawn_platform.h"
+
+#include "common/SerialQueue.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/d3d12/Forward.h"
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include <memory>
+
+namespace dawn_native { namespace d3d12 {
+
+ class CommandAllocatorManager;
+ class DescriptorHeapAllocator;
+ class MapRequestTracker;
+ class PlatformFunctions;
+ class ResourceAllocator;
+ class ResourceUploader;
+
+ void ASSERT_SUCCESS(HRESULT hr);
+
+ // Definition of backend types
+ class Device : public DeviceBase {
+ public:
+ Device();
+ ~Device();
+
+ BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
+ BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
+ BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
+ CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
+ DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
+ InputStateBase* CreateInputState(InputStateBuilder* builder) override;
+ RenderPassDescriptorBase* CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) override;
+ RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
+ SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
+
+ void TickImpl() override;
+
+ const dawn_native::PCIInfo& GetPCIInfo() const override;
+
+ ComPtr<IDXGIFactory4> GetFactory();
+ ComPtr<ID3D12Device> GetD3D12Device();
+ ComPtr<ID3D12CommandQueue> GetCommandQueue();
+
+ DescriptorHeapAllocator* GetDescriptorHeapAllocator();
+ MapRequestTracker* GetMapRequestTracker() const;
+ const PlatformFunctions* GetFunctions();
+ ResourceAllocator* GetResourceAllocator();
+ ResourceUploader* GetResourceUploader();
+
+ void OpenCommandList(ComPtr<ID3D12GraphicsCommandList>* commandList);
+ ComPtr<ID3D12GraphicsCommandList> GetPendingCommandList();
+
+ uint64_t GetSerial() const;
+ void NextSerial();
+ void WaitForSerial(uint64_t serial);
+
+ void ReferenceUntilUnused(ComPtr<IUnknown> object);
+
+ void ExecuteCommandLists(std::initializer_list<ID3D12CommandList*> commandLists);
+
+ private:
+ ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) override;
+ ResultOrError<BufferBase*> CreateBufferImpl(const BufferDescriptor* descriptor) override;
+ ResultOrError<ComputePipelineBase*> CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) override;
+ ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) override;
+ ResultOrError<QueueBase*> CreateQueueImpl() override;
+ ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
+ ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) override;
+ ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
+ ResultOrError<TextureViewBase*> CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) override;
+ void CollectPCIInfo();
+
+ // Keep mFunctions as the first member so that in the destructor it is freed. Otherwise the
+ // D3D12 DLLs are unloaded before we are done using it.
+ std::unique_ptr<PlatformFunctions> mFunctions;
+
+ uint64_t mSerial = 0;
+ ComPtr<ID3D12Fence> mFence;
+ HANDLE mFenceEvent;
+
+ ComPtr<IDXGIFactory4> mFactory;
+ ComPtr<IDXGIAdapter1> mHardwareAdapter;
+ ComPtr<ID3D12Device> mD3d12Device;
+ ComPtr<ID3D12CommandQueue> mCommandQueue;
+
+ struct PendingCommandList {
+ ComPtr<ID3D12GraphicsCommandList> commandList;
+ bool open = false;
+ } mPendingCommands;
+
+ SerialQueue<ComPtr<IUnknown>> mUsedComObjectRefs;
+
+ std::unique_ptr<CommandAllocatorManager> mCommandAllocatorManager;
+ std::unique_ptr<DescriptorHeapAllocator> mDescriptorHeapAllocator;
+ std::unique_ptr<MapRequestTracker> mMapRequestTracker;
+ std::unique_ptr<ResourceAllocator> mResourceAllocator;
+ std::unique_ptr<ResourceUploader> mResourceUploader;
+
+ dawn_native::PCIInfo mPCIInfo;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_DEVICED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/Forward.h b/chromium/third_party/dawn/src/dawn_native/d3d12/Forward.h
new file mode 100644
index 00000000000..80cf0d42417
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/Forward.h
@@ -0,0 +1,71 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_FORWARD_H_
+#define DAWNNATIVE_D3D12_FORWARD_H_
+
+#include "dawn_native/ToBackend.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class BindGroup;
+ class BindGroupLayout;
+ class BlendState;
+ class Buffer;
+ class BufferView;
+ class CommandBuffer;
+ class ComputePipeline;
+ class DepthStencilState;
+ class Device;
+ class InputState;
+ class PipelineLayout;
+ class Queue;
+ class RenderPassDescriptor;
+ class RenderPipeline;
+ class Sampler;
+ class ShaderModule;
+ class SwapChain;
+ class Texture;
+ class TextureView;
+
+ struct D3D12BackendTraits {
+ using BindGroupType = BindGroup;
+ using BindGroupLayoutType = BindGroupLayout;
+ using BlendStateType = BlendState;
+ using BufferType = Buffer;
+ using BufferViewType = BufferView;
+ using CommandBufferType = CommandBuffer;
+ using ComputePipelineType = ComputePipeline;
+ using DepthStencilStateType = DepthStencilState;
+ using DeviceType = Device;
+ using InputStateType = InputState;
+ using PipelineLayoutType = PipelineLayout;
+ using QueueType = Queue;
+ using RenderPassDescriptorType = RenderPassDescriptor;
+ using RenderPipelineType = RenderPipeline;
+ using SamplerType = Sampler;
+ using ShaderModuleType = ShaderModule;
+ using SwapChainType = SwapChain;
+ using TextureType = Texture;
+ using TextureViewType = TextureView;
+ };
+
+ template <typename T>
+ auto ToBackend(T&& common) -> decltype(ToBackendBase<D3D12BackendTraits>(common)) {
+ return ToBackendBase<D3D12BackendTraits>(common);
+ }
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_FORWARD_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/InputStateD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/InputStateD3D12.cpp
new file mode 100644
index 00000000000..3469f9e04a3
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/InputStateD3D12.cpp
@@ -0,0 +1,103 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/InputStateD3D12.h"
+
+#include "common/BitSetIterator.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ static DXGI_FORMAT VertexFormatType(dawn::VertexFormat format) {
+ switch (format) {
+ case dawn::VertexFormat::FloatR32G32B32A32:
+ return DXGI_FORMAT_R32G32B32A32_FLOAT;
+ case dawn::VertexFormat::FloatR32G32B32:
+ return DXGI_FORMAT_R32G32B32_FLOAT;
+ case dawn::VertexFormat::FloatR32G32:
+ return DXGI_FORMAT_R32G32_FLOAT;
+ case dawn::VertexFormat::FloatR32:
+ return DXGI_FORMAT_R32_FLOAT;
+ case dawn::VertexFormat::IntR32G32B32A32:
+ return DXGI_FORMAT_R32G32B32A32_SINT;
+ case dawn::VertexFormat::IntR32G32B32:
+ return DXGI_FORMAT_R32G32B32_SINT;
+ case dawn::VertexFormat::IntR32G32:
+ return DXGI_FORMAT_R32G32_SINT;
+ case dawn::VertexFormat::IntR32:
+ return DXGI_FORMAT_R32_SINT;
+ case dawn::VertexFormat::UshortR16G16B16A16:
+ return DXGI_FORMAT_R16G16B16A16_UINT;
+ case dawn::VertexFormat::UshortR16G16:
+ return DXGI_FORMAT_R16G16_UINT;
+ case dawn::VertexFormat::UnormR8G8B8A8:
+ return DXGI_FORMAT_R8G8B8A8_UNORM;
+ case dawn::VertexFormat::UnormR8G8:
+ return DXGI_FORMAT_R8G8_UNORM;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ static D3D12_INPUT_CLASSIFICATION InputStepModeFunction(dawn::InputStepMode mode) {
+ switch (mode) {
+ case dawn::InputStepMode::Vertex:
+ return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA;
+ case dawn::InputStepMode::Instance:
+ return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ InputState::InputState(InputStateBuilder* builder) : InputStateBase(builder) {
+ const auto& attributesSetMask = GetAttributesSetMask();
+
+ unsigned int count = 0;
+ for (auto i : IterateBitSet(attributesSetMask)) {
+ if (!attributesSetMask[i]) {
+ continue;
+ }
+
+ D3D12_INPUT_ELEMENT_DESC& inputElementDescriptor = mInputElementDescriptors[count++];
+
+ const AttributeInfo& attribute = GetAttribute(i);
+
+ // If the HLSL semantic is TEXCOORDN the SemanticName should be "TEXCOORD" and the
+ // SemanticIndex N
+ inputElementDescriptor.SemanticName = "TEXCOORD";
+ inputElementDescriptor.SemanticIndex = static_cast<uint32_t>(i);
+ inputElementDescriptor.Format = VertexFormatType(attribute.format);
+ inputElementDescriptor.InputSlot = attribute.bindingSlot;
+
+ const InputInfo& input = GetInput(attribute.bindingSlot);
+
+ inputElementDescriptor.AlignedByteOffset = attribute.offset;
+ inputElementDescriptor.InputSlotClass = InputStepModeFunction(input.stepMode);
+ if (inputElementDescriptor.InputSlotClass ==
+ D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA) {
+ inputElementDescriptor.InstanceDataStepRate = 0;
+ } else {
+ inputElementDescriptor.InstanceDataStepRate = 1;
+ }
+ }
+
+ mInputLayoutDescriptor.pInputElementDescs = mInputElementDescriptors;
+ mInputLayoutDescriptor.NumElements = count;
+ }
+
+ const D3D12_INPUT_LAYOUT_DESC& InputState::GetD3D12InputLayoutDescriptor() const {
+ return mInputLayoutDescriptor;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/InputStateD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/InputStateD3D12.h
new file mode 100644
index 00000000000..f42b74734e7
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/InputStateD3D12.h
@@ -0,0 +1,39 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_INPUTSTATED3D12_H_
+#define DAWNNATIVE_D3D12_INPUTSTATED3D12_H_
+
+#include "dawn_native/InputState.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class InputState : public InputStateBase {
+ public:
+ InputState(InputStateBuilder* builder);
+
+ const D3D12_INPUT_LAYOUT_DESC& GetD3D12InputLayoutDescriptor() const;
+
+ private:
+ D3D12_INPUT_LAYOUT_DESC mInputLayoutDescriptor;
+ D3D12_INPUT_ELEMENT_DESC mInputElementDescriptors[kMaxVertexAttributes];
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_INPUTSTATED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/NativeSwapChainImplD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/NativeSwapChainImplD3D12.cpp
new file mode 100644
index 00000000000..99ac8f80918
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/NativeSwapChainImplD3D12.cpp
@@ -0,0 +1,118 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/NativeSwapChainImplD3D12.h"
+
+#include "common/Assert.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/TextureD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ DXGI_USAGE D3D12SwapChainBufferUsage(dawnTextureUsageBit allowedUsages) {
+ DXGI_USAGE usage = DXGI_CPU_ACCESS_NONE;
+ if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_SAMPLED) {
+ usage |= DXGI_USAGE_SHADER_INPUT;
+ }
+ if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_STORAGE) {
+ usage |= DXGI_USAGE_UNORDERED_ACCESS;
+ }
+ if (allowedUsages & DAWN_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT) {
+ usage |= DXGI_USAGE_RENDER_TARGET_OUTPUT;
+ }
+ return usage;
+ }
+
+ static constexpr unsigned int kFrameCount = 2;
+ } // anonymous namespace
+
+ NativeSwapChainImpl::NativeSwapChainImpl(Device* device, HWND window)
+ : mWindow(window), mDevice(device) {
+ }
+
+ NativeSwapChainImpl::~NativeSwapChainImpl() {
+ }
+
+ void NativeSwapChainImpl::Init(dawnWSIContextD3D12* /*context*/) {
+ }
+
+ dawnSwapChainError NativeSwapChainImpl::Configure(dawnTextureFormat format,
+ dawnTextureUsageBit usage,
+ uint32_t width,
+ uint32_t height) {
+ ASSERT(width > 0);
+ ASSERT(height > 0);
+ ASSERT(format == static_cast<dawnTextureFormat>(GetPreferredFormat()));
+
+ ComPtr<IDXGIFactory4> factory = mDevice->GetFactory();
+ ComPtr<ID3D12CommandQueue> queue = mDevice->GetCommandQueue();
+
+ // Create the D3D12 swapchain, assuming only two buffers for now
+ DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {};
+ swapChainDesc.Width = width;
+ swapChainDesc.Height = height;
+ swapChainDesc.Format = D3D12TextureFormat(GetPreferredFormat());
+ swapChainDesc.BufferUsage = D3D12SwapChainBufferUsage(usage);
+ swapChainDesc.BufferCount = kFrameCount;
+ swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
+ swapChainDesc.SampleDesc.Count = 1;
+ swapChainDesc.SampleDesc.Quality = 0;
+
+ ComPtr<IDXGISwapChain1> swapChain1;
+ ASSERT_SUCCESS(factory->CreateSwapChainForHwnd(queue.Get(), mWindow, &swapChainDesc,
+ nullptr, nullptr, &swapChain1));
+
+ ASSERT_SUCCESS(swapChain1.As(&mSwapChain));
+
+ // Gather the resources that will be used to present to the swapchain
+ mBuffers.resize(kFrameCount);
+ for (uint32_t i = 0; i < kFrameCount; ++i) {
+ ASSERT_SUCCESS(mSwapChain->GetBuffer(i, IID_PPV_ARGS(&mBuffers[i])));
+ }
+
+ // Set the initial serial of buffers to 0 so that we don't wait on them when they are first
+ // used
+ mBufferSerials.resize(kFrameCount, 0);
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError NativeSwapChainImpl::GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
+ mCurrentBuffer = mSwapChain->GetCurrentBackBufferIndex();
+ nextTexture->texture.ptr = mBuffers[mCurrentBuffer].Get();
+
+ // TODO(cwallez@chromium.org) Currently we force the CPU to wait for the GPU to be finished
+ // with the buffer. Ideally the synchronization should be all done on the GPU.
+ mDevice->WaitForSerial(mBufferSerials[mCurrentBuffer]);
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError NativeSwapChainImpl::Present() {
+ // This assumes the texture has already been transition to the PRESENT state.
+
+ ASSERT_SUCCESS(mSwapChain->Present(1, 0));
+ // TODO(cwallez@chromium.org): Make the serial ticking implicit.
+ mDevice->NextSerial();
+
+ mBufferSerials[mCurrentBuffer] = mDevice->GetSerial();
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
+ return dawn::TextureFormat::R8G8B8A8Unorm;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/NativeSwapChainImplD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/NativeSwapChainImplD3D12.h
new file mode 100644
index 00000000000..f953da5e62b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/NativeSwapChainImplD3D12.h
@@ -0,0 +1,58 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_NATIVESWAPCHAINIMPLD3D12_H_
+#define DAWNNATIVE_D3D12_NATIVESWAPCHAINIMPLD3D12_H_
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include "dawn/dawn_wsi.h"
+#include "dawn_native/dawn_platform.h"
+
+#include <vector>
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class NativeSwapChainImpl {
+ public:
+ using WSIContext = dawnWSIContextD3D12;
+
+ NativeSwapChainImpl(Device* device, HWND window);
+ ~NativeSwapChainImpl();
+
+ void Init(dawnWSIContextD3D12* context);
+ dawnSwapChainError Configure(dawnTextureFormat format,
+ dawnTextureUsageBit,
+ uint32_t width,
+ uint32_t height);
+ dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
+ dawnSwapChainError Present();
+
+ dawn::TextureFormat GetPreferredFormat() const;
+
+ private:
+ HWND mWindow = nullptr;
+ Device* mDevice = nullptr;
+
+ ComPtr<IDXGISwapChain3> mSwapChain = nullptr;
+ std::vector<ComPtr<ID3D12Resource>> mBuffers;
+ std::vector<uint64_t> mBufferSerials;
+ uint32_t mCurrentBuffer;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_NATIVESWAPCHAINIMPLD3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp
new file mode 100644
index 00000000000..1ee21e16830
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/PipelineLayoutD3D12.cpp
@@ -0,0 +1,116 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
+
+#include "common/Assert.h"
+#include "common/BitSetIterator.h"
+#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/PlatformFunctions.h"
+
+using Microsoft::WRL::ComPtr;
+
+namespace dawn_native { namespace d3d12 {
+
+ PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor)
+ : PipelineLayoutBase(device, descriptor) {
+ D3D12_ROOT_PARAMETER rootParameters[kMaxBindGroups * 2];
+
+ // A root parameter is one of these types
+ union {
+ D3D12_ROOT_DESCRIPTOR_TABLE DescriptorTable;
+ D3D12_ROOT_CONSTANTS Constants;
+ D3D12_ROOT_DESCRIPTOR Descriptor;
+ } rootParameterValues[kMaxBindGroups * 2];
+ // samplers must be in a separate descriptor table so we need at most twice as many tables
+ // as bind groups
+
+ // Ranges are D3D12_DESCRIPTOR_RANGE_TYPE_(SRV|UAV|CBV|SAMPLER)
+ // They are grouped together so each bind group has at most 4 ranges
+ D3D12_DESCRIPTOR_RANGE ranges[kMaxBindGroups * 4];
+
+ uint32_t parameterIndex = 0;
+ uint32_t rangeIndex = 0;
+
+ for (uint32_t group : IterateBitSet(GetBindGroupLayoutsMask())) {
+ const BindGroupLayout* bindGroupLayout = ToBackend(GetBindGroupLayout(group));
+
+ // Set the root descriptor table parameter and copy ranges. Ranges are offset by the
+ // bind group index Returns whether or not the parameter was set. A root parameter is
+ // not set if the number of ranges is 0
+ auto SetRootDescriptorTable =
+ [&](uint32_t rangeCount, const D3D12_DESCRIPTOR_RANGE* descriptorRanges) -> bool {
+ if (rangeCount == 0) {
+ return false;
+ }
+
+ auto& rootParameter = rootParameters[parameterIndex];
+ rootParameter.ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
+ rootParameter.DescriptorTable = rootParameterValues[parameterIndex].DescriptorTable;
+ rootParameter.ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
+ rootParameter.DescriptorTable.NumDescriptorRanges = rangeCount;
+ rootParameter.DescriptorTable.pDescriptorRanges = &ranges[rangeIndex];
+
+ for (uint32_t i = 0; i < rangeCount; ++i) {
+ ranges[rangeIndex] = descriptorRanges[i];
+ ranges[rangeIndex].BaseShaderRegister += group * kMaxBindingsPerGroup;
+ rangeIndex++;
+ }
+
+ return true;
+ };
+
+ if (SetRootDescriptorTable(bindGroupLayout->GetCbvUavSrvDescriptorTableSize(),
+ bindGroupLayout->GetCbvUavSrvDescriptorRanges())) {
+ mCbvUavSrvRootParameterInfo[group] = parameterIndex++;
+ }
+
+ if (SetRootDescriptorTable(bindGroupLayout->GetSamplerDescriptorTableSize(),
+ bindGroupLayout->GetSamplerDescriptorRanges())) {
+ mSamplerRootParameterInfo[group] = parameterIndex++;
+ }
+ }
+
+ D3D12_ROOT_SIGNATURE_DESC rootSignatureDescriptor;
+ rootSignatureDescriptor.NumParameters = parameterIndex;
+ rootSignatureDescriptor.pParameters = rootParameters;
+ rootSignatureDescriptor.NumStaticSamplers = 0;
+ rootSignatureDescriptor.pStaticSamplers = nullptr;
+ rootSignatureDescriptor.Flags =
+ D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT;
+
+ ComPtr<ID3DBlob> signature;
+ ComPtr<ID3DBlob> error;
+ ASSERT_SUCCESS(device->GetFunctions()->d3d12SerializeRootSignature(
+ &rootSignatureDescriptor, D3D_ROOT_SIGNATURE_VERSION_1, &signature, &error));
+ ASSERT_SUCCESS(device->GetD3D12Device()->CreateRootSignature(
+ 0, signature->GetBufferPointer(), signature->GetBufferSize(),
+ IID_PPV_ARGS(&mRootSignature)));
+ }
+
+ uint32_t PipelineLayout::GetCbvUavSrvRootParameterIndex(uint32_t group) const {
+ ASSERT(group < kMaxBindGroups);
+ return mCbvUavSrvRootParameterInfo[group];
+ }
+
+ uint32_t PipelineLayout::GetSamplerRootParameterIndex(uint32_t group) const {
+ ASSERT(group < kMaxBindGroups);
+ return mSamplerRootParameterInfo[group];
+ }
+
+ ComPtr<ID3D12RootSignature> PipelineLayout::GetRootSignature() {
+ return mRootSignature;
+ }
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/PipelineLayoutD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/PipelineLayoutD3D12.h
new file mode 100644
index 00000000000..90c1802a4cc
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/PipelineLayoutD3D12.h
@@ -0,0 +1,44 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_PIPELINELAYOUTD3D12_H_
+#define DAWNNATIVE_D3D12_PIPELINELAYOUTD3D12_H_
+
+#include "dawn_native/PipelineLayout.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class PipelineLayout : public PipelineLayoutBase {
+ public:
+ PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
+
+ uint32_t GetCbvUavSrvRootParameterIndex(uint32_t group) const;
+ uint32_t GetSamplerRootParameterIndex(uint32_t group) const;
+
+ ComPtr<ID3D12RootSignature> GetRootSignature();
+
+ private:
+ std::array<uint32_t, kMaxBindGroups> mCbvUavSrvRootParameterInfo;
+ std::array<uint32_t, kMaxBindGroups> mSamplerRootParameterInfo;
+
+ ComPtr<ID3D12RootSignature> mRootSignature;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_PIPELINELAYOUTD3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/PlatformFunctions.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/PlatformFunctions.cpp
new file mode 100644
index 00000000000..5834a2a931b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/PlatformFunctions.cpp
@@ -0,0 +1,74 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/PlatformFunctions.h"
+
+#include "common/DynamicLib.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ PlatformFunctions::PlatformFunctions() {
+ }
+ PlatformFunctions::~PlatformFunctions() {
+ }
+
+ MaybeError PlatformFunctions::LoadFunctions() {
+ DAWN_TRY(LoadD3D12());
+ DAWN_TRY(LoadDXGI());
+ DAWN_TRY(LoadD3DCompiler());
+
+ return {};
+ }
+
+ MaybeError PlatformFunctions::LoadD3D12() {
+ std::string error;
+ if (!mD3D12Lib.Open("d3d12.dll", &error) ||
+ !mD3D12Lib.GetProc(&d3d12CreateDevice, "D3D12CreateDevice", &error) ||
+ !mD3D12Lib.GetProc(&d3d12GetDebugInterface, "D3D12GetDebugInterface", &error) ||
+ !mD3D12Lib.GetProc(&d3d12SerializeRootSignature, "D3D12SerializeRootSignature",
+ &error) ||
+ !mD3D12Lib.GetProc(&d3d12CreateRootSignatureDeserializer,
+ "D3D12CreateRootSignatureDeserializer", &error) ||
+ !mD3D12Lib.GetProc(&d3d12SerializeVersionedRootSignature,
+ "D3D12SerializeVersionedRootSignature", &error) ||
+ !mD3D12Lib.GetProc(&d3d12CreateVersionedRootSignatureDeserializer,
+ "D3D12CreateVersionedRootSignatureDeserializer", &error)) {
+ return DAWN_CONTEXT_LOST_ERROR(error.c_str());
+ }
+
+ return {};
+ }
+
+ MaybeError PlatformFunctions::LoadDXGI() {
+ std::string error;
+ if (!mDXGILib.Open("dxgi.dll", &error) ||
+ !mDXGILib.GetProc(&dxgiGetDebugInterface1, "DXGIGetDebugInterface1", &error) ||
+ !mDXGILib.GetProc(&createDxgiFactory2, "CreateDXGIFactory2", &error)) {
+ return DAWN_CONTEXT_LOST_ERROR(error.c_str());
+ }
+
+ return {};
+ }
+
+ MaybeError PlatformFunctions::LoadD3DCompiler() {
+ std::string error;
+ if (!mD3DCompilerLib.Open("d3dcompiler_47.dll", &error) ||
+ !mD3DCompilerLib.GetProc(&d3dCompile, "D3DCompile", &error)) {
+ return DAWN_CONTEXT_LOST_ERROR(error.c_str());
+ }
+
+ return {};
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/PlatformFunctions.h b/chromium/third_party/dawn/src/dawn_native/d3d12/PlatformFunctions.h
new file mode 100644
index 00000000000..710fb84a2b2
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/PlatformFunctions.h
@@ -0,0 +1,75 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_PLATFORMFUNCTIONS_H_
+#define DAWNNATIVE_D3D12_PLATFORMFUNCTIONS_H_
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include "common/DynamicLib.h"
+#include "dawn_native/Error.h"
+
+#include <d3dcompiler.h>
+
+class DynamicLib;
+
+namespace dawn_native { namespace d3d12 {
+
+ // Loads the functions required from the platform dynamically so that we don't need to rely on
+ // them being present in the system. For example linking against d3d12.lib would prevent
+ // dawn_native from loading on Windows 7 system where d3d12.dll doesn't exist.
+ class PlatformFunctions {
+ public:
+ PlatformFunctions();
+ ~PlatformFunctions();
+
+ MaybeError LoadFunctions();
+
+ // Functions from d3d12.dll
+ PFN_D3D12_CREATE_DEVICE d3d12CreateDevice = nullptr;
+ PFN_D3D12_GET_DEBUG_INTERFACE d3d12GetDebugInterface = nullptr;
+
+ PFN_D3D12_SERIALIZE_ROOT_SIGNATURE d3d12SerializeRootSignature = nullptr;
+ PFN_D3D12_CREATE_ROOT_SIGNATURE_DESERIALIZER d3d12CreateRootSignatureDeserializer = nullptr;
+ PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE d3d12SerializeVersionedRootSignature = nullptr;
+ PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER
+ d3d12CreateVersionedRootSignatureDeserializer = nullptr;
+
+ // Functions from dxgi.dll
+ using PFN_DXGI_GET_DEBUG_INTERFACE1 = HRESULT(WINAPI*)(UINT Flags,
+ REFIID riid,
+ _COM_Outptr_ void** pDebug);
+ PFN_DXGI_GET_DEBUG_INTERFACE1 dxgiGetDebugInterface1 = nullptr;
+
+ using PFN_CREATE_DXGI_FACTORY2 = HRESULT(WINAPI*)(UINT Flags,
+ REFIID riid,
+ _COM_Outptr_ void** ppFactory);
+ PFN_CREATE_DXGI_FACTORY2 createDxgiFactory2 = nullptr;
+
+ // Functions from d3d3compiler.dll
+ pD3DCompile d3dCompile = nullptr;
+
+ private:
+ MaybeError LoadD3D12();
+ MaybeError LoadDXGI();
+ MaybeError LoadD3DCompiler();
+
+ DynamicLib mD3D12Lib;
+ DynamicLib mDXGILib;
+ DynamicLib mD3DCompilerLib;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_VULKAN_VULKANFUNCTIONS_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/QueueD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/QueueD3D12.cpp
new file mode 100644
index 00000000000..e9866f2e70b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/QueueD3D12.cpp
@@ -0,0 +1,41 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/QueueD3D12.h"
+
+#include "dawn_native/d3d12/CommandBufferD3D12.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ Queue::Queue(Device* device) : QueueBase(device) {
+ }
+
+ void Queue::SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) {
+ Device* device = ToBackend(GetDevice());
+
+ device->Tick();
+
+ device->OpenCommandList(&mCommandList);
+ for (uint32_t i = 0; i < numCommands; ++i) {
+ ToBackend(commands[i])->RecordCommands(mCommandList, i);
+ }
+ ASSERT_SUCCESS(mCommandList->Close());
+
+ device->ExecuteCommandLists({mCommandList.Get()});
+
+ device->NextSerial();
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/QueueD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/QueueD3D12.h
new file mode 100644
index 00000000000..7420b1d4470
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/QueueD3D12.h
@@ -0,0 +1,39 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_QUEUED3D12_H_
+#define DAWNNATIVE_D3D12_QUEUED3D12_H_
+
+#include "dawn_native/Queue.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+ class CommandBuffer;
+
+ class Queue : public QueueBase {
+ public:
+ Queue(Device* device);
+
+ private:
+ void SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) override;
+
+ ComPtr<ID3D12GraphicsCommandList> mCommandList;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_QUEUED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPassDescriptorD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPassDescriptorD3D12.cpp
new file mode 100644
index 00000000000..74ac4c9bf41
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPassDescriptorD3D12.cpp
@@ -0,0 +1,84 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/RenderPassDescriptorD3D12.h"
+
+#include "common/BitSetIterator.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/TextureD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ RenderPassDescriptor::RenderPassDescriptor(RenderPassDescriptorBuilder* builder)
+ : RenderPassDescriptorBase(builder) {
+ Device* device = ToBackend(GetDevice());
+
+ // Get and fill an RTV heap with the color attachments
+ uint32_t colorAttachmentCount = static_cast<uint32_t>(GetColorAttachmentMask().count());
+ if (colorAttachmentCount != 0) {
+ mRtvHeap = device->GetDescriptorHeapAllocator()->AllocateCPUHeap(
+ D3D12_DESCRIPTOR_HEAP_TYPE_RTV, colorAttachmentCount);
+
+ for (uint32_t i : IterateBitSet(GetColorAttachmentMask())) {
+ TextureView* view = ToBackend(GetColorAttachment(i).view.Get());
+ ComPtr<ID3D12Resource> resource = ToBackend(view->GetTexture())->GetD3D12Resource();
+
+ D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle = mRtvHeap.GetCPUHandle(i);
+ D3D12_RENDER_TARGET_VIEW_DESC rtvDesc = view->GetRTVDescriptor();
+ device->GetD3D12Device()->CreateRenderTargetView(resource.Get(), &rtvDesc,
+ rtvHandle);
+ }
+ }
+
+ // Get and fill a DSV heap with the depth stencil attachment
+ if (HasDepthStencilAttachment()) {
+ mDsvHeap = device->GetDescriptorHeapAllocator()->AllocateCPUHeap(
+ D3D12_DESCRIPTOR_HEAP_TYPE_DSV, 1);
+
+ TextureView* view = ToBackend(GetDepthStencilAttachment().view.Get());
+ ComPtr<ID3D12Resource> resource = ToBackend(view->GetTexture())->GetD3D12Resource();
+
+ D3D12_CPU_DESCRIPTOR_HANDLE dsvHandle = mDsvHeap.GetCPUHandle(0);
+ D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = view->GetDSVDescriptor();
+ device->GetD3D12Device()->CreateDepthStencilView(resource.Get(), &dsvDesc, dsvHandle);
+ }
+ }
+
+ RenderPassDescriptor::OMSetRenderTargetArgs
+ RenderPassDescriptor::GetSubpassOMSetRenderTargetArgs() {
+ OMSetRenderTargetArgs args = {};
+
+ unsigned int rtvIndex = 0;
+ for (uint32_t i : IterateBitSet(GetColorAttachmentMask())) {
+ args.RTVs[rtvIndex] = GetRTVDescriptor(i);
+ rtvIndex++;
+ }
+ args.numRTVs = rtvIndex;
+
+ if (HasDepthStencilAttachment()) {
+ args.dsv = GetDSVDescriptor();
+ }
+
+ return args;
+ }
+
+ D3D12_CPU_DESCRIPTOR_HANDLE RenderPassDescriptor::GetRTVDescriptor(uint32_t attachmentSlot) {
+ return mRtvHeap.GetCPUHandle(attachmentSlot);
+ }
+
+ D3D12_CPU_DESCRIPTOR_HANDLE RenderPassDescriptor::GetDSVDescriptor() {
+ return mDsvHeap.GetCPUHandle(0);
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPassDescriptorD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPassDescriptorD3D12.h
new file mode 100644
index 00000000000..11aec2483a8
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPassDescriptorD3D12.h
@@ -0,0 +1,51 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_RENDERPASSDESCRIPTORD3D12_H_
+#define DAWNNATIVE_D3D12_RENDERPASSDESCRIPTORD3D12_H_
+
+#include "dawn_native/RenderPassDescriptor.h"
+
+#include "common/Constants.h"
+#include "dawn_native/d3d12/DescriptorHeapAllocator.h"
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include <array>
+#include <vector>
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class RenderPassDescriptor : public RenderPassDescriptorBase {
+ public:
+ struct OMSetRenderTargetArgs {
+ unsigned int numRTVs = 0;
+ std::array<D3D12_CPU_DESCRIPTOR_HANDLE, kMaxColorAttachments> RTVs = {};
+ D3D12_CPU_DESCRIPTOR_HANDLE dsv = {};
+ };
+
+ RenderPassDescriptor(RenderPassDescriptorBuilder* builder);
+ OMSetRenderTargetArgs GetSubpassOMSetRenderTargetArgs();
+ D3D12_CPU_DESCRIPTOR_HANDLE GetRTVDescriptor(uint32_t attachmentSlot);
+ D3D12_CPU_DESCRIPTOR_HANDLE GetDSVDescriptor();
+
+ private:
+ DescriptorHeapHandle mRtvHeap = {};
+ DescriptorHeapHandle mDsvHeap = {};
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_RENDERPASSDESCRIPTORD3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPipelineD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPipelineD3D12.cpp
new file mode 100644
index 00000000000..63385dbf1b6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPipelineD3D12.cpp
@@ -0,0 +1,179 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/RenderPipelineD3D12.h"
+
+#include "common/Assert.h"
+#include "dawn_native/d3d12/BlendStateD3D12.h"
+#include "dawn_native/d3d12/DepthStencilStateD3D12.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/InputStateD3D12.h"
+#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
+#include "dawn_native/d3d12/PlatformFunctions.h"
+#include "dawn_native/d3d12/ShaderModuleD3D12.h"
+#include "dawn_native/d3d12/TextureD3D12.h"
+
+#include <d3dcompiler.h>
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ D3D12_PRIMITIVE_TOPOLOGY D3D12PrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
+ switch (primitiveTopology) {
+ case dawn::PrimitiveTopology::PointList:
+ return D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
+ case dawn::PrimitiveTopology::LineList:
+ return D3D_PRIMITIVE_TOPOLOGY_LINELIST;
+ case dawn::PrimitiveTopology::LineStrip:
+ return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP;
+ case dawn::PrimitiveTopology::TriangleList:
+ return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
+ case dawn::PrimitiveTopology::TriangleStrip:
+ return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ D3D12_PRIMITIVE_TOPOLOGY_TYPE D3D12PrimitiveTopologyType(
+ dawn::PrimitiveTopology primitiveTopology) {
+ switch (primitiveTopology) {
+ case dawn::PrimitiveTopology::PointList:
+ return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT;
+ case dawn::PrimitiveTopology::LineList:
+ case dawn::PrimitiveTopology::LineStrip:
+ return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
+ case dawn::PrimitiveTopology::TriangleList:
+ case dawn::PrimitiveTopology::TriangleStrip:
+ return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
+ default:
+ UNREACHABLE();
+ }
+ }
+ } // namespace
+
+ RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
+ : RenderPipelineBase(builder),
+ mD3d12PrimitiveTopology(D3D12PrimitiveTopology(GetPrimitiveTopology())),
+ mDevice(ToBackend(builder->GetDevice())) {
+ uint32_t compileFlags = 0;
+#if defined(_DEBUG)
+ // Enable better shader debugging with the graphics debugging tools.
+ compileFlags |= D3DCOMPILE_DEBUG | D3DCOMPILE_SKIP_OPTIMIZATION;
+#endif
+ // SPRIV-cross does matrix multiplication expecting row major matrices
+ compileFlags |= D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
+
+ D3D12_GRAPHICS_PIPELINE_STATE_DESC descriptor = {};
+
+ PerStage<ComPtr<ID3DBlob>> compiledShader;
+ ComPtr<ID3DBlob> errors;
+
+ for (auto stage : IterateStages(GetStageMask())) {
+ const auto& module = ToBackend(builder->GetStageInfo(stage).module);
+ const auto& entryPoint = builder->GetStageInfo(stage).entryPoint;
+ const auto& hlslSource = module->GetHLSLSource(ToBackend(GetLayout()));
+
+ const char* compileTarget = nullptr;
+
+ D3D12_SHADER_BYTECODE* shader = nullptr;
+ switch (stage) {
+ case dawn::ShaderStage::Vertex:
+ shader = &descriptor.VS;
+ compileTarget = "vs_5_1";
+ break;
+ case dawn::ShaderStage::Fragment:
+ shader = &descriptor.PS;
+ compileTarget = "ps_5_1";
+ break;
+ case dawn::ShaderStage::Compute:
+ UNREACHABLE();
+ break;
+ }
+
+ const PlatformFunctions* functions = ToBackend(builder->GetDevice())->GetFunctions();
+ if (FAILED(functions->d3dCompile(hlslSource.c_str(), hlslSource.length(), nullptr,
+ nullptr, nullptr, entryPoint.c_str(), compileTarget,
+ compileFlags, 0, &compiledShader[stage], &errors))) {
+ printf("%s\n", reinterpret_cast<char*>(errors->GetBufferPointer()));
+ ASSERT(false);
+ }
+
+ if (shader != nullptr) {
+ shader->pShaderBytecode = compiledShader[stage]->GetBufferPointer();
+ shader->BytecodeLength = compiledShader[stage]->GetBufferSize();
+ }
+ }
+
+ PipelineLayout* layout = ToBackend(GetLayout());
+
+ descriptor.pRootSignature = layout->GetRootSignature().Get();
+
+ // D3D12 logs warnings if any empty input state is used
+ InputState* inputState = ToBackend(GetInputState());
+ if (inputState->GetAttributesSetMask().any()) {
+ descriptor.InputLayout = inputState->GetD3D12InputLayoutDescriptor();
+ }
+
+ descriptor.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID;
+ descriptor.RasterizerState.CullMode = D3D12_CULL_MODE_NONE;
+ descriptor.RasterizerState.FrontCounterClockwise = FALSE;
+ descriptor.RasterizerState.DepthBias = D3D12_DEFAULT_DEPTH_BIAS;
+ descriptor.RasterizerState.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP;
+ descriptor.RasterizerState.SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS;
+ descriptor.RasterizerState.DepthClipEnable = TRUE;
+ descriptor.RasterizerState.MultisampleEnable = FALSE;
+ descriptor.RasterizerState.AntialiasedLineEnable = FALSE;
+ descriptor.RasterizerState.ForcedSampleCount = 0;
+ descriptor.RasterizerState.ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF;
+
+ if (HasDepthStencilAttachment()) {
+ descriptor.DSVFormat = D3D12TextureFormat(GetDepthStencilFormat());
+ }
+
+ for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) {
+ descriptor.RTVFormats[i] = D3D12TextureFormat(GetColorAttachmentFormat(i));
+ descriptor.BlendState.RenderTarget[i] =
+ ToBackend(GetBlendState(i))->GetD3D12BlendDesc();
+ }
+ descriptor.NumRenderTargets = static_cast<uint32_t>(GetColorAttachmentsMask().count());
+
+ descriptor.BlendState.AlphaToCoverageEnable = FALSE;
+ descriptor.BlendState.IndependentBlendEnable = TRUE;
+
+ DepthStencilState* depthStencilState = ToBackend(GetDepthStencilState());
+ descriptor.DepthStencilState = depthStencilState->GetD3D12DepthStencilDescriptor();
+
+ descriptor.SampleMask = UINT_MAX;
+ descriptor.PrimitiveTopologyType = D3D12PrimitiveTopologyType(GetPrimitiveTopology());
+ descriptor.SampleDesc.Count = 1;
+
+ Device* device = ToBackend(builder->GetDevice());
+ ASSERT_SUCCESS(device->GetD3D12Device()->CreateGraphicsPipelineState(
+ &descriptor, IID_PPV_ARGS(&mPipelineState)));
+ }
+
+ RenderPipeline::~RenderPipeline() {
+ mDevice->ReferenceUntilUnused(mPipelineState);
+ }
+
+ D3D12_PRIMITIVE_TOPOLOGY RenderPipeline::GetD3D12PrimitiveTopology() const {
+ return mD3d12PrimitiveTopology;
+ }
+
+ ComPtr<ID3D12PipelineState> RenderPipeline::GetPipelineState() {
+ return mPipelineState;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPipelineD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPipelineD3D12.h
new file mode 100644
index 00000000000..81596a1e55b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/RenderPipelineD3D12.h
@@ -0,0 +1,43 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_RENDERPIPELINED3D12_H_
+#define DAWNNATIVE_D3D12_RENDERPIPELINED3D12_H_
+
+#include "dawn_native/RenderPipeline.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class RenderPipeline : public RenderPipelineBase {
+ public:
+ RenderPipeline(RenderPipelineBuilder* builder);
+ ~RenderPipeline();
+
+ D3D12_PRIMITIVE_TOPOLOGY GetD3D12PrimitiveTopology() const;
+ ComPtr<ID3D12PipelineState> GetPipelineState();
+
+ private:
+ D3D12_PRIMITIVE_TOPOLOGY mD3d12PrimitiveTopology;
+ ComPtr<ID3D12PipelineState> mPipelineState;
+
+ Device* mDevice = nullptr;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_RENDERPIPELINED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceAllocator.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceAllocator.cpp
new file mode 100644
index 00000000000..c50de5b5c4e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceAllocator.cpp
@@ -0,0 +1,77 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/ResourceAllocator.h"
+
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ static constexpr D3D12_HEAP_PROPERTIES kDefaultHeapProperties = {
+ D3D12_HEAP_TYPE_DEFAULT, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 0,
+ 0};
+
+ static constexpr D3D12_HEAP_PROPERTIES kUploadHeapProperties = {
+ D3D12_HEAP_TYPE_UPLOAD, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 0,
+ 0};
+
+ static constexpr D3D12_HEAP_PROPERTIES kReadbackHeapProperties = {
+ D3D12_HEAP_TYPE_READBACK, D3D12_CPU_PAGE_PROPERTY_UNKNOWN, D3D12_MEMORY_POOL_UNKNOWN, 0,
+ 0};
+ } // namespace
+
+ ResourceAllocator::ResourceAllocator(Device* device) : mDevice(device) {
+ }
+
+ ComPtr<ID3D12Resource> ResourceAllocator::Allocate(
+ D3D12_HEAP_TYPE heapType,
+ const D3D12_RESOURCE_DESC& resourceDescriptor,
+ D3D12_RESOURCE_STATES initialUsage) {
+ const D3D12_HEAP_PROPERTIES* heapProperties = nullptr;
+ switch (heapType) {
+ case D3D12_HEAP_TYPE_DEFAULT:
+ heapProperties = &kDefaultHeapProperties;
+ break;
+ case D3D12_HEAP_TYPE_UPLOAD:
+ heapProperties = &kUploadHeapProperties;
+ break;
+ case D3D12_HEAP_TYPE_READBACK:
+ heapProperties = &kReadbackHeapProperties;
+ break;
+ default:
+ UNREACHABLE();
+ }
+
+ ComPtr<ID3D12Resource> resource;
+
+ // TODO(enga@google.com): Use CreatePlacedResource
+ ASSERT_SUCCESS(mDevice->GetD3D12Device()->CreateCommittedResource(
+ heapProperties, D3D12_HEAP_FLAG_NONE, &resourceDescriptor, initialUsage, nullptr,
+ IID_PPV_ARGS(&resource)));
+
+ return resource;
+ }
+
+ void ResourceAllocator::Release(ComPtr<ID3D12Resource> resource) {
+ // Resources may still be in use on the GPU. Enqueue them so that we hold onto them until
+ // GPU execution has completed
+ mReleasedResources.Enqueue(resource, mDevice->GetSerial());
+ }
+
+ void ResourceAllocator::Tick(uint64_t lastCompletedSerial) {
+ mReleasedResources.ClearUpTo(lastCompletedSerial);
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceAllocator.h b/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceAllocator.h
new file mode 100644
index 00000000000..9311db6df0b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceAllocator.h
@@ -0,0 +1,44 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_RESOURCEALLOCATIONMANAGER_H_
+#define DAWNNATIVE_D3D12_RESOURCEALLOCATIONMANAGER_H_
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include "common/SerialQueue.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class ResourceAllocator {
+ public:
+ ResourceAllocator(Device* device);
+
+ ComPtr<ID3D12Resource> Allocate(D3D12_HEAP_TYPE heapType,
+ const D3D12_RESOURCE_DESC& resourceDescriptor,
+ D3D12_RESOURCE_STATES initialUsage);
+ void Release(ComPtr<ID3D12Resource> resource);
+ void Tick(uint64_t lastCompletedSerial);
+
+ private:
+ Device* mDevice;
+
+ SerialQueue<ComPtr<ID3D12Resource>> mReleasedResources;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_RESOURCEALLOCATIONMANAGER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceUploader.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceUploader.cpp
new file mode 100644
index 00000000000..6aa9a6b950d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceUploader.cpp
@@ -0,0 +1,73 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/ResourceUploader.h"
+
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/ResourceAllocator.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ ResourceUploader::ResourceUploader(Device* device) : mDevice(device) {
+ }
+
+ void ResourceUploader::BufferSubData(ComPtr<ID3D12Resource> resource,
+ uint32_t start,
+ uint32_t count,
+ const void* data) {
+ // TODO(enga@google.com): Use a handle to a subset of a large ring buffer. On Release,
+ // decrease reference count on the ring buffer and free when 0. Alternatively, the
+ // SerialQueue could be used to track which last point of the ringbuffer is in use, and
+ // start reusing chunks of it that aren't in flight.
+ UploadHandle uploadHandle = GetUploadBuffer(count);
+ memcpy(uploadHandle.mappedBuffer, data, count);
+ mDevice->GetPendingCommandList()->CopyBufferRegion(resource.Get(), start,
+ uploadHandle.resource.Get(), 0, count);
+ Release(uploadHandle);
+ }
+
+ ResourceUploader::UploadHandle ResourceUploader::GetUploadBuffer(uint32_t requiredSize) {
+ // TODO(enga@google.com): This will find or create a mapped buffer of sufficient size and
+ // return a handle to a mapped range
+ D3D12_RESOURCE_DESC resourceDescriptor;
+ resourceDescriptor.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
+ resourceDescriptor.Alignment = 0;
+ resourceDescriptor.Width = requiredSize;
+ resourceDescriptor.Height = 1;
+ resourceDescriptor.DepthOrArraySize = 1;
+ resourceDescriptor.MipLevels = 1;
+ resourceDescriptor.Format = DXGI_FORMAT_UNKNOWN;
+ resourceDescriptor.SampleDesc.Count = 1;
+ resourceDescriptor.SampleDesc.Quality = 0;
+ resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
+ resourceDescriptor.Flags = D3D12_RESOURCE_FLAG_NONE;
+
+ UploadHandle uploadHandle;
+ uploadHandle.resource = mDevice->GetResourceAllocator()->Allocate(
+ D3D12_HEAP_TYPE_UPLOAD, resourceDescriptor, D3D12_RESOURCE_STATE_GENERIC_READ);
+ D3D12_RANGE readRange;
+ readRange.Begin = 0;
+ readRange.End = 0;
+
+ uploadHandle.resource->Map(0, &readRange,
+ reinterpret_cast<void**>(&uploadHandle.mappedBuffer));
+ return uploadHandle;
+ }
+
+ void ResourceUploader::Release(UploadHandle uploadHandle) {
+ uploadHandle.resource->Unmap(0, nullptr);
+ mDevice->GetResourceAllocator()->Release(uploadHandle.resource);
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceUploader.h b/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceUploader.h
new file mode 100644
index 00000000000..c3307e54cc5
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/ResourceUploader.h
@@ -0,0 +1,48 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_RESOURCEUPLOADER_H_
+#define DAWNNATIVE_D3D12_RESOURCEUPLOADER_H_
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+#include "dawn_native/Forward.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class ResourceUploader {
+ public:
+ ResourceUploader(Device* device);
+
+ void BufferSubData(ComPtr<ID3D12Resource> resource,
+ uint32_t start,
+ uint32_t count,
+ const void* data);
+
+ private:
+ struct UploadHandle {
+ ComPtr<ID3D12Resource> resource;
+ uint8_t* mappedBuffer;
+ };
+
+ UploadHandle GetUploadBuffer(uint32_t requiredSize);
+ void Release(UploadHandle uploadHandle);
+
+ Device* mDevice;
+ };
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_RESOURCEUPLOADER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/SamplerD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/SamplerD3D12.cpp
new file mode 100644
index 00000000000..9c3559c25e7
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/SamplerD3D12.cpp
@@ -0,0 +1,96 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/SamplerD3D12.h"
+
+#include "dawn_native/d3d12/DeviceD3D12.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ D3D12_TEXTURE_ADDRESS_MODE AddressMode(dawn::AddressMode mode) {
+ switch (mode) {
+ case dawn::AddressMode::Repeat:
+ return D3D12_TEXTURE_ADDRESS_MODE_WRAP;
+ case dawn::AddressMode::MirroredRepeat:
+ return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
+ case dawn::AddressMode::ClampToEdge:
+ return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
+ default:
+ UNREACHABLE();
+ }
+ }
+ } // namespace
+
+ Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
+ : SamplerBase(device, descriptor) {
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/dn770367(v=vs.85).aspx
+ // hex value, decimal value, min linear, mag linear, mip linear
+ // D3D12_FILTER_MIN_MAG_MIP_POINT = 0 0 0 0 0
+ // D3D12_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1 1 0 0 1
+ // D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4 4 0 1 0
+ // D3D12_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5 5 0 1 1
+ // D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10 16 1 0 0
+ // D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11 17 1 0 1
+ // D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14 20 1 1 0
+ // D3D12_FILTER_MIN_MAG_MIP_LINEAR = 0x15 21 1 1 1
+
+ // if mip mode is linear, add 1
+ // if mag mode is linear, add 4
+ // if min mode is linear, add 16
+
+ uint8_t mode = 0;
+
+ switch (descriptor->minFilter) {
+ case dawn::FilterMode::Nearest:
+ break;
+ case dawn::FilterMode::Linear:
+ mode += 16;
+ break;
+ }
+
+ switch (descriptor->magFilter) {
+ case dawn::FilterMode::Nearest:
+ break;
+ case dawn::FilterMode::Linear:
+ mode += 4;
+ break;
+ }
+
+ switch (descriptor->mipmapFilter) {
+ case dawn::FilterMode::Nearest:
+ break;
+ case dawn::FilterMode::Linear:
+ mode += 1;
+ break;
+ }
+
+ mSamplerDesc.Filter = static_cast<D3D12_FILTER>(mode);
+ mSamplerDesc.AddressU = AddressMode(descriptor->addressModeU);
+ mSamplerDesc.AddressV = AddressMode(descriptor->addressModeV);
+ mSamplerDesc.AddressW = AddressMode(descriptor->addressModeW);
+ mSamplerDesc.MipLODBias = 0.f;
+ mSamplerDesc.MaxAnisotropy = 1;
+ mSamplerDesc.ComparisonFunc = D3D12_COMPARISON_FUNC_ALWAYS;
+ mSamplerDesc.BorderColor[0] = mSamplerDesc.BorderColor[1] = mSamplerDesc.BorderColor[2] =
+ mSamplerDesc.BorderColor[3] = 0;
+ mSamplerDesc.MinLOD = 0;
+ mSamplerDesc.MaxLOD = D3D12_FLOAT32_MAX;
+ }
+
+ const D3D12_SAMPLER_DESC& Sampler::GetSamplerDescriptor() const {
+ return mSamplerDesc;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/SamplerD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/SamplerD3D12.h
new file mode 100644
index 00000000000..46e82b5852a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/SamplerD3D12.h
@@ -0,0 +1,38 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_SAMPLERD3D12_H_
+#define DAWNNATIVE_D3D12_SAMPLERD3D12_H_
+
+#include "dawn_native/Sampler.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ class Sampler : public SamplerBase {
+ public:
+ Sampler(Device* device, const SamplerDescriptor* descriptor);
+
+ const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const;
+
+ private:
+ D3D12_SAMPLER_DESC mSamplerDesc;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_SAMPLERD3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/ShaderModuleD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
new file mode 100644
index 00000000000..ad1c5068ad8
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/ShaderModuleD3D12.cpp
@@ -0,0 +1,65 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/ShaderModuleD3D12.h"
+
+#include "common/Assert.h"
+#include "dawn_native/d3d12/BindGroupLayoutD3D12.h"
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/PipelineLayoutD3D12.h"
+
+#include <spirv-cross/spirv_hlsl.hpp>
+
+namespace dawn_native { namespace d3d12 {
+
+ ShaderModule::ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor)
+ : ShaderModuleBase(device, descriptor) {
+ mSpirv.assign(descriptor->code, descriptor->code + descriptor->codeSize);
+ spirv_cross::CompilerHLSL compiler(mSpirv);
+ ExtractSpirvInfo(compiler);
+ }
+
+ const std::string ShaderModule::GetHLSLSource(PipelineLayout* layout) const {
+ spirv_cross::CompilerHLSL compiler(mSpirv);
+
+ // If these options are changed, the values in DawnSPIRVCrossHLSLFastFuzzer.cpp need to be
+ // updated.
+ spirv_cross::CompilerGLSL::Options options_glsl;
+ options_glsl.vertex.fixup_clipspace = true;
+ options_glsl.vertex.flip_vert_y = true;
+ compiler.set_common_options(options_glsl);
+
+ spirv_cross::CompilerHLSL::Options options_hlsl;
+ options_hlsl.shader_model = 51;
+ compiler.set_hlsl_options(options_hlsl);
+
+ const ModuleBindingInfo& moduleBindingInfo = GetBindingInfo();
+ for (uint32_t group = 0; group < moduleBindingInfo.size(); ++group) {
+ const auto& bindingOffsets =
+ ToBackend(layout->GetBindGroupLayout(group))->GetBindingOffsets();
+ const auto& groupBindingInfo = moduleBindingInfo[group];
+ for (uint32_t binding = 0; binding < groupBindingInfo.size(); ++binding) {
+ const BindingInfo& bindingInfo = groupBindingInfo[binding];
+ if (bindingInfo.used) {
+ uint32_t bindGroupOffset = group * kMaxBindingsPerGroup;
+ uint32_t bindingOffset = bindingOffsets[binding];
+ compiler.set_decoration(bindingInfo.id, spv::DecorationBinding,
+ bindGroupOffset + bindingOffset);
+ }
+ }
+ }
+ return compiler.compile();
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/ShaderModuleD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/ShaderModuleD3D12.h
new file mode 100644
index 00000000000..7cafd1cb218
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/ShaderModuleD3D12.h
@@ -0,0 +1,37 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_SHADERMODULED3D12_H_
+#define DAWNNATIVE_D3D12_SHADERMODULED3D12_H_
+
+#include "dawn_native/ShaderModule.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+ class PipelineLayout;
+
+ class ShaderModule : public ShaderModuleBase {
+ public:
+ ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor);
+
+ const std::string GetHLSLSource(PipelineLayout* layout) const;
+
+ private:
+ std::vector<uint32_t> mSpirv;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_SHADERMODULED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/SwapChainD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/SwapChainD3D12.cpp
new file mode 100644
index 00000000000..2b3b6c40692
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/SwapChainD3D12.cpp
@@ -0,0 +1,59 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/SwapChainD3D12.h"
+
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/TextureD3D12.h"
+
+#include <dawn/dawn_wsi.h>
+
+namespace dawn_native { namespace d3d12 {
+
+ SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
+ const auto& im = GetImplementation();
+ dawnWSIContextD3D12 wsiContext = {};
+ wsiContext.device = reinterpret_cast<dawnDevice>(GetDevice());
+ im.Init(im.userData, &wsiContext);
+
+ ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_BIT_NONE);
+ mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
+ }
+
+ SwapChain::~SwapChain() {
+ }
+
+ TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
+ const auto& im = GetImplementation();
+ dawnSwapChainNextTexture next = {};
+ dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
+ if (error) {
+ GetDevice()->HandleError(error);
+ return nullptr;
+ }
+
+ ID3D12Resource* nativeTexture = reinterpret_cast<ID3D12Resource*>(next.texture.ptr);
+ return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
+ }
+
+ void SwapChain::OnBeforePresent(TextureBase* texture) {
+ Device* device = ToBackend(GetDevice());
+
+ // Perform the necessary transition for the texture to be presented.
+ ToBackend(texture)->TransitionUsageNow(device->GetPendingCommandList(), mTextureUsage);
+
+ device->ExecuteCommandLists({});
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/SwapChainD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/SwapChainD3D12.h
new file mode 100644
index 00000000000..8a82aa99c1a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/SwapChainD3D12.h
@@ -0,0 +1,36 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_SWAPCHAIND3D12_H_
+#define DAWNNATIVE_D3D12_SWAPCHAIND3D12_H_
+
+#include "dawn_native/SwapChain.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class SwapChain : public SwapChainBase {
+ public:
+ SwapChain(SwapChainBuilder* builder);
+ ~SwapChain();
+
+ protected:
+ TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
+ void OnBeforePresent(TextureBase* texture) override;
+
+ dawn::TextureUsageBit mTextureUsage;
+ };
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_SWAPCHAIN_D3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/TextureCopySplitter.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/TextureCopySplitter.cpp
new file mode 100644
index 00000000000..32f53094c61
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/TextureCopySplitter.cpp
@@ -0,0 +1,209 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/TextureCopySplitter.h"
+
+#include "common/Assert.h"
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ void ComputeTexelOffsets(uint32_t offset,
+ uint32_t rowPitch,
+ uint32_t slicePitch,
+ uint32_t texelSize,
+ uint32_t* texelOffsetX,
+ uint32_t* texelOffsetY,
+ uint32_t* texelOffsetZ) {
+ uint32_t byteOffsetX = offset % rowPitch;
+ offset -= byteOffsetX;
+ uint32_t byteOffsetY = offset % slicePitch;
+ uint32_t byteOffsetZ = offset - byteOffsetY;
+
+ *texelOffsetX = byteOffsetX / texelSize;
+ *texelOffsetY = byteOffsetY / rowPitch;
+ *texelOffsetZ = byteOffsetZ / slicePitch;
+ }
+ } // namespace
+
+ TextureCopySplit ComputeTextureCopySplit(uint32_t x,
+ uint32_t y,
+ uint32_t z,
+ uint32_t width,
+ uint32_t height,
+ uint32_t depth,
+ uint32_t texelSize,
+ uint32_t offset,
+ uint32_t rowPitch) {
+ TextureCopySplit copy;
+
+ if (z != 0 || depth > 1) {
+ // TODO(enga@google.com): Handle 3D
+ ASSERT(false);
+ return copy;
+ }
+
+ ASSERT(rowPitch % texelSize == 0);
+
+ uint32_t alignedOffset = offset & ~(D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT - 1);
+
+ copy.offset = alignedOffset;
+ if (offset == alignedOffset) {
+ copy.count = 1;
+
+ copy.copies[0].textureOffset.x = x;
+ copy.copies[0].textureOffset.y = y;
+ copy.copies[0].textureOffset.z = z;
+
+ copy.copies[0].copySize.width = width;
+ copy.copies[0].copySize.height = height;
+ copy.copies[0].copySize.depth = depth;
+
+ copy.copies[0].bufferOffset.x = 0;
+ copy.copies[0].bufferOffset.y = 0;
+ copy.copies[0].bufferOffset.z = 0;
+ copy.copies[0].bufferSize.width = width;
+ copy.copies[0].bufferSize.height = height;
+ copy.copies[0].bufferSize.depth = depth;
+
+ // Return early. There is only one copy needed because the offset is already 512-byte
+ // aligned
+ return copy;
+ }
+
+ ASSERT(alignedOffset < offset);
+
+ uint32_t texelOffsetX, texelOffsetY, texelOffsetZ;
+ ComputeTexelOffsets(offset - alignedOffset, rowPitch, rowPitch * height, texelSize,
+ &texelOffsetX, &texelOffsetY, &texelOffsetZ);
+
+ uint32_t rowPitchInTexels = rowPitch / texelSize;
+
+ if (width + texelOffsetX <= rowPitchInTexels) {
+ // The region's rows fit inside the row pitch. In this case, extend the width of the
+ // PlacedFootprint and copy the buffer with an offset location
+ // |<--------------- row pitch --------------->|
+ //
+ // |-------------------------------------------|
+ // | |
+ // | +++++++++++++++++~~~~~~~~~|
+ // |~~~~~~~~~~~~~~~~~+++++++++++++++++~~~~~~~~~|
+ // |~~~~~~~~~~~~~~~~~+++++++++++++++++~~~~~~~~~|
+ // |~~~~~~~~~~~~~~~~~+++++++++++++++++~~~~~~~~~|
+ // |~~~~~~~~~~~~~~~~~+++++++++++++++++ |
+ // |-------------------------------------------|
+
+ // Copy 0:
+ // |----------------------------------|
+ // | |
+ // | +++++++++++++++++|
+ // |~~~~~~~~~~~~~~~~~+++++++++++++++++|
+ // |~~~~~~~~~~~~~~~~~+++++++++++++++++|
+ // |~~~~~~~~~~~~~~~~~+++++++++++++++++|
+ // |~~~~~~~~~~~~~~~~~+++++++++++++++++|
+ // |----------------------------------|
+
+ copy.count = 1;
+
+ copy.copies[0].textureOffset.x = x;
+ copy.copies[0].textureOffset.y = y;
+ copy.copies[0].textureOffset.z = z;
+
+ copy.copies[0].copySize.width = width;
+ copy.copies[0].copySize.height = height;
+ copy.copies[0].copySize.depth = depth;
+
+ copy.copies[0].bufferOffset.x = texelOffsetX;
+ copy.copies[0].bufferOffset.y = texelOffsetY;
+ copy.copies[0].bufferOffset.z = texelOffsetZ;
+ copy.copies[0].bufferSize.width = width + texelOffsetX;
+ copy.copies[0].bufferSize.height = height + texelOffsetY;
+ copy.copies[0].bufferSize.depth = depth + texelOffsetZ;
+
+ return copy;
+ }
+
+ // The region's rows straddle the row pitch. Split the copy into two copies
+ // |<--------------- row pitch --------------->|
+ //
+ // |-------------------------------------------|
+ // | |
+ // | ++++++++|
+ // |+++++++++~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++|
+ // |+++++++++~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++|
+ // |+++++++++~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++|
+ // |+++++++++~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++|
+ // |+++++++++ |
+ // |-------------------------------------------|
+
+ // Copy 0:
+ // |-------------------------------------------|
+ // | |
+ // | ++++++++|
+ // |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++|
+ // |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++|
+ // |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++|
+ // |~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++++++++|
+ // |-------------------------------------------|
+
+ // Copy 1:
+ // |---------|
+ // | |
+ // | |
+ // |+++++++++|
+ // |+++++++++|
+ // |+++++++++|
+ // |+++++++++|
+ // |+++++++++|
+ // |---------|
+
+ copy.count = 2;
+
+ copy.copies[0].textureOffset.x = x;
+ copy.copies[0].textureOffset.y = y;
+ copy.copies[0].textureOffset.z = z;
+
+ ASSERT(rowPitchInTexels > texelOffsetX);
+ copy.copies[0].copySize.width = rowPitchInTexels - texelOffsetX;
+ copy.copies[0].copySize.height = height;
+ copy.copies[0].copySize.depth = depth;
+
+ copy.copies[0].bufferOffset.x = texelOffsetX;
+ copy.copies[0].bufferOffset.y = texelOffsetY;
+ copy.copies[0].bufferOffset.z = texelOffsetZ;
+ copy.copies[0].bufferSize.width = rowPitchInTexels;
+ copy.copies[0].bufferSize.height = height + texelOffsetY;
+ copy.copies[0].bufferSize.depth = depth + texelOffsetZ;
+
+ copy.copies[1].textureOffset.x = x + copy.copies[0].copySize.width;
+ copy.copies[1].textureOffset.y = y;
+ copy.copies[1].textureOffset.z = z;
+
+ ASSERT(width > copy.copies[0].copySize.width);
+ copy.copies[1].copySize.width = width - copy.copies[0].copySize.width;
+ copy.copies[1].copySize.height = height;
+ copy.copies[1].copySize.depth = depth;
+
+ copy.copies[1].bufferOffset.x = 0;
+ copy.copies[1].bufferOffset.y = texelOffsetY + 1;
+ copy.copies[1].bufferOffset.z = texelOffsetZ;
+ copy.copies[1].bufferSize.width = copy.copies[1].copySize.width;
+ copy.copies[1].bufferSize.height = height + texelOffsetY + 1;
+ copy.copies[1].bufferSize.depth = depth + texelOffsetZ;
+
+ return copy;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/TextureCopySplitter.h b/chromium/third_party/dawn/src/dawn_native/d3d12/TextureCopySplitter.h
new file mode 100644
index 00000000000..eec55e29868
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/TextureCopySplitter.h
@@ -0,0 +1,64 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_
+#define DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_
+
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+
+namespace dawn_native { namespace d3d12 {
+
+ struct TextureCopySplit {
+ static constexpr unsigned int kMaxTextureCopyRegions = 2;
+
+ struct Extent {
+ uint32_t width = 0;
+ uint32_t height = 0;
+ uint32_t depth = 0;
+ };
+
+ struct Origin {
+ uint32_t x = 0;
+ uint32_t y = 0;
+ uint32_t z = 0;
+ };
+
+ struct CopyInfo {
+ Origin textureOffset;
+ Origin bufferOffset;
+ Extent bufferSize;
+
+ Extent copySize;
+ };
+
+ uint32_t offset = 0;
+ uint32_t count = 0;
+ std::array<CopyInfo, kMaxTextureCopyRegions> copies;
+ };
+
+ TextureCopySplit ComputeTextureCopySplit(uint32_t x,
+ uint32_t y,
+ uint32_t z,
+ uint32_t width,
+ uint32_t height,
+ uint32_t depth,
+ uint32_t texelSize,
+ uint32_t offset,
+ uint32_t rowPitch);
+
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_TEXTURECOPYSPLITTER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/TextureD3D12.cpp b/chromium/third_party/dawn/src/dawn_native/d3d12/TextureD3D12.cpp
new file mode 100644
index 00000000000..4fd16ab0f8e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/TextureD3D12.cpp
@@ -0,0 +1,253 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/d3d12/TextureD3D12.h"
+
+#include "dawn_native/d3d12/DeviceD3D12.h"
+#include "dawn_native/d3d12/ResourceAllocator.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ namespace {
+ D3D12_RESOURCE_STATES D3D12TextureUsage(dawn::TextureUsageBit usage,
+ dawn::TextureFormat format) {
+ D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
+
+ // Present is an exclusive flag.
+ if (usage & dawn::TextureUsageBit::Present) {
+ return D3D12_RESOURCE_STATE_PRESENT;
+ }
+
+ if (usage & dawn::TextureUsageBit::TransferSrc) {
+ resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
+ }
+ if (usage & dawn::TextureUsageBit::TransferDst) {
+ resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
+ }
+ if (usage & dawn::TextureUsageBit::Sampled) {
+ resourceState |= (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE |
+ D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
+ }
+ if (usage & dawn::TextureUsageBit::Storage) {
+ resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
+ }
+ if (usage & dawn::TextureUsageBit::OutputAttachment) {
+ if (TextureFormatHasDepth(format) || TextureFormatHasStencil(format)) {
+ resourceState |= D3D12_RESOURCE_STATE_DEPTH_WRITE;
+ } else {
+ resourceState |= D3D12_RESOURCE_STATE_RENDER_TARGET;
+ }
+ }
+
+ return resourceState;
+ }
+
+ D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::TextureUsageBit usage,
+ dawn::TextureFormat format) {
+ D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
+
+ if (usage & dawn::TextureUsageBit::Storage) {
+ flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
+ }
+ if (usage & dawn::TextureUsageBit::OutputAttachment) {
+ if (TextureFormatHasDepth(format) || TextureFormatHasStencil(format)) {
+ flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
+ } else {
+ flags |= D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
+ }
+ }
+
+ ASSERT(!(flags & D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) ||
+ flags == D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL);
+ return flags;
+ }
+
+ D3D12_RESOURCE_DIMENSION D3D12TextureDimension(dawn::TextureDimension dimension) {
+ switch (dimension) {
+ case dawn::TextureDimension::e2D:
+ return D3D12_RESOURCE_DIMENSION_TEXTURE2D;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ } // namespace
+
+ DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::R8G8B8A8Unorm:
+ return DXGI_FORMAT_R8G8B8A8_UNORM;
+ case dawn::TextureFormat::R8G8Unorm:
+ return DXGI_FORMAT_R8G8_UNORM;
+ case dawn::TextureFormat::R8Unorm:
+ return DXGI_FORMAT_R8_UNORM;
+ case dawn::TextureFormat::R8G8B8A8Uint:
+ return DXGI_FORMAT_R8G8B8A8_UINT;
+ case dawn::TextureFormat::R8G8Uint:
+ return DXGI_FORMAT_R8G8_UINT;
+ case dawn::TextureFormat::R8Uint:
+ return DXGI_FORMAT_R8_UINT;
+ case dawn::TextureFormat::B8G8R8A8Unorm:
+ return DXGI_FORMAT_B8G8R8A8_UNORM;
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ Texture::Texture(Device* device, const TextureDescriptor* descriptor)
+ : TextureBase(device, descriptor) {
+ D3D12_RESOURCE_DESC resourceDescriptor;
+ resourceDescriptor.Dimension = D3D12TextureDimension(GetDimension());
+ resourceDescriptor.Alignment = 0;
+
+ const Extent3D& size = GetSize();
+ resourceDescriptor.Width = size.width;
+ resourceDescriptor.Height = size.height;
+
+ resourceDescriptor.DepthOrArraySize = GetDepthOrArraySize();
+ resourceDescriptor.MipLevels = static_cast<UINT16>(GetNumMipLevels());
+ resourceDescriptor.Format = D3D12TextureFormat(GetFormat());
+ resourceDescriptor.SampleDesc.Count = 1;
+ resourceDescriptor.SampleDesc.Quality = 0;
+ resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
+ resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage(), GetFormat());
+
+ mResource = ToBackend(GetDevice())
+ ->GetResourceAllocator()
+ ->Allocate(D3D12_HEAP_TYPE_DEFAULT, resourceDescriptor,
+ D3D12_RESOURCE_STATE_COMMON);
+ mResourcePtr = mResource.Get();
+ }
+
+ // With this constructor, the lifetime of the ID3D12Resource is externally managed.
+ Texture::Texture(Device* device,
+ const TextureDescriptor* descriptor,
+ ID3D12Resource* nativeTexture)
+ : TextureBase(device, descriptor), mResourcePtr(nativeTexture) {
+ }
+
+ Texture::~Texture() {
+ if (mResource) {
+ // If we own the resource, release it.
+ ToBackend(GetDevice())->GetResourceAllocator()->Release(mResource);
+ }
+ }
+
+ DXGI_FORMAT Texture::GetD3D12Format() const {
+ return D3D12TextureFormat(GetFormat());
+ }
+
+ ID3D12Resource* Texture::GetD3D12Resource() {
+ return mResourcePtr;
+ }
+
+ UINT16 Texture::GetDepthOrArraySize() {
+ switch (GetDimension()) {
+ case dawn::TextureDimension::e2D:
+ return static_cast<UINT16>(GetArrayLayers());
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ void Texture::TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
+ dawn::TextureUsageBit usage) {
+ // Avoid transitioning the texture when it isn't needed.
+ // TODO(cwallez@chromium.org): Need some form of UAV barriers at some point.
+ if (usage == mLastUsage) {
+ return;
+ }
+
+ D3D12_RESOURCE_STATES lastState = D3D12TextureUsage(mLastUsage, GetFormat());
+ D3D12_RESOURCE_STATES newState = D3D12TextureUsage(usage, GetFormat());
+
+ D3D12_RESOURCE_BARRIER barrier;
+ barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
+ barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
+ barrier.Transition.pResource = mResourcePtr;
+ barrier.Transition.StateBefore = lastState;
+ barrier.Transition.StateAfter = newState;
+ barrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
+
+ commandList->ResourceBarrier(1, &barrier);
+
+ mLastUsage = usage;
+ }
+
+ TextureView::TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor)
+ : TextureViewBase(texture, descriptor) {
+ mSrvDesc.Format = D3D12TextureFormat(descriptor->format);
+ mSrvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
+
+ // Currently we always use D3D12_TEX2D_ARRAY_SRV because we cannot specify base array layer
+ // and layer count in D3D12_TEX2D_SRV. For 2D texture views, we treat them as 1-layer 2D
+ // array textures.
+ // https://docs.microsoft.com/en-us/windows/desktop/api/d3d12/ns-d3d12-d3d12_tex2d_srv
+ // https://docs.microsoft.com/en-us/windows/desktop/api/d3d12/ns-d3d12-d3d12_tex2d_array_srv
+ // TODO(jiawei.shao@intel.com): support more texture view dimensions.
+ switch (descriptor->dimension) {
+ case dawn::TextureViewDimension::e2D:
+ case dawn::TextureViewDimension::e2DArray:
+ ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D);
+ mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
+ mSrvDesc.Texture2DArray.ArraySize = descriptor->layerCount;
+ mSrvDesc.Texture2DArray.FirstArraySlice = descriptor->baseArrayLayer;
+ mSrvDesc.Texture2DArray.MipLevels = descriptor->levelCount;
+ mSrvDesc.Texture2DArray.MostDetailedMip = descriptor->baseMipLevel;
+ mSrvDesc.Texture2DArray.PlaneSlice = 0;
+ mSrvDesc.Texture2DArray.ResourceMinLODClamp = 0;
+ break;
+ case dawn::TextureViewDimension::Cube:
+ case dawn::TextureViewDimension::CubeArray:
+ ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D);
+ ASSERT(descriptor->layerCount % 6 == 0);
+ mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
+ mSrvDesc.TextureCubeArray.First2DArrayFace = descriptor->baseArrayLayer;
+ mSrvDesc.TextureCubeArray.NumCubes = descriptor->layerCount / 6;
+ mSrvDesc.TextureCubeArray.MostDetailedMip = descriptor->baseMipLevel;
+ mSrvDesc.TextureCubeArray.MipLevels = descriptor->levelCount;
+ mSrvDesc.TextureCubeArray.ResourceMinLODClamp = 0;
+ break;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ const D3D12_SHADER_RESOURCE_VIEW_DESC& TextureView::GetSRVDescriptor() const {
+ return mSrvDesc;
+ }
+
+ // TODO(jiawei.shao@intel.com): support rendering into a layer of a texture.
+ D3D12_RENDER_TARGET_VIEW_DESC TextureView::GetRTVDescriptor() {
+ D3D12_RENDER_TARGET_VIEW_DESC rtvDesc;
+ rtvDesc.Format = ToBackend(GetTexture())->GetD3D12Format();
+ rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2D;
+ rtvDesc.Texture2D.MipSlice = 0;
+ rtvDesc.Texture2D.PlaneSlice = 0;
+ return rtvDesc;
+ }
+
+ // TODO(jiawei.shao@intel.com): support rendering into a layer of a texture.
+ D3D12_DEPTH_STENCIL_VIEW_DESC TextureView::GetDSVDescriptor() {
+ D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc;
+ dsvDesc.Format = ToBackend(GetTexture())->GetD3D12Format();
+ dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2D;
+ dsvDesc.Texture2D.MipSlice = 0;
+ dsvDesc.Flags = D3D12_DSV_FLAG_NONE;
+ return dsvDesc;
+ }
+
+}} // namespace dawn_native::d3d12
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/TextureD3D12.h b/chromium/third_party/dawn/src/dawn_native/d3d12/TextureD3D12.h
new file mode 100644
index 00000000000..23a0d52de13
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/TextureD3D12.h
@@ -0,0 +1,61 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_TEXTURED3D12_H_
+#define DAWNNATIVE_D3D12_TEXTURED3D12_H_
+
+#include "dawn_native/Texture.h"
+
+#include "dawn_native/d3d12/d3d12_platform.h"
+
+namespace dawn_native { namespace d3d12 {
+
+ class Device;
+
+ DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format);
+
+ class Texture : public TextureBase {
+ public:
+ Texture(Device* device, const TextureDescriptor* descriptor);
+ Texture(Device* device, const TextureDescriptor* descriptor, ID3D12Resource* nativeTexture);
+ ~Texture();
+
+ DXGI_FORMAT GetD3D12Format() const;
+ ID3D12Resource* GetD3D12Resource();
+
+ void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
+ dawn::TextureUsageBit usage);
+
+ private:
+ UINT16 GetDepthOrArraySize();
+
+ ComPtr<ID3D12Resource> mResource = {};
+ ID3D12Resource* mResourcePtr = nullptr;
+ dawn::TextureUsageBit mLastUsage = dawn::TextureUsageBit::None;
+ };
+
+ class TextureView : public TextureViewBase {
+ public:
+ TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor);
+
+ const D3D12_SHADER_RESOURCE_VIEW_DESC& GetSRVDescriptor() const;
+ D3D12_RENDER_TARGET_VIEW_DESC GetRTVDescriptor();
+ D3D12_DEPTH_STENCIL_VIEW_DESC GetDSVDescriptor();
+
+ private:
+ D3D12_SHADER_RESOURCE_VIEW_DESC mSrvDesc;
+ };
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12_TEXTURED3D12_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/d3d12/d3d12_platform.h b/chromium/third_party/dawn/src/dawn_native/d3d12/d3d12_platform.h
new file mode 100644
index 00000000000..9864c006728
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/d3d12/d3d12_platform.h
@@ -0,0 +1,34 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12_D3D12PLATFORM_H_
+#define DAWNNATIVE_D3D12_D3D12PLATFORM_H_
+
+#include <d3d12.h>
+#include <dxgi1_4.h>
+#include <wrl.h>
+
+#if defined(DAWN_ENABLE_ASSERTS)
+# include <dxgidebug.h>
+#endif // defined(DAWN_ENABLE_ASSERTS)
+
+using Microsoft::WRL::ComPtr;
+
+// Remove windows.h macros after d3d12's include of windows.h
+#include "common/Platform.h"
+#if defined(DAWN_PLATFORM_WINDOWS)
+# include "common/windows_with_undefs.h"
+#endif
+
+#endif // DAWNNATIVE_D3D12_D3D12PLATFORM_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/dawn_platform.h b/chromium/third_party/dawn/src/dawn_native/dawn_platform.h
new file mode 100644
index 00000000000..795c371225c
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/dawn_platform.h
@@ -0,0 +1,25 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_DAWNPLATFORM_H_
+#define DAWNNATIVE_DAWNPLATFORM_H_
+
+// Use dawncpp to have the enum and bitfield definitions
+#include <dawn/dawncpp.h>
+
+// Use our autogenerated version of the dawn structures that point to dawn_native object types
+// (dawn::Buffer is dawn_native::BufferBase*)
+#include <dawn_native/dawn_structs_autogen.h>
+
+#endif // DAWNNATIVE_DAWNPLATFORM_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/BlendStateMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/BlendStateMTL.h
new file mode 100644
index 00000000000..484bf519f3e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/BlendStateMTL.h
@@ -0,0 +1,32 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_BLENDSTATEMTL_H_
+#define DAWNNATIVE_METAL_BLENDSTATEMTL_H_
+
+#include "dawn_native/BlendState.h"
+
+#import <Metal/Metal.h>
+namespace dawn_native { namespace metal {
+
+ class BlendState : public BlendStateBase {
+ public:
+ BlendState(BlendStateBuilder* builder);
+
+ void ApplyBlendState(MTLRenderPipelineColorAttachmentDescriptor* descriptor) const;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_BLENDSTATEMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/BlendStateMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/BlendStateMTL.mm
new file mode 100644
index 00000000000..06227555e3f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/BlendStateMTL.mm
@@ -0,0 +1,99 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/BlendStateMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ namespace {
+
+ MTLBlendFactor MetalBlendFactor(dawn::BlendFactor factor, bool alpha) {
+ switch (factor) {
+ case dawn::BlendFactor::Zero:
+ return MTLBlendFactorZero;
+ case dawn::BlendFactor::One:
+ return MTLBlendFactorOne;
+ case dawn::BlendFactor::SrcColor:
+ return MTLBlendFactorSourceColor;
+ case dawn::BlendFactor::OneMinusSrcColor:
+ return MTLBlendFactorOneMinusSourceColor;
+ case dawn::BlendFactor::SrcAlpha:
+ return MTLBlendFactorSourceAlpha;
+ case dawn::BlendFactor::OneMinusSrcAlpha:
+ return MTLBlendFactorOneMinusSourceAlpha;
+ case dawn::BlendFactor::DstColor:
+ return MTLBlendFactorDestinationColor;
+ case dawn::BlendFactor::OneMinusDstColor:
+ return MTLBlendFactorOneMinusDestinationColor;
+ case dawn::BlendFactor::DstAlpha:
+ return MTLBlendFactorDestinationAlpha;
+ case dawn::BlendFactor::OneMinusDstAlpha:
+ return MTLBlendFactorOneMinusDestinationAlpha;
+ case dawn::BlendFactor::SrcAlphaSaturated:
+ return MTLBlendFactorSourceAlphaSaturated;
+ case dawn::BlendFactor::BlendColor:
+ return alpha ? MTLBlendFactorBlendAlpha : MTLBlendFactorBlendColor;
+ case dawn::BlendFactor::OneMinusBlendColor:
+ return alpha ? MTLBlendFactorOneMinusBlendAlpha
+ : MTLBlendFactorOneMinusBlendColor;
+ }
+ }
+
+ MTLBlendOperation MetalBlendOperation(dawn::BlendOperation operation) {
+ switch (operation) {
+ case dawn::BlendOperation::Add:
+ return MTLBlendOperationAdd;
+ case dawn::BlendOperation::Subtract:
+ return MTLBlendOperationSubtract;
+ case dawn::BlendOperation::ReverseSubtract:
+ return MTLBlendOperationReverseSubtract;
+ case dawn::BlendOperation::Min:
+ return MTLBlendOperationMin;
+ case dawn::BlendOperation::Max:
+ return MTLBlendOperationMax;
+ }
+ }
+
+ MTLColorWriteMask MetalColorWriteMask(dawn::ColorWriteMask colorWriteMask) {
+ return (((colorWriteMask & dawn::ColorWriteMask::Red) != dawn::ColorWriteMask::None
+ ? MTLColorWriteMaskRed
+ : MTLColorWriteMaskNone) |
+ ((colorWriteMask & dawn::ColorWriteMask::Green) != dawn::ColorWriteMask::None
+ ? MTLColorWriteMaskGreen
+ : MTLColorWriteMaskNone) |
+ ((colorWriteMask & dawn::ColorWriteMask::Blue) != dawn::ColorWriteMask::None
+ ? MTLColorWriteMaskBlue
+ : MTLColorWriteMaskNone) |
+ ((colorWriteMask & dawn::ColorWriteMask::Alpha) != dawn::ColorWriteMask::None
+ ? MTLColorWriteMaskAlpha
+ : MTLColorWriteMaskNone));
+ }
+ }
+
+ BlendState::BlendState(BlendStateBuilder* builder) : BlendStateBase(builder) {
+ }
+
+ void BlendState::ApplyBlendState(MTLRenderPipelineColorAttachmentDescriptor* descriptor) const {
+ auto& info = GetBlendInfo();
+ descriptor.blendingEnabled = info.blendEnabled;
+ descriptor.sourceRGBBlendFactor = MetalBlendFactor(info.colorBlend.srcFactor, false);
+ descriptor.destinationRGBBlendFactor = MetalBlendFactor(info.colorBlend.dstFactor, false);
+ descriptor.rgbBlendOperation = MetalBlendOperation(info.colorBlend.operation);
+ descriptor.sourceAlphaBlendFactor = MetalBlendFactor(info.alphaBlend.srcFactor, true);
+ descriptor.destinationAlphaBlendFactor = MetalBlendFactor(info.alphaBlend.dstFactor, true);
+ descriptor.alphaBlendOperation = MetalBlendOperation(info.alphaBlend.operation);
+ descriptor.writeMask = MetalColorWriteMask(info.colorWriteMask);
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/BufferMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/BufferMTL.h
new file mode 100644
index 00000000000..fbf4d37c5b7
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/BufferMTL.h
@@ -0,0 +1,72 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_BUFFERMTL_H_
+#define DAWNNATIVE_METAL_BUFFERMTL_H_
+
+#include "common/SerialQueue.h"
+#include "dawn_native/Buffer.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ class Buffer : public BufferBase {
+ public:
+ Buffer(Device* device, const BufferDescriptor* descriptor);
+ ~Buffer();
+
+ id<MTLBuffer> GetMTLBuffer();
+
+ void OnMapCommandSerialFinished(uint32_t mapSerial, uint32_t offset, bool isWrite);
+
+ private:
+ void SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
+ void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void UnmapImpl() override;
+
+ id<MTLBuffer> mMtlBuffer = nil;
+ };
+
+ class BufferView : public BufferViewBase {
+ public:
+ BufferView(BufferViewBuilder* builder);
+ };
+
+ class MapRequestTracker {
+ public:
+ MapRequestTracker(Device* device);
+ ~MapRequestTracker();
+
+ void Track(Buffer* buffer, uint32_t mapSerial, uint32_t offset, bool isWrite);
+ void Tick(Serial finishedSerial);
+
+ private:
+ Device* mDevice;
+
+ struct Request {
+ Ref<Buffer> buffer;
+ uint32_t mapSerial;
+ uint32_t offset;
+ bool isWrite;
+ };
+ SerialQueue<Request> mInflightRequests;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_BUFFERMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/BufferMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/BufferMTL.mm
new file mode 100644
index 00000000000..ebef40d614d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/BufferMTL.mm
@@ -0,0 +1,102 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/BufferMTL.h"
+
+#include "dawn_native/metal/DeviceMTL.h"
+#include "dawn_native/metal/ResourceUploader.h"
+
+namespace dawn_native { namespace metal {
+
+ Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
+ : BufferBase(device, descriptor) {
+ MTLResourceOptions storageMode;
+ if (GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
+ storageMode = MTLResourceStorageModeShared;
+ } else {
+ storageMode = MTLResourceStorageModePrivate;
+ }
+
+ mMtlBuffer = [device->GetMTLDevice() newBufferWithLength:GetSize() options:storageMode];
+ }
+
+ Buffer::~Buffer() {
+ [mMtlBuffer release];
+ mMtlBuffer = nil;
+ }
+
+ id<MTLBuffer> Buffer::GetMTLBuffer() {
+ return mMtlBuffer;
+ }
+
+ void Buffer::OnMapCommandSerialFinished(uint32_t mapSerial, uint32_t offset, bool isWrite) {
+ char* data = reinterpret_cast<char*>([mMtlBuffer contents]);
+ if (isWrite) {
+ CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data + offset);
+ } else {
+ CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data + offset);
+ }
+ }
+
+ void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) {
+ auto* uploader = ToBackend(GetDevice())->GetResourceUploader();
+ uploader->BufferSubData(mMtlBuffer, start, count, data);
+ }
+
+ void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t) {
+ MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
+ tracker->Track(this, serial, start, false);
+ }
+
+ void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t) {
+ MapRequestTracker* tracker = ToBackend(GetDevice())->GetMapTracker();
+ tracker->Track(this, serial, start, true);
+ }
+
+ void Buffer::UnmapImpl() {
+ // Nothing to do, Metal StorageModeShared buffers are always mapped.
+ }
+
+ BufferView::BufferView(BufferViewBuilder* builder) : BufferViewBase(builder) {
+ }
+
+ MapRequestTracker::MapRequestTracker(Device* device) : mDevice(device) {
+ }
+
+ MapRequestTracker::~MapRequestTracker() {
+ ASSERT(mInflightRequests.Empty());
+ }
+
+ void MapRequestTracker::Track(Buffer* buffer,
+ uint32_t mapSerial,
+ uint32_t offset,
+ bool isWrite) {
+ Request request;
+ request.buffer = buffer;
+ request.mapSerial = mapSerial;
+ request.offset = offset;
+ request.isWrite = isWrite;
+
+ mInflightRequests.Enqueue(std::move(request), mDevice->GetPendingCommandSerial());
+ }
+
+ void MapRequestTracker::Tick(Serial finishedSerial) {
+ for (auto& request : mInflightRequests.IterateUpTo(finishedSerial)) {
+ request.buffer->OnMapCommandSerialFinished(request.mapSerial, request.offset,
+ request.isWrite);
+ }
+ mInflightRequests.ClearUpTo(finishedSerial);
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/CommandBufferMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/CommandBufferMTL.h
new file mode 100644
index 00000000000..ab1b13f71b8
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/CommandBufferMTL.h
@@ -0,0 +1,48 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_COMMANDBUFFERMTL_H_
+#define DAWNNATIVE_METAL_COMMANDBUFFERMTL_H_
+
+#include "dawn_native/CommandBuffer.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native {
+ class RenderPassDescriptorBase;
+}
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ class CommandBuffer : public CommandBufferBase {
+ public:
+ CommandBuffer(CommandBufferBuilder* builder);
+ ~CommandBuffer();
+
+ void FillCommands(id<MTLCommandBuffer> commandBuffer);
+
+ private:
+ void EncodeComputePass(id<MTLCommandBuffer> commandBuffer);
+ void EncodeRenderPass(id<MTLCommandBuffer> commandBuffer,
+ RenderPassDescriptorBase* renderPass);
+
+ Device* mDevice;
+ CommandIterator mCommands;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_COMMANDBUFFERMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/CommandBufferMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/CommandBufferMTL.mm
new file mode 100644
index 00000000000..3aff3784108
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/CommandBufferMTL.mm
@@ -0,0 +1,530 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/CommandBufferMTL.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/Commands.h"
+#include "dawn_native/metal/BufferMTL.h"
+#include "dawn_native/metal/ComputePipelineMTL.h"
+#include "dawn_native/metal/DepthStencilStateMTL.h"
+#include "dawn_native/metal/DeviceMTL.h"
+#include "dawn_native/metal/InputStateMTL.h"
+#include "dawn_native/metal/PipelineLayoutMTL.h"
+#include "dawn_native/metal/RenderPipelineMTL.h"
+#include "dawn_native/metal/SamplerMTL.h"
+#include "dawn_native/metal/TextureMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ namespace {
+
+ struct GlobalEncoders {
+ id<MTLBlitCommandEncoder> blit = nil;
+
+ void Finish() {
+ if (blit != nil) {
+ [blit endEncoding];
+ blit = nil; // This will be autoreleased.
+ }
+ }
+
+ void EnsureBlit(id<MTLCommandBuffer> commandBuffer) {
+ if (blit == nil) {
+ blit = [commandBuffer blitCommandEncoder];
+ }
+ }
+ };
+
+ // Creates an autoreleased MTLRenderPassDescriptor matching desc
+ MTLRenderPassDescriptor* CreateMTLRenderPassDescriptor(RenderPassDescriptorBase* desc) {
+ MTLRenderPassDescriptor* descriptor = [MTLRenderPassDescriptor renderPassDescriptor];
+
+ for (uint32_t i : IterateBitSet(desc->GetColorAttachmentMask())) {
+ auto& attachmentInfo = desc->GetColorAttachment(i);
+
+ if (attachmentInfo.loadOp == dawn::LoadOp::Clear) {
+ descriptor.colorAttachments[i].loadAction = MTLLoadActionClear;
+ descriptor.colorAttachments[i].clearColor = MTLClearColorMake(
+ attachmentInfo.clearColor[0], attachmentInfo.clearColor[1],
+ attachmentInfo.clearColor[2], attachmentInfo.clearColor[3]);
+ } else {
+ descriptor.colorAttachments[i].loadAction = MTLLoadActionLoad;
+ }
+
+ // TODO(jiawei.shao@intel.com): support rendering into a layer of a texture.
+ descriptor.colorAttachments[i].texture =
+ ToBackend(attachmentInfo.view->GetTexture())->GetMTLTexture();
+ descriptor.colorAttachments[i].storeAction = MTLStoreActionStore;
+ }
+
+ if (desc->HasDepthStencilAttachment()) {
+ auto& attachmentInfo = desc->GetDepthStencilAttachment();
+
+ // TODO(jiawei.shao@intel.com): support rendering into a layer of a texture.
+ id<MTLTexture> texture =
+ ToBackend(attachmentInfo.view->GetTexture())->GetMTLTexture();
+ dawn::TextureFormat format = attachmentInfo.view->GetTexture()->GetFormat();
+
+ if (TextureFormatHasDepth(format)) {
+ descriptor.depthAttachment.texture = texture;
+ descriptor.depthAttachment.storeAction = MTLStoreActionStore;
+
+ if (attachmentInfo.depthLoadOp == dawn::LoadOp::Clear) {
+ descriptor.depthAttachment.loadAction = MTLLoadActionClear;
+ descriptor.depthAttachment.clearDepth = attachmentInfo.clearDepth;
+ } else {
+ descriptor.depthAttachment.loadAction = MTLLoadActionLoad;
+ }
+ }
+
+ if (TextureFormatHasStencil(format)) {
+ descriptor.stencilAttachment.texture = texture;
+ descriptor.stencilAttachment.storeAction = MTLStoreActionStore;
+
+ if (attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear) {
+ descriptor.stencilAttachment.loadAction = MTLLoadActionClear;
+ descriptor.stencilAttachment.clearStencil = attachmentInfo.clearStencil;
+ } else {
+ descriptor.stencilAttachment.loadAction = MTLLoadActionLoad;
+ }
+ }
+ }
+
+ return descriptor;
+ }
+
+ // Handles a call to SetBindGroup, directing the commands to the correct encoder.
+ // There is a single function that takes both encoders to factor code. Other approaches like
+ // templates wouldn't work because the name of methods are different between the two encoder
+ // types.
+ void ApplyBindGroup(uint32_t index,
+ BindGroup* group,
+ PipelineLayout* pipelineLayout,
+ id<MTLRenderCommandEncoder> render,
+ id<MTLComputeCommandEncoder> compute) {
+ const auto& layout = group->GetLayout()->GetBindingInfo();
+
+ // TODO(kainino@chromium.org): Maintain buffers and offsets arrays in BindGroup
+ // so that we only have to do one setVertexBuffers and one setFragmentBuffers
+ // call here.
+ for (size_t binding = 0; binding < layout.mask.size(); ++binding) {
+ if (!layout.mask[binding]) {
+ continue;
+ }
+
+ auto stage = layout.visibilities[binding];
+ bool hasVertStage = stage & dawn::ShaderStageBit::Vertex && render != nil;
+ bool hasFragStage = stage & dawn::ShaderStageBit::Fragment && render != nil;
+ bool hasComputeStage = stage & dawn::ShaderStageBit::Compute && compute != nil;
+
+ uint32_t vertIndex = 0;
+ uint32_t fragIndex = 0;
+ uint32_t computeIndex = 0;
+
+ if (hasVertStage) {
+ vertIndex = pipelineLayout->GetBindingIndexInfo(
+ dawn::ShaderStage::Vertex)[index][binding];
+ }
+ if (hasFragStage) {
+ fragIndex = pipelineLayout->GetBindingIndexInfo(
+ dawn::ShaderStage::Fragment)[index][binding];
+ }
+ if (hasComputeStage) {
+ computeIndex = pipelineLayout->GetBindingIndexInfo(
+ dawn::ShaderStage::Compute)[index][binding];
+ }
+
+ switch (layout.types[binding]) {
+ case dawn::BindingType::UniformBuffer:
+ case dawn::BindingType::StorageBuffer: {
+ BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
+ auto b = ToBackend(view->GetBuffer());
+ const id<MTLBuffer> buffer = b->GetMTLBuffer();
+ const NSUInteger offset = view->GetOffset();
+
+ if (hasVertStage) {
+ [render setVertexBuffers:&buffer
+ offsets:&offset
+ withRange:NSMakeRange(vertIndex, 1)];
+ }
+ if (hasFragStage) {
+ [render setFragmentBuffers:&buffer
+ offsets:&offset
+ withRange:NSMakeRange(fragIndex, 1)];
+ }
+ if (hasComputeStage) {
+ [compute setBuffers:&buffer
+ offsets:&offset
+ withRange:NSMakeRange(computeIndex, 1)];
+ }
+
+ } break;
+
+ case dawn::BindingType::Sampler: {
+ auto sampler = ToBackend(group->GetBindingAsSampler(binding));
+ if (hasVertStage) {
+ [render setVertexSamplerState:sampler->GetMTLSamplerState()
+ atIndex:vertIndex];
+ }
+ if (hasFragStage) {
+ [render setFragmentSamplerState:sampler->GetMTLSamplerState()
+ atIndex:fragIndex];
+ }
+ if (hasComputeStage) {
+ [compute setSamplerState:sampler->GetMTLSamplerState()
+ atIndex:computeIndex];
+ }
+ } break;
+
+ case dawn::BindingType::SampledTexture: {
+ auto textureView = ToBackend(group->GetBindingAsTextureView(binding));
+ if (hasVertStage) {
+ [render setVertexTexture:textureView->GetMTLTexture()
+ atIndex:vertIndex];
+ }
+ if (hasFragStage) {
+ [render setFragmentTexture:textureView->GetMTLTexture()
+ atIndex:fragIndex];
+ }
+ if (hasComputeStage) {
+ [compute setTexture:textureView->GetMTLTexture() atIndex:computeIndex];
+ }
+ } break;
+ }
+ }
+ }
+
+ } // anonymous namespace
+
+ CommandBuffer::CommandBuffer(CommandBufferBuilder* builder)
+ : CommandBufferBase(builder),
+ mDevice(ToBackend(builder->GetDevice())),
+ mCommands(builder->AcquireCommands()) {
+ }
+
+ CommandBuffer::~CommandBuffer() {
+ FreeCommands(&mCommands);
+ }
+
+ void CommandBuffer::FillCommands(id<MTLCommandBuffer> commandBuffer) {
+ GlobalEncoders encoders;
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::BeginComputePass: {
+ mCommands.NextCommand<BeginComputePassCmd>();
+ encoders.Finish();
+ EncodeComputePass(commandBuffer);
+ } break;
+
+ case Command::BeginRenderPass: {
+ BeginRenderPassCmd* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
+ encoders.Finish();
+ EncodeRenderPass(commandBuffer, ToBackend(cmd->info.Get()));
+ } break;
+
+ case Command::CopyBufferToBuffer: {
+ CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+
+ encoders.EnsureBlit(commandBuffer);
+ [encoders.blit copyFromBuffer:ToBackend(src.buffer)->GetMTLBuffer()
+ sourceOffset:src.offset
+ toBuffer:ToBackend(dst.buffer)->GetMTLBuffer()
+ destinationOffset:dst.offset
+ size:copy->size];
+ } break;
+
+ case Command::CopyBufferToTexture: {
+ CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+ Buffer* buffer = ToBackend(src.buffer.Get());
+ Texture* texture = ToBackend(dst.texture.Get());
+
+ MTLOrigin origin;
+ origin.x = dst.x;
+ origin.y = dst.y;
+ origin.z = dst.z;
+
+ MTLSize size;
+ size.width = dst.width;
+ size.height = dst.height;
+ size.depth = dst.depth;
+
+ encoders.EnsureBlit(commandBuffer);
+ [encoders.blit copyFromBuffer:buffer->GetMTLBuffer()
+ sourceOffset:src.offset
+ sourceBytesPerRow:copy->rowPitch
+ sourceBytesPerImage:(copy->rowPitch * dst.height)
+ sourceSize:size
+ toTexture:texture->GetMTLTexture()
+ destinationSlice:dst.slice
+ destinationLevel:dst.level
+ destinationOrigin:origin];
+ } break;
+
+ case Command::CopyTextureToBuffer: {
+ CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+ Texture* texture = ToBackend(src.texture.Get());
+ Buffer* buffer = ToBackend(dst.buffer.Get());
+
+ MTLOrigin origin;
+ origin.x = src.x;
+ origin.y = src.y;
+ origin.z = src.z;
+
+ MTLSize size;
+ size.width = src.width;
+ size.height = src.height;
+ size.depth = src.depth;
+
+ encoders.EnsureBlit(commandBuffer);
+ [encoders.blit copyFromTexture:texture->GetMTLTexture()
+ sourceSlice:src.slice
+ sourceLevel:src.level
+ sourceOrigin:origin
+ sourceSize:size
+ toBuffer:buffer->GetMTLBuffer()
+ destinationOffset:dst.offset
+ destinationBytesPerRow:copy->rowPitch
+ destinationBytesPerImage:copy->rowPitch * src.height];
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+
+ encoders.Finish();
+ }
+
+ void CommandBuffer::EncodeComputePass(id<MTLCommandBuffer> commandBuffer) {
+ ComputePipeline* lastPipeline = nullptr;
+ std::array<uint32_t, kMaxPushConstants> pushConstants;
+
+ // Will be autoreleased
+ id<MTLComputeCommandEncoder> encoder = [commandBuffer computeCommandEncoder];
+
+ // Set default values for push constants
+ pushConstants.fill(0);
+ [encoder setBytes:&pushConstants length:sizeof(uint32_t) * kMaxPushConstants atIndex:0];
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndComputePass: {
+ mCommands.NextCommand<EndComputePassCmd>();
+ [encoder endEncoding];
+ return;
+ } break;
+
+ case Command::Dispatch: {
+ DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
+ [encoder dispatchThreadgroups:MTLSizeMake(dispatch->x, dispatch->y, dispatch->z)
+ threadsPerThreadgroup:lastPipeline->GetLocalWorkGroupSize()];
+ } break;
+
+ case Command::SetComputePipeline: {
+ SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
+ lastPipeline = ToBackend(cmd->pipeline).Get();
+
+ lastPipeline->Encode(encoder);
+ } break;
+
+ case Command::SetPushConstants: {
+ SetPushConstantsCmd* cmd = mCommands.NextCommand<SetPushConstantsCmd>();
+ uint32_t* values = mCommands.NextData<uint32_t>(cmd->count);
+
+ if (cmd->stages & dawn::ShaderStageBit::Compute) {
+ memcpy(&pushConstants[cmd->offset], values, cmd->count * sizeof(uint32_t));
+
+ [encoder setBytes:&pushConstants
+ length:sizeof(uint32_t) * kMaxPushConstants
+ atIndex:0];
+ }
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
+ ApplyBindGroup(cmd->index, ToBackend(cmd->group.Get()),
+ ToBackend(lastPipeline->GetLayout()), nil, encoder);
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+
+ // EndComputePass should have been called
+ UNREACHABLE();
+ }
+
+ void CommandBuffer::EncodeRenderPass(id<MTLCommandBuffer> commandBuffer,
+ RenderPassDescriptorBase* renderPass) {
+ RenderPipeline* lastPipeline = nullptr;
+ id<MTLBuffer> indexBuffer = nil;
+ uint32_t indexBufferBaseOffset = 0;
+
+ std::array<uint32_t, kMaxPushConstants> vertexPushConstants;
+ std::array<uint32_t, kMaxPushConstants> fragmentPushConstants;
+
+ // This will be autoreleased
+ id<MTLRenderCommandEncoder> encoder = [commandBuffer
+ renderCommandEncoderWithDescriptor:CreateMTLRenderPassDescriptor(renderPass)];
+
+ // Set default values for push constants
+ vertexPushConstants.fill(0);
+ fragmentPushConstants.fill(0);
+
+ [encoder setVertexBytes:&vertexPushConstants
+ length:sizeof(uint32_t) * kMaxPushConstants
+ atIndex:0];
+ [encoder setFragmentBytes:&fragmentPushConstants
+ length:sizeof(uint32_t) * kMaxPushConstants
+ atIndex:0];
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndRenderPass: {
+ mCommands.NextCommand<EndRenderPassCmd>();
+ [encoder endEncoding];
+ return;
+ } break;
+
+ case Command::DrawArrays: {
+ DrawArraysCmd* draw = mCommands.NextCommand<DrawArraysCmd>();
+
+ [encoder drawPrimitives:lastPipeline->GetMTLPrimitiveTopology()
+ vertexStart:draw->firstVertex
+ vertexCount:draw->vertexCount
+ instanceCount:draw->instanceCount
+ baseInstance:draw->firstInstance];
+ } break;
+
+ case Command::DrawElements: {
+ DrawElementsCmd* draw = mCommands.NextCommand<DrawElementsCmd>();
+ size_t formatSize = IndexFormatSize(lastPipeline->GetIndexFormat());
+
+ [encoder
+ drawIndexedPrimitives:lastPipeline->GetMTLPrimitiveTopology()
+ indexCount:draw->indexCount
+ indexType:lastPipeline->GetMTLIndexType()
+ indexBuffer:indexBuffer
+ indexBufferOffset:indexBufferBaseOffset + draw->firstIndex * formatSize
+ instanceCount:draw->instanceCount
+ baseVertex:0
+ baseInstance:draw->firstInstance];
+ } break;
+
+ case Command::SetRenderPipeline: {
+ SetRenderPipelineCmd* cmd = mCommands.NextCommand<SetRenderPipelineCmd>();
+ lastPipeline = ToBackend(cmd->pipeline).Get();
+
+ DepthStencilState* depthStencilState =
+ ToBackend(lastPipeline->GetDepthStencilState());
+ [encoder setDepthStencilState:depthStencilState->GetMTLDepthStencilState()];
+ lastPipeline->Encode(encoder);
+ } break;
+
+ case Command::SetPushConstants: {
+ SetPushConstantsCmd* cmd = mCommands.NextCommand<SetPushConstantsCmd>();
+ uint32_t* values = mCommands.NextData<uint32_t>(cmd->count);
+
+ if (cmd->stages & dawn::ShaderStageBit::Vertex) {
+ memcpy(&vertexPushConstants[cmd->offset], values,
+ cmd->count * sizeof(uint32_t));
+ [encoder setVertexBytes:&vertexPushConstants
+ length:sizeof(uint32_t) * kMaxPushConstants
+ atIndex:0];
+ }
+
+ if (cmd->stages & dawn::ShaderStageBit::Fragment) {
+ memcpy(&fragmentPushConstants[cmd->offset], values,
+ cmd->count * sizeof(uint32_t));
+ [encoder setFragmentBytes:&fragmentPushConstants
+ length:sizeof(uint32_t) * kMaxPushConstants
+ atIndex:0];
+ }
+ } break;
+
+ case Command::SetStencilReference: {
+ SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
+ [encoder setStencilReferenceValue:cmd->reference];
+ } break;
+
+ case Command::SetScissorRect: {
+ SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
+ MTLScissorRect rect;
+ rect.x = cmd->x;
+ rect.y = cmd->y;
+ rect.width = cmd->width;
+ rect.height = cmd->height;
+
+ [encoder setScissorRect:rect];
+ } break;
+
+ case Command::SetBlendColor: {
+ SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
+ [encoder setBlendColorRed:cmd->r green:cmd->g blue:cmd->b alpha:cmd->a];
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
+ ApplyBindGroup(cmd->index, ToBackend(cmd->group.Get()),
+ ToBackend(lastPipeline->GetLayout()), encoder, nil);
+ } break;
+
+ case Command::SetIndexBuffer: {
+ SetIndexBufferCmd* cmd = mCommands.NextCommand<SetIndexBufferCmd>();
+ auto b = ToBackend(cmd->buffer.Get());
+ indexBuffer = b->GetMTLBuffer();
+ indexBufferBaseOffset = cmd->offset;
+ } break;
+
+ case Command::SetVertexBuffers: {
+ SetVertexBuffersCmd* cmd = mCommands.NextCommand<SetVertexBuffersCmd>();
+ auto buffers = mCommands.NextData<Ref<BufferBase>>(cmd->count);
+ auto offsets = mCommands.NextData<uint32_t>(cmd->count);
+
+ std::array<id<MTLBuffer>, kMaxVertexInputs> mtlBuffers;
+ std::array<NSUInteger, kMaxVertexInputs> mtlOffsets;
+
+ // Perhaps an "array of vertex buffers(+offsets?)" should be
+ // a Dawn API primitive to avoid reconstructing this array?
+ for (uint32_t i = 0; i < cmd->count; ++i) {
+ Buffer* buffer = ToBackend(buffers[i].Get());
+ mtlBuffers[i] = buffer->GetMTLBuffer();
+ mtlOffsets[i] = offsets[i];
+ }
+
+ [encoder setVertexBuffers:mtlBuffers.data()
+ offsets:mtlOffsets.data()
+ withRange:NSMakeRange(kMaxBindingsPerGroup + cmd->startSlot,
+ cmd->count)];
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+
+ // EndRenderPass should have been called
+ UNREACHABLE();
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/ComputePipelineMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/ComputePipelineMTL.h
new file mode 100644
index 00000000000..6f3aca9a5c7
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/ComputePipelineMTL.h
@@ -0,0 +1,41 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_COMPUTEPIPELINEMTL_H_
+#define DAWNNATIVE_METAL_COMPUTEPIPELINEMTL_H_
+
+#include "dawn_native/ComputePipeline.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ class ComputePipeline : public ComputePipelineBase {
+ public:
+ ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor);
+ ~ComputePipeline();
+
+ void Encode(id<MTLComputeCommandEncoder> encoder);
+ MTLSize GetLocalWorkGroupSize() const;
+
+ private:
+ id<MTLComputePipelineState> mMtlComputePipelineState = nil;
+ MTLSize mLocalWorkgroupSize;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_COMPUTEPIPELINEMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/ComputePipelineMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/ComputePipelineMTL.mm
new file mode 100644
index 00000000000..5c6eaa62f49
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/ComputePipelineMTL.mm
@@ -0,0 +1,57 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/ComputePipelineMTL.h"
+
+#include "dawn_native/metal/DeviceMTL.h"
+#include "dawn_native/metal/ShaderModuleMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ ComputePipeline::ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor)
+ : ComputePipelineBase(device, descriptor) {
+ auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();
+
+ const auto& module = ToBackend(descriptor->module);
+ const char* entryPoint = descriptor->entryPoint;
+
+ auto compilationData =
+ module->GetFunction(entryPoint, dawn::ShaderStage::Compute, ToBackend(GetLayout()));
+
+ NSError* error = nil;
+ mMtlComputePipelineState =
+ [mtlDevice newComputePipelineStateWithFunction:compilationData.function error:&error];
+ if (error != nil) {
+ NSLog(@" error => %@", error);
+ GetDevice()->HandleError("Error creating pipeline state");
+ return;
+ }
+
+ // Copy over the local workgroup size as it is passed to dispatch explicitly in Metal
+ mLocalWorkgroupSize = compilationData.localWorkgroupSize;
+ }
+
+ ComputePipeline::~ComputePipeline() {
+ [mMtlComputePipelineState release];
+ }
+
+ void ComputePipeline::Encode(id<MTLComputeCommandEncoder> encoder) {
+ [encoder setComputePipelineState:mMtlComputePipelineState];
+ }
+
+ MTLSize ComputePipeline::GetLocalWorkGroupSize() const {
+ return mLocalWorkgroupSize;
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/DepthStencilStateMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/DepthStencilStateMTL.h
new file mode 100644
index 00000000000..c33fadfbd2e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/DepthStencilStateMTL.h
@@ -0,0 +1,39 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_DEPTHSTENCILSTATEMTL_H_
+#define DAWNNATIVE_METAL_DEPTHSTENCILSTATEMTL_H_
+
+#include "dawn_native/DepthStencilState.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ class DepthStencilState : public DepthStencilStateBase {
+ public:
+ DepthStencilState(DepthStencilStateBuilder* builder);
+ ~DepthStencilState();
+
+ id<MTLDepthStencilState> GetMTLDepthStencilState();
+
+ private:
+ id<MTLDepthStencilState> mMtlDepthStencilState = nil;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_DEPTHSTENCILSTATEMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/DepthStencilStateMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/DepthStencilStateMTL.mm
new file mode 100644
index 00000000000..fc811339928
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/DepthStencilStateMTL.mm
@@ -0,0 +1,120 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/DepthStencilStateMTL.h"
+
+#include "dawn_native/metal/DeviceMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ namespace {
+ MTLCompareFunction MetalDepthStencilCompareFunction(dawn::CompareFunction compareFunction) {
+ switch (compareFunction) {
+ case dawn::CompareFunction::Never:
+ return MTLCompareFunctionNever;
+ case dawn::CompareFunction::Less:
+ return MTLCompareFunctionLess;
+ case dawn::CompareFunction::LessEqual:
+ return MTLCompareFunctionLessEqual;
+ case dawn::CompareFunction::Greater:
+ return MTLCompareFunctionGreater;
+ case dawn::CompareFunction::GreaterEqual:
+ return MTLCompareFunctionGreaterEqual;
+ case dawn::CompareFunction::NotEqual:
+ return MTLCompareFunctionNotEqual;
+ case dawn::CompareFunction::Equal:
+ return MTLCompareFunctionEqual;
+ case dawn::CompareFunction::Always:
+ return MTLCompareFunctionAlways;
+ }
+ }
+
+ MTLStencilOperation MetalStencilOperation(dawn::StencilOperation stencilOperation) {
+ switch (stencilOperation) {
+ case dawn::StencilOperation::Keep:
+ return MTLStencilOperationKeep;
+ case dawn::StencilOperation::Zero:
+ return MTLStencilOperationZero;
+ case dawn::StencilOperation::Replace:
+ return MTLStencilOperationReplace;
+ case dawn::StencilOperation::Invert:
+ return MTLStencilOperationInvert;
+ case dawn::StencilOperation::IncrementClamp:
+ return MTLStencilOperationIncrementClamp;
+ case dawn::StencilOperation::DecrementClamp:
+ return MTLStencilOperationDecrementClamp;
+ case dawn::StencilOperation::IncrementWrap:
+ return MTLStencilOperationIncrementWrap;
+ case dawn::StencilOperation::DecrementWrap:
+ return MTLStencilOperationDecrementWrap;
+ }
+ }
+ }
+
+ DepthStencilState::DepthStencilState(DepthStencilStateBuilder* builder)
+ : DepthStencilStateBase(builder) {
+ MTLDepthStencilDescriptor* mtlDepthStencilDescriptor = [MTLDepthStencilDescriptor new];
+
+ auto& depth = GetDepth();
+ mtlDepthStencilDescriptor.depthCompareFunction =
+ MetalDepthStencilCompareFunction(depth.compareFunction);
+ mtlDepthStencilDescriptor.depthWriteEnabled = depth.depthWriteEnabled;
+
+ auto& stencil = GetStencil();
+ if (StencilTestEnabled()) {
+ MTLStencilDescriptor* backFaceStencil = [MTLStencilDescriptor new];
+ MTLStencilDescriptor* frontFaceStencil = [MTLStencilDescriptor new];
+
+ backFaceStencil.stencilCompareFunction =
+ MetalDepthStencilCompareFunction(stencil.back.compareFunction);
+ backFaceStencil.stencilFailureOperation =
+ MetalStencilOperation(stencil.back.stencilFail);
+ backFaceStencil.depthFailureOperation = MetalStencilOperation(stencil.back.depthFail);
+ backFaceStencil.depthStencilPassOperation =
+ MetalStencilOperation(stencil.back.depthStencilPass);
+ backFaceStencil.readMask = stencil.readMask;
+ backFaceStencil.writeMask = stencil.writeMask;
+
+ frontFaceStencil.stencilCompareFunction =
+ MetalDepthStencilCompareFunction(stencil.front.compareFunction);
+ frontFaceStencil.stencilFailureOperation =
+ MetalStencilOperation(stencil.front.stencilFail);
+ frontFaceStencil.depthFailureOperation = MetalStencilOperation(stencil.front.depthFail);
+ frontFaceStencil.depthStencilPassOperation =
+ MetalStencilOperation(stencil.front.depthStencilPass);
+ frontFaceStencil.readMask = stencil.readMask;
+ frontFaceStencil.writeMask = stencil.writeMask;
+
+ mtlDepthStencilDescriptor.backFaceStencil = backFaceStencil;
+ mtlDepthStencilDescriptor.frontFaceStencil = frontFaceStencil;
+ [backFaceStencil release];
+ [frontFaceStencil release];
+ }
+
+ auto mtlDevice = ToBackend(builder->GetDevice())->GetMTLDevice();
+ mMtlDepthStencilState =
+ [mtlDevice newDepthStencilStateWithDescriptor:mtlDepthStencilDescriptor];
+ [mtlDepthStencilDescriptor release];
+ }
+
+ DepthStencilState::~DepthStencilState() {
+ [mMtlDepthStencilState release];
+ mMtlDepthStencilState = nil;
+ }
+
+ id<MTLDepthStencilState> DepthStencilState::GetMTLDepthStencilState() {
+ return mMtlDepthStencilState;
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/DeviceMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/DeviceMTL.h
new file mode 100644
index 00000000000..da586ee459c
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/DeviceMTL.h
@@ -0,0 +1,98 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_DEVICEMTL_H_
+#define DAWNNATIVE_METAL_DEVICEMTL_H_
+
+#include "dawn_native/dawn_platform.h"
+
+#include "common/Serial.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/metal/Forward.h"
+
+#import <Metal/Metal.h>
+#import <QuartzCore/CAMetalLayer.h>
+
+#include <memory>
+#include <type_traits>
+
+namespace dawn_native { namespace metal {
+
+ class MapRequestTracker;
+ class ResourceUploader;
+
+ class Device : public DeviceBase {
+ public:
+ Device(id<MTLDevice> mtlDevice);
+ ~Device();
+
+ BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
+ BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
+ BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
+ CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
+ DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
+ InputStateBase* CreateInputState(InputStateBuilder* builder) override;
+ RenderPassDescriptorBase* CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) override;
+ RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
+ SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
+
+ void TickImpl() override;
+
+ const dawn_native::PCIInfo& GetPCIInfo() const override;
+
+ id<MTLDevice> GetMTLDevice();
+
+ id<MTLCommandBuffer> GetPendingCommandBuffer();
+ void SubmitPendingCommandBuffer();
+ Serial GetPendingCommandSerial();
+
+ MapRequestTracker* GetMapTracker() const;
+ ResourceUploader* GetResourceUploader() const;
+
+ private:
+ ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) override;
+ ResultOrError<BufferBase*> CreateBufferImpl(const BufferDescriptor* descriptor) override;
+ ResultOrError<ComputePipelineBase*> CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) override;
+ ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) override;
+ ResultOrError<QueueBase*> CreateQueueImpl() override;
+ ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
+ ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) override;
+ ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
+ ResultOrError<TextureViewBase*> CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) override;
+ void CollectPCIInfo();
+
+ void OnCompletedHandler();
+
+ id<MTLDevice> mMtlDevice = nil;
+ id<MTLCommandQueue> mCommandQueue = nil;
+ std::unique_ptr<MapRequestTracker> mMapTracker;
+ std::unique_ptr<ResourceUploader> mResourceUploader;
+
+ Serial mFinishedCommandSerial = 0;
+ Serial mPendingCommandSerial = 1;
+ id<MTLCommandBuffer> mPendingCommands = nil;
+
+ dawn_native::PCIInfo mPCIInfo;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_DEVICEMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/DeviceMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/DeviceMTL.mm
new file mode 100644
index 00000000000..a01ab6a83e8
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/DeviceMTL.mm
@@ -0,0 +1,300 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/DeviceMTL.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/MetalBackend.h"
+#include "dawn_native/RenderPassDescriptor.h"
+#include "dawn_native/metal/BlendStateMTL.h"
+#include "dawn_native/metal/BufferMTL.h"
+#include "dawn_native/metal/CommandBufferMTL.h"
+#include "dawn_native/metal/ComputePipelineMTL.h"
+#include "dawn_native/metal/DepthStencilStateMTL.h"
+#include "dawn_native/metal/InputStateMTL.h"
+#include "dawn_native/metal/PipelineLayoutMTL.h"
+#include "dawn_native/metal/QueueMTL.h"
+#include "dawn_native/metal/RenderPipelineMTL.h"
+#include "dawn_native/metal/ResourceUploader.h"
+#include "dawn_native/metal/SamplerMTL.h"
+#include "dawn_native/metal/ShaderModuleMTL.h"
+#include "dawn_native/metal/SwapChainMTL.h"
+#include "dawn_native/metal/TextureMTL.h"
+
+#include <IOKit/graphics/IOGraphicsLib.h>
+#include <unistd.h>
+
+namespace dawn_native { namespace metal {
+
+ namespace {
+ // Since CGDisplayIOServicePort was deprecated in macOS 10.9, we need create
+ // an alternative function for getting I/O service port from current display.
+ io_service_t GetDisplayIOServicePort() {
+ // The matching service port (or 0 if none can be found)
+ io_service_t servicePort = 0;
+
+ // Create matching dictionary for display service
+ CFMutableDictionaryRef matchingDict = IOServiceMatching("IODisplayConnect");
+ if (matchingDict == nullptr) {
+ return 0;
+ }
+
+ io_iterator_t iter;
+ // IOServiceGetMatchingServices look up the default master ports that match a
+ // matching dictionary, and will consume the reference on the matching dictionary,
+ // so we don't need to release the dictionary, but the iterator handle should
+ // be released when its iteration is finished.
+ if (IOServiceGetMatchingServices(kIOMasterPortDefault, matchingDict, &iter) !=
+ kIOReturnSuccess) {
+ return 0;
+ }
+
+ // Vendor number and product number of current main display
+ const uint32_t displayVendorNumber = CGDisplayVendorNumber(kCGDirectMainDisplay);
+ const uint32_t displayProductNumber = CGDisplayModelNumber(kCGDirectMainDisplay);
+
+ io_service_t serv;
+ while ((serv = IOIteratorNext(iter)) != IO_OBJECT_NULL) {
+ CFDictionaryRef displayInfo =
+ IODisplayCreateInfoDictionary(serv, kIODisplayOnlyPreferredName);
+
+ CFNumberRef vendorIDRef, productIDRef;
+ Boolean success;
+ // The ownership of CF object follows the 'Get Rule', we don't need to
+ // release these values
+ success = CFDictionaryGetValueIfPresent(displayInfo, CFSTR(kDisplayVendorID),
+ (const void**)&vendorIDRef);
+ success &= CFDictionaryGetValueIfPresent(displayInfo, CFSTR(kDisplayProductID),
+ (const void**)&productIDRef);
+ if (success) {
+ CFIndex vendorID = 0, productID = 0;
+ CFNumberGetValue(vendorIDRef, kCFNumberSInt32Type, &vendorID);
+ CFNumberGetValue(productIDRef, kCFNumberSInt32Type, &productID);
+
+ if (vendorID == displayVendorNumber && productID == displayProductNumber) {
+ // Check if vendor id and product id match with current display's
+ // If it does, we find the desired service port
+ servicePort = serv;
+ CFRelease(displayInfo);
+ break;
+ }
+ }
+
+ CFRelease(displayInfo);
+ IOObjectRelease(serv);
+ }
+ IOObjectRelease(iter);
+ return servicePort;
+ }
+
+ // Get integer property from registry entry.
+ uint32_t GetEntryProperty(io_registry_entry_t entry, CFStringRef name) {
+ uint32_t value = 0;
+
+ // Recursively search registry entry and its parents for property name
+ // The data should release with CFRelease
+ CFDataRef data = static_cast<CFDataRef>(IORegistryEntrySearchCFProperty(
+ entry, kIOServicePlane, name, kCFAllocatorDefault,
+ kIORegistryIterateRecursively | kIORegistryIterateParents));
+
+ if (data != nullptr) {
+ const uint32_t* valuePtr =
+ reinterpret_cast<const uint32_t*>(CFDataGetBytePtr(data));
+ if (valuePtr) {
+ value = *valuePtr;
+ }
+
+ CFRelease(data);
+ }
+
+ return value;
+ }
+ } // anonymous namespace
+
+ dawnDevice CreateDevice(id<MTLDevice> metalDevice) {
+ return reinterpret_cast<dawnDevice>(new Device(metalDevice));
+ }
+
+ // Device
+
+ Device::Device(id<MTLDevice> mtlDevice)
+ : mMtlDevice(mtlDevice),
+ mMapTracker(new MapRequestTracker(this)),
+ mResourceUploader(new ResourceUploader(this)) {
+ [mMtlDevice retain];
+ mCommandQueue = [mMtlDevice newCommandQueue];
+ CollectPCIInfo();
+ }
+
+ Device::~Device() {
+ // Wait for all commands to be finished so we can free resources SubmitPendingCommandBuffer
+ // may not increment the pendingCommandSerial if there are no pending commands, so we can't
+ // store the pendingSerial before SubmitPendingCommandBuffer then wait for it to be passed.
+ // Instead we submit and wait for the serial before the next pendingCommandSerial.
+ SubmitPendingCommandBuffer();
+ while (mFinishedCommandSerial != mPendingCommandSerial - 1) {
+ usleep(100);
+ }
+ Tick();
+
+ [mPendingCommands release];
+ mPendingCommands = nil;
+
+ mMapTracker = nullptr;
+ mResourceUploader = nullptr;
+
+ [mMtlDevice release];
+ mMtlDevice = nil;
+
+ [mCommandQueue release];
+ mCommandQueue = nil;
+ }
+
+ BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
+ return new BindGroup(builder);
+ }
+ ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) {
+ return new BindGroupLayout(this, descriptor);
+ }
+ BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
+ return new BlendState(builder);
+ }
+ ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
+ return new Buffer(this, descriptor);
+ }
+ BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
+ return new BufferView(builder);
+ }
+ CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
+ return new CommandBuffer(builder);
+ }
+ ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) {
+ return new ComputePipeline(this, descriptor);
+ }
+ DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
+ return new DepthStencilState(builder);
+ }
+ InputStateBase* Device::CreateInputState(InputStateBuilder* builder) {
+ return new InputState(builder);
+ }
+ ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) {
+ return new PipelineLayout(this, descriptor);
+ }
+ RenderPassDescriptorBase* Device::CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) {
+ return new RenderPassDescriptor(builder);
+ }
+ RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
+ return new RenderPipeline(builder);
+ }
+ ResultOrError<QueueBase*> Device::CreateQueueImpl() {
+ return new Queue(this);
+ }
+ ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
+ return new Sampler(this, descriptor);
+ }
+ ResultOrError<ShaderModuleBase*> Device::CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) {
+ return new ShaderModule(this, descriptor);
+ }
+ SwapChainBase* Device::CreateSwapChain(SwapChainBuilder* builder) {
+ return new SwapChain(builder);
+ }
+ ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
+ return new Texture(this, descriptor);
+ }
+ ResultOrError<TextureViewBase*> Device::CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ return new TextureView(texture, descriptor);
+ }
+
+ void Device::TickImpl() {
+ mResourceUploader->Tick(mFinishedCommandSerial);
+ mMapTracker->Tick(mFinishedCommandSerial);
+
+ // Code above might have added GPU work, submit it. This also makes sure
+ // that even when no GPU work is happening, the serial number keeps incrementing.
+ SubmitPendingCommandBuffer();
+ }
+
+ const dawn_native::PCIInfo& Device::GetPCIInfo() const {
+ return mPCIInfo;
+ }
+
+ id<MTLDevice> Device::GetMTLDevice() {
+ return mMtlDevice;
+ }
+
+ id<MTLCommandBuffer> Device::GetPendingCommandBuffer() {
+ if (mPendingCommands == nil) {
+ mPendingCommands = [mCommandQueue commandBuffer];
+ [mPendingCommands retain];
+ }
+ return mPendingCommands;
+ }
+
+ void Device::SubmitPendingCommandBuffer() {
+ if (mPendingCommands == nil) {
+ return;
+ }
+
+ // Ok, ObjC blocks are weird. My understanding is that local variables are captured by value
+ // so this-> works as expected. However it is unclear how members are captured, (are they
+ // captured using this-> or by value?) so we make a copy of the pendingCommandSerial on the
+ // stack.
+ Serial pendingSerial = mPendingCommandSerial;
+ [mPendingCommands addCompletedHandler:^(id<MTLCommandBuffer>) {
+ this->mFinishedCommandSerial = pendingSerial;
+ }];
+
+ [mPendingCommands commit];
+ [mPendingCommands release];
+ mPendingCommands = nil;
+ mPendingCommandSerial++;
+ }
+
+ uint64_t Device::GetPendingCommandSerial() {
+ // If this is called, then it means some piece of code somewhere will wait for this serial
+ // to complete. Make sure the pending command buffer is created so that it is on the worst
+ // case enqueued on the next Tick() and eventually increments the serial. Otherwise if no
+ // GPU work happens we could be waiting for this serial forever.
+ GetPendingCommandBuffer();
+ return mPendingCommandSerial;
+ }
+
+ MapRequestTracker* Device::GetMapTracker() const {
+ return mMapTracker.get();
+ }
+
+ ResourceUploader* Device::GetResourceUploader() const {
+ return mResourceUploader.get();
+ }
+
+ void Device::CollectPCIInfo() {
+ io_registry_entry_t entry = GetDisplayIOServicePort();
+ if (entry != IO_OBJECT_NULL) {
+ mPCIInfo.vendorId = GetEntryProperty(entry, CFSTR("vendor-id"));
+ mPCIInfo.deviceId = GetEntryProperty(entry, CFSTR("device-id"));
+ IOObjectRelease(entry);
+ }
+
+ mPCIInfo.name = std::string([mMtlDevice.name UTF8String]);
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/Forward.h b/chromium/third_party/dawn/src/dawn_native/metal/Forward.h
new file mode 100644
index 00000000000..d11f5a95b30
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/Forward.h
@@ -0,0 +1,78 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_FORWARD_H_
+#define DAWNNATIVE_METAL_FORWARD_H_
+
+#include "dawn_native/ToBackend.h"
+
+namespace {
+ class BindGroupBase;
+ class BindGroup;
+ class RenderPassDescriptor;
+} // namespace
+
+namespace dawn_native { namespace metal {
+
+ using BindGroup = BindGroupBase;
+ using BindGroupLayout = BindGroupLayoutBase;
+ class BlendState;
+ class Buffer;
+ class BufferView;
+ class CommandBuffer;
+ class ComputePipeline;
+ class DepthStencilState;
+ class Device;
+ class Framebuffer;
+ class InputState;
+ class PipelineLayout;
+ class Queue;
+ using RenderPassDescriptor = RenderPassDescriptorBase;
+ class RenderPipeline;
+ class Sampler;
+ class ShaderModule;
+ class SwapChain;
+ class Texture;
+ class TextureView;
+
+ struct MetalBackendTraits {
+ using BindGroupType = BindGroup;
+ using BindGroupLayoutType = BindGroupLayout;
+ using BlendStateType = BlendState;
+ using BufferType = Buffer;
+ using BufferViewType = BufferView;
+ using CommandBufferType = CommandBuffer;
+ using ComputePipelineType = ComputePipeline;
+ using DepthStencilStateType = DepthStencilState;
+ using DeviceType = Device;
+ using InputStateType = InputState;
+ using PipelineLayoutType = PipelineLayout;
+ using QueueType = Queue;
+ using RenderPassDescriptorType = RenderPassDescriptor;
+ using RenderPipelineType = RenderPipeline;
+ using SamplerType = Sampler;
+ using ShaderModuleType = ShaderModule;
+ using SwapChainType = SwapChain;
+ using TextureType = Texture;
+ using TextureViewType = TextureView;
+ };
+
+ template <typename T>
+ auto ToBackend(T&& common) -> decltype(ToBackendBase<MetalBackendTraits>(common)) {
+ return ToBackendBase<MetalBackendTraits>(common);
+ }
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_FORWARD_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/InputStateMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/InputStateMTL.h
new file mode 100644
index 00000000000..496e6eae274
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/InputStateMTL.h
@@ -0,0 +1,37 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_INPUTSTATEMTL_H_
+#define DAWNNATIVE_METAL_INPUTSTATEMTL_H_
+
+#include "dawn_native/InputState.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native { namespace metal {
+
+ class InputState : public InputStateBase {
+ public:
+ InputState(InputStateBuilder* builder);
+ ~InputState();
+
+ MTLVertexDescriptor* GetMTLVertexDescriptor();
+
+ private:
+ MTLVertexDescriptor* mMtlVertexDescriptor = nil;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_COMMANDINPUTSTATEMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/InputStateMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/InputStateMTL.mm
new file mode 100644
index 00000000000..1dd94d2f7ee
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/InputStateMTL.mm
@@ -0,0 +1,111 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/InputStateMTL.h"
+
+#include "common/BitSetIterator.h"
+
+namespace dawn_native { namespace metal {
+
+ namespace {
+ MTLVertexFormat VertexFormatType(dawn::VertexFormat format) {
+ switch (format) {
+ case dawn::VertexFormat::FloatR32G32B32A32:
+ return MTLVertexFormatFloat4;
+ case dawn::VertexFormat::FloatR32G32B32:
+ return MTLVertexFormatFloat3;
+ case dawn::VertexFormat::FloatR32G32:
+ return MTLVertexFormatFloat2;
+ case dawn::VertexFormat::FloatR32:
+ return MTLVertexFormatFloat;
+ case dawn::VertexFormat::IntR32G32B32A32:
+ return MTLVertexFormatInt4;
+ case dawn::VertexFormat::IntR32G32B32:
+ return MTLVertexFormatInt3;
+ case dawn::VertexFormat::IntR32G32:
+ return MTLVertexFormatInt2;
+ case dawn::VertexFormat::IntR32:
+ return MTLVertexFormatInt;
+ case dawn::VertexFormat::UshortR16G16B16A16:
+ return MTLVertexFormatUShort4;
+ case dawn::VertexFormat::UshortR16G16:
+ return MTLVertexFormatUShort2;
+ case dawn::VertexFormat::UnormR8G8B8A8:
+ return MTLVertexFormatUChar4Normalized;
+ case dawn::VertexFormat::UnormR8G8:
+ return MTLVertexFormatUChar2Normalized;
+ }
+ }
+
+ MTLVertexStepFunction InputStepModeFunction(dawn::InputStepMode mode) {
+ switch (mode) {
+ case dawn::InputStepMode::Vertex:
+ return MTLVertexStepFunctionPerVertex;
+ case dawn::InputStepMode::Instance:
+ return MTLVertexStepFunctionPerInstance;
+ }
+ }
+ }
+
+ InputState::InputState(InputStateBuilder* builder) : InputStateBase(builder) {
+ mMtlVertexDescriptor = [MTLVertexDescriptor new];
+
+ const auto& attributesSetMask = GetAttributesSetMask();
+ for (uint32_t i = 0; i < attributesSetMask.size(); ++i) {
+ if (!attributesSetMask[i]) {
+ continue;
+ }
+ const AttributeInfo& info = GetAttribute(i);
+
+ auto attribDesc = [MTLVertexAttributeDescriptor new];
+ attribDesc.format = VertexFormatType(info.format);
+ attribDesc.offset = info.offset;
+ attribDesc.bufferIndex = kMaxBindingsPerGroup + info.bindingSlot;
+ mMtlVertexDescriptor.attributes[i] = attribDesc;
+ [attribDesc release];
+ }
+
+ for (uint32_t i : IterateBitSet(GetInputsSetMask())) {
+ const InputInfo& info = GetInput(i);
+
+ auto layoutDesc = [MTLVertexBufferLayoutDescriptor new];
+ if (info.stride == 0) {
+ // For MTLVertexStepFunctionConstant, the stepRate must be 0,
+ // but the stride must NOT be 0, so I made up a value (256).
+ // TODO(cwallez@chromium.org): the made up value will need to be at least
+ // max(attrib.offset + sizeof(attrib) for each attrib)
+ layoutDesc.stepFunction = MTLVertexStepFunctionConstant;
+ layoutDesc.stepRate = 0;
+ layoutDesc.stride = 256;
+ } else {
+ layoutDesc.stepFunction = InputStepModeFunction(info.stepMode);
+ layoutDesc.stepRate = 1;
+ layoutDesc.stride = info.stride;
+ }
+ // TODO(cwallez@chromium.org): make the offset depend on the pipeline layout
+ mMtlVertexDescriptor.layouts[kMaxBindingsPerGroup + i] = layoutDesc;
+ [layoutDesc release];
+ }
+ }
+
+ InputState::~InputState() {
+ [mMtlVertexDescriptor release];
+ mMtlVertexDescriptor = nil;
+ }
+
+ MTLVertexDescriptor* InputState::GetMTLVertexDescriptor() {
+ return mMtlVertexDescriptor;
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/PipelineLayoutMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/PipelineLayoutMTL.h
new file mode 100644
index 00000000000..149f375fa3a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/PipelineLayoutMTL.h
@@ -0,0 +1,46 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_PIPELINELAYOUTMTL_H_
+#define DAWNNATIVE_METAL_PIPELINELAYOUTMTL_H_
+
+#include "dawn_native/PipelineLayout.h"
+
+#include "dawn_native/PerStage.h"
+
+#import <Metal/Metal.h>
+
+namespace spirv_cross {
+ class CompilerMSL;
+}
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ class PipelineLayout : public PipelineLayoutBase {
+ public:
+ PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
+
+ using BindingIndexInfo =
+ std::array<std::array<uint32_t, kMaxBindingsPerGroup>, kMaxBindGroups>;
+ const BindingIndexInfo& GetBindingIndexInfo(dawn::ShaderStage stage) const;
+
+ private:
+ PerStage<BindingIndexInfo> mIndexInfo;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_PIPELINELAYOUTMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/PipelineLayoutMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/PipelineLayoutMTL.mm
new file mode 100644
index 00000000000..9912f94de26
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/PipelineLayoutMTL.mm
@@ -0,0 +1,67 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/PipelineLayoutMTL.h"
+
+#include "common/BitSetIterator.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/metal/DeviceMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor)
+ : PipelineLayoutBase(device, descriptor) {
+ // Each stage has its own numbering namespace in CompilerMSL.
+ for (auto stage : IterateStages(kAllStages)) {
+ // Buffer number 0 is reserved for push constants
+ uint32_t bufferIndex = 1;
+ uint32_t samplerIndex = 0;
+ uint32_t textureIndex = 0;
+
+ for (uint32_t group : IterateBitSet(GetBindGroupLayoutsMask())) {
+ const auto& groupInfo = GetBindGroupLayout(group)->GetBindingInfo();
+ for (size_t binding = 0; binding < kMaxBindingsPerGroup; ++binding) {
+ if (!(groupInfo.visibilities[binding] & StageBit(stage))) {
+ continue;
+ }
+ if (!groupInfo.mask[binding]) {
+ continue;
+ }
+
+ switch (groupInfo.types[binding]) {
+ case dawn::BindingType::UniformBuffer:
+ case dawn::BindingType::StorageBuffer:
+ mIndexInfo[stage][group][binding] = bufferIndex;
+ bufferIndex++;
+ break;
+ case dawn::BindingType::Sampler:
+ mIndexInfo[stage][group][binding] = samplerIndex;
+ samplerIndex++;
+ break;
+ case dawn::BindingType::SampledTexture:
+ mIndexInfo[stage][group][binding] = textureIndex;
+ textureIndex++;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo(
+ dawn::ShaderStage stage) const {
+ return mIndexInfo[stage];
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/QueueMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/QueueMTL.h
new file mode 100644
index 00000000000..e5c6de74599
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/QueueMTL.h
@@ -0,0 +1,35 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_QUEUEMTL_H_
+#define DAWNNATIVE_METAL_QUEUEMTL_H_
+
+#include "dawn_native/Queue.h"
+
+namespace dawn_native { namespace metal {
+
+ class CommandBuffer;
+ class Device;
+
+ class Queue : public QueueBase {
+ public:
+ Queue(Device* device);
+
+ private:
+ void SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) override;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_QUEUEMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/QueueMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/QueueMTL.mm
new file mode 100644
index 00000000000..fdcf47b9bec
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/QueueMTL.mm
@@ -0,0 +1,37 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/QueueMTL.h"
+
+#include "dawn_native/metal/CommandBufferMTL.h"
+#include "dawn_native/metal/DeviceMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ Queue::Queue(Device* device) : QueueBase(device) {
+ }
+
+ void Queue::SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) {
+ Device* device = ToBackend(GetDevice());
+ device->Tick();
+ id<MTLCommandBuffer> commandBuffer = device->GetPendingCommandBuffer();
+
+ for (uint32_t i = 0; i < numCommands; ++i) {
+ ToBackend(commands[i])->FillCommands(commandBuffer);
+ }
+
+ device->SubmitPendingCommandBuffer();
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/RenderPipelineMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/RenderPipelineMTL.h
new file mode 100644
index 00000000000..beace61cc10
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/RenderPipelineMTL.h
@@ -0,0 +1,42 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_RENDERPIPELINEMTL_H_
+#define DAWNNATIVE_METAL_RENDERPIPELINEMTL_H_
+
+#include "dawn_native/RenderPipeline.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native { namespace metal {
+
+ class RenderPipeline : public RenderPipelineBase {
+ public:
+ RenderPipeline(RenderPipelineBuilder* builder);
+ ~RenderPipeline();
+
+ MTLIndexType GetMTLIndexType() const;
+ MTLPrimitiveType GetMTLPrimitiveTopology() const;
+
+ void Encode(id<MTLRenderCommandEncoder> encoder);
+
+ private:
+ MTLIndexType mMtlIndexType;
+ MTLPrimitiveType mMtlPrimitiveTopology;
+ id<MTLRenderPipelineState> mMtlRenderPipelineState = nil;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_RENDERPIPELINEMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/RenderPipelineMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/RenderPipelineMTL.mm
new file mode 100644
index 00000000000..2b38e0389bd
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/RenderPipelineMTL.mm
@@ -0,0 +1,144 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/RenderPipelineMTL.h"
+
+#include "dawn_native/metal/BlendStateMTL.h"
+#include "dawn_native/metal/DepthStencilStateMTL.h"
+#include "dawn_native/metal/DeviceMTL.h"
+#include "dawn_native/metal/InputStateMTL.h"
+#include "dawn_native/metal/PipelineLayoutMTL.h"
+#include "dawn_native/metal/ShaderModuleMTL.h"
+#include "dawn_native/metal/TextureMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ namespace {
+ MTLPrimitiveType MTLPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
+ switch (primitiveTopology) {
+ case dawn::PrimitiveTopology::PointList:
+ return MTLPrimitiveTypePoint;
+ case dawn::PrimitiveTopology::LineList:
+ return MTLPrimitiveTypeLine;
+ case dawn::PrimitiveTopology::LineStrip:
+ return MTLPrimitiveTypeLineStrip;
+ case dawn::PrimitiveTopology::TriangleList:
+ return MTLPrimitiveTypeTriangle;
+ case dawn::PrimitiveTopology::TriangleStrip:
+ return MTLPrimitiveTypeTriangleStrip;
+ }
+ }
+
+ MTLPrimitiveTopologyClass MTLInputPrimitiveTopology(
+ dawn::PrimitiveTopology primitiveTopology) {
+ switch (primitiveTopology) {
+ case dawn::PrimitiveTopology::PointList:
+ return MTLPrimitiveTopologyClassPoint;
+ case dawn::PrimitiveTopology::LineList:
+ case dawn::PrimitiveTopology::LineStrip:
+ return MTLPrimitiveTopologyClassLine;
+ case dawn::PrimitiveTopology::TriangleList:
+ case dawn::PrimitiveTopology::TriangleStrip:
+ return MTLPrimitiveTopologyClassTriangle;
+ }
+ }
+
+ MTLIndexType MTLIndexFormat(dawn::IndexFormat format) {
+ switch (format) {
+ case dawn::IndexFormat::Uint16:
+ return MTLIndexTypeUInt16;
+ case dawn::IndexFormat::Uint32:
+ return MTLIndexTypeUInt32;
+ }
+ }
+ }
+
+ RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
+ : RenderPipelineBase(builder),
+ mMtlIndexType(MTLIndexFormat(GetIndexFormat())),
+ mMtlPrimitiveTopology(MTLPrimitiveTopology(GetPrimitiveTopology())) {
+ auto mtlDevice = ToBackend(builder->GetDevice())->GetMTLDevice();
+
+ MTLRenderPipelineDescriptor* descriptor = [MTLRenderPipelineDescriptor new];
+
+ for (auto stage : IterateStages(GetStageMask())) {
+ const auto& module = ToBackend(builder->GetStageInfo(stage).module);
+
+ const auto& entryPoint = builder->GetStageInfo(stage).entryPoint;
+ ShaderModule::MetalFunctionData data =
+ module->GetFunction(entryPoint.c_str(), stage, ToBackend(GetLayout()));
+ id<MTLFunction> function = data.function;
+
+ switch (stage) {
+ case dawn::ShaderStage::Vertex:
+ descriptor.vertexFunction = function;
+ break;
+ case dawn::ShaderStage::Fragment:
+ descriptor.fragmentFunction = function;
+ break;
+ case dawn::ShaderStage::Compute:
+ UNREACHABLE();
+ }
+ }
+
+ if (HasDepthStencilAttachment()) {
+ // TODO(kainino@chromium.org): Handle depth-only and stencil-only formats.
+ dawn::TextureFormat depthStencilFormat = GetDepthStencilFormat();
+ descriptor.depthAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat);
+ descriptor.stencilAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat);
+ }
+
+ for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) {
+ descriptor.colorAttachments[i].pixelFormat =
+ MetalPixelFormat(GetColorAttachmentFormat(i));
+ ToBackend(GetBlendState(i))->ApplyBlendState(descriptor.colorAttachments[i]);
+ }
+
+ descriptor.inputPrimitiveTopology = MTLInputPrimitiveTopology(GetPrimitiveTopology());
+
+ InputState* inputState = ToBackend(GetInputState());
+ descriptor.vertexDescriptor = inputState->GetMTLVertexDescriptor();
+
+ // TODO(kainino@chromium.org): push constants, textures, samplers
+
+ NSError* error = nil;
+ mMtlRenderPipelineState = [mtlDevice newRenderPipelineStateWithDescriptor:descriptor
+ error:&error];
+ if (error != nil) {
+ NSLog(@" error => %@", error);
+ builder->HandleError("Error creating pipeline state");
+ [descriptor release];
+ return;
+ }
+
+ [descriptor release];
+ }
+
+ RenderPipeline::~RenderPipeline() {
+ [mMtlRenderPipelineState release];
+ }
+
+ MTLIndexType RenderPipeline::GetMTLIndexType() const {
+ return mMtlIndexType;
+ }
+
+ MTLPrimitiveType RenderPipeline::GetMTLPrimitiveTopology() const {
+ return mMtlPrimitiveTopology;
+ }
+
+ void RenderPipeline::Encode(id<MTLRenderCommandEncoder> encoder) {
+ [encoder setRenderPipelineState:mMtlRenderPipelineState];
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/ResourceUploader.h b/chromium/third_party/dawn/src/dawn_native/metal/ResourceUploader.h
new file mode 100644
index 00000000000..d6e057b8ad8
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/ResourceUploader.h
@@ -0,0 +1,42 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_RESOURCEUPLOADER_H_
+#define DAWNNATIVE_METAL_RESOURCEUPLOADER_H_
+
+#include "common/Serial.h"
+#include "common/SerialQueue.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ class ResourceUploader {
+ public:
+ ResourceUploader(Device* device);
+ ~ResourceUploader();
+
+ void BufferSubData(id<MTLBuffer> buffer, uint32_t start, uint32_t size, const void* data);
+ void Tick(Serial finishedSerial);
+
+ private:
+ Device* mDevice;
+ SerialQueue<id<MTLBuffer>> mInflightUploadBuffers;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_RESOURCEUPLOADER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/ResourceUploader.mm b/chromium/third_party/dawn/src/dawn_native/metal/ResourceUploader.mm
new file mode 100644
index 00000000000..fd990374a51
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/ResourceUploader.mm
@@ -0,0 +1,57 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/ResourceUploader.h"
+
+#include "dawn_native/metal/DeviceMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ ResourceUploader::ResourceUploader(Device* device) : mDevice(device) {
+ }
+
+ ResourceUploader::~ResourceUploader() {
+ ASSERT(mInflightUploadBuffers.Empty());
+ }
+
+ void ResourceUploader::BufferSubData(id<MTLBuffer> buffer,
+ uint32_t start,
+ uint32_t size,
+ const void* data) {
+ // TODO(cwallez@chromium.org) use a ringbuffer instead of creating a small buffer for each
+ // update
+ id<MTLBuffer> uploadBuffer =
+ [mDevice->GetMTLDevice() newBufferWithLength:size options:MTLResourceStorageModeShared];
+ memcpy([uploadBuffer contents], data, size);
+
+ id<MTLCommandBuffer> commandBuffer = mDevice->GetPendingCommandBuffer();
+ id<MTLBlitCommandEncoder> encoder = [commandBuffer blitCommandEncoder];
+ [encoder copyFromBuffer:uploadBuffer
+ sourceOffset:0
+ toBuffer:buffer
+ destinationOffset:start
+ size:size];
+ [encoder endEncoding];
+
+ mInflightUploadBuffers.Enqueue(uploadBuffer, mDevice->GetPendingCommandSerial());
+ }
+
+ void ResourceUploader::Tick(Serial finishedSerial) {
+ for (id<MTLBuffer> buffer : mInflightUploadBuffers.IterateUpTo(finishedSerial)) {
+ [buffer release];
+ }
+ mInflightUploadBuffers.ClearUpTo(finishedSerial);
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/SamplerMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/SamplerMTL.h
new file mode 100644
index 00000000000..776c9356295
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/SamplerMTL.h
@@ -0,0 +1,39 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_SAMPLERMTL_H_
+#define DAWNNATIVE_METAL_SAMPLERMTL_H_
+
+#include "dawn_native/Sampler.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ class Sampler : public SamplerBase {
+ public:
+ Sampler(Device* device, const SamplerDescriptor* descriptor);
+ ~Sampler();
+
+ id<MTLSamplerState> GetMTLSamplerState();
+
+ private:
+ id<MTLSamplerState> mMtlSamplerState = nil;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_SAMPLERMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/SamplerMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/SamplerMTL.mm
new file mode 100644
index 00000000000..539431ce783
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/SamplerMTL.mm
@@ -0,0 +1,75 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/SamplerMTL.h"
+
+#include "dawn_native/metal/DeviceMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ namespace {
+ MTLSamplerMinMagFilter FilterModeToMinMagFilter(dawn::FilterMode mode) {
+ switch (mode) {
+ case dawn::FilterMode::Nearest:
+ return MTLSamplerMinMagFilterNearest;
+ case dawn::FilterMode::Linear:
+ return MTLSamplerMinMagFilterLinear;
+ }
+ }
+
+ MTLSamplerMipFilter FilterModeToMipFilter(dawn::FilterMode mode) {
+ switch (mode) {
+ case dawn::FilterMode::Nearest:
+ return MTLSamplerMipFilterNearest;
+ case dawn::FilterMode::Linear:
+ return MTLSamplerMipFilterLinear;
+ }
+ }
+
+ MTLSamplerAddressMode AddressMode(dawn::AddressMode mode) {
+ switch (mode) {
+ case dawn::AddressMode::Repeat:
+ return MTLSamplerAddressModeRepeat;
+ case dawn::AddressMode::MirroredRepeat:
+ return MTLSamplerAddressModeMirrorRepeat;
+ case dawn::AddressMode::ClampToEdge:
+ return MTLSamplerAddressModeClampToEdge;
+ }
+ }
+ }
+
+ Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
+ : SamplerBase(device, descriptor) {
+ MTLSamplerDescriptor* mtlDesc = [MTLSamplerDescriptor new];
+ [mtlDesc autorelease];
+ mtlDesc.minFilter = FilterModeToMinMagFilter(descriptor->minFilter);
+ mtlDesc.magFilter = FilterModeToMinMagFilter(descriptor->magFilter);
+ mtlDesc.mipFilter = FilterModeToMipFilter(descriptor->mipmapFilter);
+
+ mtlDesc.sAddressMode = AddressMode(descriptor->addressModeU);
+ mtlDesc.tAddressMode = AddressMode(descriptor->addressModeV);
+ mtlDesc.rAddressMode = AddressMode(descriptor->addressModeW);
+
+ mMtlSamplerState = [device->GetMTLDevice() newSamplerStateWithDescriptor:mtlDesc];
+ }
+
+ Sampler::~Sampler() {
+ [mMtlSamplerState release];
+ }
+
+ id<MTLSamplerState> Sampler::GetMTLSamplerState() {
+ return mMtlSamplerState;
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/ShaderModuleMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/ShaderModuleMTL.h
new file mode 100644
index 00000000000..1e3a7262d90
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/ShaderModuleMTL.h
@@ -0,0 +1,55 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_SHADERMODULEMTL_H_
+#define DAWNNATIVE_METAL_SHADERMODULEMTL_H_
+
+#include "dawn_native/ShaderModule.h"
+
+#import <Metal/Metal.h>
+
+namespace spirv_cross {
+ class CompilerMSL;
+}
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+ class PipelineLayout;
+
+ class ShaderModule : public ShaderModuleBase {
+ public:
+ ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor);
+
+ struct MetalFunctionData {
+ id<MTLFunction> function;
+ MTLSize localWorkgroupSize;
+ ~MetalFunctionData() {
+ [function release];
+ }
+ };
+ MetalFunctionData GetFunction(const char* functionName,
+ dawn::ShaderStage functionStage,
+ const PipelineLayout* layout) const;
+
+ private:
+ // Calling compile on CompilerMSL somehow changes internal state that makes subsequent
+ // compiles return invalid MSL. We keep the spirv around and recreate the compiler everytime
+ // we need to use it.
+ std::vector<uint32_t> mSpirv;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_SHADERMODULEMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/ShaderModuleMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/ShaderModuleMTL.mm
new file mode 100644
index 00000000000..2d38d1854f6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/ShaderModuleMTL.mm
@@ -0,0 +1,133 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/ShaderModuleMTL.h"
+
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/metal/DeviceMTL.h"
+#include "dawn_native/metal/PipelineLayoutMTL.h"
+
+#include <spirv-cross/spirv_msl.hpp>
+
+#include <sstream>
+
+namespace dawn_native { namespace metal {
+
+ namespace {
+
+ spv::ExecutionModel SpirvExecutionModelForStage(dawn::ShaderStage stage) {
+ switch (stage) {
+ case dawn::ShaderStage::Vertex:
+ return spv::ExecutionModelVertex;
+ case dawn::ShaderStage::Fragment:
+ return spv::ExecutionModelFragment;
+ case dawn::ShaderStage::Compute:
+ return spv::ExecutionModelGLCompute;
+ default:
+ UNREACHABLE();
+ }
+ }
+ }
+
+ ShaderModule::ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor)
+ : ShaderModuleBase(device, descriptor) {
+ mSpirv.assign(descriptor->code, descriptor->code + descriptor->codeSize);
+ spirv_cross::CompilerMSL compiler(mSpirv);
+ ExtractSpirvInfo(compiler);
+ }
+
+ ShaderModule::MetalFunctionData ShaderModule::GetFunction(const char* functionName,
+ dawn::ShaderStage functionStage,
+ const PipelineLayout* layout) const {
+ spirv_cross::CompilerMSL compiler(mSpirv);
+
+ // If these options are changed, the values in DawnSPIRVCrossMSLFastFuzzer.cpp need to be
+ // updated.
+ spirv_cross::CompilerGLSL::Options options_glsl;
+ options_glsl.vertex.flip_vert_y = true;
+ compiler.spirv_cross::CompilerGLSL::set_common_options(options_glsl);
+
+ // By default SPIRV-Cross will give MSL resources indices in increasing order.
+ // To make the MSL indices match the indices chosen in the PipelineLayout, we build
+ // a table of MSLResourceBinding to give to SPIRV-Cross
+ std::vector<spirv_cross::MSLResourceBinding> mslBindings;
+
+ // Reserve index 0 for buffers for the push constants buffer.
+ for (auto stage : IterateStages(kAllStages)) {
+ spirv_cross::MSLResourceBinding binding;
+ binding.stage = SpirvExecutionModelForStage(stage);
+ binding.desc_set = spirv_cross::kPushConstDescSet;
+ binding.binding = spirv_cross::kPushConstBinding;
+ binding.msl_buffer = 0;
+
+ mslBindings.push_back(binding);
+ }
+
+ // Create one resource binding entry per stage per binding.
+ for (uint32_t group : IterateBitSet(layout->GetBindGroupLayoutsMask())) {
+ const auto& bgInfo = layout->GetBindGroupLayout(group)->GetBindingInfo();
+ for (uint32_t binding : IterateBitSet(bgInfo.mask)) {
+ for (auto stage : IterateStages(bgInfo.visibilities[binding])) {
+ uint32_t index = layout->GetBindingIndexInfo(stage)[group][binding];
+
+ spirv_cross::MSLResourceBinding mslBinding;
+ mslBinding.stage = SpirvExecutionModelForStage(stage);
+ mslBinding.desc_set = group;
+ mslBinding.binding = binding;
+ mslBinding.msl_buffer = mslBinding.msl_texture = mslBinding.msl_sampler = index;
+
+ mslBindings.push_back(mslBinding);
+ }
+ }
+ }
+
+ MetalFunctionData result;
+
+ {
+ spv::ExecutionModel executionModel = SpirvExecutionModelForStage(functionStage);
+ auto size = compiler.get_entry_point(functionName, executionModel).workgroup_size;
+ result.localWorkgroupSize = MTLSizeMake(size.x, size.y, size.z);
+ }
+
+ {
+ // SPIRV-Cross also supports re-ordering attributes but it seems to do the correct thing
+ // by default.
+ std::string msl = compiler.compile(nullptr, &mslBindings);
+ NSString* mslSource = [NSString stringWithFormat:@"%s", msl.c_str()];
+
+ auto mtlDevice = ToBackend(GetDevice())->GetMTLDevice();
+ NSError* error = nil;
+ id<MTLLibrary> library = [mtlDevice newLibraryWithSource:mslSource
+ options:nil
+ error:&error];
+ if (error != nil) {
+ // TODO(cwallez@chromium.org): forward errors to caller
+ NSLog(@"MTLDevice newLibraryWithSource => %@", error);
+ }
+ // TODO(kainino@chromium.org): make this somehow more robust; it needs to behave like
+ // clean_func_name:
+ // https://github.com/KhronosGroup/SPIRV-Cross/blob/4e915e8c483e319d0dd7a1fa22318bef28f8cca3/spirv_msl.cpp#L1213
+ if (strcmp(functionName, "main") == 0) {
+ functionName = "main0";
+ }
+
+ NSString* name = [NSString stringWithFormat:@"%s", functionName];
+ result.function = [library newFunctionWithName:name];
+ [library release];
+ }
+
+ return result;
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/SwapChainMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/SwapChainMTL.h
new file mode 100644
index 00000000000..ac88ce12119
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/SwapChainMTL.h
@@ -0,0 +1,36 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_SWAPCHAINMTL_H_
+#define DAWNNATIVE_METAL_SWAPCHAINMTL_H_
+
+#include "dawn_native/SwapChain.h"
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ class SwapChain : public SwapChainBase {
+ public:
+ SwapChain(SwapChainBuilder* builder);
+ ~SwapChain();
+
+ protected:
+ TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
+ void OnBeforePresent(TextureBase* texture) override;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_SWAPCHAINMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/SwapChainMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/SwapChainMTL.mm
new file mode 100644
index 00000000000..f7d1a52c66f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/SwapChainMTL.mm
@@ -0,0 +1,50 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/SwapChainMTL.h"
+
+#include "dawn_native/metal/DeviceMTL.h"
+#include "dawn_native/metal/TextureMTL.h"
+
+#include <dawn/dawn_wsi.h>
+
+namespace dawn_native { namespace metal {
+
+ SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
+ const auto& im = GetImplementation();
+ dawnWSIContextMetal wsiContext = {};
+ wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
+ im.Init(im.userData, &wsiContext);
+ }
+
+ SwapChain::~SwapChain() {
+ }
+
+ TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
+ const auto& im = GetImplementation();
+ dawnSwapChainNextTexture next = {};
+ dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
+ if (error) {
+ GetDevice()->HandleError(error);
+ return nullptr;
+ }
+
+ id<MTLTexture> nativeTexture = reinterpret_cast<id<MTLTexture>>(next.texture.ptr);
+ return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
+ }
+
+ void SwapChain::OnBeforePresent(TextureBase*) {
+ }
+
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/TextureMTL.h b/chromium/third_party/dawn/src/dawn_native/metal/TextureMTL.h
new file mode 100644
index 00000000000..c002f569db6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/TextureMTL.h
@@ -0,0 +1,53 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METAL_TEXTUREMTL_H_
+#define DAWNNATIVE_METAL_TEXTUREMTL_H_
+
+#include "dawn_native/Texture.h"
+
+#import <Metal/Metal.h>
+
+namespace dawn_native { namespace metal {
+
+ class Device;
+
+ MTLPixelFormat MetalPixelFormat(dawn::TextureFormat format);
+
+ class Texture : public TextureBase {
+ public:
+ Texture(Device* device, const TextureDescriptor* descriptor);
+ Texture(Device* device, const TextureDescriptor* descriptor, id<MTLTexture> mtlTexture);
+ ~Texture();
+
+ id<MTLTexture> GetMTLTexture();
+
+ private:
+ id<MTLTexture> mMtlTexture = nil;
+ };
+
+ class TextureView : public TextureViewBase {
+ public:
+ TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor);
+ ~TextureView();
+
+ id<MTLTexture> GetMTLTexture();
+
+ private:
+ id<MTLTexture> mMtlTextureView = nil;
+ };
+
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METAL_TEXTUREMTL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/metal/TextureMTL.mm b/chromium/third_party/dawn/src/dawn_native/metal/TextureMTL.mm
new file mode 100644
index 00000000000..818c8daf6d1
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/metal/TextureMTL.mm
@@ -0,0 +1,147 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/metal/TextureMTL.h"
+
+#include "dawn_native/metal/DeviceMTL.h"
+
+namespace dawn_native { namespace metal {
+
+ MTLPixelFormat MetalPixelFormat(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::R8G8B8A8Unorm:
+ return MTLPixelFormatRGBA8Unorm;
+ case dawn::TextureFormat::R8G8Unorm:
+ return MTLPixelFormatRG8Unorm;
+ case dawn::TextureFormat::R8Unorm:
+ return MTLPixelFormatR8Unorm;
+ case dawn::TextureFormat::R8G8B8A8Uint:
+ return MTLPixelFormatRGBA8Uint;
+ case dawn::TextureFormat::R8G8Uint:
+ return MTLPixelFormatRG8Uint;
+ case dawn::TextureFormat::R8Uint:
+ return MTLPixelFormatR8Uint;
+ case dawn::TextureFormat::B8G8R8A8Unorm:
+ return MTLPixelFormatBGRA8Unorm;
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return MTLPixelFormatDepth32Float_Stencil8;
+ }
+ }
+
+ namespace {
+ MTLTextureUsage MetalTextureUsage(dawn::TextureUsageBit usage) {
+ MTLTextureUsage result = MTLTextureUsageUnknown; // This is 0
+
+ if (usage & (dawn::TextureUsageBit::Storage)) {
+ result |= MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
+ }
+
+ if (usage & (dawn::TextureUsageBit::Sampled)) {
+ result |= MTLTextureUsageShaderRead;
+ }
+
+ if (usage & (dawn::TextureUsageBit::OutputAttachment)) {
+ result |= MTLTextureUsageRenderTarget;
+ }
+
+ // TODO(jiawei.shao@intel.com): investigate if we should skip setting this flag when the
+ // texture is only used as a render target.
+ result |= MTLTextureUsagePixelFormatView;
+
+ return result;
+ }
+
+ MTLTextureType MetalTextureType(dawn::TextureDimension dimension,
+ unsigned int arrayLayers) {
+ switch (dimension) {
+ case dawn::TextureDimension::e2D:
+ return (arrayLayers > 1) ? MTLTextureType2DArray : MTLTextureType2D;
+ }
+ }
+
+ MTLTextureType MetalTextureViewType(dawn::TextureViewDimension dimension) {
+ switch (dimension) {
+ case dawn::TextureViewDimension::e2D:
+ return MTLTextureType2D;
+ case dawn::TextureViewDimension::e2DArray:
+ return MTLTextureType2DArray;
+ case dawn::TextureViewDimension::Cube:
+ return MTLTextureTypeCube;
+ case dawn::TextureViewDimension::CubeArray:
+ return MTLTextureTypeCubeArray;
+ default:
+ UNREACHABLE();
+ return MTLTextureType2D;
+ }
+ }
+ }
+
+ Texture::Texture(Device* device, const TextureDescriptor* descriptor)
+ : TextureBase(device, descriptor) {
+ auto desc = [MTLTextureDescriptor new];
+ [desc autorelease];
+ desc.textureType = MetalTextureType(GetDimension(), GetArrayLayers());
+ desc.usage = MetalTextureUsage(GetUsage());
+ desc.pixelFormat = MetalPixelFormat(GetFormat());
+
+ const Extent3D& size = GetSize();
+ desc.width = size.width;
+ desc.height = size.height;
+ desc.depth = size.depth;
+
+ desc.mipmapLevelCount = GetNumMipLevels();
+ desc.arrayLength = GetArrayLayers();
+ desc.storageMode = MTLStorageModePrivate;
+
+ auto mtlDevice = device->GetMTLDevice();
+ mMtlTexture = [mtlDevice newTextureWithDescriptor:desc];
+ }
+
+ Texture::Texture(Device* device, const TextureDescriptor* descriptor, id<MTLTexture> mtlTexture)
+ : TextureBase(device, descriptor), mMtlTexture(mtlTexture) {
+ [mMtlTexture retain];
+ }
+
+ Texture::~Texture() {
+ [mMtlTexture release];
+ }
+
+ id<MTLTexture> Texture::GetMTLTexture() {
+ return mMtlTexture;
+ }
+
+ // TODO(jiawei.shao@intel.com): use the original texture directly when the descriptor covers the
+ // whole texture in the same format (for example, when CreateDefaultTextureView() is called).
+ TextureView::TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor)
+ : TextureViewBase(texture, descriptor) {
+ MTLPixelFormat format = MetalPixelFormat(descriptor->format);
+ MTLTextureType textureViewType = MetalTextureViewType(descriptor->dimension);
+ auto mipLevelRange = NSMakeRange(descriptor->baseMipLevel, descriptor->levelCount);
+ auto arrayLayerRange = NSMakeRange(descriptor->baseArrayLayer, descriptor->layerCount);
+
+ id<MTLTexture> mtlTexture = ToBackend(texture)->GetMTLTexture();
+ mMtlTextureView = [mtlTexture newTextureViewWithPixelFormat:format
+ textureType:textureViewType
+ levels:mipLevelRange
+ slices:arrayLayerRange];
+ }
+
+ TextureView::~TextureView() {
+ [mMtlTextureView release];
+ }
+
+ id<MTLTexture> TextureView::GetMTLTexture() {
+ return mMtlTextureView;
+ }
+}} // namespace dawn_native::metal
diff --git a/chromium/third_party/dawn/src/dawn_native/null/NullBackend.cpp b/chromium/third_party/dawn/src/dawn_native/null/NullBackend.cpp
new file mode 100644
index 00000000000..86fbca71e96
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/null/NullBackend.cpp
@@ -0,0 +1,229 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/null/NullBackend.h"
+
+#include "dawn_native/Commands.h"
+#include "dawn_native/NullBackend.h"
+
+#include <spirv-cross/spirv_cross.hpp>
+
+namespace dawn_native { namespace null {
+
+ dawnDevice CreateDevice() {
+ return reinterpret_cast<dawnDevice>(new Device);
+ }
+
+ // Device
+
+ Device::Device() {
+ InitFakePCIInfo();
+ }
+
+ Device::~Device() {
+ }
+
+ BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
+ return new BindGroup(builder);
+ }
+ ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) {
+ return new BindGroupLayout(this, descriptor);
+ }
+ BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
+ return new BlendState(builder);
+ }
+ ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
+ return new Buffer(this, descriptor);
+ }
+ BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
+ return new BufferView(builder);
+ }
+ CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
+ return new CommandBuffer(builder);
+ }
+ ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) {
+ return new ComputePipeline(this, descriptor);
+ }
+ DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
+ return new DepthStencilState(builder);
+ }
+ InputStateBase* Device::CreateInputState(InputStateBuilder* builder) {
+ return new InputState(builder);
+ }
+ ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) {
+ return new PipelineLayout(this, descriptor);
+ }
+ ResultOrError<QueueBase*> Device::CreateQueueImpl() {
+ return new Queue(this);
+ }
+ RenderPassDescriptorBase* Device::CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) {
+ return new RenderPassDescriptor(builder);
+ }
+ RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
+ return new RenderPipeline(builder);
+ }
+ ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
+ return new Sampler(this, descriptor);
+ }
+ ResultOrError<ShaderModuleBase*> Device::CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) {
+ auto module = new ShaderModule(this, descriptor);
+
+ spirv_cross::Compiler compiler(descriptor->code, descriptor->codeSize);
+ module->ExtractSpirvInfo(compiler);
+
+ return module;
+ }
+ SwapChainBase* Device::CreateSwapChain(SwapChainBuilder* builder) {
+ return new SwapChain(builder);
+ }
+ ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
+ return new Texture(this, descriptor);
+ }
+ ResultOrError<TextureViewBase*> Device::CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ return new TextureView(texture, descriptor);
+ }
+
+ void Device::InitFakePCIInfo() {
+ mPCIInfo.name = "Null backend";
+ }
+
+ const dawn_native::PCIInfo& Device::GetPCIInfo() const {
+ return mPCIInfo;
+ }
+
+ void Device::TickImpl() {
+ }
+
+ void Device::AddPendingOperation(std::unique_ptr<PendingOperation> operation) {
+ mPendingOperations.emplace_back(std::move(operation));
+ }
+ std::vector<std::unique_ptr<PendingOperation>> Device::AcquirePendingOperations() {
+ return std::move(mPendingOperations);
+ }
+
+ // Buffer
+
+ struct BufferMapReadOperation : PendingOperation {
+ virtual void Execute() {
+ buffer->MapReadOperationCompleted(serial, ptr, isWrite);
+ }
+
+ Ref<Buffer> buffer;
+ void* ptr;
+ uint32_t serial;
+ bool isWrite;
+ };
+
+ Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
+ : BufferBase(device, descriptor) {
+ if (GetUsage() & (dawn::BufferUsageBit::TransferDst | dawn::BufferUsageBit::MapRead |
+ dawn::BufferUsageBit::MapWrite)) {
+ mBackingData = std::unique_ptr<char[]>(new char[GetSize()]);
+ }
+ }
+
+ Buffer::~Buffer() {
+ }
+
+ void Buffer::MapReadOperationCompleted(uint32_t serial, void* ptr, bool isWrite) {
+ if (isWrite) {
+ CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr);
+ } else {
+ CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, ptr);
+ }
+ }
+
+ void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) {
+ ASSERT(start + count <= GetSize());
+ ASSERT(mBackingData);
+ memcpy(mBackingData.get() + start, data, count);
+ }
+
+ void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
+ MapAsyncImplCommon(serial, start, count, false);
+ }
+
+ void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
+ MapAsyncImplCommon(serial, start, count, true);
+ }
+
+ void Buffer::MapAsyncImplCommon(uint32_t serial, uint32_t start, uint32_t count, bool isWrite) {
+ ASSERT(start + count <= GetSize());
+ ASSERT(mBackingData);
+
+ auto operation = new BufferMapReadOperation;
+ operation->buffer = this;
+ operation->ptr = mBackingData.get() + start;
+ operation->serial = serial;
+ operation->isWrite = isWrite;
+
+ ToBackend(GetDevice())->AddPendingOperation(std::unique_ptr<PendingOperation>(operation));
+ }
+
+ void Buffer::UnmapImpl() {
+ }
+
+ // CommandBuffer
+
+ CommandBuffer::CommandBuffer(CommandBufferBuilder* builder)
+ : CommandBufferBase(builder), mCommands(builder->AcquireCommands()) {
+ }
+
+ CommandBuffer::~CommandBuffer() {
+ FreeCommands(&mCommands);
+ }
+
+ // Queue
+
+ Queue::Queue(Device* device) : QueueBase(device) {
+ }
+
+ Queue::~Queue() {
+ }
+
+ void Queue::SubmitImpl(uint32_t, CommandBufferBase* const*) {
+ auto operations = ToBackend(GetDevice())->AcquirePendingOperations();
+
+ for (auto& operation : operations) {
+ operation->Execute();
+ }
+
+ operations.clear();
+ }
+
+ // SwapChain
+
+ SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
+ const auto& im = GetImplementation();
+ im.Init(im.userData, nullptr);
+ }
+
+ SwapChain::~SwapChain() {
+ }
+
+ TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
+ return GetDevice()->CreateTexture(descriptor);
+ }
+
+ void SwapChain::OnBeforePresent(TextureBase*) {
+ }
+
+}} // namespace dawn_native::null
diff --git a/chromium/third_party/dawn/src/dawn_native/null/NullBackend.h b/chromium/third_party/dawn/src/dawn_native/null/NullBackend.h
new file mode 100644
index 00000000000..0c50ae9493e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/null/NullBackend.h
@@ -0,0 +1,186 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_NULL_NULLBACKEND_H_
+#define DAWNNATIVE_NULL_NULLBACKEND_H_
+
+#include "dawn_native/dawn_platform.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/BlendState.h"
+#include "dawn_native/Buffer.h"
+#include "dawn_native/CommandBuffer.h"
+#include "dawn_native/ComputePipeline.h"
+#include "dawn_native/DepthStencilState.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/InputState.h"
+#include "dawn_native/PipelineLayout.h"
+#include "dawn_native/Queue.h"
+#include "dawn_native/RenderPassDescriptor.h"
+#include "dawn_native/RenderPipeline.h"
+#include "dawn_native/Sampler.h"
+#include "dawn_native/ShaderModule.h"
+#include "dawn_native/SwapChain.h"
+#include "dawn_native/Texture.h"
+#include "dawn_native/ToBackend.h"
+
+namespace dawn_native { namespace null {
+
+ using BindGroup = BindGroupBase;
+ using BindGroupLayout = BindGroupLayoutBase;
+ using BlendState = BlendStateBase;
+ class Buffer;
+ using BufferView = BufferViewBase;
+ class CommandBuffer;
+ using ComputePipeline = ComputePipelineBase;
+ using DepthStencilState = DepthStencilStateBase;
+ class Device;
+ using InputState = InputStateBase;
+ using PipelineLayout = PipelineLayoutBase;
+ class Queue;
+ using RenderPassDescriptor = RenderPassDescriptorBase;
+ using RenderPipeline = RenderPipelineBase;
+ using Sampler = SamplerBase;
+ using ShaderModule = ShaderModuleBase;
+ class SwapChain;
+ using Texture = TextureBase;
+ using TextureView = TextureViewBase;
+
+ struct NullBackendTraits {
+ using BindGroupType = BindGroup;
+ using BindGroupLayoutType = BindGroupLayout;
+ using BlendStateType = BlendState;
+ using BufferType = Buffer;
+ using BufferViewType = BufferView;
+ using CommandBufferType = CommandBuffer;
+ using ComputePipelineType = ComputePipeline;
+ using DepthStencilStateType = DepthStencilState;
+ using DeviceType = Device;
+ using InputStateType = InputState;
+ using PipelineLayoutType = PipelineLayout;
+ using QueueType = Queue;
+ using RenderPassDescriptorType = RenderPassDescriptor;
+ using RenderPipelineType = RenderPipeline;
+ using SamplerType = Sampler;
+ using ShaderModuleType = ShaderModule;
+ using SwapChainType = SwapChain;
+ using TextureType = Texture;
+ using TextureViewType = TextureView;
+ };
+
+ template <typename T>
+ auto ToBackend(T&& common) -> decltype(ToBackendBase<NullBackendTraits>(common)) {
+ return ToBackendBase<NullBackendTraits>(common);
+ }
+
+ struct PendingOperation {
+ virtual ~PendingOperation() = default;
+ virtual void Execute() = 0;
+ };
+
+ class Device : public DeviceBase {
+ public:
+ Device();
+ ~Device();
+
+ BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
+ BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
+ BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
+ CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
+ DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
+ InputStateBase* CreateInputState(InputStateBuilder* builder) override;
+ RenderPassDescriptorBase* CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) override;
+ RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
+ SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
+
+ void TickImpl() override;
+
+ const dawn_native::PCIInfo& GetPCIInfo() const override;
+
+ void AddPendingOperation(std::unique_ptr<PendingOperation> operation);
+ std::vector<std::unique_ptr<PendingOperation>> AcquirePendingOperations();
+
+ private:
+ ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) override;
+ ResultOrError<BufferBase*> CreateBufferImpl(const BufferDescriptor* descriptor) override;
+ ResultOrError<ComputePipelineBase*> CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) override;
+ ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) override;
+ ResultOrError<QueueBase*> CreateQueueImpl() override;
+ ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
+ ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) override;
+ ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
+ ResultOrError<TextureViewBase*> CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) override;
+ void InitFakePCIInfo();
+
+ std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
+ dawn_native::PCIInfo mPCIInfo;
+ };
+
+ class Buffer : public BufferBase {
+ public:
+ Buffer(Device* device, const BufferDescriptor* descriptor);
+ ~Buffer();
+
+ void MapReadOperationCompleted(uint32_t serial, void* ptr, bool isWrite);
+
+ private:
+ void SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
+ void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void UnmapImpl() override;
+
+ void MapAsyncImplCommon(uint32_t serial, uint32_t start, uint32_t count, bool isWrite);
+
+ std::unique_ptr<char[]> mBackingData;
+ };
+
+ class CommandBuffer : public CommandBufferBase {
+ public:
+ CommandBuffer(CommandBufferBuilder* builder);
+ ~CommandBuffer();
+
+ private:
+ CommandIterator mCommands;
+ };
+
+ class Queue : public QueueBase {
+ public:
+ Queue(Device* device);
+ ~Queue();
+
+ private:
+ void SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) override;
+ };
+
+ class SwapChain : public SwapChainBase {
+ public:
+ SwapChain(SwapChainBuilder* builder);
+ ~SwapChain();
+
+ protected:
+ TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
+ void OnBeforePresent(TextureBase*) override;
+ };
+
+}} // namespace dawn_native::null
+
+#endif // DAWNNATIVE_NULL_NULLBACKEND_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/BlendStateGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/BlendStateGL.cpp
new file mode 100644
index 00000000000..6460cec282e
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/BlendStateGL.cpp
@@ -0,0 +1,96 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/BlendStateGL.h"
+
+#include "common/Assert.h"
+
+namespace dawn_native { namespace opengl {
+
+ namespace {
+ GLenum GLBlendFactor(dawn::BlendFactor factor, bool alpha) {
+ switch (factor) {
+ case dawn::BlendFactor::Zero:
+ return GL_ZERO;
+ case dawn::BlendFactor::One:
+ return GL_ONE;
+ case dawn::BlendFactor::SrcColor:
+ return GL_SRC_COLOR;
+ case dawn::BlendFactor::OneMinusSrcColor:
+ return GL_ONE_MINUS_SRC_COLOR;
+ case dawn::BlendFactor::SrcAlpha:
+ return GL_SRC_ALPHA;
+ case dawn::BlendFactor::OneMinusSrcAlpha:
+ return GL_ONE_MINUS_SRC_ALPHA;
+ case dawn::BlendFactor::DstColor:
+ return GL_DST_COLOR;
+ case dawn::BlendFactor::OneMinusDstColor:
+ return GL_ONE_MINUS_DST_COLOR;
+ case dawn::BlendFactor::DstAlpha:
+ return GL_DST_ALPHA;
+ case dawn::BlendFactor::OneMinusDstAlpha:
+ return GL_ONE_MINUS_DST_ALPHA;
+ case dawn::BlendFactor::SrcAlphaSaturated:
+ return GL_SRC_ALPHA_SATURATE;
+ case dawn::BlendFactor::BlendColor:
+ return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR;
+ case dawn::BlendFactor::OneMinusBlendColor:
+ return alpha ? GL_ONE_MINUS_CONSTANT_ALPHA : GL_ONE_MINUS_CONSTANT_COLOR;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ GLenum GLBlendMode(dawn::BlendOperation operation) {
+ switch (operation) {
+ case dawn::BlendOperation::Add:
+ return GL_FUNC_ADD;
+ case dawn::BlendOperation::Subtract:
+ return GL_FUNC_SUBTRACT;
+ case dawn::BlendOperation::ReverseSubtract:
+ return GL_FUNC_REVERSE_SUBTRACT;
+ case dawn::BlendOperation::Min:
+ return GL_MIN;
+ case dawn::BlendOperation::Max:
+ return GL_MAX;
+ default:
+ UNREACHABLE();
+ }
+ }
+ } // namespace
+
+ BlendState::BlendState(BlendStateBuilder* builder) : BlendStateBase(builder) {
+ }
+
+ void BlendState::ApplyNow(uint32_t attachment) {
+ const auto& info = GetBlendInfo();
+
+ if (info.blendEnabled) {
+ glEnablei(GL_BLEND, attachment);
+ glBlendEquationSeparatei(attachment, GLBlendMode(info.colorBlend.operation),
+ GLBlendMode(info.alphaBlend.operation));
+ glBlendFuncSeparatei(attachment, GLBlendFactor(info.colorBlend.srcFactor, false),
+ GLBlendFactor(info.colorBlend.dstFactor, false),
+ GLBlendFactor(info.alphaBlend.srcFactor, true),
+ GLBlendFactor(info.alphaBlend.dstFactor, true));
+ } else {
+ glDisablei(GL_BLEND, attachment);
+ }
+ glColorMaski(attachment, info.colorWriteMask & dawn::ColorWriteMask::Red,
+ info.colorWriteMask & dawn::ColorWriteMask::Green,
+ info.colorWriteMask & dawn::ColorWriteMask::Blue,
+ info.colorWriteMask & dawn::ColorWriteMask::Alpha);
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/BlendStateGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/BlendStateGL.h
new file mode 100644
index 00000000000..afc2bdecf22
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/BlendStateGL.h
@@ -0,0 +1,33 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_BLENDSTATEGL_H_
+#define DAWNNATIVE_OPENGL_BLENDSTATEGL_H_
+
+#include "dawn_native/BlendState.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class BlendState : public BlendStateBase {
+ public:
+ BlendState(BlendStateBuilder* builder);
+
+ void ApplyNow(uint32_t attachment);
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_BLENDSTATEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/BufferGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/BufferGL.cpp
new file mode 100644
index 00000000000..6f2387bdad7
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/BufferGL.cpp
@@ -0,0 +1,65 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/BufferGL.h"
+
+#include "dawn_native/opengl/DeviceGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ // Buffer
+
+ Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
+ : BufferBase(device, descriptor) {
+ glGenBuffers(1, &mBuffer);
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
+ glBufferData(GL_ARRAY_BUFFER, GetSize(), nullptr, GL_STATIC_DRAW);
+ }
+
+ GLuint Buffer::GetHandle() const {
+ return mBuffer;
+ }
+
+ void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) {
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
+ glBufferSubData(GL_ARRAY_BUFFER, start, count, data);
+ }
+
+ void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
+ // TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
+ // version of OpenGL that would let us map the buffer unsynchronized.
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
+ void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_READ_BIT);
+ CallMapReadCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
+ }
+
+ void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) {
+ // TODO(cwallez@chromium.org): this does GPU->CPU synchronization, we could require a high
+ // version of OpenGL that would let us map the buffer unsynchronized.
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
+ void* data = glMapBufferRange(GL_ARRAY_BUFFER, start, count, GL_MAP_WRITE_BIT);
+ CallMapWriteCallback(serial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
+ }
+
+ void Buffer::UnmapImpl() {
+ glBindBuffer(GL_ARRAY_BUFFER, mBuffer);
+ glUnmapBuffer(GL_ARRAY_BUFFER);
+ }
+
+ // BufferView
+
+ BufferView::BufferView(BufferViewBuilder* builder) : BufferViewBase(builder) {
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/BufferGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/BufferGL.h
new file mode 100644
index 00000000000..98c3d1e8ebf
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/BufferGL.h
@@ -0,0 +1,48 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_BUFFERGL_H_
+#define DAWNNATIVE_OPENGL_BUFFERGL_H_
+
+#include "dawn_native/Buffer.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ class Buffer : public BufferBase {
+ public:
+ Buffer(Device* device, const BufferDescriptor* descriptor);
+
+ GLuint GetHandle() const;
+
+ private:
+ void SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
+ void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void UnmapImpl() override;
+
+ GLuint mBuffer = 0;
+ };
+
+ class BufferView : public BufferViewBase {
+ public:
+ BufferView(BufferViewBuilder* builder);
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_BUFFERGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/CommandBufferGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/CommandBufferGL.cpp
new file mode 100644
index 00000000000..ec03c77995f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/CommandBufferGL.cpp
@@ -0,0 +1,683 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/CommandBufferGL.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/Commands.h"
+#include "dawn_native/opengl/BufferGL.h"
+#include "dawn_native/opengl/ComputePipelineGL.h"
+#include "dawn_native/opengl/Forward.h"
+#include "dawn_native/opengl/InputStateGL.h"
+#include "dawn_native/opengl/PersistentPipelineStateGL.h"
+#include "dawn_native/opengl/PipelineLayoutGL.h"
+#include "dawn_native/opengl/RenderPipelineGL.h"
+#include "dawn_native/opengl/SamplerGL.h"
+#include "dawn_native/opengl/TextureGL.h"
+
+#include <cstring>
+
+namespace dawn_native { namespace opengl {
+
+ namespace {
+
+ GLenum IndexFormatType(dawn::IndexFormat format) {
+ switch (format) {
+ case dawn::IndexFormat::Uint16:
+ return GL_UNSIGNED_SHORT;
+ case dawn::IndexFormat::Uint32:
+ return GL_UNSIGNED_INT;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ GLenum VertexFormatType(dawn::VertexFormat format) {
+ switch (format) {
+ case dawn::VertexFormat::FloatR32G32B32A32:
+ case dawn::VertexFormat::FloatR32G32B32:
+ case dawn::VertexFormat::FloatR32G32:
+ case dawn::VertexFormat::FloatR32:
+ return GL_FLOAT;
+ case dawn::VertexFormat::IntR32G32B32A32:
+ case dawn::VertexFormat::IntR32G32B32:
+ case dawn::VertexFormat::IntR32G32:
+ case dawn::VertexFormat::IntR32:
+ return GL_INT;
+ case dawn::VertexFormat::UshortR16G16B16A16:
+ case dawn::VertexFormat::UshortR16G16:
+ return GL_UNSIGNED_SHORT;
+ case dawn::VertexFormat::UnormR8G8B8A8:
+ case dawn::VertexFormat::UnormR8G8:
+ return GL_UNSIGNED_BYTE;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ GLboolean VertexFormatIsNormalized(dawn::VertexFormat format) {
+ switch (format) {
+ case dawn::VertexFormat::UnormR8G8B8A8:
+ case dawn::VertexFormat::UnormR8G8:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+ }
+
+ // Push constants are implemented using OpenGL uniforms, however they aren't part of the
+ // global OpenGL state but are part of the program state instead. This means that we have to
+ // reapply push constants on pipeline change.
+ //
+ // This structure tracks the current values of push constants as well as dirty bits for push
+ // constants that should be applied before the next draw or dispatch.
+ class PushConstantTracker {
+ public:
+ PushConstantTracker() {
+ for (auto stage : IterateStages(kAllStages)) {
+ mValues[stage].fill(0);
+ // No need to set dirty bits as a pipeline will be set before the next operation
+ // using push constants.
+ }
+ }
+
+ void OnSetPushConstants(dawn::ShaderStageBit stages,
+ uint32_t count,
+ uint32_t offset,
+ const uint32_t* data) {
+ for (auto stage : IterateStages(stages)) {
+ memcpy(&mValues[stage][offset], data, count * sizeof(uint32_t));
+
+ // Use 64 bit masks and make sure there are no shift UB
+ static_assert(kMaxPushConstants <= 8 * sizeof(unsigned long long) - 1, "");
+ mDirtyBits[stage] |= ((1ull << count) - 1ull) << offset;
+ }
+ }
+
+ void OnSetPipeline(PipelineBase* pipeline) {
+ for (auto stage : IterateStages(kAllStages)) {
+ mDirtyBits[stage] = pipeline->GetPushConstants(stage).mask;
+ }
+ }
+
+ void Apply(PipelineBase* pipeline, PipelineGL* glPipeline) {
+ for (auto stage : IterateStages(kAllStages)) {
+ const auto& pushConstants = pipeline->GetPushConstants(stage);
+ const auto& glPushConstants = glPipeline->GetGLPushConstants(stage);
+
+ for (uint32_t constant :
+ IterateBitSet(mDirtyBits[stage] & pushConstants.mask)) {
+ GLint location = glPushConstants[constant];
+ switch (pushConstants.types[constant]) {
+ case PushConstantType::Int:
+ glUniform1i(location,
+ *reinterpret_cast<GLint*>(&mValues[stage][constant]));
+ break;
+ case PushConstantType::UInt:
+ glUniform1ui(location,
+ *reinterpret_cast<GLuint*>(&mValues[stage][constant]));
+ break;
+ case PushConstantType::Float:
+ float value;
+ // Use a memcpy to avoid strict-aliasing warnings, even if it is
+ // still technically undefined behavior.
+ memcpy(&value, &mValues[stage][constant], sizeof(value));
+ glUniform1f(location, value);
+ break;
+ }
+ }
+
+ mDirtyBits[stage].reset();
+ }
+ }
+
+ private:
+ PerStage<std::array<uint32_t, kMaxPushConstants>> mValues;
+ PerStage<std::bitset<kMaxPushConstants>> mDirtyBits;
+ };
+
+ // Vertex buffers and index buffers are implemented as part of an OpenGL VAO that
+ // corresponds to an InputState. On the contrary in Dawn they are part of the global state.
+ // This means that we have to re-apply these buffers on an InputState change.
+ class InputBufferTracker {
+ public:
+ void OnSetIndexBuffer(BufferBase* buffer) {
+ mIndexBufferDirty = true;
+ mIndexBuffer = ToBackend(buffer);
+ }
+
+ void OnSetVertexBuffers(uint32_t startSlot,
+ uint32_t count,
+ Ref<BufferBase>* buffers,
+ uint32_t* offsets) {
+ for (uint32_t i = 0; i < count; ++i) {
+ uint32_t slot = startSlot + i;
+ mVertexBuffers[slot] = ToBackend(buffers[i].Get());
+ mVertexBufferOffsets[slot] = offsets[i];
+ }
+
+ // Use 64 bit masks and make sure there are no shift UB
+ static_assert(kMaxVertexInputs <= 8 * sizeof(unsigned long long) - 1, "");
+ mDirtyVertexBuffers |= ((1ull << count) - 1ull) << startSlot;
+ }
+
+ void OnSetPipeline(RenderPipelineBase* pipeline) {
+ InputStateBase* inputState = pipeline->GetInputState();
+ if (mLastInputState == inputState) {
+ return;
+ }
+
+ mIndexBufferDirty = true;
+ mDirtyVertexBuffers |= inputState->GetInputsSetMask();
+
+ mLastInputState = ToBackend(inputState);
+ }
+
+ void Apply() {
+ if (mIndexBufferDirty && mIndexBuffer != nullptr) {
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mIndexBuffer->GetHandle());
+ mIndexBufferDirty = false;
+ }
+
+ for (uint32_t slot :
+ IterateBitSet(mDirtyVertexBuffers & mLastInputState->GetInputsSetMask())) {
+ for (uint32_t location :
+ IterateBitSet(mLastInputState->GetAttributesUsingInput(slot))) {
+ auto attribute = mLastInputState->GetAttribute(location);
+
+ GLuint buffer = mVertexBuffers[slot]->GetHandle();
+ uint32_t offset = mVertexBufferOffsets[slot];
+
+ auto input = mLastInputState->GetInput(slot);
+ auto components = VertexFormatNumComponents(attribute.format);
+ auto formatType = VertexFormatType(attribute.format);
+
+ GLboolean normalized = VertexFormatIsNormalized(attribute.format);
+ glBindBuffer(GL_ARRAY_BUFFER, buffer);
+ glVertexAttribPointer(
+ location, components, formatType, normalized, input.stride,
+ reinterpret_cast<void*>(
+ static_cast<intptr_t>(offset + attribute.offset)));
+ }
+ }
+
+ mDirtyVertexBuffers.reset();
+ }
+
+ private:
+ bool mIndexBufferDirty = false;
+ Buffer* mIndexBuffer = nullptr;
+
+ std::bitset<kMaxVertexInputs> mDirtyVertexBuffers;
+ std::array<Buffer*, kMaxVertexInputs> mVertexBuffers;
+ std::array<uint32_t, kMaxVertexInputs> mVertexBufferOffsets;
+
+ InputState* mLastInputState = nullptr;
+ };
+
+ // Handles SetBindGroup commands with the specifics of translating to OpenGL texture and
+ // buffer units
+ void ApplyBindGroup(uint32_t index,
+ BindGroupBase* group,
+ PipelineLayout* pipelineLayout,
+ PipelineGL* pipeline) {
+ const auto& indices = pipelineLayout->GetBindingIndexInfo()[index];
+ const auto& layout = group->GetLayout()->GetBindingInfo();
+
+ for (uint32_t binding : IterateBitSet(layout.mask)) {
+ switch (layout.types[binding]) {
+ case dawn::BindingType::UniformBuffer: {
+ BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
+ GLuint buffer = ToBackend(view->GetBuffer())->GetHandle();
+ GLuint uboIndex = indices[binding];
+
+ glBindBufferRange(GL_UNIFORM_BUFFER, uboIndex, buffer, view->GetOffset(),
+ view->GetSize());
+ } break;
+
+ case dawn::BindingType::Sampler: {
+ GLuint sampler =
+ ToBackend(group->GetBindingAsSampler(binding))->GetHandle();
+ GLuint samplerIndex = indices[binding];
+
+ for (auto unit : pipeline->GetTextureUnitsForSampler(samplerIndex)) {
+ glBindSampler(unit, sampler);
+ }
+ } break;
+
+ case dawn::BindingType::SampledTexture: {
+ TextureView* view = ToBackend(group->GetBindingAsTextureView(binding));
+ GLuint handle = view->GetHandle();
+ GLenum target = view->GetGLTarget();
+ GLuint viewIndex = indices[binding];
+
+ for (auto unit : pipeline->GetTextureUnitsForTextureView(viewIndex)) {
+ glActiveTexture(GL_TEXTURE0 + unit);
+ glBindTexture(target, handle);
+ }
+ } break;
+
+ case dawn::BindingType::StorageBuffer: {
+ BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
+ GLuint buffer = ToBackend(view->GetBuffer())->GetHandle();
+ GLuint ssboIndex = indices[binding];
+
+ glBindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer,
+ view->GetOffset(), view->GetSize());
+ } break;
+ }
+ }
+ }
+ } // namespace
+
+ CommandBuffer::CommandBuffer(CommandBufferBuilder* builder)
+ : CommandBufferBase(builder), mCommands(builder->AcquireCommands()) {
+ }
+
+ CommandBuffer::~CommandBuffer() {
+ FreeCommands(&mCommands);
+ }
+
+ void CommandBuffer::Execute() {
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::BeginComputePass: {
+ mCommands.NextCommand<BeginComputePassCmd>();
+ ExecuteComputePass();
+ } break;
+
+ case Command::BeginRenderPass: {
+ auto* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
+ ExecuteRenderPass(ToBackend(cmd->info.Get()));
+ } break;
+
+ case Command::CopyBufferToBuffer: {
+ CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, ToBackend(src.buffer)->GetHandle());
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, ToBackend(dst.buffer)->GetHandle());
+ glCopyBufferSubData(GL_PIXEL_PACK_BUFFER, GL_PIXEL_UNPACK_BUFFER, src.offset,
+ dst.offset, copy->size);
+
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+ } break;
+
+ case Command::CopyBufferToTexture: {
+ CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+ Buffer* buffer = ToBackend(src.buffer.Get());
+ Texture* texture = ToBackend(dst.texture.Get());
+ GLenum target = texture->GetGLTarget();
+ auto format = texture->GetGLFormat();
+
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer->GetHandle());
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(target, texture->GetHandle());
+
+ glPixelStorei(GL_UNPACK_ROW_LENGTH,
+ copy->rowPitch / TextureFormatPixelSize(texture->GetFormat()));
+ switch (texture->GetDimension()) {
+ case dawn::TextureDimension::e2D:
+ if (texture->GetArrayLayers() > 1) {
+ glTexSubImage3D(
+ target, dst.level, dst.x, dst.y, dst.slice, dst.width,
+ dst.height, 1, format.format, format.type,
+ reinterpret_cast<void*>(static_cast<uintptr_t>(src.offset)));
+ } else {
+ glTexSubImage2D(
+ target, dst.level, dst.x, dst.y, dst.width, dst.height,
+ format.format, format.type,
+ reinterpret_cast<void*>(static_cast<uintptr_t>(src.offset)));
+ }
+ break;
+
+ default:
+ UNREACHABLE();
+ }
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+
+ glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
+ } break;
+
+ case Command::CopyTextureToBuffer: {
+ CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+ Texture* texture = ToBackend(src.texture.Get());
+ Buffer* buffer = ToBackend(dst.buffer.Get());
+ auto format = texture->GetGLFormat();
+ GLenum target = texture->GetGLTarget();
+
+ // The only way to move data from a texture to a buffer in GL is via
+ // glReadPixels with a pack buffer. Create a temporary FBO for the copy.
+ glBindTexture(target, texture->GetHandle());
+
+ GLuint readFBO = 0;
+ glGenFramebuffers(1, &readFBO);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, readFBO);
+ switch (texture->GetDimension()) {
+ case dawn::TextureDimension::e2D:
+ if (texture->GetArrayLayers() > 1) {
+ glFramebufferTextureLayer(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ texture->GetHandle(), src.level,
+ src.slice);
+ } else {
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+ GL_TEXTURE_2D, texture->GetHandle(),
+ src.level);
+ }
+ break;
+
+ default:
+ UNREACHABLE();
+ }
+
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, buffer->GetHandle());
+ glPixelStorei(GL_PACK_ROW_LENGTH,
+ copy->rowPitch / TextureFormatPixelSize(texture->GetFormat()));
+ ASSERT(src.depth == 1 && src.z == 0);
+ void* offset = reinterpret_cast<void*>(static_cast<uintptr_t>(dst.offset));
+ glReadPixels(src.x, src.y, src.width, src.height, format.format, format.type,
+ offset);
+ glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+ glDeleteFramebuffers(1, &readFBO);
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+ }
+
+ void CommandBuffer::ExecuteComputePass() {
+ PushConstantTracker pushConstants;
+ ComputePipeline* lastPipeline = nullptr;
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndComputePass: {
+ mCommands.NextCommand<EndComputePassCmd>();
+ return;
+ } break;
+
+ case Command::Dispatch: {
+ DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
+ pushConstants.Apply(lastPipeline, lastPipeline);
+ glDispatchCompute(dispatch->x, dispatch->y, dispatch->z);
+ // TODO(cwallez@chromium.org): add barriers to the API
+ glMemoryBarrier(GL_ALL_BARRIER_BITS);
+ } break;
+
+ case Command::SetComputePipeline: {
+ SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
+ lastPipeline = ToBackend(cmd->pipeline).Get();
+
+ lastPipeline->ApplyNow();
+ pushConstants.OnSetPipeline(lastPipeline);
+ } break;
+
+ case Command::SetPushConstants: {
+ SetPushConstantsCmd* cmd = mCommands.NextCommand<SetPushConstantsCmd>();
+ uint32_t* data = mCommands.NextData<uint32_t>(cmd->count);
+ pushConstants.OnSetPushConstants(cmd->stages, cmd->count, cmd->offset, data);
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
+ ApplyBindGroup(cmd->index, cmd->group.Get(),
+ ToBackend(lastPipeline->GetLayout()), lastPipeline);
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+
+ // EndComputePass should have been called
+ UNREACHABLE();
+ }
+
+ void CommandBuffer::ExecuteRenderPass(RenderPassDescriptorBase* renderPass) {
+ GLuint fbo = 0;
+
+ // Create the framebuffer used for this render pass and calls the correct glDrawBuffers
+ {
+ // TODO(kainino@chromium.org): This is added to possibly work around an issue seen on
+ // Windows/Intel. It should break any feedback loop before the clears, even if there
+ // shouldn't be any negative effects from this. Investigate whether it's actually
+ // needed.
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
+ // TODO(kainino@chromium.org): possible future optimization: create these framebuffers
+ // at Framebuffer build time (or maybe CommandBuffer build time) so they don't have to
+ // be created and destroyed at draw time.
+ glGenFramebuffers(1, &fbo);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fbo);
+
+ // Mapping from attachmentSlot to GL framebuffer attachment points. Defaults to zero
+ // (GL_NONE).
+ std::array<GLenum, kMaxColorAttachments> drawBuffers = {};
+
+ // Construct GL framebuffer
+
+ unsigned int attachmentCount = 0;
+ for (uint32_t i : IterateBitSet(renderPass->GetColorAttachmentMask())) {
+ TextureViewBase* textureView = renderPass->GetColorAttachment(i).view.Get();
+ GLuint texture = ToBackend(textureView->GetTexture())->GetHandle();
+
+ // Attach color buffers.
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D,
+ texture, 0);
+ drawBuffers[i] = GL_COLOR_ATTACHMENT0 + i;
+ attachmentCount = i + 1;
+
+ // TODO(kainino@chromium.org): the color clears (later in
+ // this function) may be undefined for non-normalized integer formats.
+ dawn::TextureFormat format = textureView->GetTexture()->GetFormat();
+ ASSERT(format == dawn::TextureFormat::R8G8B8A8Unorm ||
+ format == dawn::TextureFormat::R8G8Unorm ||
+ format == dawn::TextureFormat::R8Unorm ||
+ format == dawn::TextureFormat::B8G8R8A8Unorm);
+ }
+ glDrawBuffers(attachmentCount, drawBuffers.data());
+
+ if (renderPass->HasDepthStencilAttachment()) {
+ TextureViewBase* textureView = renderPass->GetDepthStencilAttachment().view.Get();
+ GLuint texture = ToBackend(textureView->GetTexture())->GetHandle();
+ dawn::TextureFormat format = textureView->GetTexture()->GetFormat();
+
+ // Attach depth/stencil buffer.
+ GLenum glAttachment = 0;
+ // TODO(kainino@chromium.org): it may be valid to just always use
+ // GL_DEPTH_STENCIL_ATTACHMENT here.
+ if (TextureFormatHasDepth(format)) {
+ if (TextureFormatHasStencil(format)) {
+ glAttachment = GL_DEPTH_STENCIL_ATTACHMENT;
+ } else {
+ glAttachment = GL_DEPTH_ATTACHMENT;
+ }
+ } else {
+ glAttachment = GL_STENCIL_ATTACHMENT;
+ }
+
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, glAttachment, GL_TEXTURE_2D, texture,
+ 0);
+
+ // TODO(kainino@chromium.org): the depth/stencil clears (later in
+ // this function) may be undefined for other texture formats.
+ ASSERT(format == dawn::TextureFormat::D32FloatS8Uint);
+ }
+ }
+
+ // Clear framebuffer attachments as needed
+ {
+ for (uint32_t i : IterateBitSet(renderPass->GetColorAttachmentMask())) {
+ const auto& attachmentInfo = renderPass->GetColorAttachment(i);
+
+ // Load op - color
+ if (attachmentInfo.loadOp == dawn::LoadOp::Clear) {
+ glClearBufferfv(GL_COLOR, i, attachmentInfo.clearColor.data());
+ }
+ }
+
+ if (renderPass->HasDepthStencilAttachment()) {
+ const auto& attachmentInfo = renderPass->GetDepthStencilAttachment();
+ dawn::TextureFormat attachmentFormat =
+ attachmentInfo.view->GetTexture()->GetFormat();
+
+ // Load op - depth/stencil
+ bool doDepthClear = TextureFormatHasDepth(attachmentFormat) &&
+ (attachmentInfo.depthLoadOp == dawn::LoadOp::Clear);
+ bool doStencilClear = TextureFormatHasStencil(attachmentFormat) &&
+ (attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear);
+ if (doDepthClear && doStencilClear) {
+ glClearBufferfi(GL_DEPTH_STENCIL, 0, attachmentInfo.clearDepth,
+ attachmentInfo.clearStencil);
+ } else if (doDepthClear) {
+ glClearBufferfv(GL_DEPTH, 0, &attachmentInfo.clearDepth);
+ } else if (doStencilClear) {
+ const GLint clearStencil = attachmentInfo.clearStencil;
+ glClearBufferiv(GL_STENCIL, 0, &clearStencil);
+ }
+ }
+ }
+
+ RenderPipeline* lastPipeline = nullptr;
+ uint32_t indexBufferBaseOffset = 0;
+
+ PersistentPipelineState persistentPipelineState;
+
+ PushConstantTracker pushConstants;
+ InputBufferTracker inputBuffers;
+
+ // Set defaults for dynamic state
+ persistentPipelineState.SetDefaultState();
+ glBlendColor(0, 0, 0, 0);
+ glViewport(0, 0, renderPass->GetWidth(), renderPass->GetHeight());
+ glScissor(0, 0, renderPass->GetWidth(), renderPass->GetHeight());
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndRenderPass: {
+ mCommands.NextCommand<EndRenderPassCmd>();
+ glDeleteFramebuffers(1, &fbo);
+ return;
+ } break;
+
+ case Command::DrawArrays: {
+ DrawArraysCmd* draw = mCommands.NextCommand<DrawArraysCmd>();
+ pushConstants.Apply(lastPipeline, lastPipeline);
+ inputBuffers.Apply();
+
+ if (draw->firstInstance > 0) {
+ glDrawArraysInstancedBaseInstance(lastPipeline->GetGLPrimitiveTopology(),
+ draw->firstVertex, draw->vertexCount,
+ draw->instanceCount, draw->firstInstance);
+ } else {
+ // This branch is only needed on OpenGL < 4.2
+ glDrawArraysInstanced(lastPipeline->GetGLPrimitiveTopology(),
+ draw->firstVertex, draw->vertexCount,
+ draw->instanceCount);
+ }
+ } break;
+
+ case Command::DrawElements: {
+ DrawElementsCmd* draw = mCommands.NextCommand<DrawElementsCmd>();
+ pushConstants.Apply(lastPipeline, lastPipeline);
+ inputBuffers.Apply();
+
+ dawn::IndexFormat indexFormat = lastPipeline->GetIndexFormat();
+ size_t formatSize = IndexFormatSize(indexFormat);
+ GLenum formatType = IndexFormatType(indexFormat);
+
+ if (draw->firstInstance > 0) {
+ glDrawElementsInstancedBaseInstance(
+ lastPipeline->GetGLPrimitiveTopology(), draw->indexCount, formatType,
+ reinterpret_cast<void*>(draw->firstIndex * formatSize +
+ indexBufferBaseOffset),
+ draw->instanceCount, draw->firstInstance);
+ } else {
+ // This branch is only needed on OpenGL < 4.2
+ glDrawElementsInstanced(
+ lastPipeline->GetGLPrimitiveTopology(), draw->indexCount, formatType,
+ reinterpret_cast<void*>(draw->firstIndex * formatSize +
+ indexBufferBaseOffset),
+ draw->instanceCount);
+ }
+ } break;
+
+ case Command::SetRenderPipeline: {
+ SetRenderPipelineCmd* cmd = mCommands.NextCommand<SetRenderPipelineCmd>();
+ lastPipeline = ToBackend(cmd->pipeline).Get();
+ lastPipeline->ApplyNow(persistentPipelineState);
+
+ pushConstants.OnSetPipeline(lastPipeline);
+ inputBuffers.OnSetPipeline(lastPipeline);
+ } break;
+
+ case Command::SetPushConstants: {
+ SetPushConstantsCmd* cmd = mCommands.NextCommand<SetPushConstantsCmd>();
+ uint32_t* data = mCommands.NextData<uint32_t>(cmd->count);
+ pushConstants.OnSetPushConstants(cmd->stages, cmd->count, cmd->offset, data);
+ } break;
+
+ case Command::SetStencilReference: {
+ SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
+ persistentPipelineState.SetStencilReference(cmd->reference);
+ } break;
+
+ case Command::SetScissorRect: {
+ SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
+ glScissor(cmd->x, cmd->y, cmd->width, cmd->height);
+ } break;
+
+ case Command::SetBlendColor: {
+ SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
+ glBlendColor(cmd->r, cmd->g, cmd->b, cmd->a);
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
+ ApplyBindGroup(cmd->index, cmd->group.Get(),
+ ToBackend(lastPipeline->GetLayout()), lastPipeline);
+ } break;
+
+ case Command::SetIndexBuffer: {
+ SetIndexBufferCmd* cmd = mCommands.NextCommand<SetIndexBufferCmd>();
+ indexBufferBaseOffset = cmd->offset;
+ inputBuffers.OnSetIndexBuffer(cmd->buffer.Get());
+ } break;
+
+ case Command::SetVertexBuffers: {
+ SetVertexBuffersCmd* cmd = mCommands.NextCommand<SetVertexBuffersCmd>();
+ auto buffers = mCommands.NextData<Ref<BufferBase>>(cmd->count);
+ auto offsets = mCommands.NextData<uint32_t>(cmd->count);
+ inputBuffers.OnSetVertexBuffers(cmd->startSlot, cmd->count, buffers, offsets);
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+
+ // EndRenderPass should have been called
+ UNREACHABLE();
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/CommandBufferGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/CommandBufferGL.h
new file mode 100644
index 00000000000..dc9218bb98c
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/CommandBufferGL.h
@@ -0,0 +1,45 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_COMMANDBUFFERGL_H_
+#define DAWNNATIVE_OPENGL_COMMANDBUFFERGL_H_
+
+#include "dawn_native/CommandAllocator.h"
+#include "dawn_native/CommandBuffer.h"
+
+namespace dawn_native {
+ class RenderPassDescriptorBase;
+} // namespace dawn_native
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ class CommandBuffer : public CommandBufferBase {
+ public:
+ CommandBuffer(CommandBufferBuilder* builder);
+ ~CommandBuffer();
+
+ void Execute();
+
+ private:
+ void ExecuteComputePass();
+ void ExecuteRenderPass(RenderPassDescriptorBase* renderPass);
+
+ CommandIterator mCommands;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_COMMANDBUFFERGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/ComputePipelineGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/ComputePipelineGL.cpp
new file mode 100644
index 00000000000..815e4d7499f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/ComputePipelineGL.cpp
@@ -0,0 +1,33 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/ComputePipelineGL.h"
+
+#include "dawn_native/opengl/DeviceGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ ComputePipeline::ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor)
+ : ComputePipelineBase(device, descriptor) {
+ PerStage<const ShaderModule*> modules(nullptr);
+ modules[dawn::ShaderStage::Compute] = ToBackend(descriptor->module);
+
+ PipelineGL::Initialize(ToBackend(descriptor->layout), modules);
+ }
+
+ void ComputePipeline::ApplyNow() {
+ PipelineGL::ApplyNow();
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/ComputePipelineGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/ComputePipelineGL.h
new file mode 100644
index 00000000000..12856cade24
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/ComputePipelineGL.h
@@ -0,0 +1,37 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_COMPUTEPIPELINEGL_H_
+#define DAWNNATIVE_OPENGL_COMPUTEPIPELINEGL_H_
+
+#include "dawn_native/ComputePipeline.h"
+
+#include "dawn_native/opengl/PipelineGL.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ class ComputePipeline : public ComputePipelineBase, public PipelineGL {
+ public:
+ ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor);
+
+ void ApplyNow();
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_COMPUTEPIPELINEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/DepthStencilStateGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/DepthStencilStateGL.cpp
new file mode 100644
index 00000000000..03cf76319c8
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/DepthStencilStateGL.cpp
@@ -0,0 +1,116 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/DepthStencilStateGL.h"
+
+#include "common/Assert.h"
+#include "dawn_native/opengl/PersistentPipelineStateGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ namespace {
+ GLuint OpenGLCompareFunction(dawn::CompareFunction compareFunction) {
+ switch (compareFunction) {
+ case dawn::CompareFunction::Never:
+ return GL_NEVER;
+ case dawn::CompareFunction::Less:
+ return GL_LESS;
+ case dawn::CompareFunction::LessEqual:
+ return GL_LEQUAL;
+ case dawn::CompareFunction::Greater:
+ return GL_GREATER;
+ case dawn::CompareFunction::GreaterEqual:
+ return GL_GEQUAL;
+ case dawn::CompareFunction::NotEqual:
+ return GL_NOTEQUAL;
+ case dawn::CompareFunction::Equal:
+ return GL_EQUAL;
+ case dawn::CompareFunction::Always:
+ return GL_ALWAYS;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ GLuint OpenGLStencilOperation(dawn::StencilOperation stencilOperation) {
+ switch (stencilOperation) {
+ case dawn::StencilOperation::Keep:
+ return GL_KEEP;
+ case dawn::StencilOperation::Zero:
+ return GL_ZERO;
+ case dawn::StencilOperation::Replace:
+ return GL_REPLACE;
+ case dawn::StencilOperation::Invert:
+ return GL_INVERT;
+ case dawn::StencilOperation::IncrementClamp:
+ return GL_INCR;
+ case dawn::StencilOperation::DecrementClamp:
+ return GL_DECR;
+ case dawn::StencilOperation::IncrementWrap:
+ return GL_INCR_WRAP;
+ case dawn::StencilOperation::DecrementWrap:
+ return GL_DECR_WRAP;
+ default:
+ UNREACHABLE();
+ }
+ }
+ } // namespace
+
+ DepthStencilState::DepthStencilState(DepthStencilStateBuilder* builder)
+ : DepthStencilStateBase(builder) {
+ }
+
+ void DepthStencilState::ApplyNow(PersistentPipelineState& persistentPipelineState) const {
+ auto& depthInfo = GetDepth();
+
+ // Depth writes only occur if depth is enabled
+ if (depthInfo.compareFunction == dawn::CompareFunction::Always &&
+ !depthInfo.depthWriteEnabled) {
+ glDisable(GL_DEPTH_TEST);
+ } else {
+ glEnable(GL_DEPTH_TEST);
+ }
+
+ if (depthInfo.depthWriteEnabled) {
+ glDepthMask(GL_TRUE);
+ } else {
+ glDepthMask(GL_FALSE);
+ }
+
+ glDepthFunc(OpenGLCompareFunction(depthInfo.compareFunction));
+
+ if (StencilTestEnabled()) {
+ glEnable(GL_STENCIL_TEST);
+ } else {
+ glDisable(GL_STENCIL_TEST);
+ }
+
+ auto& stencilInfo = GetStencil();
+
+ GLenum backCompareFunction = OpenGLCompareFunction(stencilInfo.back.compareFunction);
+ GLenum frontCompareFunction = OpenGLCompareFunction(stencilInfo.front.compareFunction);
+ persistentPipelineState.SetStencilFuncsAndMask(backCompareFunction, frontCompareFunction,
+ stencilInfo.readMask);
+
+ glStencilOpSeparate(GL_BACK, OpenGLStencilOperation(stencilInfo.back.stencilFail),
+ OpenGLStencilOperation(stencilInfo.back.depthFail),
+ OpenGLStencilOperation(stencilInfo.back.depthStencilPass));
+ glStencilOpSeparate(GL_FRONT, OpenGLStencilOperation(stencilInfo.front.stencilFail),
+ OpenGLStencilOperation(stencilInfo.front.depthFail),
+ OpenGLStencilOperation(stencilInfo.front.depthStencilPass));
+
+ glStencilMask(stencilInfo.writeMask);
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/DepthStencilStateGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/DepthStencilStateGL.h
new file mode 100644
index 00000000000..da06830db7b
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/DepthStencilStateGL.h
@@ -0,0 +1,34 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_DEPTHSTENCILSTATEGL_H_
+#define DAWNNATIVE_OPENGL_DEPTHSTENCILSTATEGL_H_
+
+#include "dawn_native/DepthStencilState.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+ class PersistentPipelineState;
+
+ class DepthStencilState : public DepthStencilStateBase {
+ public:
+ DepthStencilState(DepthStencilStateBuilder* builder);
+
+ void ApplyNow(PersistentPipelineState& persistentPipelineState) const;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_DEPTHSTENCILSTATEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/DeviceGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/DeviceGL.cpp
new file mode 100644
index 00000000000..f2dc8bcdae9
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/DeviceGL.cpp
@@ -0,0 +1,126 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/DeviceGL.h"
+
+#include "dawn_native/BindGroup.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/OpenGLBackend.h"
+#include "dawn_native/RenderPassDescriptor.h"
+#include "dawn_native/opengl/BlendStateGL.h"
+#include "dawn_native/opengl/BufferGL.h"
+#include "dawn_native/opengl/CommandBufferGL.h"
+#include "dawn_native/opengl/ComputePipelineGL.h"
+#include "dawn_native/opengl/DepthStencilStateGL.h"
+#include "dawn_native/opengl/InputStateGL.h"
+#include "dawn_native/opengl/PipelineLayoutGL.h"
+#include "dawn_native/opengl/QueueGL.h"
+#include "dawn_native/opengl/RenderPipelineGL.h"
+#include "dawn_native/opengl/SamplerGL.h"
+#include "dawn_native/opengl/ShaderModuleGL.h"
+#include "dawn_native/opengl/SwapChainGL.h"
+#include "dawn_native/opengl/TextureGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ dawnDevice CreateDevice(void* (*getProc)(const char*)) {
+ gladLoadGLLoader(reinterpret_cast<GLADloadproc>(getProc));
+
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_SCISSOR_TEST);
+ glEnable(GL_PRIMITIVE_RESTART_FIXED_INDEX);
+
+ return reinterpret_cast<dawnDevice>(new Device);
+ }
+
+ // Device
+
+ Device::Device() {
+ CollectPCIInfo();
+ }
+
+ BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
+ return new BindGroup(builder);
+ }
+ ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) {
+ return new BindGroupLayout(this, descriptor);
+ }
+ BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
+ return new BlendState(builder);
+ }
+ ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
+ return new Buffer(this, descriptor);
+ }
+ BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
+ return new BufferView(builder);
+ }
+ CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
+ return new CommandBuffer(builder);
+ }
+ ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) {
+ return new ComputePipeline(this, descriptor);
+ }
+ DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
+ return new DepthStencilState(builder);
+ }
+ InputStateBase* Device::CreateInputState(InputStateBuilder* builder) {
+ return new InputState(builder);
+ }
+ ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) {
+ return new PipelineLayout(this, descriptor);
+ }
+ ResultOrError<QueueBase*> Device::CreateQueueImpl() {
+ return new Queue(this);
+ }
+ RenderPassDescriptorBase* Device::CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) {
+ return new RenderPassDescriptor(builder);
+ }
+ RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
+ return new RenderPipeline(builder);
+ }
+ ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
+ return new Sampler(this, descriptor);
+ }
+ ResultOrError<ShaderModuleBase*> Device::CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) {
+ return new ShaderModule(this, descriptor);
+ }
+ SwapChainBase* Device::CreateSwapChain(SwapChainBuilder* builder) {
+ return new SwapChain(builder);
+ }
+ ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
+ return new Texture(this, descriptor);
+ }
+ ResultOrError<TextureViewBase*> Device::CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ return new TextureView(texture, descriptor);
+ }
+
+ void Device::TickImpl() {
+ }
+
+ const dawn_native::PCIInfo& Device::GetPCIInfo() const {
+ return mPCIInfo;
+ }
+
+ void Device::CollectPCIInfo() {
+ mPCIInfo.name = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/DeviceGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/DeviceGL.h
new file mode 100644
index 00000000000..2b39db54e43
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/DeviceGL.h
@@ -0,0 +1,74 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_DEVICEGL_H_
+#define DAWNNATIVE_OPENGL_DEVICEGL_H_
+
+#include "dawn_native/dawn_platform.h"
+
+#include "common/Platform.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/opengl/Forward.h"
+
+#include "glad/glad.h"
+
+// Remove windows.h macros after glad's include of windows.h
+#if defined(DAWN_PLATFORM_WINDOWS)
+# include "common/windows_with_undefs.h"
+#endif
+
+namespace dawn_native { namespace opengl {
+
+ class Device : public DeviceBase {
+ public:
+ Device();
+ BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
+ BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
+ BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
+ CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
+ DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
+ InputStateBase* CreateInputState(InputStateBuilder* builder) override;
+ RenderPassDescriptorBase* CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) override;
+ RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
+ SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
+
+ void TickImpl() override;
+
+ const dawn_native::PCIInfo& GetPCIInfo() const override;
+
+ private:
+ ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) override;
+ ResultOrError<BufferBase*> CreateBufferImpl(const BufferDescriptor* descriptor) override;
+ ResultOrError<ComputePipelineBase*> CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) override;
+ ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) override;
+ ResultOrError<QueueBase*> CreateQueueImpl() override;
+ ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
+ ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) override;
+ ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
+ ResultOrError<TextureViewBase*> CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) override;
+ void CollectPCIInfo();
+
+ dawn_native::PCIInfo mPCIInfo;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_DEVICEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/Forward.h b/chromium/third_party/dawn/src/dawn_native/opengl/Forward.h
new file mode 100644
index 00000000000..154919fa853
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/Forward.h
@@ -0,0 +1,78 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_FORWARD_H_
+#define DAWNNATIVE_OPENGL_FORWARD_H_
+
+#include "dawn_native/ToBackend.h"
+
+namespace {
+ class BindGroupBase;
+ class BindGroup;
+ class RenderPassDescriptor;
+} // namespace
+
+namespace dawn_native { namespace opengl {
+
+ using BindGroup = BindGroupBase;
+ using BindGroupLayout = BindGroupLayoutBase;
+ class BlendState;
+ class Buffer;
+ class BufferView;
+ class CommandBuffer;
+ class ComputePipeline;
+ class DepthStencilState;
+ class Device;
+ class InputState;
+ class PersistentPipelineState;
+ class PipelineLayout;
+ class Queue;
+ using RenderPassDescriptor = RenderPassDescriptorBase;
+ class RenderPipeline;
+ class Sampler;
+ class ShaderModule;
+ class SwapChain;
+ class Texture;
+ class TextureView;
+
+ struct OpenGLBackendTraits {
+ using BindGroupType = BindGroup;
+ using BindGroupLayoutType = BindGroupLayout;
+ using BlendStateType = BlendState;
+ using BufferType = Buffer;
+ using BufferViewType = BufferView;
+ using CommandBufferType = CommandBuffer;
+ using ComputePipelineType = ComputePipeline;
+ using DepthStencilStateType = DepthStencilState;
+ using DeviceType = Device;
+ using InputStateType = InputState;
+ using PipelineLayoutType = PipelineLayout;
+ using QueueType = Queue;
+ using RenderPassDescriptorType = RenderPassDescriptor;
+ using RenderPipelineType = RenderPipeline;
+ using SamplerType = Sampler;
+ using ShaderModuleType = ShaderModule;
+ using SwapChainType = SwapChain;
+ using TextureType = Texture;
+ using TextureViewType = TextureView;
+ };
+
+ template <typename T>
+ auto ToBackend(T&& common) -> decltype(ToBackendBase<OpenGLBackendTraits>(common)) {
+ return ToBackendBase<OpenGLBackendTraits>(common);
+ }
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_FORWARD_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/InputStateGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/InputStateGL.cpp
new file mode 100644
index 00000000000..6ecaf8f4501
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/InputStateGL.cpp
@@ -0,0 +1,61 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/InputStateGL.h"
+
+#include "common/Assert.h"
+
+namespace dawn_native { namespace opengl {
+
+ InputState::InputState(InputStateBuilder* builder) : InputStateBase(builder) {
+ glGenVertexArrays(1, &mVertexArrayObject);
+ glBindVertexArray(mVertexArrayObject);
+ auto& attributesSetMask = GetAttributesSetMask();
+ for (uint32_t location = 0; location < attributesSetMask.size(); ++location) {
+ if (!attributesSetMask[location]) {
+ continue;
+ }
+ auto attribute = GetAttribute(location);
+ glEnableVertexAttribArray(location);
+
+ attributesUsingInput[attribute.bindingSlot][location] = true;
+ auto input = GetInput(attribute.bindingSlot);
+
+ if (input.stride == 0) {
+ // Emulate a stride of zero (constant vertex attribute) by
+ // setting the attribute instance divisor to a huge number.
+ glVertexAttribDivisor(location, 0xffffffff);
+ } else {
+ switch (input.stepMode) {
+ case dawn::InputStepMode::Vertex:
+ break;
+ case dawn::InputStepMode::Instance:
+ glVertexAttribDivisor(location, 1);
+ break;
+ default:
+ UNREACHABLE();
+ }
+ }
+ }
+ }
+
+ std::bitset<kMaxVertexAttributes> InputState::GetAttributesUsingInput(uint32_t slot) const {
+ return attributesUsingInput[slot];
+ }
+
+ GLuint InputState::GetVAO() {
+ return mVertexArrayObject;
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/InputStateGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/InputStateGL.h
new file mode 100644
index 00000000000..dbdd84b07b9
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/InputStateGL.h
@@ -0,0 +1,40 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_INPUTSTATEGL_H_
+#define DAWNNATIVE_OPENGL_INPUTSTATEGL_H_
+
+#include "dawn_native/InputState.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ class InputState : public InputStateBase {
+ public:
+ InputState(InputStateBuilder* builder);
+
+ std::bitset<kMaxVertexAttributes> GetAttributesUsingInput(uint32_t slot) const;
+ GLuint GetVAO();
+
+ private:
+ GLuint mVertexArrayObject;
+ std::array<std::bitset<kMaxVertexAttributes>, kMaxVertexInputs> attributesUsingInput;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_INPUTSTATEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/PersistentPipelineStateGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/PersistentPipelineStateGL.cpp
new file mode 100644
index 00000000000..5d2b8328fa0
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/PersistentPipelineStateGL.cpp
@@ -0,0 +1,54 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/PersistentPipelineStateGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ void PersistentPipelineState::SetDefaultState() {
+ CallGLStencilFunc();
+ }
+
+ void PersistentPipelineState::SetStencilFuncsAndMask(GLenum stencilBackCompareFunction,
+ GLenum stencilFrontCompareFunction,
+ uint32_t stencilReadMask) {
+ if (mStencilBackCompareFunction == stencilBackCompareFunction &&
+ mStencilFrontCompareFunction == stencilFrontCompareFunction &&
+ mStencilReadMask == stencilReadMask) {
+ return;
+ }
+
+ mStencilBackCompareFunction = stencilBackCompareFunction;
+ mStencilFrontCompareFunction = stencilFrontCompareFunction;
+ mStencilReadMask = stencilReadMask;
+ CallGLStencilFunc();
+ }
+
+ void PersistentPipelineState::SetStencilReference(uint32_t stencilReference) {
+ if (mStencilReference == stencilReference) {
+ return;
+ }
+
+ mStencilReference = stencilReference;
+ CallGLStencilFunc();
+ }
+
+ void PersistentPipelineState::CallGLStencilFunc() {
+ glStencilFuncSeparate(GL_BACK, mStencilBackCompareFunction, mStencilReference,
+ mStencilReadMask);
+ glStencilFuncSeparate(GL_FRONT, mStencilFrontCompareFunction, mStencilReference,
+ mStencilReadMask);
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/PersistentPipelineStateGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/PersistentPipelineStateGL.h
new file mode 100644
index 00000000000..3519e2a9055
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/PersistentPipelineStateGL.h
@@ -0,0 +1,43 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_PERSISTENTPIPELINESTATEGL_H_
+#define DAWNNATIVE_OPENGL_PERSISTENTPIPELINESTATEGL_H_
+
+#include "dawn_native/dawn_platform.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class PersistentPipelineState {
+ public:
+ void SetDefaultState();
+ void SetStencilFuncsAndMask(GLenum stencilBackCompareFunction,
+ GLenum stencilFrontCompareFunction,
+ uint32_t stencilReadMask);
+ void SetStencilReference(uint32_t stencilReference);
+
+ private:
+ void CallGLStencilFunc();
+
+ GLenum mStencilBackCompareFunction = GL_ALWAYS;
+ GLenum mStencilFrontCompareFunction = GL_ALWAYS;
+ GLuint mStencilReadMask = 0xffffffff;
+ GLuint mStencilReference = 0;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_PERSISTENTPIPELINESTATEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/PipelineGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/PipelineGL.cpp
new file mode 100644
index 00000000000..f03ab8778db
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/PipelineGL.cpp
@@ -0,0 +1,220 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/PipelineGL.h"
+
+#include "common/BitSetIterator.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/opengl/Forward.h"
+#include "dawn_native/opengl/PersistentPipelineStateGL.h"
+#include "dawn_native/opengl/PipelineLayoutGL.h"
+#include "dawn_native/opengl/ShaderModuleGL.h"
+
+#include <iostream>
+#include <set>
+
+namespace dawn_native { namespace opengl {
+
+ namespace {
+
+ GLenum GLShaderType(dawn::ShaderStage stage) {
+ switch (stage) {
+ case dawn::ShaderStage::Vertex:
+ return GL_VERTEX_SHADER;
+ case dawn::ShaderStage::Fragment:
+ return GL_FRAGMENT_SHADER;
+ case dawn::ShaderStage::Compute:
+ return GL_COMPUTE_SHADER;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ } // namespace
+
+ PipelineGL::PipelineGL() {
+ }
+
+ void PipelineGL::Initialize(const PipelineLayout* layout,
+ const PerStage<const ShaderModule*>& modules) {
+ auto CreateShader = [](GLenum type, const char* source) -> GLuint {
+ GLuint shader = glCreateShader(type);
+ glShaderSource(shader, 1, &source, nullptr);
+ glCompileShader(shader);
+
+ GLint compileStatus = GL_FALSE;
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &compileStatus);
+ if (compileStatus == GL_FALSE) {
+ GLint infoLogLength = 0;
+ glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
+
+ if (infoLogLength > 1) {
+ std::vector<char> buffer(infoLogLength);
+ glGetShaderInfoLog(shader, infoLogLength, nullptr, &buffer[0]);
+ std::cout << source << std::endl;
+ std::cout << "Program compilation failed:\n";
+ std::cout << buffer.data() << std::endl;
+ }
+ }
+ return shader;
+ };
+
+ auto FillPushConstants = [](const ShaderModule* module, GLPushConstantInfo* info,
+ GLuint program) {
+ const auto& moduleInfo = module->GetPushConstants();
+ for (uint32_t i = 0; i < moduleInfo.names.size(); i++) {
+ (*info)[i] = -1;
+
+ unsigned int size = moduleInfo.sizes[i];
+ if (size == 0) {
+ continue;
+ }
+
+ GLint location = glGetUniformLocation(program, moduleInfo.names[i].c_str());
+ if (location == -1) {
+ continue;
+ }
+
+ for (uint32_t offset = 0; offset < size; offset++) {
+ (*info)[i + offset] = location + offset;
+ }
+ i += size - 1;
+ }
+ };
+
+ mProgram = glCreateProgram();
+
+ dawn::ShaderStageBit activeStages = dawn::ShaderStageBit::None;
+ for (dawn::ShaderStage stage : IterateStages(kAllStages)) {
+ if (modules[stage] != nullptr) {
+ activeStages |= StageBit(stage);
+ }
+ }
+
+ for (dawn::ShaderStage stage : IterateStages(activeStages)) {
+ GLuint shader = CreateShader(GLShaderType(stage), modules[stage]->GetSource());
+ glAttachShader(mProgram, shader);
+ }
+
+ glLinkProgram(mProgram);
+
+ GLint linkStatus = GL_FALSE;
+ glGetProgramiv(mProgram, GL_LINK_STATUS, &linkStatus);
+ if (linkStatus == GL_FALSE) {
+ GLint infoLogLength = 0;
+ glGetProgramiv(mProgram, GL_INFO_LOG_LENGTH, &infoLogLength);
+
+ if (infoLogLength > 1) {
+ std::vector<char> buffer(infoLogLength);
+ glGetProgramInfoLog(mProgram, infoLogLength, nullptr, &buffer[0]);
+ std::cout << "Program link failed:\n";
+ std::cout << buffer.data() << std::endl;
+ }
+ }
+
+ for (dawn::ShaderStage stage : IterateStages(activeStages)) {
+ FillPushConstants(modules[stage], &mGlPushConstants[stage], mProgram);
+ }
+
+ glUseProgram(mProgram);
+
+ // The uniforms are part of the program state so we can pre-bind buffer units, texture units
+ // etc.
+ const auto& indices = layout->GetBindingIndexInfo();
+
+ for (uint32_t group : IterateBitSet(layout->GetBindGroupLayoutsMask())) {
+ const auto& groupInfo = layout->GetBindGroupLayout(group)->GetBindingInfo();
+
+ for (uint32_t binding = 0; binding < kMaxBindingsPerGroup; ++binding) {
+ if (!groupInfo.mask[binding]) {
+ continue;
+ }
+
+ std::string name = GetBindingName(group, binding);
+ switch (groupInfo.types[binding]) {
+ case dawn::BindingType::UniformBuffer: {
+ GLint location = glGetUniformBlockIndex(mProgram, name.c_str());
+ glUniformBlockBinding(mProgram, location, indices[group][binding]);
+ } break;
+
+ case dawn::BindingType::StorageBuffer: {
+ GLuint location = glGetProgramResourceIndex(
+ mProgram, GL_SHADER_STORAGE_BLOCK, name.c_str());
+ glShaderStorageBlockBinding(mProgram, location, indices[group][binding]);
+ } break;
+
+ case dawn::BindingType::Sampler:
+ case dawn::BindingType::SampledTexture:
+ // These binding types are handled in the separate sampler and texture
+ // emulation
+ break;
+ }
+ }
+ }
+
+ // Compute links between stages for combined samplers, then bind them to texture units
+ {
+ std::set<CombinedSampler> combinedSamplersSet;
+ for (dawn::ShaderStage stage : IterateStages(activeStages)) {
+ for (const auto& combined : modules[stage]->GetCombinedSamplerInfo()) {
+ combinedSamplersSet.insert(combined);
+ }
+ }
+
+ mUnitsForSamplers.resize(layout->GetNumSamplers());
+ mUnitsForTextures.resize(layout->GetNumSampledTextures());
+
+ GLuint textureUnit = layout->GetTextureUnitsUsed();
+ for (const auto& combined : combinedSamplersSet) {
+ std::string name = combined.GetName();
+ GLint location = glGetUniformLocation(mProgram, name.c_str());
+ glUniform1i(location, textureUnit);
+
+ GLuint samplerIndex =
+ indices[combined.samplerLocation.group][combined.samplerLocation.binding];
+ mUnitsForSamplers[samplerIndex].push_back(textureUnit);
+
+ GLuint textureIndex =
+ indices[combined.textureLocation.group][combined.textureLocation.binding];
+ mUnitsForTextures[textureIndex].push_back(textureUnit);
+
+ textureUnit++;
+ }
+ }
+ }
+
+ const PipelineGL::GLPushConstantInfo& PipelineGL::GetGLPushConstants(
+ dawn::ShaderStage stage) const {
+ return mGlPushConstants[stage];
+ }
+
+ const std::vector<GLuint>& PipelineGL::GetTextureUnitsForSampler(GLuint index) const {
+ ASSERT(index < mUnitsForSamplers.size());
+ return mUnitsForSamplers[index];
+ }
+
+ const std::vector<GLuint>& PipelineGL::GetTextureUnitsForTextureView(GLuint index) const {
+ ASSERT(index < mUnitsForSamplers.size());
+ return mUnitsForTextures[index];
+ }
+
+ GLuint PipelineGL::GetProgramHandle() const {
+ return mProgram;
+ }
+
+ void PipelineGL::ApplyNow() {
+ glUseProgram(mProgram);
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/PipelineGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/PipelineGL.h
new file mode 100644
index 00000000000..b3feeb96a59
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/PipelineGL.h
@@ -0,0 +1,57 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_PIPELINEGL_H_
+#define DAWNNATIVE_OPENGL_PIPELINEGL_H_
+
+#include "dawn_native/Pipeline.h"
+
+#include "glad/glad.h"
+
+#include <vector>
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+ class PersistentPipelineState;
+ class PipelineLayout;
+ class ShaderModule;
+
+ class PipelineGL {
+ public:
+ PipelineGL();
+
+ void Initialize(const PipelineLayout* layout, const PerStage<const ShaderModule*>& modules);
+
+ using GLPushConstantInfo = std::array<GLint, kMaxPushConstants>;
+ using BindingLocations =
+ std::array<std::array<GLint, kMaxBindingsPerGroup>, kMaxBindGroups>;
+
+ const GLPushConstantInfo& GetGLPushConstants(dawn::ShaderStage stage) const;
+ const std::vector<GLuint>& GetTextureUnitsForSampler(GLuint index) const;
+ const std::vector<GLuint>& GetTextureUnitsForTextureView(GLuint index) const;
+ GLuint GetProgramHandle() const;
+
+ void ApplyNow();
+
+ private:
+ GLuint mProgram;
+ PerStage<GLPushConstantInfo> mGlPushConstants;
+ std::vector<std::vector<GLuint>> mUnitsForSamplers;
+ std::vector<std::vector<GLuint>> mUnitsForTextures;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_PIPELINEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/PipelineLayoutGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/PipelineLayoutGL.cpp
new file mode 100644
index 00000000000..8f2cdaaf969
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/PipelineLayoutGL.cpp
@@ -0,0 +1,80 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/PipelineLayoutGL.h"
+
+#include "common/BitSetIterator.h"
+#include "dawn_native/BindGroupLayout.h"
+#include "dawn_native/opengl/DeviceGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor)
+ : PipelineLayoutBase(device, descriptor) {
+ GLuint uboIndex = 0;
+ GLuint samplerIndex = 0;
+ GLuint sampledTextureIndex = 0;
+ GLuint ssboIndex = 0;
+
+ for (uint32_t group : IterateBitSet(GetBindGroupLayoutsMask())) {
+ const auto& groupInfo = GetBindGroupLayout(group)->GetBindingInfo();
+
+ for (size_t binding = 0; binding < kMaxBindingsPerGroup; ++binding) {
+ if (!groupInfo.mask[binding]) {
+ continue;
+ }
+
+ switch (groupInfo.types[binding]) {
+ case dawn::BindingType::UniformBuffer:
+ mIndexInfo[group][binding] = uboIndex;
+ uboIndex++;
+ break;
+ case dawn::BindingType::Sampler:
+ mIndexInfo[group][binding] = samplerIndex;
+ samplerIndex++;
+ break;
+ case dawn::BindingType::SampledTexture:
+ mIndexInfo[group][binding] = sampledTextureIndex;
+ sampledTextureIndex++;
+ break;
+
+ case dawn::BindingType::StorageBuffer:
+ mIndexInfo[group][binding] = ssboIndex;
+ ssboIndex++;
+ break;
+ }
+ }
+ }
+
+ mNumSamplers = samplerIndex;
+ mNumSampledTextures = sampledTextureIndex;
+ }
+
+ const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo() const {
+ return mIndexInfo;
+ }
+
+ GLuint PipelineLayout::GetTextureUnitsUsed() const {
+ return 0;
+ }
+
+ size_t PipelineLayout::GetNumSamplers() const {
+ return mNumSamplers;
+ }
+
+ size_t PipelineLayout::GetNumSampledTextures() const {
+ return mNumSampledTextures;
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/PipelineLayoutGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/PipelineLayoutGL.h
new file mode 100644
index 00000000000..abf6acf91e6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/PipelineLayoutGL.h
@@ -0,0 +1,46 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_PIPELINELAYOUTGL_H_
+#define DAWNNATIVE_OPENGL_PIPELINELAYOUTGL_H_
+
+#include "dawn_native/PipelineLayout.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ class PipelineLayout : public PipelineLayoutBase {
+ public:
+ PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
+
+ using BindingIndexInfo =
+ std::array<std::array<GLuint, kMaxBindingsPerGroup>, kMaxBindGroups>;
+ const BindingIndexInfo& GetBindingIndexInfo() const;
+
+ GLuint GetTextureUnitsUsed() const;
+ size_t GetNumSamplers() const;
+ size_t GetNumSampledTextures() const;
+
+ private:
+ BindingIndexInfo mIndexInfo;
+ size_t mNumSamplers;
+ size_t mNumSampledTextures;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_PIPELINELAYOUTGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/QueueGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/QueueGL.cpp
new file mode 100644
index 00000000000..ad171603073
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/QueueGL.cpp
@@ -0,0 +1,31 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/QueueGL.h"
+
+#include "dawn_native/opengl/CommandBufferGL.h"
+#include "dawn_native/opengl/DeviceGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ Queue::Queue(Device* device) : QueueBase(device) {
+ }
+
+ void Queue::SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) {
+ for (uint32_t i = 0; i < numCommands; ++i) {
+ ToBackend(commands[i])->Execute();
+ }
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/QueueGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/QueueGL.h
new file mode 100644
index 00000000000..f47304914be
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/QueueGL.h
@@ -0,0 +1,35 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_QUEUEGL_H_
+#define DAWNNATIVE_OPENGL_QUEUEGL_H_
+
+#include "dawn_native/Queue.h"
+
+namespace dawn_native { namespace opengl {
+
+ class CommandBuffer;
+ class Device;
+
+ class Queue : public QueueBase {
+ public:
+ Queue(Device* device);
+
+ private:
+ void SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) override;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_QUEUEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/RenderPipelineGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/RenderPipelineGL.cpp
new file mode 100644
index 00000000000..f6faca0a760
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/RenderPipelineGL.cpp
@@ -0,0 +1,73 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/RenderPipelineGL.h"
+
+#include "dawn_native/opengl/BlendStateGL.h"
+#include "dawn_native/opengl/DepthStencilStateGL.h"
+#include "dawn_native/opengl/Forward.h"
+#include "dawn_native/opengl/InputStateGL.h"
+#include "dawn_native/opengl/PersistentPipelineStateGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ namespace {
+ GLenum GLPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
+ switch (primitiveTopology) {
+ case dawn::PrimitiveTopology::PointList:
+ return GL_POINTS;
+ case dawn::PrimitiveTopology::LineList:
+ return GL_LINES;
+ case dawn::PrimitiveTopology::LineStrip:
+ return GL_LINE_STRIP;
+ case dawn::PrimitiveTopology::TriangleList:
+ return GL_TRIANGLES;
+ case dawn::PrimitiveTopology::TriangleStrip:
+ return GL_TRIANGLE_STRIP;
+ default:
+ UNREACHABLE();
+ }
+ }
+ } // namespace
+
+ RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
+ : RenderPipelineBase(builder),
+ mGlPrimitiveTopology(GLPrimitiveTopology(GetPrimitiveTopology())) {
+ PerStage<const ShaderModule*> modules(nullptr);
+ for (dawn::ShaderStage stage : IterateStages(GetStageMask())) {
+ modules[stage] = ToBackend(builder->GetStageInfo(stage).module.Get());
+ }
+
+ PipelineGL::Initialize(ToBackend(GetLayout()), modules);
+ }
+
+ GLenum RenderPipeline::GetGLPrimitiveTopology() const {
+ return mGlPrimitiveTopology;
+ }
+
+ void RenderPipeline::ApplyNow(PersistentPipelineState& persistentPipelineState) {
+ PipelineGL::ApplyNow();
+
+ auto inputState = ToBackend(GetInputState());
+ glBindVertexArray(inputState->GetVAO());
+
+ auto depthStencilState = ToBackend(GetDepthStencilState());
+ depthStencilState->ApplyNow(persistentPipelineState);
+
+ for (uint32_t attachmentSlot : IterateBitSet(GetColorAttachmentsMask())) {
+ ToBackend(GetBlendState(attachmentSlot))->ApplyNow(attachmentSlot);
+ }
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/RenderPipelineGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/RenderPipelineGL.h
new file mode 100644
index 00000000000..042000c558c
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/RenderPipelineGL.h
@@ -0,0 +1,44 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_RENDERPIPELINEGL_H_
+#define DAWNNATIVE_OPENGL_RENDERPIPELINEGL_H_
+
+#include "dawn_native/RenderPipeline.h"
+
+#include "dawn_native/opengl/PipelineGL.h"
+
+#include "glad/glad.h"
+
+#include <vector>
+
+namespace dawn_native { namespace opengl {
+
+ class PersistentPipelineState;
+
+ class RenderPipeline : public RenderPipelineBase, public PipelineGL {
+ public:
+ RenderPipeline(RenderPipelineBuilder* builder);
+
+ GLenum GetGLPrimitiveTopology() const;
+
+ void ApplyNow(PersistentPipelineState& persistentPipelineState);
+
+ private:
+ GLenum mGlPrimitiveTopology;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_RENDERPIPELINEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/SamplerGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/SamplerGL.cpp
new file mode 100644
index 00000000000..ebf47578afc
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/SamplerGL.cpp
@@ -0,0 +1,89 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/SamplerGL.h"
+
+#include "common/Assert.h"
+#include "dawn_native/opengl/DeviceGL.h"
+
+namespace dawn_native { namespace opengl {
+
+ namespace {
+ GLenum MagFilterMode(dawn::FilterMode filter) {
+ switch (filter) {
+ case dawn::FilterMode::Nearest:
+ return GL_NEAREST;
+ case dawn::FilterMode::Linear:
+ return GL_LINEAR;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ GLenum MinFilterMode(dawn::FilterMode minFilter, dawn::FilterMode mipMapFilter) {
+ switch (minFilter) {
+ case dawn::FilterMode::Nearest:
+ switch (mipMapFilter) {
+ case dawn::FilterMode::Nearest:
+ return GL_NEAREST_MIPMAP_NEAREST;
+ case dawn::FilterMode::Linear:
+ return GL_NEAREST_MIPMAP_LINEAR;
+ default:
+ UNREACHABLE();
+ }
+ case dawn::FilterMode::Linear:
+ switch (mipMapFilter) {
+ case dawn::FilterMode::Nearest:
+ return GL_LINEAR_MIPMAP_NEAREST;
+ case dawn::FilterMode::Linear:
+ return GL_LINEAR_MIPMAP_LINEAR;
+ default:
+ UNREACHABLE();
+ }
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ GLenum WrapMode(dawn::AddressMode mode) {
+ switch (mode) {
+ case dawn::AddressMode::Repeat:
+ return GL_REPEAT;
+ case dawn::AddressMode::MirroredRepeat:
+ return GL_MIRRORED_REPEAT;
+ case dawn::AddressMode::ClampToEdge:
+ return GL_CLAMP_TO_EDGE;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ } // namespace
+
+ Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
+ : SamplerBase(device, descriptor) {
+ glGenSamplers(1, &mHandle);
+ glSamplerParameteri(mHandle, GL_TEXTURE_MAG_FILTER, MagFilterMode(descriptor->magFilter));
+ glSamplerParameteri(mHandle, GL_TEXTURE_MIN_FILTER,
+ MinFilterMode(descriptor->minFilter, descriptor->mipmapFilter));
+ glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_R, WrapMode(descriptor->addressModeW));
+ glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_S, WrapMode(descriptor->addressModeU));
+ glSamplerParameteri(mHandle, GL_TEXTURE_WRAP_T, WrapMode(descriptor->addressModeV));
+ }
+
+ GLuint Sampler::GetHandle() const {
+ return mHandle;
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/SamplerGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/SamplerGL.h
new file mode 100644
index 00000000000..3e6e84c86a1
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/SamplerGL.h
@@ -0,0 +1,38 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_SAMPLERGL_H_
+#define DAWNNATIVE_OPENGL_SAMPLERGL_H_
+
+#include "dawn_native/Sampler.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ class Sampler : public SamplerBase {
+ public:
+ Sampler(Device* device, const SamplerDescriptor* descriptor);
+
+ GLuint GetHandle() const;
+
+ private:
+ GLuint mHandle;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_SAMPLERGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/ShaderModuleGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/ShaderModuleGL.cpp
new file mode 100644
index 00000000000..ab24940bd0a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/ShaderModuleGL.cpp
@@ -0,0 +1,136 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/ShaderModuleGL.h"
+
+#include "common/Assert.h"
+#include "common/Platform.h"
+#include "dawn_native/opengl/DeviceGL.h"
+
+#include <spirv-cross/spirv_glsl.hpp>
+
+#include <sstream>
+
+namespace dawn_native { namespace opengl {
+
+ std::string GetBindingName(uint32_t group, uint32_t binding) {
+ std::ostringstream o;
+ o << "dawn_binding_" << group << "_" << binding;
+ return o.str();
+ }
+
+ bool operator<(const BindingLocation& a, const BindingLocation& b) {
+ return std::tie(a.group, a.binding) < std::tie(b.group, b.binding);
+ }
+
+ bool operator<(const CombinedSampler& a, const CombinedSampler& b) {
+ return std::tie(a.samplerLocation, a.textureLocation) <
+ std::tie(b.samplerLocation, b.textureLocation);
+ }
+
+ std::string CombinedSampler::GetName() const {
+ std::ostringstream o;
+ o << "dawn_combined";
+ o << "_" << samplerLocation.group << "_" << samplerLocation.binding;
+ o << "_with_" << textureLocation.group << "_" << textureLocation.binding;
+ return o.str();
+ }
+
+ ShaderModule::ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor)
+ : ShaderModuleBase(device, descriptor) {
+ spirv_cross::CompilerGLSL compiler(descriptor->code, descriptor->codeSize);
+ // If these options are changed, the values in DawnSPIRVCrossGLSLFastFuzzer.cpp need to be
+ // updated.
+ spirv_cross::CompilerGLSL::Options options;
+
+ // TODO(cwallez@chromium.org): discover the backing context version and use that.
+#if defined(DAWN_PLATFORM_APPLE)
+ options.version = 410;
+#else
+ options.version = 440;
+#endif
+ compiler.set_common_options(options);
+
+ // Rename the push constant block to be prefixed with the shader stage type so that uniform
+ // names don't match between the FS and the VS.
+ const auto& resources = compiler.get_shader_resources();
+ if (resources.push_constant_buffers.size() > 0) {
+ const char* prefix = nullptr;
+ switch (compiler.get_execution_model()) {
+ case spv::ExecutionModelVertex:
+ prefix = "vs_";
+ break;
+ case spv::ExecutionModelFragment:
+ prefix = "fs_";
+ break;
+ case spv::ExecutionModelGLCompute:
+ prefix = "cs_";
+ break;
+ default:
+ UNREACHABLE();
+ }
+ auto interfaceBlock = resources.push_constant_buffers[0];
+ compiler.set_name(interfaceBlock.id, prefix + interfaceBlock.name);
+ }
+
+ ExtractSpirvInfo(compiler);
+
+ const auto& bindingInfo = GetBindingInfo();
+
+ // Extract bindings names so that it can be used to get its location in program.
+ // Now translate the separate sampler / textures into combined ones and store their info.
+ // We need to do this before removing the set and binding decorations.
+ compiler.build_combined_image_samplers();
+
+ for (const auto& combined : compiler.get_combined_image_samplers()) {
+ mCombinedInfo.emplace_back();
+
+ auto& info = mCombinedInfo.back();
+ info.samplerLocation.group =
+ compiler.get_decoration(combined.sampler_id, spv::DecorationDescriptorSet);
+ info.samplerLocation.binding =
+ compiler.get_decoration(combined.sampler_id, spv::DecorationBinding);
+ info.textureLocation.group =
+ compiler.get_decoration(combined.image_id, spv::DecorationDescriptorSet);
+ info.textureLocation.binding =
+ compiler.get_decoration(combined.image_id, spv::DecorationBinding);
+ compiler.set_name(combined.combined_id, info.GetName());
+ }
+
+ // Change binding names to be "dawn_binding_<group>_<binding>".
+ // Also unsets the SPIRV "Binding" decoration as it outputs "layout(binding=)" which
+ // isn't supported on OSX's OpenGL.
+ for (uint32_t group = 0; group < kMaxBindGroups; ++group) {
+ for (uint32_t binding = 0; binding < kMaxBindingsPerGroup; ++binding) {
+ const auto& info = bindingInfo[group][binding];
+ if (info.used) {
+ compiler.set_name(info.base_type_id, GetBindingName(group, binding));
+ compiler.unset_decoration(info.id, spv::DecorationBinding);
+ compiler.unset_decoration(info.id, spv::DecorationDescriptorSet);
+ }
+ }
+ }
+
+ mGlslSource = compiler.compile();
+ }
+
+ const char* ShaderModule::GetSource() const {
+ return reinterpret_cast<const char*>(mGlslSource.data());
+ }
+
+ const ShaderModule::CombinedSamplerInfo& ShaderModule::GetCombinedSamplerInfo() const {
+ return mCombinedInfo;
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/ShaderModuleGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/ShaderModuleGL.h
new file mode 100644
index 00000000000..8e485e6afd6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/ShaderModuleGL.h
@@ -0,0 +1,57 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_SHADERMODULEGL_H_
+#define DAWNNATIVE_OPENGL_SHADERMODULEGL_H_
+
+#include "dawn_native/ShaderModule.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ std::string GetBindingName(uint32_t group, uint32_t binding);
+
+ struct BindingLocation {
+ uint32_t group;
+ uint32_t binding;
+ };
+ bool operator<(const BindingLocation& a, const BindingLocation& b);
+
+ struct CombinedSampler {
+ BindingLocation samplerLocation;
+ BindingLocation textureLocation;
+ std::string GetName() const;
+ };
+ bool operator<(const CombinedSampler& a, const CombinedSampler& b);
+
+ class ShaderModule : public ShaderModuleBase {
+ public:
+ ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor);
+
+ using CombinedSamplerInfo = std::vector<CombinedSampler>;
+
+ const char* GetSource() const;
+ const CombinedSamplerInfo& GetCombinedSamplerInfo() const;
+
+ private:
+ CombinedSamplerInfo mCombinedInfo;
+ std::string mGlslSource;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_SHADERMODULEGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/SwapChainGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/SwapChainGL.cpp
new file mode 100644
index 00000000000..5e46808e412
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/SwapChainGL.cpp
@@ -0,0 +1,48 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/SwapChainGL.h"
+
+#include "dawn_native/Device.h"
+#include "dawn_native/opengl/Forward.h"
+#include "dawn_native/opengl/TextureGL.h"
+
+#include <dawn/dawn_wsi.h>
+
+namespace dawn_native { namespace opengl {
+
+ SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
+ const auto& im = GetImplementation();
+ im.Init(im.userData, nullptr);
+ }
+
+ SwapChain::~SwapChain() {
+ }
+
+ TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
+ const auto& im = GetImplementation();
+ dawnSwapChainNextTexture next = {};
+ dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
+ if (error) {
+ GetDevice()->HandleError(error);
+ return nullptr;
+ }
+ GLuint nativeTexture = next.texture.u32;
+ return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
+ }
+
+ void SwapChain::OnBeforePresent(TextureBase*) {
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/SwapChainGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/SwapChainGL.h
new file mode 100644
index 00000000000..d1df75088dd
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/SwapChainGL.h
@@ -0,0 +1,38 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_SWAPCHAINGL_H_
+#define DAWNNATIVE_OPENGL_SWAPCHAINGL_H_
+
+#include "dawn_native/SwapChain.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ class SwapChain : public SwapChainBase {
+ public:
+ SwapChain(SwapChainBuilder* builder);
+ ~SwapChain();
+
+ protected:
+ TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
+ void OnBeforePresent(TextureBase* texture) override;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_SWAPCHAINGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/TextureGL.cpp b/chromium/third_party/dawn/src/dawn_native/opengl/TextureGL.cpp
new file mode 100644
index 00000000000..a16b07ab115
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/TextureGL.cpp
@@ -0,0 +1,173 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/opengl/TextureGL.h"
+#include "dawn_native/opengl/DeviceGL.h"
+
+#include "common/Assert.h"
+
+#include <algorithm>
+#include <vector>
+
+namespace dawn_native { namespace opengl {
+
+ namespace {
+
+ GLenum TargetForDimensionAndArrayLayers(dawn::TextureDimension dimension,
+ uint32_t arrayLayer) {
+ switch (dimension) {
+ case dawn::TextureDimension::e2D:
+ return (arrayLayer > 1) ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;
+ default:
+ UNREACHABLE();
+ return GL_TEXTURE_2D;
+ }
+ }
+
+ GLenum TargetForTextureViewDimension(dawn::TextureViewDimension dimension) {
+ switch (dimension) {
+ case dawn::TextureViewDimension::e2D:
+ return GL_TEXTURE_2D;
+ case dawn::TextureViewDimension::e2DArray:
+ return GL_TEXTURE_2D_ARRAY;
+ case dawn::TextureViewDimension::Cube:
+ return GL_TEXTURE_CUBE_MAP;
+ case dawn::TextureViewDimension::CubeArray:
+ return GL_TEXTURE_CUBE_MAP_ARRAY;
+ default:
+ UNREACHABLE();
+ return GL_TEXTURE_2D;
+ }
+ }
+
+ TextureFormatInfo GetGLFormatInfo(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::R8G8B8A8Unorm:
+ return {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE};
+ case dawn::TextureFormat::R8G8Unorm:
+ return {GL_RG8, GL_RG, GL_UNSIGNED_BYTE};
+ case dawn::TextureFormat::R8Unorm:
+ return {GL_R8, GL_RED, GL_UNSIGNED_BYTE};
+ case dawn::TextureFormat::R8G8B8A8Uint:
+ return {GL_RGBA8UI, GL_RGBA, GL_UNSIGNED_INT};
+ case dawn::TextureFormat::R8G8Uint:
+ return {GL_RG8UI, GL_RG, GL_UNSIGNED_INT};
+ case dawn::TextureFormat::R8Uint:
+ return {GL_R8UI, GL_RED, GL_UNSIGNED_INT};
+ case dawn::TextureFormat::B8G8R8A8Unorm:
+ // This doesn't have an enum for the internal format in OpenGL, so use RGBA8.
+ return {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE};
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL,
+ GL_FLOAT_32_UNSIGNED_INT_24_8_REV};
+ default:
+ UNREACHABLE();
+ return {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE};
+ }
+ }
+
+ GLuint GenTexture() {
+ GLuint handle = 0;
+ glGenTextures(1, &handle);
+ return handle;
+ }
+
+ } // namespace
+
+ // Texture
+
+ Texture::Texture(Device* device, const TextureDescriptor* descriptor)
+ : Texture(device, descriptor, GenTexture()) {
+ }
+
+ Texture::Texture(Device* device, const TextureDescriptor* descriptor, GLuint handle)
+ : TextureBase(device, descriptor), mHandle(handle) {
+ mTarget = TargetForDimensionAndArrayLayers(GetDimension(), GetArrayLayers());
+
+ uint32_t width = GetSize().width;
+ uint32_t height = GetSize().height;
+ uint32_t levels = GetNumMipLevels();
+ uint32_t arrayLayers = GetArrayLayers();
+
+ auto formatInfo = GetGLFormatInfo(GetFormat());
+
+ glBindTexture(mTarget, handle);
+
+ // glTextureView() requires the value of GL_TEXTURE_IMMUTABLE_FORMAT for origtexture to be
+ // GL_TRUE, so the storage of the texture must be allocated with glTexStorage*D.
+ // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTextureView.xhtml
+ switch (GetDimension()) {
+ case dawn::TextureDimension::e2D:
+ if (arrayLayers > 1) {
+ glTexStorage3D(mTarget, levels, formatInfo.internalFormat, width, height,
+ arrayLayers);
+ } else {
+ glTexStorage2D(mTarget, levels, formatInfo.internalFormat, width, height);
+ }
+ break;
+ default:
+ UNREACHABLE();
+ }
+
+ // The texture is not complete if it uses mipmapping and not all levels up to
+ // MAX_LEVEL have been defined.
+ glTexParameteri(mTarget, GL_TEXTURE_MAX_LEVEL, levels - 1);
+ }
+
+ Texture::~Texture() {
+ // TODO(kainino@chromium.org): delete texture (but only when not using the native texture
+ // constructor?)
+ }
+
+ GLuint Texture::GetHandle() const {
+ return mHandle;
+ }
+
+ GLenum Texture::GetGLTarget() const {
+ return mTarget;
+ }
+
+ TextureFormatInfo Texture::GetGLFormat() const {
+ return GetGLFormatInfo(GetFormat());
+ }
+
+ // TextureView
+
+ TextureView::TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor)
+ : TextureViewBase(texture, descriptor) {
+ mTarget = TargetForTextureViewDimension(descriptor->dimension);
+
+ // glTextureView() is supported on OpenGL version >= 4.3
+ // TODO(jiawei.shao@intel.com): support texture view on OpenGL version <= 4.2
+ mHandle = GenTexture();
+ const Texture* textureGL = ToBackend(texture);
+ TextureFormatInfo textureViewFormat = GetGLFormatInfo(descriptor->format);
+ glTextureView(mHandle, mTarget, textureGL->GetHandle(), textureViewFormat.internalFormat,
+ descriptor->baseMipLevel, descriptor->levelCount, descriptor->baseArrayLayer,
+ descriptor->layerCount);
+ }
+
+ TextureView::~TextureView() {
+ glDeleteTextures(1, &mHandle);
+ }
+
+ GLuint TextureView::GetHandle() const {
+ return mHandle;
+ }
+
+ GLenum TextureView::GetGLTarget() const {
+ return mTarget;
+ }
+
+}} // namespace dawn_native::opengl
diff --git a/chromium/third_party/dawn/src/dawn_native/opengl/TextureGL.h b/chromium/third_party/dawn/src/dawn_native/opengl/TextureGL.h
new file mode 100644
index 00000000000..5b12da5eccf
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/opengl/TextureGL.h
@@ -0,0 +1,62 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGL_TEXTUREGL_H_
+#define DAWNNATIVE_OPENGL_TEXTUREGL_H_
+
+#include "dawn_native/Texture.h"
+
+#include "glad/glad.h"
+
+namespace dawn_native { namespace opengl {
+
+ class Device;
+
+ struct TextureFormatInfo {
+ GLenum internalFormat;
+ GLenum format;
+ GLenum type;
+ };
+
+ class Texture : public TextureBase {
+ public:
+ Texture(Device* device, const TextureDescriptor* descriptor);
+ Texture(Device* device, const TextureDescriptor* descriptor, GLuint handle);
+ ~Texture();
+
+ GLuint GetHandle() const;
+ GLenum GetGLTarget() const;
+ TextureFormatInfo GetGLFormat() const;
+
+ private:
+ GLuint mHandle;
+ GLenum mTarget;
+ };
+
+ class TextureView : public TextureViewBase {
+ public:
+ TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor);
+ ~TextureView();
+
+ GLuint GetHandle() const;
+ GLenum GetGLTarget() const;
+
+ private:
+ GLuint mHandle;
+ GLenum mTarget;
+ };
+
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGL_TEXTUREGL_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupLayoutVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupLayoutVk.cpp
new file mode 100644
index 00000000000..94a3429184a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupLayoutVk.cpp
@@ -0,0 +1,153 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/BindGroupLayoutVk.h"
+
+#include "common/BitSetIterator.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+
+ VkShaderStageFlags VulkanShaderStageFlags(dawn::ShaderStageBit stages) {
+ VkShaderStageFlags flags = 0;
+
+ if (stages & dawn::ShaderStageBit::Vertex) {
+ flags |= VK_SHADER_STAGE_VERTEX_BIT;
+ }
+ if (stages & dawn::ShaderStageBit::Fragment) {
+ flags |= VK_SHADER_STAGE_FRAGMENT_BIT;
+ }
+ if (stages & dawn::ShaderStageBit::Compute) {
+ flags |= VK_SHADER_STAGE_COMPUTE_BIT;
+ }
+
+ return flags;
+ }
+
+ } // anonymous namespace
+
+ VkDescriptorType VulkanDescriptorType(dawn::BindingType type) {
+ switch (type) {
+ case dawn::BindingType::UniformBuffer:
+ return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
+ case dawn::BindingType::Sampler:
+ return VK_DESCRIPTOR_TYPE_SAMPLER;
+ case dawn::BindingType::SampledTexture:
+ return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
+ case dawn::BindingType::StorageBuffer:
+ return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ BindGroupLayout::BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor)
+ : BindGroupLayoutBase(device, descriptor) {
+ const auto& info = GetBindingInfo();
+
+ // Compute the bindings that will be chained in the DescriptorSetLayout create info. We add
+ // one entry per binding set. This might be optimized by computing continuous ranges of
+ // bindings of the same type.
+ uint32_t numBindings = 0;
+ std::array<VkDescriptorSetLayoutBinding, kMaxBindingsPerGroup> bindings;
+ for (uint32_t bindingIndex : IterateBitSet(info.mask)) {
+ auto& binding = bindings[numBindings];
+ binding.binding = bindingIndex;
+ binding.descriptorType = VulkanDescriptorType(info.types[bindingIndex]);
+ binding.descriptorCount = 1;
+ binding.stageFlags = VulkanShaderStageFlags(info.visibilities[bindingIndex]);
+ binding.pImmutableSamplers = nullptr;
+
+ numBindings++;
+ }
+
+ VkDescriptorSetLayoutCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.bindingCount = numBindings;
+ createInfo.pBindings = bindings.data();
+
+ if (device->fn.CreateDescriptorSetLayout(device->GetVkDevice(), &createInfo, nullptr,
+ &mHandle) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ BindGroupLayout::~BindGroupLayout() {
+ // DescriptorSetLayout aren't used by execution on the GPU and can be deleted at any time,
+ // so we destroy mHandle immediately instead of using the FencedDeleter
+ if (mHandle != VK_NULL_HANDLE) {
+ Device* device = ToBackend(GetDevice());
+ device->fn.DestroyDescriptorSetLayout(device->GetVkDevice(), mHandle, nullptr);
+ mHandle = VK_NULL_HANDLE;
+ }
+ }
+
+ VkDescriptorSetLayout BindGroupLayout::GetHandle() const {
+ return mHandle;
+ }
+
+ BindGroupLayout::PoolSizeSpec BindGroupLayout::ComputePoolSizes(uint32_t* numPoolSizes) const {
+ uint32_t numSizes = 0;
+ PoolSizeSpec result{};
+
+ // Defines an array and indices into it that will contain for each sampler type at which
+ // position it is in the PoolSizeSpec, or -1 if it isn't present yet.
+ enum DescriptorType {
+ UNIFORM_BUFFER,
+ SAMPLER,
+ SAMPLED_IMAGE,
+ STORAGE_BUFFER,
+ MAX_TYPE,
+ };
+ static_assert(MAX_TYPE == kMaxPoolSizesNeeded, "");
+ auto ToDescriptorType = [](dawn::BindingType type) -> DescriptorType {
+ switch (type) {
+ case dawn::BindingType::UniformBuffer:
+ return UNIFORM_BUFFER;
+ case dawn::BindingType::Sampler:
+ return SAMPLER;
+ case dawn::BindingType::SampledTexture:
+ return SAMPLED_IMAGE;
+ case dawn::BindingType::StorageBuffer:
+ return STORAGE_BUFFER;
+ default:
+ UNREACHABLE();
+ }
+ };
+
+ std::array<int, MAX_TYPE> descriptorTypeIndex;
+ descriptorTypeIndex.fill(-1);
+
+ const auto& info = GetBindingInfo();
+ for (uint32_t bindingIndex : IterateBitSet(info.mask)) {
+ DescriptorType type = ToDescriptorType(info.types[bindingIndex]);
+
+ if (descriptorTypeIndex[type] == -1) {
+ descriptorTypeIndex[type] = numSizes;
+ result[numSizes].type = VulkanDescriptorType(info.types[bindingIndex]);
+ result[numSizes].descriptorCount = 1;
+ numSizes++;
+ } else {
+ result[descriptorTypeIndex[type]].descriptorCount++;
+ }
+ }
+
+ *numPoolSizes = numSizes;
+ return result;
+ }
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupLayoutVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupLayoutVk.h
new file mode 100644
index 00000000000..6a6d8cd58c8
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupLayoutVk.h
@@ -0,0 +1,45 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_BINDGROUPLAYOUTVK_H_
+#define DAWNNATIVE_VULKAN_BINDGROUPLAYOUTVK_H_
+
+#include "dawn_native/BindGroupLayout.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ VkDescriptorType VulkanDescriptorType(dawn::BindingType type);
+
+ class BindGroupLayout : public BindGroupLayoutBase {
+ public:
+ BindGroupLayout(Device* device, const BindGroupLayoutDescriptor* descriptor);
+ ~BindGroupLayout();
+
+ VkDescriptorSetLayout GetHandle() const;
+
+ static constexpr size_t kMaxPoolSizesNeeded = 4;
+ using PoolSizeSpec = std::array<VkDescriptorPoolSize, kMaxPoolSizesNeeded>;
+ PoolSizeSpec ComputePoolSizes(uint32_t* numPoolSizes) const;
+
+ private:
+ VkDescriptorSetLayout mHandle = VK_NULL_HANDLE;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_BINDGROUPLAYOUTVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupVk.cpp
new file mode 100644
index 00000000000..49a972c2e0a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupVk.cpp
@@ -0,0 +1,138 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/BindGroupVk.h"
+
+#include "dawn_native/vulkan/BindGroupLayoutVk.h"
+#include "dawn_native/vulkan/BufferVk.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+#include "dawn_native/vulkan/SamplerVk.h"
+#include "dawn_native/vulkan/TextureVk.h"
+
+#include "common/BitSetIterator.h"
+
+namespace dawn_native { namespace vulkan {
+
+ BindGroup::BindGroup(BindGroupBuilder* builder) : BindGroupBase(builder) {
+ // Create a pool to hold our descriptor set.
+ // TODO(cwallez@chromium.org): This horribly inefficient, find a way to be better, for
+ // example by having one pool per bind group layout instead.
+ uint32_t numPoolSizes = 0;
+ auto poolSizes = ToBackend(GetLayout())->ComputePoolSizes(&numPoolSizes);
+
+ VkDescriptorPoolCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.maxSets = 1;
+ createInfo.poolSizeCount = numPoolSizes;
+ createInfo.pPoolSizes = poolSizes.data();
+
+ Device* device = ToBackend(GetDevice());
+ if (device->fn.CreateDescriptorPool(device->GetVkDevice(), &createInfo, nullptr, &mPool) !=
+ VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ // Now do the allocation of one descriptor set, this is very suboptimal too.
+ VkDescriptorSetLayout vkLayout = ToBackend(GetLayout())->GetHandle();
+
+ VkDescriptorSetAllocateInfo allocateInfo;
+ allocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
+ allocateInfo.pNext = nullptr;
+ allocateInfo.descriptorPool = mPool;
+ allocateInfo.descriptorSetCount = 1;
+ allocateInfo.pSetLayouts = &vkLayout;
+
+ if (device->fn.AllocateDescriptorSets(device->GetVkDevice(), &allocateInfo, &mHandle) !=
+ VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ // Now do a write of a single descriptor set with all possible chained data allocated on the
+ // stack.
+ uint32_t numWrites = 0;
+ std::array<VkWriteDescriptorSet, kMaxBindingsPerGroup> writes;
+ std::array<VkDescriptorBufferInfo, kMaxBindingsPerGroup> writeBufferInfo;
+ std::array<VkDescriptorImageInfo, kMaxBindingsPerGroup> writeImageInfo;
+
+ const auto& layoutInfo = GetLayout()->GetBindingInfo();
+ for (uint32_t bindingIndex : IterateBitSet(layoutInfo.mask)) {
+ auto& write = writes[numWrites];
+ write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
+ write.pNext = nullptr;
+ write.dstSet = mHandle;
+ write.dstBinding = bindingIndex;
+ write.dstArrayElement = 0;
+ write.descriptorCount = 1;
+ write.descriptorType = VulkanDescriptorType(layoutInfo.types[bindingIndex]);
+
+ switch (layoutInfo.types[bindingIndex]) {
+ case dawn::BindingType::UniformBuffer:
+ case dawn::BindingType::StorageBuffer: {
+ BufferViewBase* view = GetBindingAsBufferView(bindingIndex);
+ Buffer* buffer = ToBackend(view->GetBuffer());
+
+ writeBufferInfo[numWrites].buffer = buffer->GetHandle();
+ writeBufferInfo[numWrites].offset = view->GetOffset();
+ writeBufferInfo[numWrites].range = view->GetSize();
+
+ write.pBufferInfo = &writeBufferInfo[numWrites];
+ } break;
+
+ case dawn::BindingType::Sampler: {
+ Sampler* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
+ writeImageInfo[numWrites].sampler = sampler->GetHandle();
+ write.pImageInfo = &writeImageInfo[numWrites];
+ } break;
+
+ case dawn::BindingType::SampledTexture: {
+ TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
+
+ writeImageInfo[numWrites].imageView = view->GetHandle();
+ // TODO(cwallez@chromium.org): This isn't true in general: if the image can has
+ // two read-only usages one of which is Sampled. Works for now though :)
+ writeImageInfo[numWrites].imageLayout =
+ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+
+ write.pImageInfo = &writeImageInfo[numWrites];
+ } break;
+ default:
+ UNREACHABLE();
+ }
+
+ numWrites++;
+ }
+
+ device->fn.UpdateDescriptorSets(device->GetVkDevice(), numWrites, writes.data(), 0,
+ nullptr);
+ }
+
+ BindGroup::~BindGroup() {
+ // The descriptor set doesn't need to be delete because it's done implicitly when the
+ // descriptor pool is destroyed.
+ mHandle = VK_NULL_HANDLE;
+
+ if (mPool != VK_NULL_HANDLE) {
+ ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mPool);
+ mPool = VK_NULL_HANDLE;
+ }
+ }
+
+ VkDescriptorSet BindGroup::GetHandle() const {
+ return mHandle;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupVk.h
new file mode 100644
index 00000000000..9dee3a3bcf2
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BindGroupVk.h
@@ -0,0 +1,40 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_BINDGROUPVK_H_
+#define DAWNNATIVE_VULKAN_BINDGROUPVK_H_
+
+#include "dawn_native/BindGroup.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class BindGroup : public BindGroupBase {
+ public:
+ BindGroup(BindGroupBuilder* builder);
+ ~BindGroup();
+
+ VkDescriptorSet GetHandle() const;
+
+ private:
+ VkDescriptorPool mPool = VK_NULL_HANDLE;
+ VkDescriptorSet mHandle = VK_NULL_HANDLE;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_BINDGROUPVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BlendStateVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/BlendStateVk.cpp
new file mode 100644
index 00000000000..cc4911b609f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BlendStateVk.cpp
@@ -0,0 +1,110 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/BlendStateVk.h"
+
+#include "common/Assert.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+ VkBlendFactor VulkanBlendFactor(dawn::BlendFactor factor) {
+ switch (factor) {
+ case dawn::BlendFactor::Zero:
+ return VK_BLEND_FACTOR_ZERO;
+ case dawn::BlendFactor::One:
+ return VK_BLEND_FACTOR_ONE;
+ case dawn::BlendFactor::SrcColor:
+ return VK_BLEND_FACTOR_SRC_COLOR;
+ case dawn::BlendFactor::OneMinusSrcColor:
+ return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
+ case dawn::BlendFactor::SrcAlpha:
+ return VK_BLEND_FACTOR_SRC_ALPHA;
+ case dawn::BlendFactor::OneMinusSrcAlpha:
+ return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
+ case dawn::BlendFactor::DstColor:
+ return VK_BLEND_FACTOR_DST_COLOR;
+ case dawn::BlendFactor::OneMinusDstColor:
+ return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
+ case dawn::BlendFactor::DstAlpha:
+ return VK_BLEND_FACTOR_DST_ALPHA;
+ case dawn::BlendFactor::OneMinusDstAlpha:
+ return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA;
+ case dawn::BlendFactor::SrcAlphaSaturated:
+ return VK_BLEND_FACTOR_SRC_ALPHA_SATURATE;
+ case dawn::BlendFactor::BlendColor:
+ return VK_BLEND_FACTOR_CONSTANT_COLOR;
+ case dawn::BlendFactor::OneMinusBlendColor:
+ return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ VkBlendOp VulkanBlendOperation(dawn::BlendOperation operation) {
+ switch (operation) {
+ case dawn::BlendOperation::Add:
+ return VK_BLEND_OP_ADD;
+ case dawn::BlendOperation::Subtract:
+ return VK_BLEND_OP_SUBTRACT;
+ case dawn::BlendOperation::ReverseSubtract:
+ return VK_BLEND_OP_REVERSE_SUBTRACT;
+ case dawn::BlendOperation::Min:
+ return VK_BLEND_OP_MIN;
+ case dawn::BlendOperation::Max:
+ return VK_BLEND_OP_MAX;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ VkColorComponentFlagBits VulkanColorWriteMask(dawn::ColorWriteMask mask) {
+ // Vulkan and Dawn color write masks match, static assert it and return the mask
+ static_assert(static_cast<VkColorComponentFlagBits>(dawn::ColorWriteMask::Red) ==
+ VK_COLOR_COMPONENT_R_BIT,
+ "");
+ static_assert(static_cast<VkColorComponentFlagBits>(dawn::ColorWriteMask::Green) ==
+ VK_COLOR_COMPONENT_G_BIT,
+ "");
+ static_assert(static_cast<VkColorComponentFlagBits>(dawn::ColorWriteMask::Blue) ==
+ VK_COLOR_COMPONENT_B_BIT,
+ "");
+ static_assert(static_cast<VkColorComponentFlagBits>(dawn::ColorWriteMask::Alpha) ==
+ VK_COLOR_COMPONENT_A_BIT,
+ "");
+
+ return static_cast<VkColorComponentFlagBits>(mask);
+ }
+ } // anonymous namespace
+
+ BlendState::BlendState(BlendStateBuilder* builder) : BlendStateBase(builder) {
+ // Fill the "color blend attachment info" that will be copied in an array and chained in
+ // the pipeline create info.
+ const auto& info = GetBlendInfo();
+
+ mState.blendEnable = info.blendEnabled ? VK_TRUE : VK_FALSE;
+ mState.srcColorBlendFactor = VulkanBlendFactor(info.colorBlend.srcFactor);
+ mState.dstColorBlendFactor = VulkanBlendFactor(info.colorBlend.dstFactor);
+ mState.colorBlendOp = VulkanBlendOperation(info.colorBlend.operation);
+ mState.srcAlphaBlendFactor = VulkanBlendFactor(info.alphaBlend.srcFactor);
+ mState.dstAlphaBlendFactor = VulkanBlendFactor(info.alphaBlend.dstFactor);
+ mState.alphaBlendOp = VulkanBlendOperation(info.alphaBlend.operation);
+ mState.colorWriteMask = VulkanColorWriteMask(info.colorWriteMask);
+ }
+
+ const VkPipelineColorBlendAttachmentState& BlendState::GetState() const {
+ return mState;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BlendStateVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/BlendStateVk.h
new file mode 100644
index 00000000000..fd025707c55
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BlendStateVk.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_BLENDSTATEVK_H_
+#define DAWNNATIVE_VULKAN_BLENDSTATEVK_H_
+
+#include "dawn_native/BlendState.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ // Pre-computes the blend state configuration to give to a graphics pipeline create info.
+ class BlendState : public BlendStateBase {
+ public:
+ BlendState(BlendStateBuilder* builder);
+
+ const VkPipelineColorBlendAttachmentState& GetState() const;
+
+ private:
+ VkPipelineColorBlendAttachmentState mState;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_BLENDSTATEVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BufferUploader.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/BufferUploader.cpp
new file mode 100644
index 00000000000..e74143f05d9
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BufferUploader.cpp
@@ -0,0 +1,102 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/BufferUploader.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+#include "dawn_native/vulkan/MemoryAllocator.h"
+
+#include <cstring>
+
+namespace dawn_native { namespace vulkan {
+
+ BufferUploader::BufferUploader(Device* device) : mDevice(device) {
+ }
+
+ BufferUploader::~BufferUploader() {
+ }
+
+ void BufferUploader::BufferSubData(VkBuffer buffer,
+ VkDeviceSize offset,
+ VkDeviceSize size,
+ const void* data) {
+ // TODO(cwallez@chromium.org): this is soooooo bad. We should use some sort of ring buffer
+ // for this.
+
+ // Create a staging buffer
+ VkBufferCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.size = size;
+ createInfo.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ createInfo.queueFamilyIndexCount = 0;
+ createInfo.pQueueFamilyIndices = 0;
+
+ VkBuffer stagingBuffer = VK_NULL_HANDLE;
+ if (mDevice->fn.CreateBuffer(mDevice->GetVkDevice(), &createInfo, nullptr,
+ &stagingBuffer) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ VkMemoryRequirements requirements;
+ mDevice->fn.GetBufferMemoryRequirements(mDevice->GetVkDevice(), stagingBuffer,
+ &requirements);
+
+ DeviceMemoryAllocation allocation;
+ if (!mDevice->GetMemoryAllocator()->Allocate(requirements, true, &allocation)) {
+ ASSERT(false);
+ }
+
+ if (mDevice->fn.BindBufferMemory(mDevice->GetVkDevice(), stagingBuffer,
+ allocation.GetMemory(),
+ allocation.GetMemoryOffset()) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ // Write to the staging buffer
+ ASSERT(allocation.GetMappedPointer() != nullptr);
+ memcpy(allocation.GetMappedPointer(), data, static_cast<size_t>(size));
+
+ // Enqueue host write -> transfer src barrier and copy command
+ VkCommandBuffer commands = mDevice->GetPendingCommandBuffer();
+
+ VkMemoryBarrier barrier;
+ barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
+ barrier.pNext = nullptr;
+ barrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
+ barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
+
+ mDevice->fn.CmdPipelineBarrier(commands, VK_PIPELINE_STAGE_HOST_BIT,
+ VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 1, &barrier, 0, nullptr,
+ 0, nullptr);
+
+ VkBufferCopy copy;
+ copy.srcOffset = 0;
+ copy.dstOffset = offset;
+ copy.size = size;
+ mDevice->fn.CmdCopyBuffer(commands, stagingBuffer, buffer, 1, &copy);
+
+ // TODO(cwallez@chromium.org): Buffers must be deleted before the memory.
+ // This happens to work for now, but is fragile.
+ mDevice->GetMemoryAllocator()->Free(&allocation);
+ mDevice->GetFencedDeleter()->DeleteWhenUnused(stagingBuffer);
+ }
+
+ void BufferUploader::Tick(Serial) {
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BufferUploader.h b/chromium/third_party/dawn/src/dawn_native/vulkan/BufferUploader.h
new file mode 100644
index 00000000000..37ff0d7d6e8
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BufferUploader.h
@@ -0,0 +1,43 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_BUFFERUPLOADER_H_
+#define DAWNNATIVE_VULKAN_BUFFERUPLOADER_H_
+
+#include "common/SerialQueue.h"
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class BufferUploader {
+ public:
+ BufferUploader(Device* device);
+ ~BufferUploader();
+
+ void BufferSubData(VkBuffer buffer,
+ VkDeviceSize offset,
+ VkDeviceSize size,
+ const void* data);
+
+ void Tick(Serial completedSerial);
+
+ private:
+ Device* mDevice = nullptr;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_BUFFERUPLOADER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BufferVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/BufferVk.cpp
new file mode 100644
index 00000000000..3c7d1370b7d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BufferVk.cpp
@@ -0,0 +1,269 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/BufferVk.h"
+
+#include "dawn_native/vulkan/BufferUploader.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+
+#include <cstring>
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+
+ VkBufferUsageFlags VulkanBufferUsage(dawn::BufferUsageBit usage) {
+ VkBufferUsageFlags flags = 0;
+
+ if (usage & dawn::BufferUsageBit::TransferSrc) {
+ flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::TransferDst) {
+ flags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::Index) {
+ flags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::Vertex) {
+ flags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::Uniform) {
+ flags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::Storage) {
+ flags |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
+ }
+
+ return flags;
+ }
+
+ VkPipelineStageFlags VulkanPipelineStage(dawn::BufferUsageBit usage) {
+ VkPipelineStageFlags flags = 0;
+
+ if (usage & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
+ flags |= VK_PIPELINE_STAGE_HOST_BIT;
+ }
+ if (usage & (dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)) {
+ flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
+ }
+ if (usage & (dawn::BufferUsageBit::Index | dawn::BufferUsageBit::Vertex)) {
+ flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
+ }
+ if (usage & (dawn::BufferUsageBit::Uniform | dawn::BufferUsageBit::Storage)) {
+ flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
+ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
+ VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+ }
+
+ return flags;
+ }
+
+ VkAccessFlags VulkanAccessFlags(dawn::BufferUsageBit usage) {
+ VkAccessFlags flags = 0;
+
+ if (usage & dawn::BufferUsageBit::MapRead) {
+ flags |= VK_ACCESS_HOST_READ_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::MapWrite) {
+ flags |= VK_ACCESS_HOST_WRITE_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::TransferSrc) {
+ flags |= VK_ACCESS_TRANSFER_READ_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::TransferDst) {
+ flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::Index) {
+ flags |= VK_ACCESS_INDEX_READ_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::Vertex) {
+ flags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::Uniform) {
+ flags |= VK_ACCESS_UNIFORM_READ_BIT;
+ }
+ if (usage & dawn::BufferUsageBit::Storage) {
+ flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
+ }
+
+ return flags;
+ }
+
+ } // namespace
+
+ Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
+ : BufferBase(device, descriptor) {
+ VkBufferCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.size = GetSize();
+ createInfo.usage = VulkanBufferUsage(GetUsage());
+ createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ createInfo.queueFamilyIndexCount = 0;
+ createInfo.pQueueFamilyIndices = 0;
+
+ if (device->fn.CreateBuffer(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
+ VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ VkMemoryRequirements requirements;
+ device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
+
+ bool requestMappable =
+ (GetUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) != 0;
+ if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable,
+ &mMemoryAllocation)) {
+ ASSERT(false);
+ }
+
+ if (device->fn.BindBufferMemory(device->GetVkDevice(), mHandle,
+ mMemoryAllocation.GetMemory(),
+ mMemoryAllocation.GetMemoryOffset()) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ Buffer::~Buffer() {
+ Device* device = ToBackend(GetDevice());
+
+ device->GetMemoryAllocator()->Free(&mMemoryAllocation);
+
+ if (mHandle != VK_NULL_HANDLE) {
+ device->GetFencedDeleter()->DeleteWhenUnused(mHandle);
+ mHandle = VK_NULL_HANDLE;
+ }
+ }
+
+ void Buffer::OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data) {
+ CallMapReadCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
+ }
+
+ void Buffer::OnMapWriteCommandSerialFinished(uint32_t mapSerial, void* data) {
+ CallMapWriteCallback(mapSerial, DAWN_BUFFER_MAP_ASYNC_STATUS_SUCCESS, data);
+ }
+
+ VkBuffer Buffer::GetHandle() const {
+ return mHandle;
+ }
+
+ void Buffer::TransitionUsageNow(VkCommandBuffer commands, dawn::BufferUsageBit usage) {
+ bool lastIncludesTarget = (mLastUsage & usage) == usage;
+ bool lastReadOnly = (mLastUsage & kReadOnlyBufferUsages) == mLastUsage;
+
+ // We can skip transitions to already current read-only usages.
+ if (lastIncludesTarget && lastReadOnly) {
+ return;
+ }
+
+ // Special-case for the initial transition: Vulkan doesn't allow access flags to be 0.
+ if (mLastUsage == dawn::BufferUsageBit::None) {
+ mLastUsage = usage;
+ return;
+ }
+
+ VkPipelineStageFlags srcStages = VulkanPipelineStage(mLastUsage);
+ VkPipelineStageFlags dstStages = VulkanPipelineStage(usage);
+
+ VkBufferMemoryBarrier barrier;
+ barrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
+ barrier.pNext = nullptr;
+ barrier.srcAccessMask = VulkanAccessFlags(mLastUsage);
+ barrier.dstAccessMask = VulkanAccessFlags(usage);
+ barrier.srcQueueFamilyIndex = 0;
+ barrier.dstQueueFamilyIndex = 0;
+ barrier.buffer = mHandle;
+ barrier.offset = 0;
+ barrier.size = GetSize();
+
+ ToBackend(GetDevice())
+ ->fn.CmdPipelineBarrier(commands, srcStages, dstStages, 0, 0, nullptr, 1, &barrier, 0,
+ nullptr);
+
+ mLastUsage = usage;
+ }
+
+ void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) {
+ Device* device = ToBackend(GetDevice());
+
+ VkCommandBuffer commands = device->GetPendingCommandBuffer();
+ TransitionUsageNow(commands, dawn::BufferUsageBit::TransferDst);
+
+ BufferUploader* uploader = device->GetBufferUploader();
+ uploader->BufferSubData(mHandle, start, count, data);
+ }
+
+ void Buffer::MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t /*count*/) {
+ Device* device = ToBackend(GetDevice());
+
+ VkCommandBuffer commands = device->GetPendingCommandBuffer();
+ TransitionUsageNow(commands, dawn::BufferUsageBit::MapRead);
+
+ uint8_t* memory = mMemoryAllocation.GetMappedPointer();
+ ASSERT(memory != nullptr);
+
+ MapRequestTracker* tracker = device->GetMapRequestTracker();
+ tracker->Track(this, serial, memory + start, false);
+ }
+
+ void Buffer::MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t /*count*/) {
+ Device* device = ToBackend(GetDevice());
+
+ VkCommandBuffer commands = device->GetPendingCommandBuffer();
+ TransitionUsageNow(commands, dawn::BufferUsageBit::MapWrite);
+
+ uint8_t* memory = mMemoryAllocation.GetMappedPointer();
+ ASSERT(memory != nullptr);
+
+ MapRequestTracker* tracker = device->GetMapRequestTracker();
+ tracker->Track(this, serial, memory + start, true);
+ }
+
+ void Buffer::UnmapImpl() {
+ // No need to do anything, we keep CPU-visible memory mapped at all time.
+ }
+
+ // MapRequestTracker
+
+ MapRequestTracker::MapRequestTracker(Device* device) : mDevice(device) {
+ }
+
+ MapRequestTracker::~MapRequestTracker() {
+ ASSERT(mInflightRequests.Empty());
+ }
+
+ void MapRequestTracker::Track(Buffer* buffer, uint32_t mapSerial, void* data, bool isWrite) {
+ Request request;
+ request.buffer = buffer;
+ request.mapSerial = mapSerial;
+ request.data = data;
+ request.isWrite = isWrite;
+
+ mInflightRequests.Enqueue(std::move(request), mDevice->GetSerial());
+ }
+
+ void MapRequestTracker::Tick(Serial finishedSerial) {
+ for (auto& request : mInflightRequests.IterateUpTo(finishedSerial)) {
+ if (request.isWrite) {
+ request.buffer->OnMapWriteCommandSerialFinished(request.mapSerial, request.data);
+ } else {
+ request.buffer->OnMapReadCommandSerialFinished(request.mapSerial, request.data);
+ }
+ }
+ mInflightRequests.ClearUpTo(finishedSerial);
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/BufferVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/BufferVk.h
new file mode 100644
index 00000000000..d2ff4f63ba6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/BufferVk.h
@@ -0,0 +1,79 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_BUFFERVK_H_
+#define DAWNNATIVE_VULKAN_BUFFERVK_H_
+
+#include "dawn_native/Buffer.h"
+
+#include "common/SerialQueue.h"
+#include "common/vulkan_platform.h"
+#include "dawn_native/vulkan/MemoryAllocator.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class Buffer : public BufferBase {
+ public:
+ Buffer(Device* device, const BufferDescriptor* descriptor);
+ ~Buffer();
+
+ void OnMapReadCommandSerialFinished(uint32_t mapSerial, const void* data);
+ void OnMapWriteCommandSerialFinished(uint32_t mapSerial, void* data);
+
+ VkBuffer GetHandle() const;
+
+ // Transitions the buffer to be used as `usage`, recording any necessary barrier in
+ // `commands`.
+ // TODO(cwallez@chromium.org): coalesce barriers and do them early when possible.
+ void TransitionUsageNow(VkCommandBuffer commands, dawn::BufferUsageBit usage);
+
+ private:
+ void SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) override;
+ void MapReadAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t count) override;
+ void UnmapImpl() override;
+
+ VkBuffer mHandle = VK_NULL_HANDLE;
+ DeviceMemoryAllocation mMemoryAllocation;
+
+ dawn::BufferUsageBit mLastUsage = dawn::BufferUsageBit::None;
+ };
+
+ using BufferView = BufferViewBase;
+
+ class MapRequestTracker {
+ public:
+ MapRequestTracker(Device* device);
+ ~MapRequestTracker();
+
+ void Track(Buffer* buffer, uint32_t mapSerial, void* data, bool isWrite);
+ void Tick(Serial finishedSerial);
+
+ private:
+ Device* mDevice;
+
+ struct Request {
+ Ref<Buffer> buffer;
+ uint32_t mapSerial;
+ void* data;
+ bool isWrite;
+ };
+ SerialQueue<Request> mInflightRequests;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_BUFFERVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/CommandBufferVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/CommandBufferVk.cpp
new file mode 100644
index 00000000000..8f5c46271c0
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/CommandBufferVk.cpp
@@ -0,0 +1,423 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/CommandBufferVk.h"
+
+#include "dawn_native/Commands.h"
+#include "dawn_native/vulkan/BindGroupVk.h"
+#include "dawn_native/vulkan/BufferVk.h"
+#include "dawn_native/vulkan/ComputePipelineVk.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/PipelineLayoutVk.h"
+#include "dawn_native/vulkan/RenderPassDescriptorVk.h"
+#include "dawn_native/vulkan/RenderPipelineVk.h"
+#include "dawn_native/vulkan/TextureVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+
+ VkIndexType VulkanIndexType(dawn::IndexFormat format) {
+ switch (format) {
+ case dawn::IndexFormat::Uint16:
+ return VK_INDEX_TYPE_UINT16;
+ case dawn::IndexFormat::Uint32:
+ return VK_INDEX_TYPE_UINT32;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ VkBufferImageCopy ComputeBufferImageCopyRegion(uint32_t rowPitch,
+ const BufferCopyLocation& bufferLocation,
+ const TextureCopyLocation& textureLocation) {
+ const Texture* texture = ToBackend(textureLocation.texture).Get();
+
+ VkBufferImageCopy region;
+
+ region.bufferOffset = bufferLocation.offset;
+ // In Vulkan the row length is in texels while it is in bytes for Dawn
+ region.bufferRowLength = rowPitch / TextureFormatPixelSize(texture->GetFormat());
+ region.bufferImageHeight = rowPitch * textureLocation.height;
+
+ region.imageSubresource.aspectMask = texture->GetVkAspectMask();
+ region.imageSubresource.mipLevel = textureLocation.level;
+ region.imageSubresource.baseArrayLayer = textureLocation.slice;
+ region.imageSubresource.layerCount = 1;
+
+ region.imageOffset.x = textureLocation.x;
+ region.imageOffset.y = textureLocation.y;
+ region.imageOffset.z = textureLocation.z;
+
+ region.imageExtent.width = textureLocation.width;
+ region.imageExtent.height = textureLocation.height;
+ region.imageExtent.depth = textureLocation.depth;
+
+ return region;
+ }
+
+ class DescriptorSetTracker {
+ public:
+ void OnSetBindGroup(uint32_t index, VkDescriptorSet set) {
+ mDirtySets.set(index);
+ mSets[index] = set;
+ }
+
+ void OnPipelineLayoutChange(PipelineLayout* layout) {
+ if (layout == mCurrentLayout) {
+ return;
+ }
+
+ if (mCurrentLayout == nullptr) {
+ // We're at the beginning of a pass so all bind groups will be set before any
+ // draw / dispatch. Still clear the dirty sets to avoid leftover dirty sets
+ // from previous passes.
+ mDirtySets.reset();
+ } else {
+ // Bindgroups that are not inherited will be set again before any draw or
+ // dispatch. Resetting the bits also makes sure we don't have leftover dirty
+ // bindgroups that don't exist in the pipeline layout.
+ mDirtySets &= ~layout->InheritedGroupsMask(mCurrentLayout);
+ }
+ mCurrentLayout = layout;
+ }
+
+ void Flush(Device* device, VkCommandBuffer commands, VkPipelineBindPoint bindPoint) {
+ for (uint32_t dirtyIndex : IterateBitSet(mDirtySets)) {
+ device->fn.CmdBindDescriptorSets(commands, bindPoint,
+ mCurrentLayout->GetHandle(), dirtyIndex, 1,
+ &mSets[dirtyIndex], 0, nullptr);
+ }
+ mDirtySets.reset();
+ }
+
+ private:
+ PipelineLayout* mCurrentLayout = nullptr;
+ std::array<VkDescriptorSet, kMaxBindGroups> mSets;
+ std::bitset<kMaxBindGroups> mDirtySets;
+ };
+
+ } // anonymous namespace
+
+ CommandBuffer::CommandBuffer(CommandBufferBuilder* builder)
+ : CommandBufferBase(builder), mCommands(builder->AcquireCommands()) {
+ }
+
+ CommandBuffer::~CommandBuffer() {
+ FreeCommands(&mCommands);
+ }
+
+ void CommandBuffer::RecordCommands(VkCommandBuffer commands) {
+ Device* device = ToBackend(GetDevice());
+
+ // Records the necessary barriers for the resource usage pre-computed by the frontend
+ auto TransitionForPass = [](VkCommandBuffer commands, const PassResourceUsage& usages) {
+ for (size_t i = 0; i < usages.buffers.size(); ++i) {
+ Buffer* buffer = ToBackend(usages.buffers[i]);
+ buffer->TransitionUsageNow(commands, usages.bufferUsages[i]);
+ }
+ for (size_t i = 0; i < usages.textures.size(); ++i) {
+ Texture* texture = ToBackend(usages.textures[i]);
+ texture->TransitionUsageNow(commands, usages.textureUsages[i]);
+ }
+ };
+
+ const std::vector<PassResourceUsage>& passResourceUsages = GetResourceUsages().perPass;
+ size_t nextPassNumber = 0;
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::CopyBufferToBuffer: {
+ CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+
+ ToBackend(src.buffer)
+ ->TransitionUsageNow(commands, dawn::BufferUsageBit::TransferSrc);
+ ToBackend(dst.buffer)
+ ->TransitionUsageNow(commands, dawn::BufferUsageBit::TransferDst);
+
+ VkBufferCopy region;
+ region.srcOffset = src.offset;
+ region.dstOffset = dst.offset;
+ region.size = copy->size;
+
+ VkBuffer srcHandle = ToBackend(src.buffer)->GetHandle();
+ VkBuffer dstHandle = ToBackend(dst.buffer)->GetHandle();
+ device->fn.CmdCopyBuffer(commands, srcHandle, dstHandle, 1, &region);
+ } break;
+
+ case Command::CopyBufferToTexture: {
+ CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+
+ ToBackend(src.buffer)
+ ->TransitionUsageNow(commands, dawn::BufferUsageBit::TransferSrc);
+ ToBackend(dst.texture)
+ ->TransitionUsageNow(commands, dawn::TextureUsageBit::TransferDst);
+
+ VkBuffer srcBuffer = ToBackend(src.buffer)->GetHandle();
+ VkImage dstImage = ToBackend(dst.texture)->GetHandle();
+
+ VkBufferImageCopy region =
+ ComputeBufferImageCopyRegion(copy->rowPitch, src, dst);
+
+ // The image is written to so the Dawn guarantees make sure it is in the
+ // TRANSFER_DST_OPTIMAL layout
+ device->fn.CmdCopyBufferToImage(commands, srcBuffer, dstImage,
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,
+ &region);
+ } break;
+
+ case Command::CopyTextureToBuffer: {
+ CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
+ auto& src = copy->source;
+ auto& dst = copy->destination;
+
+ ToBackend(src.texture)
+ ->TransitionUsageNow(commands, dawn::TextureUsageBit::TransferSrc);
+ ToBackend(dst.buffer)
+ ->TransitionUsageNow(commands, dawn::BufferUsageBit::TransferDst);
+
+ VkImage srcImage = ToBackend(src.texture)->GetHandle();
+ VkBuffer dstBuffer = ToBackend(dst.buffer)->GetHandle();
+
+ VkBufferImageCopy region =
+ ComputeBufferImageCopyRegion(copy->rowPitch, dst, src);
+
+ // The Dawn TransferSrc usage is always mapped to GENERAL
+ device->fn.CmdCopyImageToBuffer(commands, srcImage, VK_IMAGE_LAYOUT_GENERAL,
+ dstBuffer, 1, &region);
+ } break;
+
+ case Command::BeginRenderPass: {
+ BeginRenderPassCmd* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
+
+ TransitionForPass(commands, passResourceUsages[nextPassNumber]);
+ RecordRenderPass(commands, ToBackend(cmd->info.Get()));
+
+ nextPassNumber++;
+ } break;
+
+ case Command::BeginComputePass: {
+ mCommands.NextCommand<BeginComputePassCmd>();
+
+ TransitionForPass(commands, passResourceUsages[nextPassNumber]);
+ RecordComputePass(commands);
+
+ nextPassNumber++;
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+ }
+
+ void CommandBuffer::RecordComputePass(VkCommandBuffer commands) {
+ Device* device = ToBackend(GetDevice());
+
+ DescriptorSetTracker descriptorSets;
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndComputePass: {
+ mCommands.NextCommand<EndComputePassCmd>();
+ return;
+ } break;
+
+ case Command::Dispatch: {
+ DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
+ descriptorSets.Flush(device, commands, VK_PIPELINE_BIND_POINT_COMPUTE);
+ device->fn.CmdDispatch(commands, dispatch->x, dispatch->y, dispatch->z);
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
+ VkDescriptorSet set = ToBackend(cmd->group.Get())->GetHandle();
+
+ descriptorSets.OnSetBindGroup(cmd->index, set);
+ } break;
+
+ case Command::SetComputePipeline: {
+ SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
+ ComputePipeline* pipeline = ToBackend(cmd->pipeline).Get();
+
+ device->fn.CmdBindPipeline(commands, VK_PIPELINE_BIND_POINT_COMPUTE,
+ pipeline->GetHandle());
+ descriptorSets.OnPipelineLayoutChange(ToBackend(pipeline->GetLayout()));
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+
+ // EndComputePass should have been called
+ UNREACHABLE();
+ }
+ void CommandBuffer::RecordRenderPass(VkCommandBuffer commands,
+ RenderPassDescriptor* renderPass) {
+ Device* device = ToBackend(GetDevice());
+
+ renderPass->RecordBeginRenderPass(commands);
+
+ // Set the default value for the dynamic state
+ {
+ device->fn.CmdSetLineWidth(commands, 1.0f);
+ device->fn.CmdSetDepthBounds(commands, 0.0f, 1.0f);
+
+ device->fn.CmdSetStencilReference(commands, VK_STENCIL_FRONT_AND_BACK, 0);
+
+ float blendConstants[4] = {
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ 0.0f,
+ };
+ device->fn.CmdSetBlendConstants(commands, blendConstants);
+
+ // The viewport and scissor default to cover all of the attachments
+ VkViewport viewport;
+ viewport.x = 0.0f;
+ viewport.y = 0.0f;
+ viewport.width = static_cast<float>(renderPass->GetWidth());
+ viewport.height = static_cast<float>(renderPass->GetHeight());
+ viewport.minDepth = 0.0f;
+ viewport.maxDepth = 1.0f;
+ device->fn.CmdSetViewport(commands, 0, 1, &viewport);
+
+ VkRect2D scissorRect;
+ scissorRect.offset.x = 0;
+ scissorRect.offset.y = 0;
+ scissorRect.extent.width = renderPass->GetWidth();
+ scissorRect.extent.height = renderPass->GetHeight();
+ device->fn.CmdSetScissor(commands, 0, 1, &scissorRect);
+ }
+
+ DescriptorSetTracker descriptorSets;
+ RenderPipeline* lastPipeline = nullptr;
+
+ Command type;
+ while (mCommands.NextCommandId(&type)) {
+ switch (type) {
+ case Command::EndRenderPass: {
+ mCommands.NextCommand<EndRenderPassCmd>();
+ device->fn.CmdEndRenderPass(commands);
+ return;
+ } break;
+
+ case Command::DrawArrays: {
+ DrawArraysCmd* draw = mCommands.NextCommand<DrawArraysCmd>();
+
+ descriptorSets.Flush(device, commands, VK_PIPELINE_BIND_POINT_GRAPHICS);
+ device->fn.CmdDraw(commands, draw->vertexCount, draw->instanceCount,
+ draw->firstVertex, draw->firstInstance);
+ } break;
+
+ case Command::DrawElements: {
+ DrawElementsCmd* draw = mCommands.NextCommand<DrawElementsCmd>();
+
+ descriptorSets.Flush(device, commands, VK_PIPELINE_BIND_POINT_GRAPHICS);
+ uint32_t vertexOffset = 0;
+ device->fn.CmdDrawIndexed(commands, draw->indexCount, draw->instanceCount,
+ draw->firstIndex, vertexOffset, draw->firstInstance);
+ } break;
+
+ case Command::SetBindGroup: {
+ SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
+ VkDescriptorSet set = ToBackend(cmd->group.Get())->GetHandle();
+
+ descriptorSets.OnSetBindGroup(cmd->index, set);
+ } break;
+
+ case Command::SetBlendColor: {
+ SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
+ float blendConstants[4] = {
+ cmd->r,
+ cmd->g,
+ cmd->b,
+ cmd->a,
+ };
+ device->fn.CmdSetBlendConstants(commands, blendConstants);
+ } break;
+
+ case Command::SetIndexBuffer: {
+ SetIndexBufferCmd* cmd = mCommands.NextCommand<SetIndexBufferCmd>();
+ VkBuffer indexBuffer = ToBackend(cmd->buffer)->GetHandle();
+
+ // TODO(cwallez@chromium.org): get the index type from the last render pipeline
+ // and rebind if needed on pipeline change
+ ASSERT(lastPipeline != nullptr);
+ VkIndexType indexType = VulkanIndexType(lastPipeline->GetIndexFormat());
+ device->fn.CmdBindIndexBuffer(
+ commands, indexBuffer, static_cast<VkDeviceSize>(cmd->offset), indexType);
+ } break;
+
+ case Command::SetRenderPipeline: {
+ SetRenderPipelineCmd* cmd = mCommands.NextCommand<SetRenderPipelineCmd>();
+ RenderPipeline* pipeline = ToBackend(cmd->pipeline).Get();
+
+ device->fn.CmdBindPipeline(commands, VK_PIPELINE_BIND_POINT_GRAPHICS,
+ pipeline->GetHandle());
+ lastPipeline = pipeline;
+
+ descriptorSets.OnPipelineLayoutChange(ToBackend(pipeline->GetLayout()));
+ } break;
+
+ case Command::SetStencilReference: {
+ SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
+ device->fn.CmdSetStencilReference(commands, VK_STENCIL_FRONT_AND_BACK,
+ cmd->reference);
+ } break;
+
+ case Command::SetScissorRect: {
+ SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
+ VkRect2D rect;
+ rect.offset.x = cmd->x;
+ rect.offset.y = cmd->y;
+ rect.extent.width = cmd->width;
+ rect.extent.height = cmd->height;
+
+ device->fn.CmdSetScissor(commands, 0, 1, &rect);
+ } break;
+
+ case Command::SetVertexBuffers: {
+ SetVertexBuffersCmd* cmd = mCommands.NextCommand<SetVertexBuffersCmd>();
+ auto buffers = mCommands.NextData<Ref<BufferBase>>(cmd->count);
+ auto offsets = mCommands.NextData<uint32_t>(cmd->count);
+
+ std::array<VkBuffer, kMaxVertexInputs> vkBuffers;
+ std::array<VkDeviceSize, kMaxVertexInputs> vkOffsets;
+
+ for (uint32_t i = 0; i < cmd->count; ++i) {
+ Buffer* buffer = ToBackend(buffers[i].Get());
+ vkBuffers[i] = buffer->GetHandle();
+ vkOffsets[i] = static_cast<VkDeviceSize>(offsets[i]);
+ }
+
+ device->fn.CmdBindVertexBuffers(commands, cmd->startSlot, cmd->count,
+ vkBuffers.data(), vkOffsets.data());
+ } break;
+
+ default: { UNREACHABLE(); } break;
+ }
+ }
+
+ // EndRenderPass should have been called
+ UNREACHABLE();
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/CommandBufferVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/CommandBufferVk.h
new file mode 100644
index 00000000000..2ca5a628655
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/CommandBufferVk.h
@@ -0,0 +1,42 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_COMMANDBUFFERVK_H_
+#define DAWNNATIVE_VULKAN_COMMANDBUFFERVK_H_
+
+#include "dawn_native/CommandBuffer.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class RenderPassDescriptor;
+
+ class CommandBuffer : public CommandBufferBase {
+ public:
+ CommandBuffer(CommandBufferBuilder* builder);
+ ~CommandBuffer();
+
+ void RecordCommands(VkCommandBuffer commands);
+
+ private:
+ void RecordComputePass(VkCommandBuffer commands);
+ void RecordRenderPass(VkCommandBuffer commands, RenderPassDescriptor* renderPass);
+
+ CommandIterator mCommands;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_COMMANDBUFFERVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/ComputePipelineVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/ComputePipelineVk.cpp
new file mode 100644
index 00000000000..06948b35a87
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/ComputePipelineVk.cpp
@@ -0,0 +1,59 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/ComputePipelineVk.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+#include "dawn_native/vulkan/PipelineLayoutVk.h"
+#include "dawn_native/vulkan/ShaderModuleVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ ComputePipeline::ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor)
+ : ComputePipelineBase(device, descriptor) {
+ VkComputePipelineCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.layout = ToBackend(descriptor->layout)->GetHandle();
+ createInfo.basePipelineHandle = VK_NULL_HANDLE;
+ createInfo.basePipelineIndex = -1;
+
+ createInfo.stage.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+ createInfo.stage.pNext = nullptr;
+ createInfo.stage.flags = 0;
+ createInfo.stage.stage = VK_SHADER_STAGE_COMPUTE_BIT;
+ createInfo.stage.module = ToBackend(descriptor->module)->GetHandle();
+ createInfo.stage.pName = descriptor->entryPoint;
+ createInfo.stage.pSpecializationInfo = nullptr;
+
+ if (device->fn.CreateComputePipelines(device->GetVkDevice(), VK_NULL_HANDLE, 1, &createInfo,
+ nullptr, &mHandle) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ ComputePipeline::~ComputePipeline() {
+ if (mHandle != VK_NULL_HANDLE) {
+ ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
+ mHandle = VK_NULL_HANDLE;
+ }
+ }
+
+ VkPipeline ComputePipeline::GetHandle() const {
+ return mHandle;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/ComputePipelineVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/ComputePipelineVk.h
new file mode 100644
index 00000000000..d1b589c8c41
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/ComputePipelineVk.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_COMPUTEPIPELINEVK_H_
+#define DAWNNATIVE_VULKAN_COMPUTEPIPELINEVK_H_
+
+#include "dawn_native/ComputePipeline.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class ComputePipeline : public ComputePipelineBase {
+ public:
+ ComputePipeline(Device* device, const ComputePipelineDescriptor* descriptor);
+ ~ComputePipeline();
+
+ VkPipeline GetHandle() const;
+
+ private:
+ VkPipeline mHandle = VK_NULL_HANDLE;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_COMPUTEPIPELINEVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/DepthStencilStateVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/DepthStencilStateVk.cpp
new file mode 100644
index 00000000000..a50bb0d7748
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/DepthStencilStateVk.cpp
@@ -0,0 +1,112 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/DepthStencilStateVk.h"
+
+#include "common/Assert.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+ VkCompareOp VulkanCompareOp(dawn::CompareFunction op) {
+ switch (op) {
+ case dawn::CompareFunction::Always:
+ return VK_COMPARE_OP_ALWAYS;
+ case dawn::CompareFunction::Equal:
+ return VK_COMPARE_OP_EQUAL;
+ case dawn::CompareFunction::Greater:
+ return VK_COMPARE_OP_GREATER;
+ case dawn::CompareFunction::GreaterEqual:
+ return VK_COMPARE_OP_GREATER_OR_EQUAL;
+ case dawn::CompareFunction::Less:
+ return VK_COMPARE_OP_LESS;
+ case dawn::CompareFunction::LessEqual:
+ return VK_COMPARE_OP_LESS_OR_EQUAL;
+ case dawn::CompareFunction::Never:
+ return VK_COMPARE_OP_NEVER;
+ case dawn::CompareFunction::NotEqual:
+ return VK_COMPARE_OP_NOT_EQUAL;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ VkStencilOp VulkanStencilOp(dawn::StencilOperation op) {
+ switch (op) {
+ case dawn::StencilOperation::Keep:
+ return VK_STENCIL_OP_KEEP;
+ case dawn::StencilOperation::Zero:
+ return VK_STENCIL_OP_ZERO;
+ case dawn::StencilOperation::Replace:
+ return VK_STENCIL_OP_REPLACE;
+ case dawn::StencilOperation::IncrementClamp:
+ return VK_STENCIL_OP_INCREMENT_AND_CLAMP;
+ case dawn::StencilOperation::DecrementClamp:
+ return VK_STENCIL_OP_DECREMENT_AND_CLAMP;
+ case dawn::StencilOperation::Invert:
+ return VK_STENCIL_OP_INVERT;
+ case dawn::StencilOperation::IncrementWrap:
+ return VK_STENCIL_OP_INCREMENT_AND_WRAP;
+ case dawn::StencilOperation::DecrementWrap:
+ return VK_STENCIL_OP_DECREMENT_AND_WRAP;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ } // anonymous namespace
+
+ DepthStencilState::DepthStencilState(DepthStencilStateBuilder* builder)
+ : DepthStencilStateBase(builder) {
+ mCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
+ mCreateInfo.pNext = nullptr;
+ mCreateInfo.flags = 0;
+
+ const auto& depth = GetDepth();
+ mCreateInfo.depthTestEnable = VK_TRUE;
+ mCreateInfo.depthWriteEnable = depth.depthWriteEnabled ? VK_TRUE : VK_FALSE;
+ mCreateInfo.depthCompareOp = VulkanCompareOp(depth.compareFunction);
+ mCreateInfo.depthBoundsTestEnable = false;
+ mCreateInfo.minDepthBounds = 0.0f;
+ mCreateInfo.maxDepthBounds = 0.0f;
+
+ const auto& stencil = GetStencil();
+ mCreateInfo.stencilTestEnable = StencilTestEnabled() ? VK_TRUE : VK_FALSE;
+
+ mCreateInfo.front.failOp = VulkanStencilOp(stencil.front.stencilFail);
+ mCreateInfo.front.passOp = VulkanStencilOp(stencil.front.depthStencilPass);
+ mCreateInfo.front.depthFailOp = VulkanStencilOp(stencil.front.depthFail);
+ mCreateInfo.front.compareOp = VulkanCompareOp(stencil.front.compareFunction);
+
+ mCreateInfo.back.failOp = VulkanStencilOp(stencil.back.stencilFail);
+ mCreateInfo.back.passOp = VulkanStencilOp(stencil.back.depthStencilPass);
+ mCreateInfo.back.depthFailOp = VulkanStencilOp(stencil.back.depthFail);
+ mCreateInfo.back.compareOp = VulkanCompareOp(stencil.back.compareFunction);
+
+ // Dawn doesn't have separate front and back stencil masks.
+ mCreateInfo.front.compareMask = stencil.readMask;
+ mCreateInfo.back.compareMask = stencil.readMask;
+ mCreateInfo.front.writeMask = stencil.writeMask;
+ mCreateInfo.back.writeMask = stencil.writeMask;
+
+ // The stencil reference is always dynamic
+ mCreateInfo.front.reference = 0;
+ mCreateInfo.back.reference = 0;
+ }
+
+ const VkPipelineDepthStencilStateCreateInfo* DepthStencilState::GetCreateInfo() const {
+ return &mCreateInfo;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/DepthStencilStateVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/DepthStencilStateVk.h
new file mode 100644
index 00000000000..1f9a2a52210
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/DepthStencilStateVk.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_DEPTHSTENCILSTATEVK_H_
+#define DAWNNATIVE_VULKAN_DEPTHSTENCILSTATEVK_H_
+
+#include "dawn_native/DepthStencilState.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ // Pre-computes the depth-stencil configuration to give to a graphics pipeline create info.
+ class DepthStencilState : public DepthStencilStateBase {
+ public:
+ DepthStencilState(DepthStencilStateBuilder* builder);
+
+ const VkPipelineDepthStencilStateCreateInfo* GetCreateInfo() const;
+
+ private:
+ VkPipelineDepthStencilStateCreateInfo mCreateInfo;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_DEPTHSTENCILSTATEVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/DeviceVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/DeviceVk.cpp
new file mode 100644
index 00000000000..5b3b976fa4c
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/DeviceVk.cpp
@@ -0,0 +1,695 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/DeviceVk.h"
+
+#include "common/Platform.h"
+#include "common/SwapChainUtils.h"
+#include "dawn_native/Commands.h"
+#include "dawn_native/VulkanBackend.h"
+#include "dawn_native/vulkan/BindGroupLayoutVk.h"
+#include "dawn_native/vulkan/BindGroupVk.h"
+#include "dawn_native/vulkan/BlendStateVk.h"
+#include "dawn_native/vulkan/BufferUploader.h"
+#include "dawn_native/vulkan/BufferVk.h"
+#include "dawn_native/vulkan/CommandBufferVk.h"
+#include "dawn_native/vulkan/ComputePipelineVk.h"
+#include "dawn_native/vulkan/DepthStencilStateVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+#include "dawn_native/vulkan/InputStateVk.h"
+#include "dawn_native/vulkan/NativeSwapChainImplVk.h"
+#include "dawn_native/vulkan/PipelineLayoutVk.h"
+#include "dawn_native/vulkan/QueueVk.h"
+#include "dawn_native/vulkan/RenderPassCache.h"
+#include "dawn_native/vulkan/RenderPassDescriptorVk.h"
+#include "dawn_native/vulkan/RenderPipelineVk.h"
+#include "dawn_native/vulkan/SamplerVk.h"
+#include "dawn_native/vulkan/ShaderModuleVk.h"
+#include "dawn_native/vulkan/SwapChainVk.h"
+#include "dawn_native/vulkan/TextureVk.h"
+
+#include <spirv-cross/spirv_cross.hpp>
+
+#include <iostream>
+
+#if DAWN_PLATFORM_LINUX
+const char kVulkanLibName[] = "libvulkan.so.1";
+#elif DAWN_PLATFORM_WINDOWS
+const char kVulkanLibName[] = "vulkan-1.dll";
+#else
+# error "Unimplemented Vulkan backend platform"
+#endif
+
+namespace dawn_native { namespace vulkan {
+
+ dawnDevice CreateDevice(const std::vector<const char*>& requiredInstanceExtensions) {
+ return reinterpret_cast<dawnDevice>(new Device(requiredInstanceExtensions));
+ }
+
+ VkInstance GetInstance(dawnDevice device) {
+ Device* backendDevice = reinterpret_cast<Device*>(device);
+ return backendDevice->GetInstance();
+ }
+
+ DAWN_NATIVE_EXPORT dawnSwapChainImplementation
+ CreateNativeSwapChainImpl(dawnDevice device, VkSurfaceKHRNative surfaceNative) {
+ Device* backendDevice = reinterpret_cast<Device*>(device);
+ VkSurfaceKHR surface = VkSurfaceKHR::CreateFromHandle(surfaceNative);
+
+ dawnSwapChainImplementation impl;
+ impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
+ impl.textureUsage = DAWN_TEXTURE_USAGE_BIT_PRESENT;
+
+ return impl;
+ }
+
+ dawnTextureFormat GetNativeSwapChainPreferredFormat(
+ const dawnSwapChainImplementation* swapChain) {
+ NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
+ return static_cast<dawnTextureFormat>(impl->GetPreferredFormat());
+ }
+
+ // Device
+
+ Device::Device(const std::vector<const char*>& requiredInstanceExtensions) {
+ if (!mVulkanLib.Open(kVulkanLibName)) {
+ ASSERT(false);
+ return;
+ }
+
+ VulkanFunctions* functions = GetMutableFunctions();
+
+ if (!functions->LoadGlobalProcs(mVulkanLib)) {
+ ASSERT(false);
+ return;
+ }
+
+ if (!GatherGlobalInfo(*this, &mGlobalInfo)) {
+ ASSERT(false);
+ return;
+ }
+
+ VulkanGlobalKnobs usedGlobalKnobs = {};
+ if (!CreateInstance(&usedGlobalKnobs, requiredInstanceExtensions)) {
+ ASSERT(false);
+ return;
+ }
+ *static_cast<VulkanGlobalKnobs*>(&mGlobalInfo) = usedGlobalKnobs;
+
+ if (!functions->LoadInstanceProcs(mInstance, usedGlobalKnobs)) {
+ ASSERT(false);
+ return;
+ }
+
+ if (usedGlobalKnobs.debugReport) {
+ if (!RegisterDebugReport()) {
+ ASSERT(false);
+ return;
+ }
+ }
+
+ std::vector<VkPhysicalDevice> physicalDevices;
+ if (!GetPhysicalDevices(*this, &physicalDevices) || physicalDevices.empty()) {
+ ASSERT(false);
+ return;
+ }
+ // TODO(cwallez@chromium.org): Choose the physical device based on ???
+ mPhysicalDevice = physicalDevices[0];
+
+ if (!GatherDeviceInfo(*this, mPhysicalDevice, &mDeviceInfo)) {
+ ASSERT(false);
+ return;
+ }
+
+ VulkanDeviceKnobs usedDeviceKnobs = {};
+ if (!CreateDevice(&usedDeviceKnobs)) {
+ ASSERT(false);
+ return;
+ }
+ *static_cast<VulkanDeviceKnobs*>(&mDeviceInfo) = usedDeviceKnobs;
+
+ if (!functions->LoadDeviceProcs(mVkDevice, usedDeviceKnobs)) {
+ ASSERT(false);
+ return;
+ }
+
+ GatherQueueFromDevice();
+
+ mBufferUploader = std::make_unique<BufferUploader>(this);
+ mDeleter = std::make_unique<FencedDeleter>(this);
+ mMapRequestTracker = std::make_unique<MapRequestTracker>(this);
+ mMemoryAllocator = std::make_unique<MemoryAllocator>(this);
+ mRenderPassCache = std::make_unique<RenderPassCache>(this);
+
+ mPCIInfo.deviceId = mDeviceInfo.properties.deviceID;
+ mPCIInfo.vendorId = mDeviceInfo.properties.vendorID;
+ mPCIInfo.name = mDeviceInfo.properties.deviceName;
+ }
+
+ Device::~Device() {
+ // Immediately forget about all pending commands so we don't try to submit them in Tick
+ FreeCommands(&mPendingCommands);
+
+ if (fn.QueueWaitIdle(mQueue) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ CheckPassedFences();
+ ASSERT(mFencesInFlight.empty());
+
+ // Some operations might have been started since the last submit and waiting
+ // on a serial that doesn't have a corresponding fence enqueued. Force all
+ // operations to look as if they were completed (because they were).
+ mCompletedSerial = mNextSerial;
+ Tick();
+
+ ASSERT(mCommandsInFlight.Empty());
+ for (auto& commands : mUnusedCommands) {
+ FreeCommands(&commands);
+ }
+ mUnusedCommands.clear();
+
+ ASSERT(mWaitSemaphores.empty());
+
+ for (VkFence fence : mUnusedFences) {
+ fn.DestroyFence(mVkDevice, fence, nullptr);
+ }
+ mUnusedFences.clear();
+
+ // Free services explicitly so that they can free Vulkan objects before vkDestroyDevice
+ mBufferUploader = nullptr;
+ mDeleter = nullptr;
+ mMapRequestTracker = nullptr;
+ mMemoryAllocator = nullptr;
+
+ // The VkRenderPasses in the cache can be destroyed immediately since all commands referring
+ // to them are guaranteed to be finished executing.
+ mRenderPassCache = nullptr;
+
+ // VkQueues are destroyed when the VkDevice is destroyed
+ if (mVkDevice != VK_NULL_HANDLE) {
+ fn.DestroyDevice(mVkDevice, nullptr);
+ mVkDevice = VK_NULL_HANDLE;
+ }
+
+ if (mDebugReportCallback != VK_NULL_HANDLE) {
+ fn.DestroyDebugReportCallbackEXT(mInstance, mDebugReportCallback, nullptr);
+ mDebugReportCallback = VK_NULL_HANDLE;
+ }
+
+ // VkPhysicalDevices are destroyed when the VkInstance is destroyed
+ if (mInstance != VK_NULL_HANDLE) {
+ fn.DestroyInstance(mInstance, nullptr);
+ mInstance = VK_NULL_HANDLE;
+ }
+ }
+
+ BindGroupBase* Device::CreateBindGroup(BindGroupBuilder* builder) {
+ return new BindGroup(builder);
+ }
+ ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) {
+ return new BindGroupLayout(this, descriptor);
+ }
+ BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
+ return new BlendState(builder);
+ }
+ ResultOrError<BufferBase*> Device::CreateBufferImpl(const BufferDescriptor* descriptor) {
+ return new Buffer(this, descriptor);
+ }
+ BufferViewBase* Device::CreateBufferView(BufferViewBuilder* builder) {
+ return new BufferView(builder);
+ }
+ CommandBufferBase* Device::CreateCommandBuffer(CommandBufferBuilder* builder) {
+ return new CommandBuffer(builder);
+ }
+ ResultOrError<ComputePipelineBase*> Device::CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) {
+ return new ComputePipeline(this, descriptor);
+ }
+ DepthStencilStateBase* Device::CreateDepthStencilState(DepthStencilStateBuilder* builder) {
+ return new DepthStencilState(builder);
+ }
+ InputStateBase* Device::CreateInputState(InputStateBuilder* builder) {
+ return new InputState(builder);
+ }
+ ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) {
+ return new PipelineLayout(this, descriptor);
+ }
+ ResultOrError<QueueBase*> Device::CreateQueueImpl() {
+ return new Queue(this);
+ }
+ RenderPassDescriptorBase* Device::CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) {
+ return new RenderPassDescriptor(builder);
+ }
+ RenderPipelineBase* Device::CreateRenderPipeline(RenderPipelineBuilder* builder) {
+ return new RenderPipeline(builder);
+ }
+ ResultOrError<SamplerBase*> Device::CreateSamplerImpl(const SamplerDescriptor* descriptor) {
+ return new Sampler(this, descriptor);
+ }
+ ResultOrError<ShaderModuleBase*> Device::CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) {
+ return new ShaderModule(this, descriptor);
+ }
+ SwapChainBase* Device::CreateSwapChain(SwapChainBuilder* builder) {
+ return new SwapChain(builder);
+ }
+ ResultOrError<TextureBase*> Device::CreateTextureImpl(const TextureDescriptor* descriptor) {
+ return new Texture(this, descriptor);
+ }
+
+ ResultOrError<TextureViewBase*> Device::CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) {
+ return new TextureView(texture, descriptor);
+ }
+
+ void Device::TickImpl() {
+ CheckPassedFences();
+ RecycleCompletedCommands();
+
+ mMapRequestTracker->Tick(mCompletedSerial);
+ mBufferUploader->Tick(mCompletedSerial);
+ mMemoryAllocator->Tick(mCompletedSerial);
+
+ mDeleter->Tick(mCompletedSerial);
+
+ if (mPendingCommands.pool != VK_NULL_HANDLE) {
+ SubmitPendingCommands();
+ } else if (mCompletedSerial == mNextSerial - 1) {
+ // If there's no GPU work in flight we still need to artificially increment the serial
+ // so that CPU operations waiting on GPU completion can know they don't have to wait.
+ mCompletedSerial++;
+ mNextSerial++;
+ }
+ }
+
+ const dawn_native::PCIInfo& Device::GetPCIInfo() const {
+ return mPCIInfo;
+ }
+
+ const VulkanDeviceInfo& Device::GetDeviceInfo() const {
+ return mDeviceInfo;
+ }
+
+ VkInstance Device::GetInstance() const {
+ return mInstance;
+ }
+
+ VkPhysicalDevice Device::GetPhysicalDevice() const {
+ return mPhysicalDevice;
+ }
+
+ VkDevice Device::GetVkDevice() const {
+ return mVkDevice;
+ }
+
+ uint32_t Device::GetGraphicsQueueFamily() const {
+ return mQueueFamily;
+ }
+
+ VkQueue Device::GetQueue() const {
+ return mQueue;
+ }
+
+ MapRequestTracker* Device::GetMapRequestTracker() const {
+ return mMapRequestTracker.get();
+ }
+
+ MemoryAllocator* Device::GetMemoryAllocator() const {
+ return mMemoryAllocator.get();
+ }
+
+ BufferUploader* Device::GetBufferUploader() const {
+ return mBufferUploader.get();
+ }
+
+ FencedDeleter* Device::GetFencedDeleter() const {
+ return mDeleter.get();
+ }
+
+ RenderPassCache* Device::GetRenderPassCache() const {
+ return mRenderPassCache.get();
+ }
+
+ Serial Device::GetSerial() const {
+ return mNextSerial;
+ }
+
+ VkCommandBuffer Device::GetPendingCommandBuffer() {
+ if (mPendingCommands.pool == VK_NULL_HANDLE) {
+ mPendingCommands = GetUnusedCommands();
+
+ VkCommandBufferBeginInfo beginInfo;
+ beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ beginInfo.pNext = nullptr;
+ beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
+ beginInfo.pInheritanceInfo = nullptr;
+
+ if (fn.BeginCommandBuffer(mPendingCommands.commandBuffer, &beginInfo) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ return mPendingCommands.commandBuffer;
+ }
+
+ void Device::SubmitPendingCommands() {
+ if (mPendingCommands.pool == VK_NULL_HANDLE) {
+ return;
+ }
+
+ if (fn.EndCommandBuffer(mPendingCommands.commandBuffer) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ std::vector<VkPipelineStageFlags> dstStageMasks(mWaitSemaphores.size(),
+ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
+
+ VkSubmitInfo submitInfo;
+ submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ submitInfo.pNext = nullptr;
+ submitInfo.waitSemaphoreCount = static_cast<uint32_t>(mWaitSemaphores.size());
+ submitInfo.pWaitSemaphores = mWaitSemaphores.data();
+ submitInfo.pWaitDstStageMask = dstStageMasks.data();
+ submitInfo.commandBufferCount = 1;
+ submitInfo.pCommandBuffers = &mPendingCommands.commandBuffer;
+ submitInfo.signalSemaphoreCount = 0;
+ submitInfo.pSignalSemaphores = 0;
+
+ VkFence fence = GetUnusedFence();
+ if (fn.QueueSubmit(mQueue, 1, &submitInfo, fence) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ mCommandsInFlight.Enqueue(mPendingCommands, mNextSerial);
+ mPendingCommands = CommandPoolAndBuffer();
+ mFencesInFlight.emplace(fence, mNextSerial);
+
+ for (VkSemaphore semaphore : mWaitSemaphores) {
+ mDeleter->DeleteWhenUnused(semaphore);
+ }
+ mWaitSemaphores.clear();
+
+ mNextSerial++;
+ }
+
+ void Device::AddWaitSemaphore(VkSemaphore semaphore) {
+ mWaitSemaphores.push_back(semaphore);
+ }
+
+ bool Device::CreateInstance(VulkanGlobalKnobs* usedKnobs,
+ const std::vector<const char*>& requiredExtensions) {
+ std::vector<const char*> layersToRequest;
+ std::vector<const char*> extensionsToRequest = requiredExtensions;
+
+ auto AddExtensionIfNotPresent = [](std::vector<const char*>* extensions,
+ const char* extension) {
+ for (const char* present : *extensions) {
+ if (strcmp(present, extension) == 0) {
+ return;
+ }
+ }
+ extensions->push_back(extension);
+ };
+
+ // vktrace works by instering a layer, but we hide it behind a macro due to the vktrace
+ // layer crashes when used without vktrace server started, see this vktrace issue:
+ // https://github.com/LunarG/VulkanTools/issues/254
+ // Also it is good to put it in first position so that it doesn't see Vulkan calls inserted
+ // by other layers.
+#if defined(DAWN_USE_VKTRACE)
+ if (mGlobalInfo.vktrace) {
+ layersToRequest.push_back(kLayerNameLunargVKTrace);
+ usedKnobs->vktrace = true;
+ }
+#endif
+ // RenderDoc installs a layer at the system level for its capture but we don't want to use
+ // it unless we are debugging in RenderDoc so we hide it behind a macro.
+#if defined(DAWN_USE_RENDERDOC)
+ if (mGlobalInfo.renderDocCapture) {
+ layersToRequest.push_back(kLayerNameRenderDocCapture);
+ usedKnobs->renderDocCapture = true;
+ }
+#endif
+#if defined(DAWN_ENABLE_ASSERTS)
+ if (mGlobalInfo.standardValidation) {
+ layersToRequest.push_back(kLayerNameLunargStandardValidation);
+ usedKnobs->standardValidation = true;
+ }
+ if (mGlobalInfo.debugReport) {
+ AddExtensionIfNotPresent(&extensionsToRequest, kExtensionNameExtDebugReport);
+ usedKnobs->debugReport = true;
+ }
+#endif
+ if (mGlobalInfo.surface) {
+ AddExtensionIfNotPresent(&extensionsToRequest, kExtensionNameKhrSurface);
+ usedKnobs->surface = true;
+ }
+
+ VkApplicationInfo appInfo;
+ appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
+ appInfo.pNext = nullptr;
+ appInfo.pApplicationName = nullptr;
+ appInfo.applicationVersion = 0;
+ appInfo.pEngineName = nullptr;
+ appInfo.engineVersion = 0;
+ appInfo.apiVersion = VK_API_VERSION_1_0;
+
+ VkInstanceCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.pApplicationInfo = &appInfo;
+ createInfo.enabledLayerCount = static_cast<uint32_t>(layersToRequest.size());
+ createInfo.ppEnabledLayerNames = layersToRequest.data();
+ createInfo.enabledExtensionCount = static_cast<uint32_t>(extensionsToRequest.size());
+ createInfo.ppEnabledExtensionNames = extensionsToRequest.data();
+
+ if (fn.CreateInstance(&createInfo, nullptr, &mInstance) != VK_SUCCESS) {
+ return false;
+ }
+
+ return true;
+ }
+
+ bool Device::CreateDevice(VulkanDeviceKnobs* usedKnobs) {
+ float zero = 0.0f;
+ std::vector<const char*> layersToRequest;
+ std::vector<const char*> extensionsToRequest;
+ std::vector<VkDeviceQueueCreateInfo> queuesToRequest;
+
+ if (mDeviceInfo.swapchain) {
+ extensionsToRequest.push_back(kExtensionNameKhrSwapchain);
+ usedKnobs->swapchain = true;
+ }
+
+ // Always require independentBlend because it is a core Dawn feature
+ usedKnobs->features.independentBlend = VK_TRUE;
+ // Always require imageCubeArray because it is a core Dawn feature
+ usedKnobs->features.imageCubeArray = VK_TRUE;
+
+ // Find a universal queue family
+ {
+ constexpr uint32_t kUniversalFlags =
+ VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT;
+ int universalQueueFamily = -1;
+ for (unsigned int i = 0; i < mDeviceInfo.queueFamilies.size(); ++i) {
+ if ((mDeviceInfo.queueFamilies[i].queueFlags & kUniversalFlags) ==
+ kUniversalFlags) {
+ universalQueueFamily = i;
+ break;
+ }
+ }
+
+ if (universalQueueFamily == -1) {
+ return false;
+ }
+ mQueueFamily = static_cast<uint32_t>(universalQueueFamily);
+ }
+
+ // Choose to create a single universal queue
+ {
+ VkDeviceQueueCreateInfo queueCreateInfo;
+ queueCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO;
+ queueCreateInfo.pNext = nullptr;
+ queueCreateInfo.flags = 0;
+ queueCreateInfo.queueFamilyIndex = static_cast<uint32_t>(mQueueFamily);
+ queueCreateInfo.queueCount = 1;
+ queueCreateInfo.pQueuePriorities = &zero;
+
+ queuesToRequest.push_back(queueCreateInfo);
+ }
+
+ VkDeviceCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.queueCreateInfoCount = static_cast<uint32_t>(queuesToRequest.size());
+ createInfo.pQueueCreateInfos = queuesToRequest.data();
+ createInfo.enabledLayerCount = static_cast<uint32_t>(layersToRequest.size());
+ createInfo.ppEnabledLayerNames = layersToRequest.data();
+ createInfo.enabledExtensionCount = static_cast<uint32_t>(extensionsToRequest.size());
+ createInfo.ppEnabledExtensionNames = extensionsToRequest.data();
+ createInfo.pEnabledFeatures = &usedKnobs->features;
+
+ if (fn.CreateDevice(mPhysicalDevice, &createInfo, nullptr, &mVkDevice) != VK_SUCCESS) {
+ return false;
+ }
+
+ return true;
+ }
+
+ void Device::GatherQueueFromDevice() {
+ fn.GetDeviceQueue(mVkDevice, mQueueFamily, 0, &mQueue);
+ }
+
+ bool Device::RegisterDebugReport() {
+ VkDebugReportCallbackCreateInfoEXT createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
+ createInfo.pNext = nullptr;
+ createInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
+ createInfo.pfnCallback = Device::OnDebugReportCallback;
+ createInfo.pUserData = this;
+
+ if (fn.CreateDebugReportCallbackEXT(mInstance, &createInfo, nullptr,
+ &mDebugReportCallback) != VK_SUCCESS) {
+ return false;
+ }
+
+ return true;
+ }
+
+ VKAPI_ATTR VkBool32 VKAPI_CALL
+ Device::OnDebugReportCallback(VkDebugReportFlagsEXT flags,
+ VkDebugReportObjectTypeEXT /*objectType*/,
+ uint64_t /*object*/,
+ size_t /*location*/,
+ int32_t /*messageCode*/,
+ const char* /*pLayerPrefix*/,
+ const char* pMessage,
+ void* /*pUserdata*/) {
+ std::cout << pMessage << std::endl;
+ ASSERT((flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) == 0);
+
+ return VK_FALSE;
+ }
+
+ VulkanFunctions* Device::GetMutableFunctions() {
+ return const_cast<VulkanFunctions*>(&fn);
+ }
+
+ VkFence Device::GetUnusedFence() {
+ if (!mUnusedFences.empty()) {
+ VkFence fence = mUnusedFences.back();
+ mUnusedFences.pop_back();
+ return fence;
+ }
+
+ VkFenceCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+
+ VkFence fence = VK_NULL_HANDLE;
+ if (fn.CreateFence(mVkDevice, &createInfo, nullptr, &fence) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ return fence;
+ }
+
+ void Device::CheckPassedFences() {
+ while (!mFencesInFlight.empty()) {
+ VkFence fence = mFencesInFlight.front().first;
+ Serial fenceSerial = mFencesInFlight.front().second;
+
+ VkResult result = fn.GetFenceStatus(mVkDevice, fence);
+ ASSERT(result == VK_SUCCESS || result == VK_NOT_READY);
+
+ // Fence are added in order, so we can stop searching as soon
+ // as we see one that's not ready.
+ if (result == VK_NOT_READY) {
+ return;
+ }
+
+ if (fn.ResetFences(mVkDevice, 1, &fence) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ mUnusedFences.push_back(fence);
+
+ mFencesInFlight.pop();
+
+ ASSERT(fenceSerial > mCompletedSerial);
+ mCompletedSerial = fenceSerial;
+ }
+ }
+
+ Device::CommandPoolAndBuffer Device::GetUnusedCommands() {
+ if (!mUnusedCommands.empty()) {
+ CommandPoolAndBuffer commands = mUnusedCommands.back();
+ mUnusedCommands.pop_back();
+ return commands;
+ }
+
+ CommandPoolAndBuffer commands;
+
+ VkCommandPoolCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
+ createInfo.queueFamilyIndex = mQueueFamily;
+
+ if (fn.CreateCommandPool(mVkDevice, &createInfo, nullptr, &commands.pool) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ VkCommandBufferAllocateInfo allocateInfo;
+ allocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+ allocateInfo.pNext = nullptr;
+ allocateInfo.commandPool = commands.pool;
+ allocateInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+ allocateInfo.commandBufferCount = 1;
+
+ if (fn.AllocateCommandBuffers(mVkDevice, &allocateInfo, &commands.commandBuffer) !=
+ VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ return commands;
+ }
+
+ void Device::RecycleCompletedCommands() {
+ for (auto& commands : mCommandsInFlight.IterateUpTo(mCompletedSerial)) {
+ if (fn.ResetCommandPool(mVkDevice, commands.pool, 0) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ mUnusedCommands.push_back(commands);
+ }
+ mCommandsInFlight.ClearUpTo(mCompletedSerial);
+ }
+
+ void Device::FreeCommands(CommandPoolAndBuffer* commands) {
+ if (commands->pool != VK_NULL_HANDLE) {
+ fn.DestroyCommandPool(mVkDevice, commands->pool, nullptr);
+ commands->pool = VK_NULL_HANDLE;
+ }
+
+ // Command buffers are implicitly destroyed when the command pool is.
+ commands->commandBuffer = VK_NULL_HANDLE;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/DeviceVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/DeviceVk.h
new file mode 100644
index 00000000000..c11427c2df3
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/DeviceVk.h
@@ -0,0 +1,168 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_DEVICEVK_H_
+#define DAWNNATIVE_VULKAN_DEVICEVK_H_
+
+#include "dawn_native/dawn_platform.h"
+
+#include "common/DynamicLib.h"
+#include "common/Serial.h"
+#include "common/SerialQueue.h"
+#include "dawn_native/Device.h"
+#include "dawn_native/vulkan/Forward.h"
+#include "dawn_native/vulkan/VulkanFunctions.h"
+#include "dawn_native/vulkan/VulkanInfo.h"
+
+#include <memory>
+#include <queue>
+
+namespace dawn_native { namespace vulkan {
+
+ class BufferUploader;
+ class FencedDeleter;
+ class MapRequestTracker;
+ class MemoryAllocator;
+ class RenderPassCache;
+
+ class Device : public DeviceBase {
+ public:
+ Device(const std::vector<const char*>& requiredInstanceExtensions);
+ ~Device();
+
+ // Contains all the Vulkan entry points, vkDoFoo is called via device->fn.DoFoo.
+ const VulkanFunctions fn;
+
+ const VulkanDeviceInfo& GetDeviceInfo() const;
+ VkInstance GetInstance() const;
+ VkPhysicalDevice GetPhysicalDevice() const;
+ VkDevice GetVkDevice() const;
+ uint32_t GetGraphicsQueueFamily() const;
+ VkQueue GetQueue() const;
+
+ BufferUploader* GetBufferUploader() const;
+ FencedDeleter* GetFencedDeleter() const;
+ MapRequestTracker* GetMapRequestTracker() const;
+ MemoryAllocator* GetMemoryAllocator() const;
+ RenderPassCache* GetRenderPassCache() const;
+
+ Serial GetSerial() const;
+
+ VkCommandBuffer GetPendingCommandBuffer();
+ void SubmitPendingCommands();
+ void AddWaitSemaphore(VkSemaphore semaphore);
+
+ // Dawn API
+ BindGroupBase* CreateBindGroup(BindGroupBuilder* builder) override;
+ BlendStateBase* CreateBlendState(BlendStateBuilder* builder) override;
+ BufferViewBase* CreateBufferView(BufferViewBuilder* builder) override;
+ CommandBufferBase* CreateCommandBuffer(CommandBufferBuilder* builder) override;
+ DepthStencilStateBase* CreateDepthStencilState(DepthStencilStateBuilder* builder) override;
+ InputStateBase* CreateInputState(InputStateBuilder* builder) override;
+ RenderPassDescriptorBase* CreateRenderPassDescriptor(
+ RenderPassDescriptorBuilder* builder) override;
+ RenderPipelineBase* CreateRenderPipeline(RenderPipelineBuilder* builder) override;
+ SwapChainBase* CreateSwapChain(SwapChainBuilder* builder) override;
+
+ void TickImpl() override;
+
+ const dawn_native::PCIInfo& GetPCIInfo() const override;
+
+ private:
+ ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
+ const BindGroupLayoutDescriptor* descriptor) override;
+ ResultOrError<BufferBase*> CreateBufferImpl(const BufferDescriptor* descriptor) override;
+ ResultOrError<ComputePipelineBase*> CreateComputePipelineImpl(
+ const ComputePipelineDescriptor* descriptor) override;
+ ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
+ const PipelineLayoutDescriptor* descriptor) override;
+ ResultOrError<QueueBase*> CreateQueueImpl() override;
+ ResultOrError<SamplerBase*> CreateSamplerImpl(const SamplerDescriptor* descriptor) override;
+ ResultOrError<ShaderModuleBase*> CreateShaderModuleImpl(
+ const ShaderModuleDescriptor* descriptor) override;
+ ResultOrError<TextureBase*> CreateTextureImpl(const TextureDescriptor* descriptor) override;
+ ResultOrError<TextureViewBase*> CreateTextureViewImpl(
+ TextureBase* texture,
+ const TextureViewDescriptor* descriptor) override;
+
+ bool CreateInstance(VulkanGlobalKnobs* usedKnobs,
+ const std::vector<const char*>& requiredExtensions);
+ bool CreateDevice(VulkanDeviceKnobs* usedKnobs);
+ void GatherQueueFromDevice();
+
+ bool RegisterDebugReport();
+ static VKAPI_ATTR VkBool32 VKAPI_CALL
+ OnDebugReportCallback(VkDebugReportFlagsEXT flags,
+ VkDebugReportObjectTypeEXT objectType,
+ uint64_t object,
+ size_t location,
+ int32_t messageCode,
+ const char* pLayerPrefix,
+ const char* pMessage,
+ void* pUserdata);
+
+ // To make it easier to use fn it is a public const member. However
+ // the Device is allowed to mutate them through these private methods.
+ VulkanFunctions* GetMutableFunctions();
+
+ VulkanGlobalInfo mGlobalInfo;
+ VulkanDeviceInfo mDeviceInfo;
+
+ DynamicLib mVulkanLib;
+
+ VkInstance mInstance = VK_NULL_HANDLE;
+ VkPhysicalDevice mPhysicalDevice = VK_NULL_HANDLE;
+ VkDevice mVkDevice = VK_NULL_HANDLE;
+ uint32_t mQueueFamily = 0;
+ VkQueue mQueue = VK_NULL_HANDLE;
+ VkDebugReportCallbackEXT mDebugReportCallback = VK_NULL_HANDLE;
+
+ std::unique_ptr<BufferUploader> mBufferUploader;
+ std::unique_ptr<FencedDeleter> mDeleter;
+ std::unique_ptr<MapRequestTracker> mMapRequestTracker;
+ std::unique_ptr<MemoryAllocator> mMemoryAllocator;
+ std::unique_ptr<RenderPassCache> mRenderPassCache;
+
+ VkFence GetUnusedFence();
+ void CheckPassedFences();
+
+ // We track which operations are in flight on the GPU with an increasing serial.
+ // This works only because we have a single queue. Each submit to a queue is associated
+ // to a serial and a fence, such that when the fence is "ready" we know the operations
+ // have finished.
+ std::queue<std::pair<VkFence, Serial>> mFencesInFlight;
+ std::vector<VkFence> mUnusedFences;
+ Serial mNextSerial = 1;
+ Serial mCompletedSerial = 0;
+
+ struct CommandPoolAndBuffer {
+ VkCommandPool pool = VK_NULL_HANDLE;
+ VkCommandBuffer commandBuffer = VK_NULL_HANDLE;
+ };
+
+ CommandPoolAndBuffer GetUnusedCommands();
+ void RecycleCompletedCommands();
+ void FreeCommands(CommandPoolAndBuffer* commands);
+
+ SerialQueue<CommandPoolAndBuffer> mCommandsInFlight;
+ std::vector<CommandPoolAndBuffer> mUnusedCommands;
+ CommandPoolAndBuffer mPendingCommands;
+ std::vector<VkSemaphore> mWaitSemaphores;
+
+ dawn_native::PCIInfo mPCIInfo;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_DEVICEVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/FencedDeleter.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/FencedDeleter.cpp
new file mode 100644
index 00000000000..6503f7334d5
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/FencedDeleter.cpp
@@ -0,0 +1,173 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/FencedDeleter.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ FencedDeleter::FencedDeleter(Device* device) : mDevice(device) {
+ }
+
+ FencedDeleter::~FencedDeleter() {
+ ASSERT(mBuffersToDelete.Empty());
+ ASSERT(mDescriptorPoolsToDelete.Empty());
+ ASSERT(mFramebuffersToDelete.Empty());
+ ASSERT(mImagesToDelete.Empty());
+ ASSERT(mImageViewsToDelete.Empty());
+ ASSERT(mMemoriesToDelete.Empty());
+ ASSERT(mPipelinesToDelete.Empty());
+ ASSERT(mPipelineLayoutsToDelete.Empty());
+ ASSERT(mRenderPassesToDelete.Empty());
+ ASSERT(mSamplersToDelete.Empty());
+ ASSERT(mSemaphoresToDelete.Empty());
+ ASSERT(mShaderModulesToDelete.Empty());
+ ASSERT(mSurfacesToDelete.Empty());
+ ASSERT(mSwapChainsToDelete.Empty());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkBuffer buffer) {
+ mBuffersToDelete.Enqueue(buffer, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkDescriptorPool pool) {
+ mDescriptorPoolsToDelete.Enqueue(pool, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkDeviceMemory memory) {
+ mMemoriesToDelete.Enqueue(memory, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkFramebuffer framebuffer) {
+ mFramebuffersToDelete.Enqueue(framebuffer, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkImage image) {
+ mImagesToDelete.Enqueue(image, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkImageView view) {
+ mImageViewsToDelete.Enqueue(view, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkPipeline pipeline) {
+ mPipelinesToDelete.Enqueue(pipeline, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkPipelineLayout layout) {
+ mPipelineLayoutsToDelete.Enqueue(layout, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkRenderPass renderPass) {
+ mRenderPassesToDelete.Enqueue(renderPass, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkSampler sampler) {
+ mSamplersToDelete.Enqueue(sampler, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkSemaphore semaphore) {
+ mSemaphoresToDelete.Enqueue(semaphore, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkShaderModule module) {
+ mShaderModulesToDelete.Enqueue(module, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkSurfaceKHR surface) {
+ mSurfacesToDelete.Enqueue(surface, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::DeleteWhenUnused(VkSwapchainKHR swapChain) {
+ mSwapChainsToDelete.Enqueue(swapChain, mDevice->GetSerial());
+ }
+
+ void FencedDeleter::Tick(Serial completedSerial) {
+ VkDevice vkDevice = mDevice->GetVkDevice();
+ VkInstance instance = mDevice->GetInstance();
+
+ // Buffers and images must be deleted before memories because it is invalid to free memory
+ // that still have resources bound to it.
+ for (VkBuffer buffer : mBuffersToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyBuffer(vkDevice, buffer, nullptr);
+ }
+ mBuffersToDelete.ClearUpTo(completedSerial);
+ for (VkImage image : mImagesToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyImage(vkDevice, image, nullptr);
+ }
+ mImagesToDelete.ClearUpTo(completedSerial);
+
+ for (VkDeviceMemory memory : mMemoriesToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.FreeMemory(vkDevice, memory, nullptr);
+ }
+ mMemoriesToDelete.ClearUpTo(completedSerial);
+
+ for (VkPipelineLayout layout : mPipelineLayoutsToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyPipelineLayout(vkDevice, layout, nullptr);
+ }
+ mPipelineLayoutsToDelete.ClearUpTo(completedSerial);
+
+ for (VkRenderPass renderPass : mRenderPassesToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyRenderPass(vkDevice, renderPass, nullptr);
+ }
+ mRenderPassesToDelete.ClearUpTo(completedSerial);
+
+ for (VkFramebuffer framebuffer : mFramebuffersToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyFramebuffer(vkDevice, framebuffer, nullptr);
+ }
+ mFramebuffersToDelete.ClearUpTo(completedSerial);
+
+ for (VkImageView view : mImageViewsToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyImageView(vkDevice, view, nullptr);
+ }
+ mImageViewsToDelete.ClearUpTo(completedSerial);
+
+ for (VkShaderModule module : mShaderModulesToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyShaderModule(vkDevice, module, nullptr);
+ }
+ mShaderModulesToDelete.ClearUpTo(completedSerial);
+
+ for (VkPipeline pipeline : mPipelinesToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyPipeline(vkDevice, pipeline, nullptr);
+ }
+ mPipelinesToDelete.ClearUpTo(completedSerial);
+
+ // Vulkan swapchains must be destroyed before their corresponding VkSurface
+ for (VkSwapchainKHR swapChain : mSwapChainsToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroySwapchainKHR(vkDevice, swapChain, nullptr);
+ }
+ mSwapChainsToDelete.ClearUpTo(completedSerial);
+ for (VkSurfaceKHR surface : mSurfacesToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroySurfaceKHR(instance, surface, nullptr);
+ }
+ mSurfacesToDelete.ClearUpTo(completedSerial);
+
+ for (VkSemaphore semaphore : mSemaphoresToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroySemaphore(vkDevice, semaphore, nullptr);
+ }
+ mSemaphoresToDelete.ClearUpTo(completedSerial);
+
+ for (VkDescriptorPool pool : mDescriptorPoolsToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroyDescriptorPool(vkDevice, pool, nullptr);
+ }
+ mDescriptorPoolsToDelete.ClearUpTo(completedSerial);
+
+ for (VkSampler sampler : mSamplersToDelete.IterateUpTo(completedSerial)) {
+ mDevice->fn.DestroySampler(vkDevice, sampler, nullptr);
+ }
+ mSamplersToDelete.ClearUpTo(completedSerial);
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/FencedDeleter.h b/chromium/third_party/dawn/src/dawn_native/vulkan/FencedDeleter.h
new file mode 100644
index 00000000000..7200eda94d6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/FencedDeleter.h
@@ -0,0 +1,67 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_FENCEDDELETER_H_
+#define DAWNNATIVE_VULKAN_FENCEDDELETER_H_
+
+#include "common/SerialQueue.h"
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class FencedDeleter {
+ public:
+ FencedDeleter(Device* device);
+ ~FencedDeleter();
+
+ void DeleteWhenUnused(VkBuffer buffer);
+ void DeleteWhenUnused(VkDescriptorPool pool);
+ void DeleteWhenUnused(VkDeviceMemory memory);
+ void DeleteWhenUnused(VkFramebuffer framebuffer);
+ void DeleteWhenUnused(VkImage image);
+ void DeleteWhenUnused(VkImageView view);
+ void DeleteWhenUnused(VkPipelineLayout layout);
+ void DeleteWhenUnused(VkRenderPass renderPass);
+ void DeleteWhenUnused(VkPipeline pipeline);
+ void DeleteWhenUnused(VkSampler sampler);
+ void DeleteWhenUnused(VkSemaphore semaphore);
+ void DeleteWhenUnused(VkShaderModule module);
+ void DeleteWhenUnused(VkSurfaceKHR surface);
+ void DeleteWhenUnused(VkSwapchainKHR swapChain);
+
+ void Tick(Serial completedSerial);
+
+ private:
+ Device* mDevice = nullptr;
+ SerialQueue<VkBuffer> mBuffersToDelete;
+ SerialQueue<VkDescriptorPool> mDescriptorPoolsToDelete;
+ SerialQueue<VkDeviceMemory> mMemoriesToDelete;
+ SerialQueue<VkFramebuffer> mFramebuffersToDelete;
+ SerialQueue<VkImage> mImagesToDelete;
+ SerialQueue<VkImageView> mImageViewsToDelete;
+ SerialQueue<VkPipeline> mPipelinesToDelete;
+ SerialQueue<VkPipelineLayout> mPipelineLayoutsToDelete;
+ SerialQueue<VkRenderPass> mRenderPassesToDelete;
+ SerialQueue<VkSampler> mSamplersToDelete;
+ SerialQueue<VkSemaphore> mSemaphoresToDelete;
+ SerialQueue<VkShaderModule> mShaderModulesToDelete;
+ SerialQueue<VkSurfaceKHR> mSurfacesToDelete;
+ SerialQueue<VkSwapchainKHR> mSwapChainsToDelete;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_FENCEDDELETER_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/Forward.h b/chromium/third_party/dawn/src/dawn_native/vulkan/Forward.h
new file mode 100644
index 00000000000..b89261ccfce
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/Forward.h
@@ -0,0 +1,75 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_FORWARD_H_
+#define DAWNNATIVE_VULKAN_FORWARD_H_
+
+#include "dawn_native/ToBackend.h"
+
+namespace dawn_native {
+ class BufferViewBase;
+}
+
+namespace dawn_native { namespace vulkan {
+
+ class BindGroup;
+ class BindGroupLayout;
+ class BlendState;
+ class Buffer;
+ using BufferView = BufferViewBase;
+ class CommandBuffer;
+ class ComputePipeline;
+ class DepthStencilState;
+ class Device;
+ class InputState;
+ class PipelineLayout;
+ class Queue;
+ class RenderPassDescriptor;
+ class RenderPipeline;
+ class Sampler;
+ class ShaderModule;
+ class SwapChain;
+ class Texture;
+ class TextureView;
+
+ struct VulkanBackendTraits {
+ using BindGroupType = BindGroup;
+ using BindGroupLayoutType = BindGroupLayout;
+ using BlendStateType = BlendState;
+ using BufferType = Buffer;
+ using BufferViewType = BufferView;
+ using CommandBufferType = CommandBuffer;
+ using ComputePipelineType = ComputePipeline;
+ using DepthStencilStateType = DepthStencilState;
+ using DeviceType = Device;
+ using InputStateType = InputState;
+ using PipelineLayoutType = PipelineLayout;
+ using QueueType = Queue;
+ using RenderPassDescriptorType = RenderPassDescriptor;
+ using RenderPipelineType = RenderPipeline;
+ using SamplerType = Sampler;
+ using ShaderModuleType = ShaderModule;
+ using SwapChainType = SwapChain;
+ using TextureType = Texture;
+ using TextureViewType = TextureView;
+ };
+
+ template <typename T>
+ auto ToBackend(T&& common) -> decltype(ToBackendBase<VulkanBackendTraits>(common)) {
+ return ToBackendBase<VulkanBackendTraits>(common);
+ }
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_FORWARD_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/InputStateVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/InputStateVk.cpp
new file mode 100644
index 00000000000..185270229c1
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/InputStateVk.cpp
@@ -0,0 +1,109 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/InputStateVk.h"
+
+#include "common/BitSetIterator.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+
+ VkVertexInputRate VulkanInputRate(dawn::InputStepMode stepMode) {
+ switch (stepMode) {
+ case dawn::InputStepMode::Vertex:
+ return VK_VERTEX_INPUT_RATE_VERTEX;
+ case dawn::InputStepMode::Instance:
+ return VK_VERTEX_INPUT_RATE_INSTANCE;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ VkFormat VulkanVertexFormat(dawn::VertexFormat format) {
+ switch (format) {
+ case dawn::VertexFormat::FloatR32G32B32A32:
+ return VK_FORMAT_R32G32B32A32_SFLOAT;
+ case dawn::VertexFormat::FloatR32G32B32:
+ return VK_FORMAT_R32G32B32_SFLOAT;
+ case dawn::VertexFormat::FloatR32G32:
+ return VK_FORMAT_R32G32_SFLOAT;
+ case dawn::VertexFormat::FloatR32:
+ return VK_FORMAT_R32_SFLOAT;
+ case dawn::VertexFormat::IntR32G32B32A32:
+ return VK_FORMAT_R32G32B32A32_SINT;
+ case dawn::VertexFormat::IntR32G32B32:
+ return VK_FORMAT_R32G32B32_SINT;
+ case dawn::VertexFormat::IntR32G32:
+ return VK_FORMAT_R32G32_SINT;
+ case dawn::VertexFormat::IntR32:
+ return VK_FORMAT_R32_SINT;
+ case dawn::VertexFormat::UshortR16G16B16A16:
+ return VK_FORMAT_R16G16B16A16_UINT;
+ case dawn::VertexFormat::UshortR16G16:
+ return VK_FORMAT_R16G16_UINT;
+ case dawn::VertexFormat::UnormR8G8B8A8:
+ return VK_FORMAT_R8G8B8A8_UNORM;
+ case dawn::VertexFormat::UnormR8G8:
+ return VK_FORMAT_R8G8_UNORM;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ } // anonymous namespace
+
+ InputState::InputState(InputStateBuilder* builder) : InputStateBase(builder) {
+ // Fill in the "binding info" that will be chained in the create info
+ uint32_t bindingCount = 0;
+ for (uint32_t i : IterateBitSet(GetInputsSetMask())) {
+ const auto& bindingInfo = GetInput(i);
+
+ auto& bindingDesc = mBindings[bindingCount];
+ bindingDesc.binding = i;
+ bindingDesc.stride = bindingInfo.stride;
+ bindingDesc.inputRate = VulkanInputRate(bindingInfo.stepMode);
+
+ bindingCount++;
+ }
+
+ // Fill in the "attribute info" that will be chained in the create info
+ uint32_t attributeCount = 0;
+ for (uint32_t i : IterateBitSet(GetAttributesSetMask())) {
+ const auto& attributeInfo = GetAttribute(i);
+
+ auto& attributeDesc = mAttributes[attributeCount];
+ attributeDesc.location = i;
+ attributeDesc.binding = attributeInfo.bindingSlot;
+ attributeDesc.format = VulkanVertexFormat(attributeInfo.format);
+ attributeDesc.offset = attributeInfo.offset;
+
+ attributeCount++;
+ }
+
+ // Build the create info
+ mCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
+ mCreateInfo.pNext = nullptr;
+ mCreateInfo.flags = 0;
+ mCreateInfo.vertexBindingDescriptionCount = bindingCount;
+ mCreateInfo.pVertexBindingDescriptions = mBindings.data();
+ mCreateInfo.vertexAttributeDescriptionCount = attributeCount;
+ mCreateInfo.pVertexAttributeDescriptions = mAttributes.data();
+ }
+
+ const VkPipelineVertexInputStateCreateInfo* InputState::GetCreateInfo() const {
+ return &mCreateInfo;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/InputStateVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/InputStateVk.h
new file mode 100644
index 00000000000..b44c08ad1cb
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/InputStateVk.h
@@ -0,0 +1,41 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_INPUTSTATEVK_H_
+#define DAWNNATIVE_VULKAN_INPUTSTATEVK_H_
+
+#include "dawn_native/InputState.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ // Pre-computes the input state configuration to give to a graphics pipeline create info.
+ class InputState : public InputStateBase {
+ public:
+ InputState(InputStateBuilder* builder);
+
+ const VkPipelineVertexInputStateCreateInfo* GetCreateInfo() const;
+
+ private:
+ VkPipelineVertexInputStateCreateInfo mCreateInfo;
+ std::array<VkVertexInputBindingDescription, kMaxVertexInputs> mBindings;
+ std::array<VkVertexInputAttributeDescription, kMaxVertexAttributes> mAttributes;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_INPUTSTATEVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/MemoryAllocator.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/MemoryAllocator.cpp
new file mode 100644
index 00000000000..3ab6c26d474
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/MemoryAllocator.cpp
@@ -0,0 +1,133 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/MemoryAllocator.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+
+namespace dawn_native { namespace vulkan {
+
+ DeviceMemoryAllocation::~DeviceMemoryAllocation() {
+ ASSERT(mMemory == VK_NULL_HANDLE);
+ }
+
+ VkDeviceMemory DeviceMemoryAllocation::GetMemory() const {
+ return mMemory;
+ }
+
+ size_t DeviceMemoryAllocation::GetMemoryOffset() const {
+ return mOffset;
+ }
+
+ uint8_t* DeviceMemoryAllocation::GetMappedPointer() const {
+ return mMappedPointer;
+ }
+
+ MemoryAllocator::MemoryAllocator(Device* device) : mDevice(device) {
+ }
+
+ MemoryAllocator::~MemoryAllocator() {
+ }
+
+ bool MemoryAllocator::Allocate(VkMemoryRequirements requirements,
+ bool mappable,
+ DeviceMemoryAllocation* allocation) {
+ const VulkanDeviceInfo& info = mDevice->GetDeviceInfo();
+
+ // Find a suitable memory type for this allocation
+ int bestType = -1;
+ for (size_t i = 0; i < info.memoryTypes.size(); ++i) {
+ // Resource must support this memory type
+ if ((requirements.memoryTypeBits & (1 << i)) == 0) {
+ continue;
+ }
+
+ // Mappable resource must be host visible
+ if (mappable &&
+ (info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0) {
+ continue;
+ }
+
+ // Found the first candidate memory type
+ if (bestType == -1) {
+ bestType = static_cast<int>(i);
+ continue;
+ }
+
+ // For non-mappable resources, favor device local memory.
+ if (!mappable) {
+ if ((info.memoryTypes[bestType].propertyFlags &
+ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == 0 &&
+ (info.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) !=
+ 0) {
+ bestType = static_cast<int>(i);
+ continue;
+ }
+ }
+
+ // All things equal favor the memory in the biggest heap
+ VkDeviceSize bestTypeHeapSize =
+ info.memoryHeaps[info.memoryTypes[bestType].heapIndex].size;
+ VkDeviceSize candidateHeapSize =
+ info.memoryHeaps[info.memoryTypes[bestType].heapIndex].size;
+ if (candidateHeapSize > bestTypeHeapSize) {
+ bestType = static_cast<int>(i);
+ continue;
+ }
+ }
+
+ // TODO(cwallez@chromium.org): I think the Vulkan spec guarantees this should never happen
+ if (bestType == -1) {
+ ASSERT(false);
+ return false;
+ }
+
+ VkMemoryAllocateInfo allocateInfo;
+ allocateInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
+ allocateInfo.pNext = nullptr;
+ allocateInfo.allocationSize = requirements.size;
+ allocateInfo.memoryTypeIndex = static_cast<uint32_t>(bestType);
+
+ VkDeviceMemory allocatedMemory = VK_NULL_HANDLE;
+ if (mDevice->fn.AllocateMemory(mDevice->GetVkDevice(), &allocateInfo, nullptr,
+ &allocatedMemory) != VK_SUCCESS) {
+ return false;
+ }
+
+ void* mappedPointer = nullptr;
+ if (mappable) {
+ if (mDevice->fn.MapMemory(mDevice->GetVkDevice(), allocatedMemory, 0, requirements.size,
+ 0, &mappedPointer) != VK_SUCCESS) {
+ return false;
+ }
+ }
+
+ allocation->mMemory = allocatedMemory;
+ allocation->mOffset = 0;
+ allocation->mMappedPointer = reinterpret_cast<uint8_t*>(mappedPointer);
+
+ return true;
+ }
+
+ void MemoryAllocator::Free(DeviceMemoryAllocation* allocation) {
+ mDevice->GetFencedDeleter()->DeleteWhenUnused(allocation->mMemory);
+ allocation->mMemory = VK_NULL_HANDLE;
+ allocation->mOffset = 0;
+ allocation->mMappedPointer = nullptr;
+ }
+
+ void MemoryAllocator::Tick(Serial) {
+ }
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/MemoryAllocator.h b/chromium/third_party/dawn/src/dawn_native/vulkan/MemoryAllocator.h
new file mode 100644
index 00000000000..afea7afc93f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/MemoryAllocator.h
@@ -0,0 +1,58 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_MEMORYALLOCATOR_H_
+#define DAWNNATIVE_VULKAN_MEMORYALLOCATOR_H_
+
+#include "common/SerialQueue.h"
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+ class MemoryAllocator;
+
+ class DeviceMemoryAllocation {
+ public:
+ ~DeviceMemoryAllocation();
+ VkDeviceMemory GetMemory() const;
+ size_t GetMemoryOffset() const;
+ uint8_t* GetMappedPointer() const;
+
+ private:
+ friend class MemoryAllocator;
+ VkDeviceMemory mMemory = VK_NULL_HANDLE;
+ size_t mOffset = 0;
+ uint8_t* mMappedPointer = nullptr;
+ };
+
+ class MemoryAllocator {
+ public:
+ MemoryAllocator(Device* device);
+ ~MemoryAllocator();
+
+ bool Allocate(VkMemoryRequirements requirements,
+ bool mappable,
+ DeviceMemoryAllocation* allocation);
+ void Free(DeviceMemoryAllocation* allocation);
+
+ void Tick(Serial finishedSerial);
+
+ private:
+ Device* mDevice = nullptr;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_MEMORYALLOCATOR_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/NativeSwapChainImplVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/NativeSwapChainImplVk.cpp
new file mode 100644
index 00000000000..a49aaffde9d
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/NativeSwapChainImplVk.cpp
@@ -0,0 +1,209 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/NativeSwapChainImplVk.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+#include "dawn_native/vulkan/TextureVk.h"
+
+#include <limits>
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+
+ bool ChooseSurfaceConfig(const VulkanSurfaceInfo& info,
+ NativeSwapChainImpl::ChosenConfig* config) {
+ // TODO(cwallez@chromium.org): For now this is hardcoded to what works with one NVIDIA
+ // driver. Need to generalize
+ config->nativeFormat = VK_FORMAT_B8G8R8A8_UNORM;
+ config->colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
+ config->format = dawn::TextureFormat::B8G8R8A8Unorm;
+ config->minImageCount = 3;
+ // TODO(cwallez@chromium.org): This is upside down compared to what we want, at least
+ // on Linux
+ config->preTransform = info.capabilities.currentTransform;
+ config->presentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
+ config->compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
+ return true;
+ }
+
+ } // anonymous namespace
+
+ NativeSwapChainImpl::NativeSwapChainImpl(Device* device, VkSurfaceKHR surface)
+ : mSurface(surface), mDevice(device) {
+ }
+
+ NativeSwapChainImpl::~NativeSwapChainImpl() {
+ if (mSwapChain != VK_NULL_HANDLE) {
+ mDevice->GetFencedDeleter()->DeleteWhenUnused(mSwapChain);
+ mSwapChain = VK_NULL_HANDLE;
+ }
+ if (mSurface != VK_NULL_HANDLE) {
+ mDevice->GetFencedDeleter()->DeleteWhenUnused(mSurface);
+ mSurface = VK_NULL_HANDLE;
+ }
+ }
+
+ void NativeSwapChainImpl::Init(dawnWSIContextVulkan* /*context*/) {
+ if (!GatherSurfaceInfo(*mDevice, mSurface, &mInfo)) {
+ ASSERT(false);
+ }
+
+ if (!ChooseSurfaceConfig(mInfo, &mConfig)) {
+ ASSERT(false);
+ }
+ }
+
+ dawnSwapChainError NativeSwapChainImpl::Configure(dawnTextureFormat format,
+ dawnTextureUsageBit usage,
+ uint32_t width,
+ uint32_t height) {
+ ASSERT(mInfo.capabilities.minImageExtent.width <= width);
+ ASSERT(mInfo.capabilities.maxImageExtent.width >= width);
+ ASSERT(mInfo.capabilities.minImageExtent.height <= height);
+ ASSERT(mInfo.capabilities.maxImageExtent.height >= height);
+
+ ASSERT(format == static_cast<dawnTextureFormat>(GetPreferredFormat()));
+ // TODO(cwallez@chromium.org): need to check usage works too
+
+ // Create the swapchain with the configuration we chose
+ VkSwapchainCreateInfoKHR createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.surface = mSurface;
+ createInfo.minImageCount = mConfig.minImageCount;
+ createInfo.imageFormat = mConfig.nativeFormat;
+ createInfo.imageColorSpace = mConfig.colorSpace;
+ createInfo.imageExtent.width = width;
+ createInfo.imageExtent.height = height;
+ createInfo.imageArrayLayers = 1;
+ createInfo.imageUsage =
+ VulkanImageUsage(static_cast<dawn::TextureUsageBit>(usage), mConfig.format);
+ createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ createInfo.queueFamilyIndexCount = 0;
+ createInfo.pQueueFamilyIndices = nullptr;
+ createInfo.preTransform = mConfig.preTransform;
+ createInfo.compositeAlpha = mConfig.compositeAlpha;
+ createInfo.presentMode = mConfig.presentMode;
+ createInfo.clipped = false;
+ createInfo.oldSwapchain = VK_NULL_HANDLE;
+
+ if (mDevice->fn.CreateSwapchainKHR(mDevice->GetVkDevice(), &createInfo, nullptr,
+ &mSwapChain) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ // Gather the swapchain's images. Implementations are allowed to return more images than the
+ // number we asked for.
+ uint32_t count = 0;
+ if (mDevice->fn.GetSwapchainImagesKHR(mDevice->GetVkDevice(), mSwapChain, &count,
+ nullptr) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ ASSERT(count >= mConfig.minImageCount);
+ mSwapChainImages.resize(count);
+ if (mDevice->fn.GetSwapchainImagesKHR(mDevice->GetVkDevice(), mSwapChain, &count,
+ mSwapChainImages.data()) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ // Do the initial layout transition for all these images from an undefined layout to
+ // present so that it matches the "present" usage after the first GetNextTexture.
+ VkCommandBuffer commands = mDevice->GetPendingCommandBuffer();
+ for (VkImage image : mSwapChainImages) {
+ VkImageMemoryBarrier barrier;
+ barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+ barrier.pNext = nullptr;
+ barrier.srcAccessMask = 0;
+ barrier.dstAccessMask = 0;
+ barrier.oldLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+ barrier.newLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
+ barrier.srcQueueFamilyIndex = 0;
+ barrier.dstQueueFamilyIndex = 0;
+ barrier.image = image;
+ barrier.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ barrier.subresourceRange.baseMipLevel = 0;
+ barrier.subresourceRange.levelCount = 1;
+ barrier.subresourceRange.baseArrayLayer = 0;
+ barrier.subresourceRange.layerCount = 1;
+
+ mDevice->fn.CmdPipelineBarrier(commands, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
+ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, 0, 0, nullptr, 0,
+ nullptr, 1, &barrier);
+ }
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError NativeSwapChainImpl::GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
+ // Transiently create a semaphore that will be signaled when the presentation engine is done
+ // with the swapchain image. Further operations on the image will wait for this semaphore.
+ VkSemaphore semaphore = VK_NULL_HANDLE;
+ {
+ VkSemaphoreCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ if (mDevice->fn.CreateSemaphore(mDevice->GetVkDevice(), &createInfo, nullptr,
+ &semaphore) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ if (mDevice->fn.AcquireNextImageKHR(mDevice->GetVkDevice(), mSwapChain,
+ std::numeric_limits<uint64_t>::max(), semaphore,
+ VK_NULL_HANDLE, &mLastImageIndex) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ nextTexture->texture.u64 = mSwapChainImages[mLastImageIndex].GetU64();
+ mDevice->AddWaitSemaphore(semaphore);
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError NativeSwapChainImpl::Present() {
+ // This assumes that the image has already been transitioned to the PRESENT layout and
+ // writes were made available to the stage.
+
+ // Assuming that the present queue is the same as the graphics queue, the proper
+ // synchronization has already been done on the queue so we don't need to wait on any
+ // semaphores.
+ VkPresentInfoKHR presentInfo;
+ presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ presentInfo.pNext = nullptr;
+ presentInfo.waitSemaphoreCount = 0;
+ presentInfo.pWaitSemaphores = nullptr;
+ presentInfo.swapchainCount = 1;
+ presentInfo.pSwapchains = &mSwapChain;
+ presentInfo.pImageIndices = &mLastImageIndex;
+ presentInfo.pResults = nullptr;
+
+ VkQueue queue = mDevice->GetQueue();
+ if (mDevice->fn.QueuePresentKHR(queue, &presentInfo) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
+ return mConfig.format;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/NativeSwapChainImplVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/NativeSwapChainImplVk.h
new file mode 100644
index 00000000000..114439afb3f
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/NativeSwapChainImplVk.h
@@ -0,0 +1,69 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_NATIVESWAPCHAINIMPLVK_H_
+#define DAWNNATIVE_VULKAN_NATIVESWAPCHAINIMPLVK_H_
+
+#include "dawn_native/vulkan/VulkanInfo.h"
+
+#include "dawn/dawn_wsi.h"
+#include "dawn_native/dawn_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class NativeSwapChainImpl {
+ public:
+ using WSIContext = dawnWSIContextVulkan;
+
+ NativeSwapChainImpl(Device* device, VkSurfaceKHR surface);
+ ~NativeSwapChainImpl();
+
+ void Init(dawnWSIContextVulkan* context);
+ dawnSwapChainError Configure(dawnTextureFormat format,
+ dawnTextureUsageBit,
+ uint32_t width,
+ uint32_t height);
+ dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
+ dawnSwapChainError Present();
+
+ dawn::TextureFormat GetPreferredFormat() const;
+
+ struct ChosenConfig {
+ VkFormat nativeFormat;
+ dawn::TextureFormat format;
+ VkColorSpaceKHR colorSpace;
+ VkSurfaceTransformFlagBitsKHR preTransform;
+ uint32_t minImageCount;
+ VkPresentModeKHR presentMode;
+ VkCompositeAlphaFlagBitsKHR compositeAlpha;
+ };
+
+ private:
+ VkSurfaceKHR mSurface = VK_NULL_HANDLE;
+ VkSwapchainKHR mSwapChain = VK_NULL_HANDLE;
+ std::vector<VkImage> mSwapChainImages;
+ uint32_t mLastImageIndex = 0;
+
+ VulkanSurfaceInfo mInfo;
+
+ ChosenConfig mConfig;
+
+ Device* mDevice = nullptr;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_NATIVESWAPCHAINIMPLVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/PipelineLayoutVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/PipelineLayoutVk.cpp
new file mode 100644
index 00000000000..3c4ad1bc17a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/PipelineLayoutVk.cpp
@@ -0,0 +1,70 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/PipelineLayoutVk.h"
+
+#include "dawn_native/vulkan/BindGroupLayoutVk.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+
+#include "common/BitSetIterator.h"
+
+namespace dawn_native { namespace vulkan {
+
+ PipelineLayout::PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor)
+ : PipelineLayoutBase(device, descriptor) {
+ // Compute the array of VkDescriptorSetLayouts that will be chained in the create info.
+ // TODO(cwallez@chromium.org) Vulkan doesn't allow holes in this array, should we expose
+ // this constraints at the Dawn level?
+ uint32_t numSetLayouts = 0;
+ std::array<VkDescriptorSetLayout, kMaxBindGroups> setLayouts;
+ for (uint32_t setIndex : IterateBitSet(GetBindGroupLayoutsMask())) {
+ setLayouts[numSetLayouts] = ToBackend(GetBindGroupLayout(setIndex))->GetHandle();
+ numSetLayouts++;
+ }
+
+ // Specify Dawn's push constant range on all pipeline layouts because we don't know which
+ // pipelines might use it.
+ VkPushConstantRange pushConstantRange;
+ pushConstantRange.stageFlags = VK_SHADER_STAGE_ALL;
+ pushConstantRange.offset = 0;
+ pushConstantRange.size = 4 * kMaxPushConstants;
+
+ VkPipelineLayoutCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.setLayoutCount = numSetLayouts;
+ createInfo.pSetLayouts = setLayouts.data();
+ createInfo.pushConstantRangeCount = 1;
+ createInfo.pPushConstantRanges = &pushConstantRange;
+
+ if (device->fn.CreatePipelineLayout(device->GetVkDevice(), &createInfo, nullptr,
+ &mHandle) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ PipelineLayout::~PipelineLayout() {
+ if (mHandle != VK_NULL_HANDLE) {
+ ToBackend(GetDevice())->GetFencedDeleter()->DeleteWhenUnused(mHandle);
+ mHandle = VK_NULL_HANDLE;
+ }
+ }
+
+ VkPipelineLayout PipelineLayout::GetHandle() const {
+ return mHandle;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/PipelineLayoutVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/PipelineLayoutVk.h
new file mode 100644
index 00000000000..a5072eb5722
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/PipelineLayoutVk.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_PIPELINELAYOUTVK_H_
+#define DAWNNATIVE_VULKAN_PIPELINELAYOUTVK_H_
+
+#include "dawn_native/PipelineLayout.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class PipelineLayout : public PipelineLayoutBase {
+ public:
+ PipelineLayout(Device* device, const PipelineLayoutDescriptor* descriptor);
+ ~PipelineLayout();
+
+ VkPipelineLayout GetHandle() const;
+
+ private:
+ VkPipelineLayout mHandle = VK_NULL_HANDLE;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_PIPELINELAYOUTVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/QueueVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/QueueVk.cpp
new file mode 100644
index 00000000000..e3de8b39649
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/QueueVk.cpp
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/QueueVk.h"
+
+#include "dawn_native/vulkan/CommandBufferVk.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ Queue::Queue(Device* device) : QueueBase(device) {
+ }
+
+ Queue::~Queue() {
+ }
+
+ void Queue::SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) {
+ Device* device = ToBackend(GetDevice());
+
+ VkCommandBuffer commandBuffer = device->GetPendingCommandBuffer();
+ for (uint32_t i = 0; i < numCommands; ++i) {
+ ToBackend(commands[i])->RecordCommands(commandBuffer);
+ }
+
+ device->SubmitPendingCommands();
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/QueueVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/QueueVk.h
new file mode 100644
index 00000000000..9fc6079a051
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/QueueVk.h
@@ -0,0 +1,36 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_QUEUEVK_H_
+#define DAWNNATIVE_VULKAN_QUEUEVK_H_
+
+#include "dawn_native/Queue.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class CommandBuffer;
+ class Device;
+
+ class Queue : public QueueBase {
+ public:
+ Queue(Device* device);
+ ~Queue();
+
+ private:
+ void SubmitImpl(uint32_t numCommands, CommandBufferBase* const* commands) override;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_QUEUEVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassCache.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassCache.cpp
new file mode 100644
index 00000000000..76e35f5d090
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassCache.cpp
@@ -0,0 +1,209 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/RenderPassCache.h"
+
+#include "common/BitSetIterator.h"
+#include "common/HashUtils.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/TextureVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+ VkAttachmentLoadOp VulkanAttachmentLoadOp(dawn::LoadOp op) {
+ switch (op) {
+ case dawn::LoadOp::Load:
+ return VK_ATTACHMENT_LOAD_OP_LOAD;
+ case dawn::LoadOp::Clear:
+ return VK_ATTACHMENT_LOAD_OP_CLEAR;
+ default:
+ UNREACHABLE();
+ }
+ }
+ } // anonymous namespace
+
+ // RenderPassCacheQuery
+
+ void RenderPassCacheQuery::SetColor(uint32_t index,
+ dawn::TextureFormat format,
+ dawn::LoadOp loadOp) {
+ colorMask.set(index);
+ colorFormats[index] = format;
+ colorLoadOp[index] = loadOp;
+ }
+
+ void RenderPassCacheQuery::SetDepthStencil(dawn::TextureFormat format,
+ dawn::LoadOp depthLoadOp,
+ dawn::LoadOp stencilLoadOp) {
+ hasDepthStencil = true;
+ depthStencilFormat = format;
+ this->depthLoadOp = depthLoadOp;
+ this->stencilLoadOp = stencilLoadOp;
+ }
+
+ // RenderPassCache
+
+ RenderPassCache::RenderPassCache(Device* device) : mDevice(device) {
+ }
+
+ RenderPassCache::~RenderPassCache() {
+ for (auto it : mCache) {
+ mDevice->fn.DestroyRenderPass(mDevice->GetVkDevice(), it.second, nullptr);
+ }
+ mCache.clear();
+ }
+
+ VkRenderPass RenderPassCache::GetRenderPass(const RenderPassCacheQuery& query) {
+ auto it = mCache.find(query);
+ if (it != mCache.end()) {
+ return it->second;
+ }
+
+ VkRenderPass renderPass = CreateRenderPassForQuery(query);
+ mCache.emplace(query, renderPass);
+ return renderPass;
+ }
+
+ VkRenderPass RenderPassCache::CreateRenderPassForQuery(
+ const RenderPassCacheQuery& query) const {
+ // The Vulkan subpasses want to know the layout of the attachments with VkAttachmentRef.
+ // Precompute them as they must be pointer-chained in VkSubpassDescription
+ std::array<VkAttachmentReference, kMaxColorAttachments + 1> attachmentRefs;
+
+ // Contains the attachment description that will be chained in the create info
+ std::array<VkAttachmentDescription, kMaxColorAttachments + 1> attachmentDescs = {};
+
+ uint32_t attachmentCount = 0;
+ for (uint32_t i : IterateBitSet(query.colorMask)) {
+ auto& attachmentRef = attachmentRefs[attachmentCount];
+ auto& attachmentDesc = attachmentDescs[attachmentCount];
+
+ attachmentRef.attachment = attachmentCount;
+ attachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+
+ attachmentDesc.flags = 0;
+ attachmentDesc.format = VulkanImageFormat(query.colorFormats[i]);
+ attachmentDesc.samples = VK_SAMPLE_COUNT_1_BIT;
+ attachmentDesc.loadOp = VulkanAttachmentLoadOp(query.colorLoadOp[i]);
+ attachmentDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+ attachmentDesc.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ attachmentDesc.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+
+ attachmentCount++;
+ }
+ uint32_t colorAttachmentCount = attachmentCount;
+
+ VkAttachmentReference* depthStencilAttachment = nullptr;
+ if (query.hasDepthStencil) {
+ auto& attachmentRef = attachmentRefs[attachmentCount];
+ auto& attachmentDesc = attachmentDescs[attachmentCount];
+
+ depthStencilAttachment = &attachmentRefs[attachmentCount];
+
+ attachmentRef.attachment = attachmentCount;
+ attachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+
+ attachmentDesc.flags = 0;
+ attachmentDesc.format = VulkanImageFormat(query.depthStencilFormat);
+ attachmentDesc.samples = VK_SAMPLE_COUNT_1_BIT;
+ attachmentDesc.loadOp = VulkanAttachmentLoadOp(query.depthLoadOp);
+ attachmentDesc.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+ attachmentDesc.stencilLoadOp = VulkanAttachmentLoadOp(query.stencilLoadOp);
+ attachmentDesc.stencilStoreOp = VK_ATTACHMENT_STORE_OP_STORE;
+ attachmentDesc.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ attachmentDesc.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+
+ attachmentCount++;
+ }
+
+ // Create the VkSubpassDescription that will be chained in the VkRenderPassCreateInfo
+ VkSubpassDescription subpassDesc;
+ subpassDesc.flags = 0;
+ subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
+ subpassDesc.inputAttachmentCount = 0;
+ subpassDesc.pInputAttachments = nullptr;
+ subpassDesc.colorAttachmentCount = colorAttachmentCount;
+ subpassDesc.pColorAttachments = attachmentRefs.data();
+ subpassDesc.pResolveAttachments = nullptr;
+ subpassDesc.pDepthStencilAttachment = depthStencilAttachment;
+ subpassDesc.preserveAttachmentCount = 0;
+ subpassDesc.pPreserveAttachments = nullptr;
+
+ // Chain everything in VkRenderPassCreateInfo
+ VkRenderPassCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.attachmentCount = attachmentCount;
+ createInfo.pAttachments = attachmentDescs.data();
+ createInfo.subpassCount = 1;
+ createInfo.pSubpasses = &subpassDesc;
+ createInfo.dependencyCount = 0;
+ createInfo.pDependencies = nullptr;
+
+ // Create the render pass from the zillion parameters
+ VkRenderPass renderPass;
+ if (mDevice->fn.CreateRenderPass(mDevice->GetVkDevice(), &createInfo, nullptr,
+ &renderPass) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ return renderPass;
+ }
+
+ // RenderPassCache
+
+ size_t RenderPassCache::CacheFuncs::operator()(const RenderPassCacheQuery& query) const {
+ size_t hash = Hash(query.colorMask);
+
+ for (uint32_t i : IterateBitSet(query.colorMask)) {
+ HashCombine(&hash, query.colorFormats[i], query.colorLoadOp[i]);
+ }
+
+ HashCombine(&hash, query.hasDepthStencil);
+ if (query.hasDepthStencil) {
+ HashCombine(&hash, query.depthStencilFormat, query.depthLoadOp, query.stencilLoadOp);
+ }
+
+ return hash;
+ }
+
+ bool RenderPassCache::CacheFuncs::operator()(const RenderPassCacheQuery& a,
+ const RenderPassCacheQuery& b) const {
+ if (a.colorMask != b.colorMask) {
+ return false;
+ }
+
+ for (uint32_t i : IterateBitSet(a.colorMask)) {
+ if ((a.colorFormats[i] != b.colorFormats[i]) ||
+ (a.colorLoadOp[i] != b.colorLoadOp[i])) {
+ return false;
+ }
+ }
+
+ if (a.hasDepthStencil != b.hasDepthStencil) {
+ return false;
+ }
+
+ if (a.hasDepthStencil) {
+ if ((a.depthStencilFormat != b.depthStencilFormat) ||
+ (a.depthLoadOp != b.depthLoadOp) || (a.stencilLoadOp != b.stencilLoadOp)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassCache.h b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassCache.h
new file mode 100644
index 00000000000..9f678a5a46a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassCache.h
@@ -0,0 +1,81 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_RENDERPASSCACHE_H_
+#define DAWNNATIVE_VULKAN_RENDERPASSCACHE_H_
+
+#include "common/vulkan_platform.h"
+
+#include "common/Constants.h"
+#include "dawn_native/dawn_platform.h"
+
+#include <array>
+#include <bitset>
+#include <unordered_map>
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ // This is a key to query the RenderPassCache, it can be sparse meaning that only the
+ // information for bits set in colorMask or hasDepthStencil need to be provided and the rest can
+ // be uninintialized.
+ struct RenderPassCacheQuery {
+ // Use these helpers to build the query, they make sure all relevant data is initialized and
+ // masks set.
+ void SetColor(uint32_t index, dawn::TextureFormat format, dawn::LoadOp loadOp);
+ void SetDepthStencil(dawn::TextureFormat format,
+ dawn::LoadOp depthLoadOp,
+ dawn::LoadOp stencilLoadOp);
+
+ std::bitset<kMaxColorAttachments> colorMask;
+ std::array<dawn::TextureFormat, kMaxColorAttachments> colorFormats;
+ std::array<dawn::LoadOp, kMaxColorAttachments> colorLoadOp;
+
+ bool hasDepthStencil = false;
+ dawn::TextureFormat depthStencilFormat;
+ dawn::LoadOp depthLoadOp;
+ dawn::LoadOp stencilLoadOp;
+ };
+
+ // Caches VkRenderPasses so that we don't create duplicate ones for every RenderPipeline or
+ // render pass.
+ // TODO(cwallez@chromium.org): Make it an LRU cache somehow?
+ class RenderPassCache {
+ public:
+ RenderPassCache(Device* device);
+ ~RenderPassCache();
+
+ VkRenderPass GetRenderPass(const RenderPassCacheQuery& query);
+
+ private:
+ // Does the actual VkRenderPass creation on a cache miss.
+ VkRenderPass CreateRenderPassForQuery(const RenderPassCacheQuery& query) const;
+
+ // Implements the functors necessary for to use RenderPassCacheQueries as unordered_map
+ // keys.
+ struct CacheFuncs {
+ size_t operator()(const RenderPassCacheQuery& query) const;
+ bool operator()(const RenderPassCacheQuery& a, const RenderPassCacheQuery& b) const;
+ };
+ using Cache =
+ std::unordered_map<RenderPassCacheQuery, VkRenderPass, CacheFuncs, CacheFuncs>;
+
+ Device* mDevice = nullptr;
+ Cache mCache;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_RENDERPASSCACHE_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassDescriptorVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassDescriptorVk.cpp
new file mode 100644
index 00000000000..a0f6d3540a7
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassDescriptorVk.cpp
@@ -0,0 +1,122 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/RenderPassDescriptorVk.h"
+
+#include "common/BitSetIterator.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+#include "dawn_native/vulkan/RenderPassCache.h"
+#include "dawn_native/vulkan/TextureVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ RenderPassDescriptor::RenderPassDescriptor(RenderPassDescriptorBuilder* builder)
+ : RenderPassDescriptorBase(builder), mDevice(ToBackend(builder->GetDevice())) {
+ }
+
+ void RenderPassDescriptor::RecordBeginRenderPass(VkCommandBuffer commands) {
+ // Query a VkRenderPass from the cache
+ VkRenderPass renderPass = VK_NULL_HANDLE;
+ {
+ RenderPassCacheQuery query;
+
+ for (uint32_t i : IterateBitSet(GetColorAttachmentMask())) {
+ const auto& attachmentInfo = GetColorAttachment(i);
+ query.SetColor(i, attachmentInfo.view->GetTexture()->GetFormat(),
+ attachmentInfo.loadOp);
+ }
+
+ if (HasDepthStencilAttachment()) {
+ const auto& attachmentInfo = GetDepthStencilAttachment();
+ query.SetDepthStencil(attachmentInfo.view->GetTexture()->GetFormat(),
+ attachmentInfo.depthLoadOp, attachmentInfo.stencilLoadOp);
+ }
+
+ renderPass = mDevice->GetRenderPassCache()->GetRenderPass(query);
+ }
+
+ // Create a framebuffer that will be used once for the render pass and gather the clear
+ // values for the attachments at the same time.
+ std::array<VkClearValue, kMaxColorAttachments + 1> clearValues;
+ VkFramebuffer framebuffer = VK_NULL_HANDLE;
+ uint32_t attachmentCount = 0;
+ {
+ // Fill in the attachment info that will be chained in the framebuffer create info.
+ std::array<VkImageView, kMaxColorAttachments + 1> attachments;
+
+ for (uint32_t i : IterateBitSet(GetColorAttachmentMask())) {
+ auto& attachmentInfo = GetColorAttachment(i);
+ TextureView* view = ToBackend(attachmentInfo.view.Get());
+
+ attachments[attachmentCount] = view->GetHandle();
+
+ clearValues[attachmentCount].color.float32[0] = attachmentInfo.clearColor[0];
+ clearValues[attachmentCount].color.float32[1] = attachmentInfo.clearColor[1];
+ clearValues[attachmentCount].color.float32[2] = attachmentInfo.clearColor[2];
+ clearValues[attachmentCount].color.float32[3] = attachmentInfo.clearColor[3];
+
+ attachmentCount++;
+ }
+
+ if (HasDepthStencilAttachment()) {
+ auto& attachmentInfo = GetDepthStencilAttachment();
+ TextureView* view = ToBackend(attachmentInfo.view.Get());
+
+ attachments[attachmentCount] = view->GetHandle();
+
+ clearValues[attachmentCount].depthStencil.depth = attachmentInfo.clearDepth;
+ clearValues[attachmentCount].depthStencil.stencil = attachmentInfo.clearStencil;
+
+ attachmentCount++;
+ }
+
+ // Chain attachments and create the framebuffer
+ VkFramebufferCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.renderPass = renderPass;
+ createInfo.attachmentCount = attachmentCount;
+ createInfo.pAttachments = attachments.data();
+ createInfo.width = GetWidth();
+ createInfo.height = GetHeight();
+ createInfo.layers = 1;
+
+ if (mDevice->fn.CreateFramebuffer(mDevice->GetVkDevice(), &createInfo, nullptr,
+ &framebuffer) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ // We don't reuse VkFramebuffers so mark the framebuffer for deletion as soon as the
+ // commands currently being recorded are finished.
+ mDevice->GetFencedDeleter()->DeleteWhenUnused(framebuffer);
+ }
+
+ VkRenderPassBeginInfo beginInfo;
+ beginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+ beginInfo.pNext = nullptr;
+ beginInfo.renderPass = renderPass;
+ beginInfo.framebuffer = framebuffer;
+ beginInfo.renderArea.offset.x = 0;
+ beginInfo.renderArea.offset.y = 0;
+ beginInfo.renderArea.extent.width = GetWidth();
+ beginInfo.renderArea.extent.height = GetHeight();
+ beginInfo.clearValueCount = attachmentCount;
+ beginInfo.pClearValues = clearValues.data();
+
+ mDevice->fn.CmdBeginRenderPass(commands, &beginInfo, VK_SUBPASS_CONTENTS_INLINE);
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassDescriptorVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassDescriptorVk.h
new file mode 100644
index 00000000000..07b65b63a47
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPassDescriptorVk.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_RENDERPASSDESCRIPTORVK_H_
+#define DAWNNATIVE_VULKAN_RENDERPASSDESCRIPTORVK_H_
+
+#include "dawn_native/RenderPassDescriptor.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class RenderPassDescriptor : public RenderPassDescriptorBase {
+ public:
+ RenderPassDescriptor(RenderPassDescriptorBuilder* builder);
+
+ // Compute all the arguments for, and record the vkCmdBeginRenderPass command.
+ void RecordBeginRenderPass(VkCommandBuffer commands);
+
+ private:
+ Device* mDevice = nullptr;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_RENDERPASSDESCRIPTORVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPipelineVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPipelineVk.cpp
new file mode 100644
index 00000000000..6c8f65331ce
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPipelineVk.cpp
@@ -0,0 +1,229 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/RenderPipelineVk.h"
+
+#include "dawn_native/vulkan/BlendStateVk.h"
+#include "dawn_native/vulkan/DepthStencilStateVk.h"
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+#include "dawn_native/vulkan/InputStateVk.h"
+#include "dawn_native/vulkan/PipelineLayoutVk.h"
+#include "dawn_native/vulkan/RenderPassCache.h"
+#include "dawn_native/vulkan/RenderPassDescriptorVk.h"
+#include "dawn_native/vulkan/ShaderModuleVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+
+ VkPrimitiveTopology VulkanPrimitiveTopology(dawn::PrimitiveTopology topology) {
+ switch (topology) {
+ case dawn::PrimitiveTopology::PointList:
+ return VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
+ case dawn::PrimitiveTopology::LineList:
+ return VK_PRIMITIVE_TOPOLOGY_LINE_LIST;
+ case dawn::PrimitiveTopology::LineStrip:
+ return VK_PRIMITIVE_TOPOLOGY_LINE_STRIP;
+ case dawn::PrimitiveTopology::TriangleList:
+ return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
+ case dawn::PrimitiveTopology::TriangleStrip:
+ return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ } // anonymous namespace
+
+ RenderPipeline::RenderPipeline(RenderPipelineBuilder* builder)
+ : RenderPipelineBase(builder), mDevice(ToBackend(builder->GetDevice())) {
+ // Eventually a bunch of the structures that need to be chained in the create info will be
+ // held by objects such as the BlendState. They aren't implemented yet so we initialize
+ // everything here.
+
+ VkPipelineShaderStageCreateInfo shaderStages[2];
+ {
+ const auto& vertexStageInfo = builder->GetStageInfo(dawn::ShaderStage::Vertex);
+ const auto& fragmentStageInfo = builder->GetStageInfo(dawn::ShaderStage::Fragment);
+
+ shaderStages[0].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+ shaderStages[0].pNext = nullptr;
+ shaderStages[0].flags = 0;
+ shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
+ shaderStages[0].module = ToBackend(vertexStageInfo.module)->GetHandle();
+ shaderStages[0].pName = vertexStageInfo.entryPoint.c_str();
+ shaderStages[0].pSpecializationInfo = nullptr;
+
+ shaderStages[1].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+ shaderStages[1].pNext = nullptr;
+ shaderStages[1].flags = 0;
+ shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
+ shaderStages[1].module = ToBackend(fragmentStageInfo.module)->GetHandle();
+ shaderStages[1].pName = fragmentStageInfo.entryPoint.c_str();
+ shaderStages[1].pSpecializationInfo = nullptr;
+ }
+
+ VkPipelineInputAssemblyStateCreateInfo inputAssembly;
+ inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
+ inputAssembly.pNext = nullptr;
+ inputAssembly.flags = 0;
+ inputAssembly.topology = VulkanPrimitiveTopology(GetPrimitiveTopology());
+ // Primitive restart is always enabled in Dawn (because of Metal)
+ inputAssembly.primitiveRestartEnable = VK_TRUE;
+
+ // A dummy viewport/scissor info. The validation layers force use to provide at least one
+ // scissor and one viewport here, even if we choose to make them dynamic.
+ VkViewport viewportDesc;
+ viewportDesc.x = 0.0f;
+ viewportDesc.y = 0.0f;
+ viewportDesc.width = 1.0f;
+ viewportDesc.height = 1.0f;
+ viewportDesc.minDepth = 0.0f;
+ viewportDesc.maxDepth = 1.0f;
+ VkRect2D scissorRect;
+ scissorRect.offset.x = 0;
+ scissorRect.offset.y = 0;
+ scissorRect.extent.width = 1;
+ scissorRect.extent.height = 1;
+ VkPipelineViewportStateCreateInfo viewport;
+ viewport.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
+ viewport.pNext = nullptr;
+ viewport.flags = 0;
+ viewport.viewportCount = 1;
+ viewport.pViewports = &viewportDesc;
+ viewport.scissorCount = 1;
+ viewport.pScissors = &scissorRect;
+
+ VkPipelineRasterizationStateCreateInfo rasterization;
+ rasterization.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
+ rasterization.pNext = nullptr;
+ rasterization.flags = 0;
+ rasterization.depthClampEnable = VK_FALSE;
+ rasterization.rasterizerDiscardEnable = VK_FALSE;
+ rasterization.polygonMode = VK_POLYGON_MODE_FILL;
+ rasterization.cullMode = VK_CULL_MODE_NONE;
+ rasterization.frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE;
+ rasterization.depthBiasEnable = VK_FALSE;
+ rasterization.depthBiasConstantFactor = 0.0f;
+ rasterization.depthBiasClamp = 0.0f;
+ rasterization.depthBiasSlopeFactor = 0.0f;
+ rasterization.lineWidth = 1.0f;
+
+ VkPipelineMultisampleStateCreateInfo multisample;
+ multisample.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
+ multisample.pNext = nullptr;
+ multisample.flags = 0;
+ multisample.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
+ multisample.sampleShadingEnable = VK_FALSE;
+ multisample.minSampleShading = 0.0f;
+ multisample.pSampleMask = nullptr;
+ multisample.alphaToCoverageEnable = VK_FALSE;
+ multisample.alphaToOneEnable = VK_FALSE;
+
+ // Initialize the "blend state info" that will be chained in the "create info" from the data
+ // pre-computed in the BlendState
+ std::array<VkPipelineColorBlendAttachmentState, kMaxColorAttachments> colorBlendAttachments;
+ for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) {
+ colorBlendAttachments[i] = ToBackend(GetBlendState(i))->GetState();
+ }
+ VkPipelineColorBlendStateCreateInfo colorBlend;
+ colorBlend.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
+ colorBlend.pNext = nullptr;
+ colorBlend.flags = 0;
+ // LogicOp isn't supported so we disable it.
+ colorBlend.logicOpEnable = VK_FALSE;
+ colorBlend.logicOp = VK_LOGIC_OP_CLEAR;
+ // TODO(cwallez@chromium.org): Do we allow holes in the color attachments?
+ colorBlend.attachmentCount = static_cast<uint32_t>(GetColorAttachmentsMask().count());
+ colorBlend.pAttachments = colorBlendAttachments.data();
+ // The blend constant is always dynamic so we fill in a dummy value
+ colorBlend.blendConstants[0] = 0.0f;
+ colorBlend.blendConstants[1] = 0.0f;
+ colorBlend.blendConstants[2] = 0.0f;
+ colorBlend.blendConstants[3] = 0.0f;
+
+ // Tag all state as dynamic but stencil masks.
+ VkDynamicState dynamicStates[] = {
+ VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR,
+ VK_DYNAMIC_STATE_LINE_WIDTH, VK_DYNAMIC_STATE_DEPTH_BIAS,
+ VK_DYNAMIC_STATE_BLEND_CONSTANTS, VK_DYNAMIC_STATE_DEPTH_BOUNDS,
+ VK_DYNAMIC_STATE_STENCIL_REFERENCE,
+ };
+ VkPipelineDynamicStateCreateInfo dynamic;
+ dynamic.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
+ dynamic.pNext = nullptr;
+ dynamic.flags = 0;
+ dynamic.dynamicStateCount = sizeof(dynamicStates) / sizeof(dynamicStates[0]);
+ dynamic.pDynamicStates = dynamicStates;
+
+ // Get a VkRenderPass that matches the attachment formats for this pipeline, load ops don't
+ // matter so set them all to LoadOp::Load
+ VkRenderPass renderPass = VK_NULL_HANDLE;
+ {
+ RenderPassCacheQuery query;
+
+ for (uint32_t i : IterateBitSet(GetColorAttachmentsMask())) {
+ query.SetColor(i, GetColorAttachmentFormat(i), dawn::LoadOp::Load);
+ }
+
+ if (HasDepthStencilAttachment()) {
+ query.SetDepthStencil(GetDepthStencilFormat(), dawn::LoadOp::Load,
+ dawn::LoadOp::Load);
+ }
+
+ renderPass = mDevice->GetRenderPassCache()->GetRenderPass(query);
+ }
+
+ // The create info chains in a bunch of things created on the stack here or inside state
+ // objects.
+ VkGraphicsPipelineCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.stageCount = 2;
+ createInfo.pStages = shaderStages;
+ createInfo.pVertexInputState = ToBackend(GetInputState())->GetCreateInfo();
+ createInfo.pInputAssemblyState = &inputAssembly;
+ createInfo.pTessellationState = nullptr;
+ createInfo.pViewportState = &viewport;
+ createInfo.pRasterizationState = &rasterization;
+ createInfo.pMultisampleState = &multisample;
+ createInfo.pDepthStencilState = ToBackend(GetDepthStencilState())->GetCreateInfo();
+ createInfo.pColorBlendState = &colorBlend;
+ createInfo.pDynamicState = &dynamic;
+ createInfo.layout = ToBackend(GetLayout())->GetHandle();
+ createInfo.renderPass = renderPass;
+ createInfo.subpass = 0;
+ createInfo.basePipelineHandle = VK_NULL_HANDLE;
+ createInfo.basePipelineIndex = -1;
+
+ if (mDevice->fn.CreateGraphicsPipelines(mDevice->GetVkDevice(), VK_NULL_HANDLE, 1,
+ &createInfo, nullptr, &mHandle) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ RenderPipeline::~RenderPipeline() {
+ if (mHandle != VK_NULL_HANDLE) {
+ mDevice->GetFencedDeleter()->DeleteWhenUnused(mHandle);
+ mHandle = VK_NULL_HANDLE;
+ }
+ }
+
+ VkPipeline RenderPipeline::GetHandle() const {
+ return mHandle;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPipelineVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPipelineVk.h
new file mode 100644
index 00000000000..e43676e7577
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/RenderPipelineVk.h
@@ -0,0 +1,40 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_RENDERPIPELINEVK_H_
+#define DAWNNATIVE_VULKAN_RENDERPIPELINEVK_H_
+
+#include "dawn_native/RenderPipeline.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class RenderPipeline : public RenderPipelineBase {
+ public:
+ RenderPipeline(RenderPipelineBuilder* builder);
+ ~RenderPipeline();
+
+ VkPipeline GetHandle() const;
+
+ private:
+ VkPipeline mHandle = VK_NULL_HANDLE;
+ Device* mDevice = nullptr;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_RENDERPIPELINEVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/SamplerVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/SamplerVk.cpp
new file mode 100644
index 00000000000..d54f358b0d9
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/SamplerVk.cpp
@@ -0,0 +1,98 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/SamplerVk.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+ VkSamplerAddressMode VulkanSamplerAddressMode(dawn::AddressMode mode) {
+ switch (mode) {
+ case dawn::AddressMode::Repeat:
+ return VK_SAMPLER_ADDRESS_MODE_REPEAT;
+ case dawn::AddressMode::MirroredRepeat:
+ return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT;
+ case dawn::AddressMode::ClampToEdge:
+ return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ VkFilter VulkanSamplerFilter(dawn::FilterMode filter) {
+ switch (filter) {
+ case dawn::FilterMode::Linear:
+ return VK_FILTER_LINEAR;
+ case dawn::FilterMode::Nearest:
+ return VK_FILTER_NEAREST;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ VkSamplerMipmapMode VulkanMipMapMode(dawn::FilterMode filter) {
+ switch (filter) {
+ case dawn::FilterMode::Linear:
+ return VK_SAMPLER_MIPMAP_MODE_LINEAR;
+ case dawn::FilterMode::Nearest:
+ return VK_SAMPLER_MIPMAP_MODE_NEAREST;
+ default:
+ UNREACHABLE();
+ }
+ }
+ } // anonymous namespace
+
+ Sampler::Sampler(Device* device, const SamplerDescriptor* descriptor)
+ : SamplerBase(device, descriptor), mDevice(device) {
+ VkSamplerCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.magFilter = VulkanSamplerFilter(descriptor->magFilter);
+ createInfo.minFilter = VulkanSamplerFilter(descriptor->minFilter);
+ createInfo.mipmapMode = VulkanMipMapMode(descriptor->mipmapFilter);
+ createInfo.addressModeU = VulkanSamplerAddressMode(descriptor->addressModeU);
+ createInfo.addressModeV = VulkanSamplerAddressMode(descriptor->addressModeV);
+ createInfo.addressModeW = VulkanSamplerAddressMode(descriptor->addressModeW);
+ createInfo.mipLodBias = 0.0f;
+ createInfo.anisotropyEnable = VK_FALSE;
+ createInfo.maxAnisotropy = 1.0f;
+ createInfo.compareEnable = VK_FALSE;
+ createInfo.compareOp = VK_COMPARE_OP_NEVER;
+ createInfo.minLod = 0.0f;
+ createInfo.maxLod = 1000.0f;
+ createInfo.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
+ createInfo.unnormalizedCoordinates = VK_FALSE;
+
+ if (device->fn.CreateSampler(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
+ VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ Sampler::~Sampler() {
+ if (mHandle != VK_NULL_HANDLE) {
+ mDevice->GetFencedDeleter()->DeleteWhenUnused(mHandle);
+ mHandle = VK_NULL_HANDLE;
+ }
+ }
+
+ VkSampler Sampler::GetHandle() const {
+ return mHandle;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/SamplerVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/SamplerVk.h
new file mode 100644
index 00000000000..2bd51f17924
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/SamplerVk.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_SAMPLERVK_H_
+#define DAWNNATIVE_VULKAN_SAMPLERVK_H_
+
+#include "dawn_native/Sampler.h"
+
+#include "common/vulkan_platform.h"
+#include "dawn_native/vulkan/MemoryAllocator.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Sampler : public SamplerBase {
+ public:
+ Sampler(Device* device, const SamplerDescriptor* descriptor);
+ ~Sampler();
+
+ VkSampler GetHandle() const;
+
+ private:
+ VkSampler mHandle = VK_NULL_HANDLE;
+ Device* mDevice = nullptr;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_SAMPLERVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp
new file mode 100644
index 00000000000..0dd8810d232
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.cpp
@@ -0,0 +1,57 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/ShaderModuleVk.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+
+#include <spirv-cross/spirv_cross.hpp>
+
+namespace dawn_native { namespace vulkan {
+
+ ShaderModule::ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor)
+ : ShaderModuleBase(device, descriptor) {
+ // Use SPIRV-Cross to extract info from the SPIRV even if Vulkan consumes SPIRV. We want to
+ // have a translation step eventually anyway.
+ spirv_cross::Compiler compiler(descriptor->code, descriptor->codeSize);
+ ExtractSpirvInfo(compiler);
+
+ VkShaderModuleCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.codeSize = descriptor->codeSize * sizeof(uint32_t);
+ createInfo.pCode = descriptor->code;
+
+ if (device->fn.CreateShaderModule(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
+ VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ ShaderModule::~ShaderModule() {
+ Device* device = ToBackend(GetDevice());
+
+ if (mHandle != VK_NULL_HANDLE) {
+ device->GetFencedDeleter()->DeleteWhenUnused(mHandle);
+ mHandle = VK_NULL_HANDLE;
+ }
+ }
+
+ VkShaderModule ShaderModule::GetHandle() const {
+ return mHandle;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.h
new file mode 100644
index 00000000000..8c904d20ee7
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/ShaderModuleVk.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_SHADERMODULEVK_H_
+#define DAWNNATIVE_VULKAN_SHADERMODULEVK_H_
+
+#include "dawn_native/ShaderModule.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ class ShaderModule : public ShaderModuleBase {
+ public:
+ ShaderModule(Device* device, const ShaderModuleDescriptor* descriptor);
+ ~ShaderModule();
+
+ VkShaderModule GetHandle() const;
+
+ private:
+ VkShaderModule mHandle = VK_NULL_HANDLE;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_SHADERMODULEVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/SwapChainVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/SwapChainVk.cpp
new file mode 100644
index 00000000000..dd84569aa33
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/SwapChainVk.cpp
@@ -0,0 +1,59 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/SwapChainVk.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/TextureVk.h"
+
+namespace dawn_native { namespace vulkan {
+
+ SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
+ const auto& im = GetImplementation();
+ dawnWSIContextVulkan wsiContext = {};
+ im.Init(im.userData, &wsiContext);
+
+ ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_BIT_NONE);
+ mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
+ }
+
+ SwapChain::~SwapChain() {
+ }
+
+ TextureBase* SwapChain::GetNextTextureImpl(const TextureDescriptor* descriptor) {
+ const auto& im = GetImplementation();
+ dawnSwapChainNextTexture next = {};
+ dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
+
+ if (error) {
+ GetDevice()->HandleError(error);
+ return nullptr;
+ }
+
+ VkImage nativeTexture = VkImage::CreateFromU64(next.texture.u64);
+ return new Texture(ToBackend(GetDevice()), descriptor, nativeTexture);
+ }
+
+ void SwapChain::OnBeforePresent(TextureBase* texture) {
+ Device* device = ToBackend(GetDevice());
+
+ // Perform the necessary pipeline barriers for the texture to be used with the usage
+ // requested by the implementation.
+ VkCommandBuffer commands = device->GetPendingCommandBuffer();
+ ToBackend(texture)->TransitionUsageNow(commands, mTextureUsage);
+
+ device->SubmitPendingCommands();
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/SwapChainVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/SwapChainVk.h
new file mode 100644
index 00000000000..87f6ee576e6
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/SwapChainVk.h
@@ -0,0 +1,39 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_SWAPCHAINVK_H_
+#define DAWNNATIVE_VULKAN_SWAPCHAINVK_H_
+
+#include "dawn_native/SwapChain.h"
+
+#include "common/vulkan_platform.h"
+
+namespace dawn_native { namespace vulkan {
+
+ class SwapChain : public SwapChainBase {
+ public:
+ SwapChain(SwapChainBuilder* builder);
+ ~SwapChain();
+
+ protected:
+ TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
+ void OnBeforePresent(TextureBase* texture) override;
+
+ private:
+ dawn::TextureUsageBit mTextureUsage;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_SWAPCHAINVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/TextureVk.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/TextureVk.cpp
new file mode 100644
index 00000000000..b120f64f128
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/TextureVk.cpp
@@ -0,0 +1,398 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/TextureVk.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+#include "dawn_native/vulkan/FencedDeleter.h"
+
+namespace dawn_native { namespace vulkan {
+
+ namespace {
+ // Converts an Dawn texture dimension to a Vulkan image type.
+ // Note that in Vulkan dimensionality is only 1D, 2D, 3D. Arrays and cube maps are expressed
+ // via the array size and a "cubemap compatible" flag.
+ VkImageType VulkanImageType(dawn::TextureDimension dimension) {
+ switch (dimension) {
+ case dawn::TextureDimension::e2D:
+ return VK_IMAGE_TYPE_2D;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ // Converts an Dawn texture dimension to a Vulkan image view type.
+ // Contrary to image types, image view types include arrayness and cubemapness
+ VkImageViewType VulkanImageViewType(dawn::TextureViewDimension dimension) {
+ switch (dimension) {
+ case dawn::TextureViewDimension::e2D:
+ return VK_IMAGE_VIEW_TYPE_2D;
+ case dawn::TextureViewDimension::e2DArray:
+ return VK_IMAGE_VIEW_TYPE_2D_ARRAY;
+ case dawn::TextureViewDimension::Cube:
+ return VK_IMAGE_VIEW_TYPE_CUBE;
+ case dawn::TextureViewDimension::CubeArray:
+ return VK_IMAGE_VIEW_TYPE_CUBE_ARRAY;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ // Computes which vulkan access type could be required for the given Dawn usage.
+ VkAccessFlags VulkanAccessFlags(dawn::TextureUsageBit usage, dawn::TextureFormat format) {
+ VkAccessFlags flags = 0;
+
+ if (usage & dawn::TextureUsageBit::TransferSrc) {
+ flags |= VK_ACCESS_TRANSFER_READ_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::TransferDst) {
+ flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::Sampled) {
+ flags |= VK_ACCESS_SHADER_READ_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::Storage) {
+ flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::OutputAttachment) {
+ if (TextureFormatHasDepthOrStencil(format)) {
+ flags |= VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT |
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
+ } else {
+ flags |=
+ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
+ }
+ }
+ if (usage & dawn::TextureUsageBit::Present) {
+ // There is no access flag for present because the VK_KHR_SWAPCHAIN extension says
+ // that vkQueuePresentKHR makes the memory of the image visible to the presentation
+ // engine. There's also a note explicitly saying dstAccessMask should be 0. On the
+ // other side srcAccessMask can also be 0 because synchronization is required to
+ // happen with a semaphore instead.
+ flags |= 0;
+ }
+
+ return flags;
+ }
+
+ // Chooses which Vulkan image layout should be used for the given Dawn usage
+ VkImageLayout VulkanImageLayout(dawn::TextureUsageBit usage, dawn::TextureFormat format) {
+ if (usage == dawn::TextureUsageBit::None) {
+ return VK_IMAGE_LAYOUT_UNDEFINED;
+ }
+
+ if (!dawn::HasZeroOrOneBits(usage)) {
+ return VK_IMAGE_LAYOUT_GENERAL;
+ }
+
+ // Usage has a single bit so we can switch on its value directly.
+ switch (usage) {
+ case dawn::TextureUsageBit::TransferDst:
+ return VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
+ case dawn::TextureUsageBit::Sampled:
+ return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+ // Vulkan texture copy functions require the image to be in _one_ known layout.
+ // Depending on whether parts of the texture have been transitioned to only
+ // TransferSrc or a combination with something else, the texture could be in a
+ // combination of GENERAL and TRANSFER_SRC_OPTIMAL. This would be a problem, so we
+ // make TransferSrc use GENERAL.
+ case dawn::TextureUsageBit::TransferSrc:
+ // Writable storage textures must use general. If we could know the texture is read
+ // only we could use SHADER_READ_ONLY_OPTIMAL
+ case dawn::TextureUsageBit::Storage:
+ return VK_IMAGE_LAYOUT_GENERAL;
+ case dawn::TextureUsageBit::OutputAttachment:
+ if (TextureFormatHasDepthOrStencil(format)) {
+ return VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
+ } else {
+ return VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+ }
+ case dawn::TextureUsageBit::Present:
+ return VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ // Computes which Vulkan pipeline stage can access a texture in the given Dawn usage
+ VkPipelineStageFlags VulkanPipelineStage(dawn::TextureUsageBit usage,
+ dawn::TextureFormat format) {
+ VkPipelineStageFlags flags = 0;
+
+ if (usage == dawn::TextureUsageBit::None) {
+ // This only happens when a texture is initially created (and for srcAccessMask) in
+ // which case there is no need to wait on anything to stop accessing this texture.
+ return VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
+ }
+ if (usage & (dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::TransferDst)) {
+ flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
+ }
+ if (usage & (dawn::TextureUsageBit::Sampled | dawn::TextureUsageBit::Storage)) {
+ flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
+ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
+ VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::OutputAttachment) {
+ if (TextureFormatHasDepthOrStencil(format)) {
+ flags |= VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT |
+ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
+ // TODO(cwallez@chromium.org): This is missing the stage where the depth and
+ // stencil values are written, but it isn't clear which one it is.
+ } else {
+ flags |= VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
+ }
+ }
+ if (usage & dawn::TextureUsageBit::Present) {
+ // There is no pipeline stage for present but a pipeline stage is required so we use
+ // "bottom of pipe" to block as little as possible and vkQueuePresentKHR will make
+ // the memory visible to the presentation engine. The spec explicitly mentions that
+ // "bottom of pipe" is ok. On the other direction, synchronization happens with a
+ // semaphore so bottom of pipe is ok too (but maybe it could be "top of pipe" to
+ // block less?)
+ flags |= VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
+ }
+
+ // A zero value isn't a valid pipeline stage mask
+ ASSERT(flags != 0);
+ return flags;
+ }
+
+ // Computes which Vulkan texture aspects are relevant for the given Dawn format
+ VkImageAspectFlags VulkanAspectMask(dawn::TextureFormat format) {
+ bool isDepth = TextureFormatHasDepth(format);
+ bool isStencil = TextureFormatHasStencil(format);
+
+ VkImageAspectFlags flags = 0;
+ if (isDepth) {
+ flags |= VK_IMAGE_ASPECT_DEPTH_BIT;
+ }
+ if (isStencil) {
+ flags |= VK_IMAGE_ASPECT_STENCIL_BIT;
+ }
+
+ if (flags != 0) {
+ return flags;
+ }
+ return VK_IMAGE_ASPECT_COLOR_BIT;
+ }
+
+ VkExtent3D VulkanExtent3D(const Extent3D& extent) {
+ return {extent.width, extent.height, extent.depth};
+ }
+
+ } // namespace
+
+ // Converts Dawn texture format to Vulkan formats.
+ VkFormat VulkanImageFormat(dawn::TextureFormat format) {
+ switch (format) {
+ case dawn::TextureFormat::R8G8B8A8Unorm:
+ return VK_FORMAT_R8G8B8A8_UNORM;
+ case dawn::TextureFormat::R8G8Unorm:
+ return VK_FORMAT_R8G8_UNORM;
+ case dawn::TextureFormat::R8Unorm:
+ return VK_FORMAT_R8_UNORM;
+ case dawn::TextureFormat::R8G8B8A8Uint:
+ return VK_FORMAT_R8G8B8A8_UINT;
+ case dawn::TextureFormat::R8G8Uint:
+ return VK_FORMAT_R8G8_UINT;
+ case dawn::TextureFormat::R8Uint:
+ return VK_FORMAT_R8_UINT;
+ case dawn::TextureFormat::B8G8R8A8Unorm:
+ return VK_FORMAT_B8G8R8A8_UNORM;
+ case dawn::TextureFormat::D32FloatS8Uint:
+ return VK_FORMAT_D32_SFLOAT_S8_UINT;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ // Converts the Dawn usage flags to Vulkan usage flags. Also needs the format to choose
+ // between color and depth attachment usages.
+ VkImageUsageFlags VulkanImageUsage(dawn::TextureUsageBit usage, dawn::TextureFormat format) {
+ VkImageUsageFlags flags = 0;
+
+ if (usage & dawn::TextureUsageBit::TransferSrc) {
+ flags |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::TransferDst) {
+ flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::Sampled) {
+ flags |= VK_IMAGE_USAGE_SAMPLED_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::Storage) {
+ flags |= VK_IMAGE_USAGE_STORAGE_BIT;
+ }
+ if (usage & dawn::TextureUsageBit::OutputAttachment) {
+ if (TextureFormatHasDepthOrStencil(format)) {
+ flags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
+ } else {
+ flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
+ }
+ }
+
+ return flags;
+ }
+
+ Texture::Texture(Device* device, const TextureDescriptor* descriptor)
+ : TextureBase(device, descriptor) {
+ // Create the Vulkan image "container". We don't need to check that the format supports the
+ // combination of sample, usage etc. because validation should have been done in the Dawn
+ // frontend already based on the minimum supported formats in the Vulkan spec
+ VkImageCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.imageType = VulkanImageType(GetDimension());
+ createInfo.format = VulkanImageFormat(GetFormat());
+ createInfo.extent = VulkanExtent3D(GetSize());
+ createInfo.mipLevels = GetNumMipLevels();
+ createInfo.arrayLayers = GetArrayLayers();
+ createInfo.samples = VK_SAMPLE_COUNT_1_BIT;
+ createInfo.tiling = VK_IMAGE_TILING_OPTIMAL;
+ createInfo.usage = VulkanImageUsage(GetUsage(), GetFormat());
+ createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
+ createInfo.queueFamilyIndexCount = 0;
+ createInfo.pQueueFamilyIndices = nullptr;
+ createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+
+ if (GetArrayLayers() >= 6 && GetSize().width == GetSize().height) {
+ createInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
+ }
+
+ if (device->fn.CreateImage(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
+ VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ // Create the image memory and associate it with the container
+ VkMemoryRequirements requirements;
+ device->fn.GetImageMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
+
+ if (!device->GetMemoryAllocator()->Allocate(requirements, false, &mMemoryAllocation)) {
+ ASSERT(false);
+ }
+
+ if (device->fn.BindImageMemory(device->GetVkDevice(), mHandle,
+ mMemoryAllocation.GetMemory(),
+ mMemoryAllocation.GetMemoryOffset()) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ Texture::Texture(Device* device, const TextureDescriptor* descriptor, VkImage nativeImage)
+ : TextureBase(device, descriptor), mHandle(nativeImage) {
+ }
+
+ Texture::~Texture() {
+ Device* device = ToBackend(GetDevice());
+
+ // If we own the resource, release it.
+ if (mMemoryAllocation.GetMemory() != VK_NULL_HANDLE) {
+ // We need to free both the memory allocation and the container. Memory should be freed
+ // after the VkImage is destroyed and this is taken care of by the FencedDeleter.
+ device->GetMemoryAllocator()->Free(&mMemoryAllocation);
+
+ if (mHandle != VK_NULL_HANDLE) {
+ device->GetFencedDeleter()->DeleteWhenUnused(mHandle);
+ }
+ }
+ mHandle = VK_NULL_HANDLE;
+ }
+
+ VkImage Texture::GetHandle() const {
+ return mHandle;
+ }
+
+ VkImageAspectFlags Texture::GetVkAspectMask() const {
+ return VulkanAspectMask(GetFormat());
+ }
+
+ void Texture::TransitionUsageNow(VkCommandBuffer commands, dawn::TextureUsageBit usage) {
+ // Avoid encoding barriers when it isn't needed.
+ bool lastReadOnly = (mLastUsage & kReadOnlyTextureUsages) == mLastUsage;
+ if (lastReadOnly && mLastUsage == usage) {
+ return;
+ }
+
+ dawn::TextureFormat format = GetFormat();
+
+ VkPipelineStageFlags srcStages = VulkanPipelineStage(mLastUsage, format);
+ VkPipelineStageFlags dstStages = VulkanPipelineStage(usage, format);
+
+ VkImageMemoryBarrier barrier;
+ barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
+ barrier.pNext = nullptr;
+ barrier.srcAccessMask = VulkanAccessFlags(mLastUsage, format);
+ barrier.dstAccessMask = VulkanAccessFlags(usage, format);
+ barrier.oldLayout = VulkanImageLayout(mLastUsage, format);
+ barrier.newLayout = VulkanImageLayout(usage, format);
+ barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
+ barrier.image = mHandle;
+ // This transitions the whole resource but assumes it is a 2D texture
+ ASSERT(GetDimension() == dawn::TextureDimension::e2D);
+ barrier.subresourceRange.aspectMask = VulkanAspectMask(format);
+ barrier.subresourceRange.baseMipLevel = 0;
+ barrier.subresourceRange.levelCount = GetNumMipLevels();
+ barrier.subresourceRange.baseArrayLayer = 0;
+ barrier.subresourceRange.layerCount = GetArrayLayers();
+
+ ToBackend(GetDevice())
+ ->fn.CmdPipelineBarrier(commands, srcStages, dstStages, 0, 0, nullptr, 0, nullptr, 1,
+ &barrier);
+
+ mLastUsage = usage;
+ }
+
+ // TODO(jiawei.shao@intel.com): create texture view by TextureViewDescriptor
+ TextureView::TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor)
+ : TextureViewBase(texture, descriptor) {
+ Device* device = ToBackend(texture->GetDevice());
+
+ VkImageViewCreateInfo createInfo;
+ createInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = 0;
+ createInfo.image = ToBackend(GetTexture())->GetHandle();
+ createInfo.viewType = VulkanImageViewType(descriptor->dimension);
+ createInfo.format = VulkanImageFormat(descriptor->format);
+ createInfo.components = VkComponentMapping{VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G,
+ VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_A};
+ createInfo.subresourceRange.aspectMask = VulkanAspectMask(descriptor->format);
+ createInfo.subresourceRange.baseMipLevel = descriptor->baseMipLevel;
+ createInfo.subresourceRange.levelCount = descriptor->levelCount;
+ createInfo.subresourceRange.baseArrayLayer = descriptor->baseArrayLayer;
+ createInfo.subresourceRange.layerCount = descriptor->layerCount;
+
+ if (device->fn.CreateImageView(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
+ VK_SUCCESS) {
+ ASSERT(false);
+ }
+ }
+
+ TextureView::~TextureView() {
+ Device* device = ToBackend(GetTexture()->GetDevice());
+
+ if (mHandle != VK_NULL_HANDLE) {
+ device->GetFencedDeleter()->DeleteWhenUnused(mHandle);
+ mHandle = VK_NULL_HANDLE;
+ }
+ }
+
+ VkImageView TextureView::GetHandle() const {
+ return mHandle;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/TextureVk.h b/chromium/third_party/dawn/src/dawn_native/vulkan/TextureVk.h
new file mode 100644
index 00000000000..e17ebb2eee4
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/TextureVk.h
@@ -0,0 +1,64 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_TEXTUREVK_H_
+#define DAWNNATIVE_VULKAN_TEXTUREVK_H_
+
+#include "dawn_native/Texture.h"
+
+#include "common/vulkan_platform.h"
+#include "dawn_native/vulkan/MemoryAllocator.h"
+
+namespace dawn_native { namespace vulkan {
+
+ VkFormat VulkanImageFormat(dawn::TextureFormat format);
+ VkImageUsageFlags VulkanImageUsage(dawn::TextureUsageBit usage, dawn::TextureFormat format);
+
+ class Texture : public TextureBase {
+ public:
+ Texture(Device* device, const TextureDescriptor* descriptor);
+ Texture(Device* device, const TextureDescriptor* descriptor, VkImage nativeImage);
+ ~Texture();
+
+ VkImage GetHandle() const;
+ VkImageAspectFlags GetVkAspectMask() const;
+
+ // Transitions the texture to be used as `usage`, recording any necessary barrier in
+ // `commands`.
+ // TODO(cwallez@chromium.org): coalesce barriers and do them early when possible.
+ void TransitionUsageNow(VkCommandBuffer commands, dawn::TextureUsageBit usage);
+
+ private:
+ VkImage mHandle = VK_NULL_HANDLE;
+ DeviceMemoryAllocation mMemoryAllocation;
+
+ // A usage of none will make sure the texture is transitioned before its first use as
+ // required by the spec.
+ dawn::TextureUsageBit mLastUsage = dawn::TextureUsageBit::None;
+ };
+
+ class TextureView : public TextureViewBase {
+ public:
+ TextureView(TextureBase* texture, const TextureViewDescriptor* descriptor);
+ ~TextureView();
+
+ VkImageView GetHandle() const;
+
+ private:
+ VkImageView mHandle = VK_NULL_HANDLE;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_TEXTUREVK_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanFunctions.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanFunctions.cpp
new file mode 100644
index 00000000000..09f6e512f45
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanFunctions.cpp
@@ -0,0 +1,221 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/VulkanFunctions.h"
+
+#include "common/DynamicLib.h"
+#include "dawn_native/vulkan/VulkanInfo.h"
+
+namespace dawn_native { namespace vulkan {
+
+#define GET_GLOBAL_PROC(name) \
+ name = reinterpret_cast<decltype(name)>(GetInstanceProcAddr(nullptr, "vk" #name)); \
+ if (name == nullptr) { \
+ return false; \
+ }
+
+ bool VulkanFunctions::LoadGlobalProcs(const DynamicLib& vulkanLib) {
+ if (!vulkanLib.GetProc(&GetInstanceProcAddr, "vkGetInstanceProcAddr")) {
+ return false;
+ }
+
+ GET_GLOBAL_PROC(CreateInstance);
+ GET_GLOBAL_PROC(EnumerateInstanceExtensionProperties);
+ GET_GLOBAL_PROC(EnumerateInstanceLayerProperties);
+
+ return true;
+ }
+
+#define GET_INSTANCE_PROC(name) \
+ name = reinterpret_cast<decltype(name)>(GetInstanceProcAddr(instance, "vk" #name)); \
+ if (name == nullptr) { \
+ return false; \
+ }
+
+ bool VulkanFunctions::LoadInstanceProcs(VkInstance instance,
+ const VulkanGlobalKnobs& usedKnobs) {
+ // Load this proc first so that we can destroy the instance even if some other
+ // GET_INSTANCE_PROC fails
+ GET_INSTANCE_PROC(DestroyInstance);
+
+ GET_INSTANCE_PROC(CreateDevice);
+ GET_INSTANCE_PROC(DestroyDevice);
+ GET_INSTANCE_PROC(EnumerateDeviceExtensionProperties);
+ GET_INSTANCE_PROC(EnumerateDeviceLayerProperties);
+ GET_INSTANCE_PROC(EnumeratePhysicalDevices);
+ GET_INSTANCE_PROC(GetDeviceProcAddr);
+ GET_INSTANCE_PROC(GetPhysicalDeviceFeatures);
+ GET_INSTANCE_PROC(GetPhysicalDeviceFormatProperties);
+ GET_INSTANCE_PROC(GetPhysicalDeviceImageFormatProperties);
+ GET_INSTANCE_PROC(GetPhysicalDeviceMemoryProperties);
+ GET_INSTANCE_PROC(GetPhysicalDeviceProperties);
+ GET_INSTANCE_PROC(GetPhysicalDeviceQueueFamilyProperties);
+ GET_INSTANCE_PROC(GetPhysicalDeviceSparseImageFormatProperties);
+
+ if (usedKnobs.debugReport) {
+ GET_INSTANCE_PROC(CreateDebugReportCallbackEXT);
+ GET_INSTANCE_PROC(DebugReportMessageEXT);
+ GET_INSTANCE_PROC(DestroyDebugReportCallbackEXT);
+ }
+
+ if (usedKnobs.surface) {
+ GET_INSTANCE_PROC(DestroySurfaceKHR);
+ GET_INSTANCE_PROC(GetPhysicalDeviceSurfaceSupportKHR);
+ GET_INSTANCE_PROC(GetPhysicalDeviceSurfaceCapabilitiesKHR);
+ GET_INSTANCE_PROC(GetPhysicalDeviceSurfaceFormatsKHR);
+ GET_INSTANCE_PROC(GetPhysicalDeviceSurfacePresentModesKHR);
+ }
+
+ return true;
+ }
+
+#define GET_DEVICE_PROC(name) \
+ name = reinterpret_cast<decltype(name)>(GetDeviceProcAddr(device, "vk" #name)); \
+ if (name == nullptr) { \
+ return false; \
+ }
+
+ bool VulkanFunctions::LoadDeviceProcs(VkDevice device, const VulkanDeviceKnobs& usedKnobs) {
+ GET_DEVICE_PROC(AllocateCommandBuffers);
+ GET_DEVICE_PROC(AllocateDescriptorSets);
+ GET_DEVICE_PROC(AllocateMemory);
+ GET_DEVICE_PROC(BeginCommandBuffer);
+ GET_DEVICE_PROC(BindBufferMemory);
+ GET_DEVICE_PROC(BindImageMemory);
+ GET_DEVICE_PROC(CmdBeginQuery);
+ GET_DEVICE_PROC(CmdBeginRenderPass);
+ GET_DEVICE_PROC(CmdBindDescriptorSets);
+ GET_DEVICE_PROC(CmdBindIndexBuffer);
+ GET_DEVICE_PROC(CmdBindPipeline);
+ GET_DEVICE_PROC(CmdBindVertexBuffers);
+ GET_DEVICE_PROC(CmdBlitImage);
+ GET_DEVICE_PROC(CmdClearAttachments);
+ GET_DEVICE_PROC(CmdClearColorImage);
+ GET_DEVICE_PROC(CmdClearDepthStencilImage);
+ GET_DEVICE_PROC(CmdCopyBuffer);
+ GET_DEVICE_PROC(CmdCopyBufferToImage);
+ GET_DEVICE_PROC(CmdCopyImage);
+ GET_DEVICE_PROC(CmdCopyImageToBuffer);
+ GET_DEVICE_PROC(CmdCopyQueryPoolResults);
+ GET_DEVICE_PROC(CmdDispatch);
+ GET_DEVICE_PROC(CmdDispatchIndirect);
+ GET_DEVICE_PROC(CmdDraw);
+ GET_DEVICE_PROC(CmdDrawIndexed);
+ GET_DEVICE_PROC(CmdDrawIndexedIndirect);
+ GET_DEVICE_PROC(CmdDrawIndirect);
+ GET_DEVICE_PROC(CmdEndQuery);
+ GET_DEVICE_PROC(CmdEndRenderPass);
+ GET_DEVICE_PROC(CmdExecuteCommands);
+ GET_DEVICE_PROC(CmdFillBuffer);
+ GET_DEVICE_PROC(CmdNextSubpass);
+ GET_DEVICE_PROC(CmdPipelineBarrier);
+ GET_DEVICE_PROC(CmdPushConstants);
+ GET_DEVICE_PROC(CmdResetEvent);
+ GET_DEVICE_PROC(CmdResetQueryPool);
+ GET_DEVICE_PROC(CmdResolveImage);
+ GET_DEVICE_PROC(CmdSetBlendConstants);
+ GET_DEVICE_PROC(CmdSetDepthBias);
+ GET_DEVICE_PROC(CmdSetDepthBounds);
+ GET_DEVICE_PROC(CmdSetEvent);
+ GET_DEVICE_PROC(CmdSetLineWidth);
+ GET_DEVICE_PROC(CmdSetScissor);
+ GET_DEVICE_PROC(CmdSetStencilCompareMask);
+ GET_DEVICE_PROC(CmdSetStencilReference);
+ GET_DEVICE_PROC(CmdSetStencilWriteMask);
+ GET_DEVICE_PROC(CmdSetViewport);
+ GET_DEVICE_PROC(CmdUpdateBuffer);
+ GET_DEVICE_PROC(CmdWaitEvents);
+ GET_DEVICE_PROC(CmdWriteTimestamp);
+ GET_DEVICE_PROC(CreateBuffer);
+ GET_DEVICE_PROC(CreateBufferView);
+ GET_DEVICE_PROC(CreateCommandPool);
+ GET_DEVICE_PROC(CreateComputePipelines);
+ GET_DEVICE_PROC(CreateDescriptorPool);
+ GET_DEVICE_PROC(CreateDescriptorSetLayout);
+ GET_DEVICE_PROC(CreateEvent);
+ GET_DEVICE_PROC(CreateFence);
+ GET_DEVICE_PROC(CreateFramebuffer);
+ GET_DEVICE_PROC(CreateGraphicsPipelines);
+ GET_DEVICE_PROC(CreateImage);
+ GET_DEVICE_PROC(CreateImageView);
+ GET_DEVICE_PROC(CreatePipelineCache);
+ GET_DEVICE_PROC(CreatePipelineLayout);
+ GET_DEVICE_PROC(CreateQueryPool);
+ GET_DEVICE_PROC(CreateRenderPass);
+ GET_DEVICE_PROC(CreateSampler);
+ GET_DEVICE_PROC(CreateSemaphore);
+ GET_DEVICE_PROC(CreateShaderModule);
+ GET_DEVICE_PROC(DestroyBuffer);
+ GET_DEVICE_PROC(DestroyBufferView);
+ GET_DEVICE_PROC(DestroyCommandPool);
+ GET_DEVICE_PROC(DestroyDescriptorPool);
+ GET_DEVICE_PROC(DestroyDescriptorSetLayout);
+ GET_DEVICE_PROC(DestroyEvent);
+ GET_DEVICE_PROC(DestroyFence);
+ GET_DEVICE_PROC(DestroyFramebuffer);
+ GET_DEVICE_PROC(DestroyImage);
+ GET_DEVICE_PROC(DestroyImageView);
+ GET_DEVICE_PROC(DestroyPipeline);
+ GET_DEVICE_PROC(DestroyPipelineCache);
+ GET_DEVICE_PROC(DestroyPipelineLayout);
+ GET_DEVICE_PROC(DestroyQueryPool);
+ GET_DEVICE_PROC(DestroyRenderPass);
+ GET_DEVICE_PROC(DestroySampler);
+ GET_DEVICE_PROC(DestroySemaphore);
+ GET_DEVICE_PROC(DestroyShaderModule);
+ GET_DEVICE_PROC(DeviceWaitIdle);
+ GET_DEVICE_PROC(EndCommandBuffer);
+ GET_DEVICE_PROC(FlushMappedMemoryRanges);
+ GET_DEVICE_PROC(FreeCommandBuffers);
+ GET_DEVICE_PROC(FreeDescriptorSets);
+ GET_DEVICE_PROC(FreeMemory);
+ GET_DEVICE_PROC(GetBufferMemoryRequirements);
+ GET_DEVICE_PROC(GetDeviceMemoryCommitment);
+ GET_DEVICE_PROC(GetDeviceQueue);
+ GET_DEVICE_PROC(GetEventStatus);
+ GET_DEVICE_PROC(GetFenceStatus);
+ GET_DEVICE_PROC(GetImageMemoryRequirements);
+ GET_DEVICE_PROC(GetImageSparseMemoryRequirements);
+ GET_DEVICE_PROC(GetImageSubresourceLayout);
+ GET_DEVICE_PROC(GetPipelineCacheData);
+ GET_DEVICE_PROC(GetQueryPoolResults);
+ GET_DEVICE_PROC(GetRenderAreaGranularity);
+ GET_DEVICE_PROC(InvalidateMappedMemoryRanges);
+ GET_DEVICE_PROC(MapMemory);
+ GET_DEVICE_PROC(MergePipelineCaches);
+ GET_DEVICE_PROC(QueueBindSparse);
+ GET_DEVICE_PROC(QueueSubmit);
+ GET_DEVICE_PROC(QueueWaitIdle);
+ GET_DEVICE_PROC(ResetCommandBuffer);
+ GET_DEVICE_PROC(ResetCommandPool);
+ GET_DEVICE_PROC(ResetDescriptorPool);
+ GET_DEVICE_PROC(ResetEvent);
+ GET_DEVICE_PROC(ResetFences);
+ GET_DEVICE_PROC(SetEvent);
+ GET_DEVICE_PROC(UnmapMemory);
+ GET_DEVICE_PROC(UpdateDescriptorSets);
+ GET_DEVICE_PROC(WaitForFences);
+
+ if (usedKnobs.swapchain) {
+ GET_DEVICE_PROC(CreateSwapchainKHR);
+ GET_DEVICE_PROC(DestroySwapchainKHR);
+ GET_DEVICE_PROC(GetSwapchainImagesKHR);
+ GET_DEVICE_PROC(AcquireNextImageKHR);
+ GET_DEVICE_PROC(QueuePresentKHR);
+ }
+
+ return true;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanFunctions.h b/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanFunctions.h
new file mode 100644
index 00000000000..a9a6a54654a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanFunctions.h
@@ -0,0 +1,215 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_VULKANFUNCTIONS_H_
+#define DAWNNATIVE_VULKAN_VULKANFUNCTIONS_H_
+
+#include "common/vulkan_platform.h"
+
+class DynamicLib;
+
+namespace dawn_native { namespace vulkan {
+
+ struct VulkanGlobalKnobs;
+ struct VulkanDeviceKnobs;
+
+ // Stores the Vulkan entry points. Also loads them from the dynamic library
+ // and the vkGet*ProcAddress entry points.
+ struct VulkanFunctions {
+ bool LoadGlobalProcs(const DynamicLib& vulkanLib);
+ bool LoadInstanceProcs(VkInstance instance, const VulkanGlobalKnobs& usedGlobals);
+ bool LoadDeviceProcs(VkDevice device, const VulkanDeviceKnobs& usedKnobs);
+
+ // ---------- Global procs
+
+ // Initial proc from which we can get all the others
+ PFN_vkGetInstanceProcAddr GetInstanceProcAddr = nullptr;
+
+ PFN_vkCreateInstance CreateInstance = nullptr;
+ PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties = nullptr;
+ PFN_vkEnumerateInstanceLayerProperties EnumerateInstanceLayerProperties = nullptr;
+ // DestroyInstance isn't technically a global proc but we want to be able to use it
+ // before querying the instance procs in case we need to error out during initialization.
+ PFN_vkDestroyInstance DestroyInstance = nullptr;
+
+ // ---------- Instance procs
+
+ // Core Vulkan 1.0
+ PFN_vkCreateDevice CreateDevice = nullptr;
+ PFN_vkEnumerateDeviceExtensionProperties EnumerateDeviceExtensionProperties = nullptr;
+ PFN_vkEnumerateDeviceLayerProperties EnumerateDeviceLayerProperties = nullptr;
+ PFN_vkEnumeratePhysicalDevices EnumeratePhysicalDevices = nullptr;
+ PFN_vkGetDeviceProcAddr GetDeviceProcAddr = nullptr;
+ PFN_vkGetPhysicalDeviceFeatures GetPhysicalDeviceFeatures = nullptr;
+ PFN_vkGetPhysicalDeviceFormatProperties GetPhysicalDeviceFormatProperties = nullptr;
+ PFN_vkGetPhysicalDeviceImageFormatProperties GetPhysicalDeviceImageFormatProperties =
+ nullptr;
+ PFN_vkGetPhysicalDeviceMemoryProperties GetPhysicalDeviceMemoryProperties = nullptr;
+ PFN_vkGetPhysicalDeviceProperties GetPhysicalDeviceProperties = nullptr;
+ PFN_vkGetPhysicalDeviceQueueFamilyProperties GetPhysicalDeviceQueueFamilyProperties =
+ nullptr;
+ PFN_vkGetPhysicalDeviceSparseImageFormatProperties
+ GetPhysicalDeviceSparseImageFormatProperties = nullptr;
+ // Not technically an instance proc but we want to be able to use it as soon as the
+ // device is created.
+ PFN_vkDestroyDevice DestroyDevice = nullptr;
+
+ // VK_EXT_debug_report
+ PFN_vkCreateDebugReportCallbackEXT CreateDebugReportCallbackEXT = nullptr;
+ PFN_vkDebugReportMessageEXT DebugReportMessageEXT = nullptr;
+ PFN_vkDestroyDebugReportCallbackEXT DestroyDebugReportCallbackEXT = nullptr;
+
+ // VK_KHR_surface
+ PFN_vkDestroySurfaceKHR DestroySurfaceKHR = nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceSupportKHR GetPhysicalDeviceSurfaceSupportKHR = nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR GetPhysicalDeviceSurfaceCapabilitiesKHR =
+ nullptr;
+ PFN_vkGetPhysicalDeviceSurfaceFormatsKHR GetPhysicalDeviceSurfaceFormatsKHR = nullptr;
+ PFN_vkGetPhysicalDeviceSurfacePresentModesKHR GetPhysicalDeviceSurfacePresentModesKHR =
+ nullptr;
+
+ // ---------- Device procs
+
+ // Core Vulkan 1.0
+ PFN_vkAllocateCommandBuffers AllocateCommandBuffers = nullptr;
+ PFN_vkAllocateDescriptorSets AllocateDescriptorSets = nullptr;
+ PFN_vkAllocateMemory AllocateMemory = nullptr;
+ PFN_vkBeginCommandBuffer BeginCommandBuffer = nullptr;
+ PFN_vkBindBufferMemory BindBufferMemory = nullptr;
+ PFN_vkBindImageMemory BindImageMemory = nullptr;
+ PFN_vkCmdBeginQuery CmdBeginQuery = nullptr;
+ PFN_vkCmdBeginRenderPass CmdBeginRenderPass = nullptr;
+ PFN_vkCmdBindDescriptorSets CmdBindDescriptorSets = nullptr;
+ PFN_vkCmdBindIndexBuffer CmdBindIndexBuffer = nullptr;
+ PFN_vkCmdBindPipeline CmdBindPipeline = nullptr;
+ PFN_vkCmdBindVertexBuffers CmdBindVertexBuffers = nullptr;
+ PFN_vkCmdBlitImage CmdBlitImage = nullptr;
+ PFN_vkCmdClearAttachments CmdClearAttachments = nullptr;
+ PFN_vkCmdClearColorImage CmdClearColorImage = nullptr;
+ PFN_vkCmdClearDepthStencilImage CmdClearDepthStencilImage = nullptr;
+ PFN_vkCmdCopyBuffer CmdCopyBuffer = nullptr;
+ PFN_vkCmdCopyBufferToImage CmdCopyBufferToImage = nullptr;
+ PFN_vkCmdCopyImage CmdCopyImage = nullptr;
+ PFN_vkCmdCopyImageToBuffer CmdCopyImageToBuffer = nullptr;
+ PFN_vkCmdCopyQueryPoolResults CmdCopyQueryPoolResults = nullptr;
+ PFN_vkCmdDispatch CmdDispatch = nullptr;
+ PFN_vkCmdDispatchIndirect CmdDispatchIndirect = nullptr;
+ PFN_vkCmdDraw CmdDraw = nullptr;
+ PFN_vkCmdDrawIndexed CmdDrawIndexed = nullptr;
+ PFN_vkCmdDrawIndexedIndirect CmdDrawIndexedIndirect = nullptr;
+ PFN_vkCmdDrawIndirect CmdDrawIndirect = nullptr;
+ PFN_vkCmdEndQuery CmdEndQuery = nullptr;
+ PFN_vkCmdEndRenderPass CmdEndRenderPass = nullptr;
+ PFN_vkCmdExecuteCommands CmdExecuteCommands = nullptr;
+ PFN_vkCmdFillBuffer CmdFillBuffer = nullptr;
+ PFN_vkCmdNextSubpass CmdNextSubpass = nullptr;
+ PFN_vkCmdPipelineBarrier CmdPipelineBarrier = nullptr;
+ PFN_vkCmdPushConstants CmdPushConstants = nullptr;
+ PFN_vkCmdResetEvent CmdResetEvent = nullptr;
+ PFN_vkCmdResetQueryPool CmdResetQueryPool = nullptr;
+ PFN_vkCmdResolveImage CmdResolveImage = nullptr;
+ PFN_vkCmdSetBlendConstants CmdSetBlendConstants = nullptr;
+ PFN_vkCmdSetDepthBias CmdSetDepthBias = nullptr;
+ PFN_vkCmdSetDepthBounds CmdSetDepthBounds = nullptr;
+ PFN_vkCmdSetEvent CmdSetEvent = nullptr;
+ PFN_vkCmdSetLineWidth CmdSetLineWidth = nullptr;
+ PFN_vkCmdSetScissor CmdSetScissor = nullptr;
+ PFN_vkCmdSetStencilCompareMask CmdSetStencilCompareMask = nullptr;
+ PFN_vkCmdSetStencilReference CmdSetStencilReference = nullptr;
+ PFN_vkCmdSetStencilWriteMask CmdSetStencilWriteMask = nullptr;
+ PFN_vkCmdSetViewport CmdSetViewport = nullptr;
+ PFN_vkCmdUpdateBuffer CmdUpdateBuffer = nullptr;
+ PFN_vkCmdWaitEvents CmdWaitEvents = nullptr;
+ PFN_vkCmdWriteTimestamp CmdWriteTimestamp = nullptr;
+ PFN_vkCreateBuffer CreateBuffer = nullptr;
+ PFN_vkCreateBufferView CreateBufferView = nullptr;
+ PFN_vkCreateCommandPool CreateCommandPool = nullptr;
+ PFN_vkCreateComputePipelines CreateComputePipelines = nullptr;
+ PFN_vkCreateDescriptorPool CreateDescriptorPool = nullptr;
+ PFN_vkCreateDescriptorSetLayout CreateDescriptorSetLayout = nullptr;
+ PFN_vkCreateEvent CreateEvent = nullptr;
+ PFN_vkCreateFence CreateFence = nullptr;
+ PFN_vkCreateFramebuffer CreateFramebuffer = nullptr;
+ PFN_vkCreateGraphicsPipelines CreateGraphicsPipelines = nullptr;
+ PFN_vkCreateImage CreateImage = nullptr;
+ PFN_vkCreateImageView CreateImageView = nullptr;
+ PFN_vkCreatePipelineCache CreatePipelineCache = nullptr;
+ PFN_vkCreatePipelineLayout CreatePipelineLayout = nullptr;
+ PFN_vkCreateQueryPool CreateQueryPool = nullptr;
+ PFN_vkCreateRenderPass CreateRenderPass = nullptr;
+ PFN_vkCreateSampler CreateSampler = nullptr;
+ PFN_vkCreateSemaphore CreateSemaphore = nullptr;
+ PFN_vkCreateShaderModule CreateShaderModule = nullptr;
+ PFN_vkDestroyBuffer DestroyBuffer = nullptr;
+ PFN_vkDestroyBufferView DestroyBufferView = nullptr;
+ PFN_vkDestroyCommandPool DestroyCommandPool = nullptr;
+ PFN_vkDestroyDescriptorPool DestroyDescriptorPool = nullptr;
+ PFN_vkDestroyDescriptorSetLayout DestroyDescriptorSetLayout = nullptr;
+ PFN_vkDestroyEvent DestroyEvent = nullptr;
+ PFN_vkDestroyFence DestroyFence = nullptr;
+ PFN_vkDestroyFramebuffer DestroyFramebuffer = nullptr;
+ PFN_vkDestroyImage DestroyImage = nullptr;
+ PFN_vkDestroyImageView DestroyImageView = nullptr;
+ PFN_vkDestroyPipeline DestroyPipeline = nullptr;
+ PFN_vkDestroyPipelineCache DestroyPipelineCache = nullptr;
+ PFN_vkDestroyPipelineLayout DestroyPipelineLayout = nullptr;
+ PFN_vkDestroyQueryPool DestroyQueryPool = nullptr;
+ PFN_vkDestroyRenderPass DestroyRenderPass = nullptr;
+ PFN_vkDestroySampler DestroySampler = nullptr;
+ PFN_vkDestroySemaphore DestroySemaphore = nullptr;
+ PFN_vkDestroyShaderModule DestroyShaderModule = nullptr;
+ PFN_vkDeviceWaitIdle DeviceWaitIdle = nullptr;
+ PFN_vkEndCommandBuffer EndCommandBuffer = nullptr;
+ PFN_vkFlushMappedMemoryRanges FlushMappedMemoryRanges = nullptr;
+ PFN_vkFreeCommandBuffers FreeCommandBuffers = nullptr;
+ PFN_vkFreeDescriptorSets FreeDescriptorSets = nullptr;
+ PFN_vkFreeMemory FreeMemory = nullptr;
+ PFN_vkGetBufferMemoryRequirements GetBufferMemoryRequirements = nullptr;
+ PFN_vkGetDeviceMemoryCommitment GetDeviceMemoryCommitment = nullptr;
+ PFN_vkGetDeviceQueue GetDeviceQueue = nullptr;
+ PFN_vkGetEventStatus GetEventStatus = nullptr;
+ PFN_vkGetFenceStatus GetFenceStatus = nullptr;
+ PFN_vkGetImageMemoryRequirements GetImageMemoryRequirements = nullptr;
+ PFN_vkGetImageSparseMemoryRequirements GetImageSparseMemoryRequirements = nullptr;
+ PFN_vkGetImageSubresourceLayout GetImageSubresourceLayout = nullptr;
+ PFN_vkGetPipelineCacheData GetPipelineCacheData = nullptr;
+ PFN_vkGetQueryPoolResults GetQueryPoolResults = nullptr;
+ PFN_vkGetRenderAreaGranularity GetRenderAreaGranularity = nullptr;
+ PFN_vkInvalidateMappedMemoryRanges InvalidateMappedMemoryRanges = nullptr;
+ PFN_vkMapMemory MapMemory = nullptr;
+ PFN_vkMergePipelineCaches MergePipelineCaches = nullptr;
+ PFN_vkQueueBindSparse QueueBindSparse = nullptr;
+ PFN_vkQueueSubmit QueueSubmit = nullptr;
+ PFN_vkQueueWaitIdle QueueWaitIdle = nullptr;
+ PFN_vkResetCommandBuffer ResetCommandBuffer = nullptr;
+ PFN_vkResetCommandPool ResetCommandPool = nullptr;
+ PFN_vkResetDescriptorPool ResetDescriptorPool = nullptr;
+ PFN_vkResetEvent ResetEvent = nullptr;
+ PFN_vkResetFences ResetFences = nullptr;
+ PFN_vkSetEvent SetEvent = nullptr;
+ PFN_vkUnmapMemory UnmapMemory = nullptr;
+ PFN_vkUpdateDescriptorSets UpdateDescriptorSets = nullptr;
+ PFN_vkWaitForFences WaitForFences = nullptr;
+
+ // VK_KHR_swapchain
+ PFN_vkCreateSwapchainKHR CreateSwapchainKHR = nullptr;
+ PFN_vkDestroySwapchainKHR DestroySwapchainKHR = nullptr;
+ PFN_vkGetSwapchainImagesKHR GetSwapchainImagesKHR = nullptr;
+ PFN_vkAcquireNextImageKHR AcquireNextImageKHR = nullptr;
+ PFN_vkQueuePresentKHR QueuePresentKHR = nullptr;
+ };
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_VULKANFUNCTIONS_H_
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanInfo.cpp b/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanInfo.cpp
new file mode 100644
index 00000000000..d7b4a846a4a
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanInfo.cpp
@@ -0,0 +1,261 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn_native/vulkan/VulkanInfo.h"
+
+#include "dawn_native/vulkan/DeviceVk.h"
+
+#include <cstring>
+
+namespace {
+ bool IsLayerName(const VkLayerProperties& layer, const char* name) {
+ return strncmp(layer.layerName, name, VK_MAX_EXTENSION_NAME_SIZE) == 0;
+ }
+
+ bool IsExtensionName(const VkExtensionProperties& extension, const char* name) {
+ return strncmp(extension.extensionName, name, VK_MAX_EXTENSION_NAME_SIZE) == 0;
+ }
+} // namespace
+
+namespace dawn_native { namespace vulkan {
+
+ const char kLayerNameLunargStandardValidation[] = "VK_LAYER_LUNARG_standard_validation";
+ const char kLayerNameLunargVKTrace[] = "VK_LAYER_LUNARG_vktrace";
+ const char kLayerNameRenderDocCapture[] = "VK_LAYER_RENDERDOC_Capture";
+
+ const char kExtensionNameExtDebugReport[] = "VK_EXT_debug_report";
+ const char kExtensionNameKhrSurface[] = "VK_KHR_surface";
+ const char kExtensionNameKhrSwapchain[] = "VK_KHR_swapchain";
+
+ bool GatherGlobalInfo(const Device& device, VulkanGlobalInfo* info) {
+ // Gather the info about the instance layers
+ {
+ uint32_t count = 0;
+ VkResult result = device.fn.EnumerateInstanceLayerProperties(&count, nullptr);
+ // From the Vulkan spec result should be success if there are 0 layers,
+ // incomplete otherwise. This means that both values represent a success.
+ // This is the same for all Enumarte functions
+ if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
+ return false;
+ }
+
+ info->layers.resize(count);
+ result = device.fn.EnumerateInstanceLayerProperties(&count, info->layers.data());
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+
+ for (const auto& layer : info->layers) {
+ if (IsLayerName(layer, kLayerNameLunargStandardValidation)) {
+ info->standardValidation = true;
+ }
+ if (IsLayerName(layer, kLayerNameLunargVKTrace)) {
+ info->vktrace = true;
+ }
+ if (IsLayerName(layer, kLayerNameRenderDocCapture)) {
+ info->renderDocCapture = true;
+ }
+ }
+ }
+
+ // Gather the info about the instance extensions
+ {
+ uint32_t count = 0;
+ VkResult result =
+ device.fn.EnumerateInstanceExtensionProperties(nullptr, &count, nullptr);
+ if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
+ return false;
+ }
+
+ info->extensions.resize(count);
+ result = device.fn.EnumerateInstanceExtensionProperties(nullptr, &count,
+ info->extensions.data());
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+
+ for (const auto& extension : info->extensions) {
+ if (IsExtensionName(extension, kExtensionNameExtDebugReport)) {
+ info->debugReport = true;
+ }
+ if (IsExtensionName(extension, kExtensionNameKhrSurface)) {
+ info->surface = true;
+ }
+ }
+ }
+
+ // TODO(cwallez@chromium:org): Each layer can expose additional extensions, query them?
+
+ return true;
+ }
+
+ bool GetPhysicalDevices(const Device& device, std::vector<VkPhysicalDevice>* physicalDevices) {
+ VkInstance instance = device.GetInstance();
+
+ uint32_t count = 0;
+ VkResult result = device.fn.EnumeratePhysicalDevices(instance, &count, nullptr);
+ if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
+ return false;
+ }
+
+ physicalDevices->resize(count);
+ result = device.fn.EnumeratePhysicalDevices(instance, &count, physicalDevices->data());
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+
+ return true;
+ }
+
+ bool GatherDeviceInfo(const Device& device,
+ VkPhysicalDevice physicalDevice,
+ VulkanDeviceInfo* info) {
+ // Gather general info about the device
+ device.fn.GetPhysicalDeviceProperties(physicalDevice, &info->properties);
+ device.fn.GetPhysicalDeviceFeatures(physicalDevice, &info->features);
+
+ // Gather info about device memory.
+ {
+ VkPhysicalDeviceMemoryProperties memory;
+ device.fn.GetPhysicalDeviceMemoryProperties(physicalDevice, &memory);
+
+ info->memoryTypes.assign(memory.memoryTypes,
+ memory.memoryTypes + memory.memoryTypeCount);
+ info->memoryHeaps.assign(memory.memoryHeaps,
+ memory.memoryHeaps + memory.memoryHeapCount);
+ }
+
+ // Gather info about device queue families
+ {
+ uint32_t count = 0;
+ device.fn.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &count, nullptr);
+
+ info->queueFamilies.resize(count);
+ device.fn.GetPhysicalDeviceQueueFamilyProperties(physicalDevice, &count,
+ info->queueFamilies.data());
+ }
+
+ // Gather the info about the device layers
+ {
+ uint32_t count = 0;
+ VkResult result =
+ device.fn.EnumerateDeviceLayerProperties(physicalDevice, &count, nullptr);
+ if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
+ return false;
+ }
+
+ info->layers.resize(count);
+ result = device.fn.EnumerateDeviceLayerProperties(physicalDevice, &count,
+ info->layers.data());
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+ }
+
+ // Gather the info about the device extensions
+ {
+ uint32_t count = 0;
+ VkResult result = device.fn.EnumerateDeviceExtensionProperties(physicalDevice, nullptr,
+ &count, nullptr);
+ if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
+ return false;
+ }
+
+ info->extensions.resize(count);
+ result = device.fn.EnumerateDeviceExtensionProperties(physicalDevice, nullptr, &count,
+ info->extensions.data());
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+
+ for (const auto& extension : info->extensions) {
+ if (IsExtensionName(extension, kExtensionNameKhrSwapchain)) {
+ info->swapchain = true;
+ }
+ }
+ }
+
+ // TODO(cwallez@chromium.org): gather info about formats
+
+ return true;
+ }
+
+ bool GatherSurfaceInfo(const Device& device, VkSurfaceKHR surface, VulkanSurfaceInfo* info) {
+ VkPhysicalDevice physicalDevice = device.GetPhysicalDevice();
+
+ // Get the surface capabilities
+ {
+ VkResult result = device.fn.GetPhysicalDeviceSurfaceCapabilitiesKHR(
+ physicalDevice, surface, &info->capabilities);
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+ }
+
+ // Query which queue families support presenting this surface
+ {
+ size_t nQueueFamilies = device.GetDeviceInfo().queueFamilies.size();
+ info->supportedQueueFamilies.resize(nQueueFamilies, false);
+
+ for (uint32_t i = 0; i < nQueueFamilies; ++i) {
+ VkBool32 supported = VK_FALSE;
+ VkResult result = device.fn.GetPhysicalDeviceSurfaceSupportKHR(physicalDevice, i,
+ surface, &supported);
+
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+
+ info->supportedQueueFamilies[i] = (supported == VK_TRUE);
+ }
+ }
+
+ // Gather supported formats
+ {
+ uint32_t count = 0;
+ VkResult result = device.fn.GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface,
+ &count, nullptr);
+ if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
+ return false;
+ }
+
+ info->formats.resize(count);
+ result = device.fn.GetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &count,
+ info->formats.data());
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+ }
+
+ // Gather supported presents modes
+ {
+ uint32_t count = 0;
+ VkResult result = device.fn.GetPhysicalDeviceSurfacePresentModesKHR(
+ physicalDevice, surface, &count, nullptr);
+ if (result != VK_SUCCESS && result != VK_INCOMPLETE) {
+ return false;
+ }
+
+ info->presentModes.resize(count);
+ result = device.fn.GetPhysicalDeviceSurfacePresentModesKHR(
+ physicalDevice, surface, &count, info->presentModes.data());
+ if (result != VK_SUCCESS) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+}} // namespace dawn_native::vulkan
diff --git a/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanInfo.h b/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanInfo.h
new file mode 100644
index 00000000000..b87b666fef4
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_native/vulkan/VulkanInfo.h
@@ -0,0 +1,88 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKAN_VULKANINFO_H_
+#define DAWNNATIVE_VULKAN_VULKANINFO_H_
+
+#include "common/vulkan_platform.h"
+
+#include <vector>
+
+namespace dawn_native { namespace vulkan {
+
+ class Device;
+
+ extern const char kLayerNameLunargStandardValidation[];
+ extern const char kLayerNameLunargVKTrace[];
+ extern const char kLayerNameRenderDocCapture[];
+
+ extern const char kExtensionNameExtDebugReport[];
+ extern const char kExtensionNameKhrSurface[];
+ extern const char kExtensionNameKhrSwapchain[];
+
+ // Global information - gathered before the instance is created
+ struct VulkanGlobalKnobs {
+ // Layers
+ bool standardValidation = false;
+ bool vktrace = false;
+ bool renderDocCapture = false;
+
+ // Extensions
+ bool debugReport = false;
+ bool surface = false;
+ };
+
+ struct VulkanGlobalInfo : VulkanGlobalKnobs {
+ std::vector<VkLayerProperties> layers;
+ std::vector<VkExtensionProperties> extensions;
+ // TODO(cwallez@chromium.org): layer instance extensions
+ };
+
+ // Device information - gathered before the device is created.
+ struct VulkanDeviceKnobs {
+ VkPhysicalDeviceFeatures features;
+
+ // Extensions
+ bool swapchain = false;
+ };
+
+ struct VulkanDeviceInfo : VulkanDeviceKnobs {
+ VkPhysicalDeviceProperties properties;
+ std::vector<VkQueueFamilyProperties> queueFamilies;
+
+ std::vector<VkMemoryType> memoryTypes;
+ std::vector<VkMemoryHeap> memoryHeaps;
+
+ std::vector<VkLayerProperties> layers;
+ std::vector<VkExtensionProperties> extensions;
+ // TODO(cwallez@chromium.org): layer instance extensions
+ };
+
+ struct VulkanSurfaceInfo {
+ VkSurfaceCapabilitiesKHR capabilities;
+ std::vector<VkSurfaceFormatKHR> formats;
+ std::vector<VkPresentModeKHR> presentModes;
+ std::vector<bool> supportedQueueFamilies;
+ };
+
+ bool GatherGlobalInfo(const Device& device, VulkanGlobalInfo* info);
+ bool GetPhysicalDevices(const Device& device, std::vector<VkPhysicalDevice>* physicalDevices);
+ bool GatherDeviceInfo(const Device& device,
+ VkPhysicalDevice physicalDevice,
+ VulkanDeviceInfo* info);
+ bool GatherSurfaceInfo(const Device& device, VkSurfaceKHR surface, VulkanSurfaceInfo* info);
+
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKAN_VULKANINFO_H_
diff --git a/chromium/third_party/dawn/src/dawn_wire/WireCmd.h b/chromium/third_party/dawn/src/dawn_wire/WireCmd.h
new file mode 100644
index 00000000000..7419cd2f0a4
--- /dev/null
+++ b/chromium/third_party/dawn/src/dawn_wire/WireCmd.h
@@ -0,0 +1,68 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNWIRE_WIRECMD_H_
+#define DAWNWIRE_WIRECMD_H_
+
+#include <dawn/dawn.h>
+
+#include "dawn_wire/WireCmd_autogen.h"
+
+namespace dawn_wire {
+
+ struct ReturnDeviceErrorCallbackCmd {
+ ReturnWireCmd commandId = ReturnWireCmd::DeviceErrorCallback;
+
+ size_t messageStrlen;
+ };
+
+ struct BufferMapAsyncCmd {
+ WireCmd commandId = WireCmd::BufferMapAsync;
+
+ ObjectId bufferId;
+ ObjectSerial requestSerial;
+ uint32_t start;
+ uint32_t size;
+ bool isWrite;
+ };
+
+ struct ReturnBufferMapReadAsyncCallbackCmd {
+ ReturnWireCmd commandId = ReturnWireCmd::BufferMapReadAsyncCallback;
+
+ ObjectId bufferId;
+ ObjectSerial bufferSerial;
+ uint32_t requestSerial;
+ uint32_t status;
+ uint32_t dataLength;
+ };
+
+ struct ReturnBufferMapWriteAsyncCallbackCmd {
+ ReturnWireCmd commandId = ReturnWireCmd::BufferMapWriteAsyncCallback;
+
+ ObjectId bufferId;
+ ObjectSerial bufferSerial;
+ uint32_t requestSerial;
+ uint32_t status;
+ };
+
+ struct BufferUpdateMappedDataCmd {
+ WireCmd commandId = WireCmd::BufferUpdateMappedDataCmd;
+
+ ObjectId bufferId;
+ uint32_t dataLength;
+ };
+
+} // namespace dawn_wire
+
+#endif // DAWNWIRE_WIRECMD_H_
diff --git a/chromium/third_party/dawn/src/fuzzers/BUILD.gn b/chromium/third_party/dawn/src/fuzzers/BUILD.gn
new file mode 100644
index 00000000000..00f378940cf
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/BUILD.gn
@@ -0,0 +1,173 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("//build_overrides/build.gni")
+
+dawn_top_level = "../.."
+
+# We only have libfuzzer in Chromium builds but if we build fuzzer targets only
+# there, we would risk breaking fuzzer targets all the time when making changes
+# to Dawn. To avoid that, we make fuzzer targets compile in standalone builds
+# as well with a dawn_fuzzer_test target that acts like Chromium's fuzzer_test.
+#
+# The standalone fuzzer targets are able to run a single fuzzer input which
+# could help reproduce fuzzer crashes more easily because you don't need a
+# whole Chromium checkout.
+
+if (build_with_chromium) {
+ import("//testing/libfuzzer/fuzzer_test.gni")
+
+ # In Chromium build we just proxy everything to the real fuzzer_test
+ template("dawn_fuzzer_test") {
+ fuzzer_test(target_name) {
+ forward_variables_from(invoker, "*")
+ }
+ }
+} else {
+ import("//testing/test.gni")
+
+ # In standalone build we do something similar to fuzzer_test.
+ template("dawn_fuzzer_test") {
+ test(target_name) {
+ forward_variables_from(invoker,
+ [
+ "asan_options",
+ "cflags",
+ "cflags_cc",
+ "check_includes",
+ "defines",
+ "deps",
+ "include_dirs",
+ "sources",
+ ])
+
+ if (defined(asan_options)) {
+ not_needed([ "asan_options" ])
+ }
+
+ if (!defined(configs)) {
+ configs = []
+ }
+
+ # Weirdly fuzzer_test uses a special variable for additional configs.
+ if (defined(invoker.additional_configs)) {
+ configs += invoker.additional_configs
+ }
+
+ sources += [ "StandaloneFuzzerMain.cpp" ]
+ }
+ }
+}
+
+static_library("dawn_spirv_cross_fuzzer_common") {
+ sources = [
+ "DawnSPIRVCrossFuzzer.cpp",
+ "DawnSPIRVCrossFuzzer.h",
+ ]
+ public_deps = [
+ "${dawn_top_level}/third_party:spirv_cross",
+ ]
+}
+
+# TODO(rharrison): Remove asan_options once signal trap is no longer
+# needed.
+# Uses Dawn specific options and varies input data
+dawn_fuzzer_test("dawn_spirv_cross_glsl_fast_fuzzer") {
+ sources = [
+ "DawnSPIRVCrossGLSLFastFuzzer.cpp",
+ ]
+ deps = [
+ ":dawn_spirv_cross_fuzzer_common",
+ ]
+ asan_options = [ "allow_user_segv_handler=1" ]
+}
+
+# TODO(rharrison): Remove asan_options once signal trap is no longer
+# needed.
+# Varies both the options and input data
+dawn_fuzzer_test("dawn_spirv_cross_glsl_full_fuzzer") {
+ sources = [
+ "DawnSPIRVCrossGLSLFullFuzzer.cpp",
+ ]
+ deps = [
+ ":dawn_spirv_cross_fuzzer_common",
+ ]
+ asan_options = [ "allow_user_segv_handler=1" ]
+}
+
+# TODO(rharrison): Remove asan_options once signal trap is no longer
+# needed.
+# Uses Dawn specific options and varies input data
+dawn_fuzzer_test("dawn_spirv_cross_hlsl_fast_fuzzer") {
+ sources = [
+ "DawnSPIRVCrossGLSLFastFuzzer.cpp",
+ ]
+ deps = [
+ ":dawn_spirv_cross_fuzzer_common",
+ ]
+ asan_options = [ "allow_user_segv_handler=1" ]
+}
+
+# TODO(rharrison): Remove asan_options once signal trap is no longer
+# needed.
+# Varies both the options and input data
+dawn_fuzzer_test("dawn_spirv_cross_hlsl_full_fuzzer") {
+ sources = [
+ "DawnSPIRVCrossGLSLFullFuzzer.cpp",
+ ]
+ deps = [
+ ":dawn_spirv_cross_fuzzer_common",
+ ]
+ asan_options = [ "allow_user_segv_handler=1" ]
+}
+
+# TODO(rharrison): Remove asan_options once signal trap is no longer
+# needed.
+# Uses Dawn specific options and varies input data
+dawn_fuzzer_test("dawn_spirv_cross_msl_fast_fuzzer") {
+ sources = [
+ "DawnSPIRVCrossGLSLFastFuzzer.cpp",
+ ]
+ deps = [
+ ":dawn_spirv_cross_fuzzer_common",
+ ]
+ asan_options = [ "allow_user_segv_handler=1" ]
+}
+
+# TODO(rharrison): Remove asan_options once signal trap is no longer
+# needed.
+# Varies both the options and input data
+dawn_fuzzer_test("dawn_spirv_cross_msl_full_fuzzer") {
+ sources = [
+ "DawnSPIRVCrossGLSLFullFuzzer.cpp",
+ ]
+ deps = [
+ ":dawn_spirv_cross_fuzzer_common",
+ ]
+ asan_options = [ "allow_user_segv_handler=1" ]
+}
+
+dawn_fuzzer_test("dawn_wire_server_and_frontend_fuzzer") {
+ sources = [
+ "DawnWireServerAndFrontendFuzzer.cpp",
+ ]
+
+ deps = [
+ "${dawn_top_level}:libdawn_sources",
+ "${dawn_top_level}:libdawn_native_sources",
+ "${dawn_top_level}:libdawn_wire_sources",
+ ]
+
+ additional_configs = [ "${dawn_top_level}:dawn_shared_library_public" ]
+}
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossFuzzer.cpp b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossFuzzer.cpp
new file mode 100644
index 00000000000..c37b2156ad5
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossFuzzer.cpp
@@ -0,0 +1,107 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <csetjmp>
+#include <csignal>
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include "DawnSPIRVCrossFuzzer.h"
+
+namespace {
+
+ std::jmp_buf jump_buffer;
+ void (*old_signal_handler)(int);
+
+ // Handler to trap signals, so that it doesn't crash the fuzzer when running
+ // the code under test. Currently the
+ // code being fuzzed uses abort() to report errors like bad input instead of
+ // returning an error code. This will be changing in the future.
+ //
+ // TODO(rharrison): Remove all of this signal trapping once SPIRV-Cross has
+ // been changed to not use abort() for reporting errors.
+ [[noreturn]] static void sigabrt_trap(int sig) {
+ std::longjmp(jump_buffer, 1);
+ }
+
+ // Setup the SIGABRT trap
+ void BeginSIGABRTTrap() {
+ old_signal_handler = signal(SIGABRT, sigabrt_trap);
+ if (old_signal_handler == SIG_ERR)
+ abort();
+ }
+
+ // Restore the previous signal handler
+ void EndSIGABRTTrap() {
+ signal(SIGABRT, old_signal_handler);
+ }
+
+} // namespace
+
+namespace DawnSPIRVCrossFuzzer {
+
+ void ExecuteWithSignalTrap(std::function<void()> exec) {
+ BeginSIGABRTTrap();
+
+ // On the first pass through setjmp will return 0, if returning here
+ // from the longjmp in the signal handler it will return 1.
+ if (setjmp(jump_buffer) == 0) {
+ exec();
+ }
+
+ EndSIGABRTTrap();
+ }
+
+ int Run(const uint8_t* data, size_t size, Task task) {
+ if (!data || size < 1)
+ return 0;
+
+ size_t sizeInU32 = size / sizeof(uint32_t);
+ const uint32_t* u32Data = reinterpret_cast<const uint32_t*>(data);
+ std::vector<uint32_t> input(u32Data, u32Data + sizeInU32);
+
+ task(input);
+ return 0;
+ }
+
+ template <class Options>
+ int RunWithOptions(const uint8_t* data, size_t size, TaskWithOptions<Options> task) {
+ if (!data || size < sizeof(Options) + 1)
+ return 0;
+
+ Options options = *reinterpret_cast<const Options*>(data);
+ data += sizeof(options);
+ size -= sizeof(options);
+
+ std::vector<uint32_t> input(data, data + (4 * (size / 4)));
+
+ task(input, options);
+
+ return 0;
+ }
+
+ template int RunWithOptions<spirv_cross::CompilerGLSL::Options>(
+ const uint8_t*,
+ size_t,
+ TaskWithOptions<spirv_cross::CompilerGLSL::Options>);
+ template int RunWithOptions<spirv_cross::CompilerHLSL::Options>(
+ const uint8_t*,
+ size_t,
+ TaskWithOptions<spirv_cross::CompilerHLSL::Options>);
+ template int RunWithOptions<CombinedOptions>(const uint8_t*,
+ size_t,
+ TaskWithOptions<CombinedOptions>);
+
+} // namespace DawnSPIRVCrossFuzzer
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossFuzzer.h b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossFuzzer.h
new file mode 100644
index 00000000000..47e30400ac8
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossFuzzer.h
@@ -0,0 +1,44 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <functional>
+#include <vector>
+
+#include "spirv-cross/spirv_glsl.hpp"
+#include "spirv-cross/spirv_hlsl.hpp"
+
+namespace DawnSPIRVCrossFuzzer {
+
+ struct CombinedOptions {
+ spirv_cross::CompilerGLSL::Options glsl;
+ spirv_cross::CompilerHLSL::Options hlsl;
+ };
+
+ using Task = std::function<int(const std::vector<uint32_t>&)>;
+ template <class Options>
+ using TaskWithOptions = std::function<int(const std::vector<uint32_t>&, Options)>;
+
+ // Used to wrap code that may fire a SIGABRT. Do not allocate anything local within |exec|, as
+ // it is not guaranteed to return.
+ void ExecuteWithSignalTrap(std::function<void()> exec);
+
+ // Used to fuzz by mutating the input data, but with fixed options to the compiler
+ int Run(const uint8_t* data, size_t size, Task task);
+
+ // Used to fuzz by mutating both the input data and options to the compiler
+ template <class Options>
+ int RunWithOptions(const uint8_t* data, size_t size, TaskWithOptions<Options> task);
+
+} // namespace DawnSPIRVCrossFuzzer
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp
new file mode 100644
index 00000000000..53b06cf3932
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossGLSLFastFuzzer.cpp
@@ -0,0 +1,46 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include "DawnSPIRVCrossFuzzer.h"
+
+namespace {
+
+ int GLSLFastFuzzTask(const std::vector<uint32_t>& input) {
+ std::unique_ptr<spirv_cross::CompilerGLSL> compiler;
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler, input]() {
+ compiler = std::make_unique<spirv_cross::CompilerGLSL>(input);
+ });
+ if (compiler == nullptr) {
+ return 0;
+ }
+
+ // Using the options that are used by Dawn, they appear in ShaderModuleGL.cpp
+ spirv_cross::CompilerGLSL::Options options;
+ options.version = 440;
+ compiler->set_common_options(options);
+
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler]() { compiler->compile(); });
+
+ return 0;
+ }
+
+} // namespace
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ return DawnSPIRVCrossFuzzer::Run(data, size, GLSLFastFuzzTask);
+}
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossGLSLFullFuzzer.cpp b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossGLSLFullFuzzer.cpp
new file mode 100644
index 00000000000..2ff9fefb7d2
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossGLSLFullFuzzer.cpp
@@ -0,0 +1,45 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include "DawnSPIRVCrossFuzzer.h"
+
+namespace {
+
+ int GLSLFullFuzzTask(const std::vector<uint32_t>& input,
+ spirv_cross::CompilerGLSL::Options options) {
+ std::unique_ptr<spirv_cross::CompilerGLSL> compiler;
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler, input]() {
+ compiler = std::make_unique<spirv_cross::CompilerGLSL>(input);
+ });
+ if (compiler == nullptr) {
+ return 0;
+ }
+
+ compiler->set_common_options(options);
+
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler]() { compiler->compile(); });
+
+ return 0;
+ }
+
+} // namespace
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ return DawnSPIRVCrossFuzzer::RunWithOptions<spirv_cross::CompilerGLSL::Options>(
+ data, size, GLSLFullFuzzTask);
+}
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp
new file mode 100644
index 00000000000..9d9cd9d24ed
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossHLSLFastFuzzer.cpp
@@ -0,0 +1,53 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include "DawnSPIRVCrossFuzzer.h"
+
+#include "spirv-cross/spirv_hlsl.hpp"
+
+namespace {
+
+ int FuzzTask(const std::vector<uint32_t>& input) {
+ std::unique_ptr<spirv_cross::CompilerHLSL> compiler;
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler, input]() {
+ compiler = std::make_unique<spirv_cross::CompilerHLSL>(input);
+ });
+ if (compiler == nullptr) {
+ return 0;
+ }
+
+ // Using the options that are used by Dawn, they appear in ShaderModuleD3D12.cpp
+ spirv_cross::CompilerGLSL::Options options_glsl;
+ options_glsl.vertex.fixup_clipspace = true;
+ options_glsl.vertex.flip_vert_y = true;
+ compiler->set_common_options(options_glsl);
+
+ spirv_cross::CompilerHLSL::Options options_hlsl;
+ options_hlsl.shader_model = 51;
+ compiler->set_hlsl_options(options_hlsl);
+
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler]() { compiler->compile(); });
+
+ return 0;
+ }
+
+} // namespace
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ return DawnSPIRVCrossFuzzer::Run(data, size, FuzzTask);
+}
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossHLSLFullFuzzer.cpp b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossHLSLFullFuzzer.cpp
new file mode 100644
index 00000000000..2433752ca4a
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossHLSLFullFuzzer.cpp
@@ -0,0 +1,46 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include "DawnSPIRVCrossFuzzer.h"
+
+#include "spirv-cross/spirv_hlsl.hpp"
+
+namespace {
+ int FuzzTask(const std::vector<uint32_t>& input,
+ DawnSPIRVCrossFuzzer::CombinedOptions options) {
+ std::unique_ptr<spirv_cross::CompilerHLSL> compiler;
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler, input]() {
+ compiler = std::make_unique<spirv_cross::CompilerHLSL>(input);
+ });
+ if (compiler == nullptr) {
+ return 0;
+ }
+
+ compiler->set_common_options(options.glsl);
+ compiler->set_hlsl_options(options.hlsl);
+
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler]() { compiler->compile(); });
+ return 0;
+ }
+
+} // namespace
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ return DawnSPIRVCrossFuzzer::RunWithOptions<DawnSPIRVCrossFuzzer::CombinedOptions>(data, size,
+ FuzzTask);
+}
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp
new file mode 100644
index 00000000000..4b0da62e276
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossMSLFastFuzzer.cpp
@@ -0,0 +1,47 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include "DawnSPIRVCrossFuzzer.h"
+
+#include "spirv-cross/spirv_msl.hpp"
+
+namespace {
+
+ int FuzzTask(const std::vector<uint32_t>& input) {
+ std::unique_ptr<spirv_cross::CompilerMSL> compiler;
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap(
+ [&compiler, input]() { compiler = std::make_unique<spirv_cross::CompilerMSL>(input); });
+ if (compiler == nullptr) {
+ return 0;
+ }
+
+ // Using the options that are used by Dawn, they appear in ShaderModuleMTL.mm
+ spirv_cross::CompilerGLSL::Options options;
+ options.vertex.flip_vert_y = true;
+ compiler->spirv_cross::CompilerGLSL::set_common_options(options);
+
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler]() { compiler->compile(); });
+
+ return 0;
+ }
+
+} // namespace
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ return DawnSPIRVCrossFuzzer::Run(data, size, FuzzTask);
+}
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossMSLFullFuzzer.cpp b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossMSLFullFuzzer.cpp
new file mode 100644
index 00000000000..7b66edd93c9
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnSPIRVCrossMSLFullFuzzer.cpp
@@ -0,0 +1,45 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <string>
+#include <vector>
+
+#include "DawnSPIRVCrossFuzzer.h"
+
+#include "spirv-cross/spirv_msl.hpp"
+
+namespace {
+
+ int FuzzTask(const std::vector<uint32_t>& input, spirv_cross::CompilerGLSL::Options options) {
+ std::unique_ptr<spirv_cross::CompilerMSL> compiler;
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap(
+ [&compiler, input]() { compiler = std::make_unique<spirv_cross::CompilerMSL>(input); });
+ if (compiler == nullptr) {
+ return 0;
+ }
+
+ compiler->spirv_cross::CompilerGLSL::set_common_options(options);
+
+ DawnSPIRVCrossFuzzer::ExecuteWithSignalTrap([&compiler]() { compiler->compile(); });
+
+ return 0;
+ }
+
+} // namespace
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ return DawnSPIRVCrossFuzzer::RunWithOptions<spirv_cross::CompilerGLSL::Options>(data, size,
+ FuzzTask);
+}
diff --git a/chromium/third_party/dawn/src/fuzzers/DawnWireServerAndFrontendFuzzer.cpp b/chromium/third_party/dawn/src/fuzzers/DawnWireServerAndFrontendFuzzer.cpp
new file mode 100644
index 00000000000..f6778921521
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/DawnWireServerAndFrontendFuzzer.cpp
@@ -0,0 +1,57 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "dawn/dawncpp.h"
+#include "dawn_native/DawnNative.h"
+#include "dawn_native/NullBackend.h"
+#include "dawn_wire/Wire.h"
+
+#include <vector>
+
+class DevNull : public dawn_wire::CommandSerializer {
+ public:
+ void* GetCmdSpace(size_t size) override {
+ if (size > buf.size()) {
+ buf.resize(size);
+ }
+ return buf.data();
+ }
+ bool Flush() override {
+ return true;
+ };
+
+ private:
+ std::vector<char> buf;
+};
+
+void SkipSwapChainBuilderSetImplementation(dawnSwapChainBuilder builder, uint64_t) {
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ dawnProcTable procs = dawn_native::GetProcs();
+ // SwapChainSetImplementation receives a pointer, skip calls to it as they would be intercepted
+ // in embedders or dawn_wire too.
+ procs.swapChainBuilderSetImplementation = SkipSwapChainBuilderSetImplementation;
+ dawnSetProcs(&procs);
+
+ dawn::Device nullDevice = dawn::Device::Acquire(dawn_native::null::CreateDevice());
+
+ DevNull devNull;
+ std::unique_ptr<dawn_wire::CommandHandler> wireServer(
+ dawn_wire::NewServerCommandHandler(nullDevice.Get(), procs, &devNull));
+
+ wireServer->HandleCommands(reinterpret_cast<const char*>(data), size);
+
+ return 0;
+}
diff --git a/chromium/third_party/dawn/src/fuzzers/StandaloneFuzzerMain.cpp b/chromium/third_party/dawn/src/fuzzers/StandaloneFuzzerMain.cpp
new file mode 100644
index 00000000000..ba8d94b99db
--- /dev/null
+++ b/chromium/third_party/dawn/src/fuzzers/StandaloneFuzzerMain.cpp
@@ -0,0 +1,62 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <cstdint>
+#include <cstdlib>
+#include <iostream>
+#include <vector>
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size);
+
+int main(int argc, char** argv) {
+ if (argc != 2) {
+ std::cout << "Usage: <standalone reproducer> [FILE]" << std::endl;
+ return 1;
+ }
+
+ std::cout << "WARNING: this is just a best-effort reproducer for fuzzer issues in standalone "
+ << "Dawn builds. For the real fuzzer, please build inside Chromium." << std::endl;
+
+ const char* filename = argv[1];
+ std::cout << "Reproducing using file: " << filename << std::endl;
+
+ std::vector<char> data;
+ {
+ FILE* file = fopen(filename, "rb");
+ if (!file) {
+ std::cerr << "Failed to open " << filename << std::endl;
+ return 1;
+ }
+
+ fseek(file, 0, SEEK_END);
+ long tellFileSize = ftell(file);
+ if (tellFileSize <= 0) {
+ std::cerr << "Input file of incorrect size: " << filename << std::endl;
+ return 1;
+ }
+ fseek(file, 0, SEEK_SET);
+
+ size_t fileSize = static_cast<size_t>(tellFileSize);
+ data.resize(fileSize);
+
+ size_t bytesRead = fread(data.data(), sizeof(char), fileSize, file);
+ fclose(file);
+ if (bytesRead != fileSize) {
+ std::cerr << "Failed to read " << filename << std::endl;
+ return 1;
+ }
+ }
+
+ return LLVMFuzzerTestOneInput(reinterpret_cast<const uint8_t*>(data.data()), data.size());
+}
diff --git a/chromium/third_party/dawn/src/include/dawn/EnumClassBitmasks.h b/chromium/third_party/dawn/src/include/dawn/EnumClassBitmasks.h
new file mode 100644
index 00000000000..7e1d769a9b0
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn/EnumClassBitmasks.h
@@ -0,0 +1,162 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWN_ENUM_CLASS_BITMASKS_H_
+#define DAWN_ENUM_CLASS_BITMASKS_H_
+
+#include <type_traits>
+
+namespace dawn {
+
+// std::underlying_type doesn't work in old GLIBC still used in Chrome
+#define CR_GLIBCXX_4_7_0 20120322
+#define CR_GLIBCXX_4_5_4 20120702
+#define CR_GLIBCXX_4_6_4 20121127
+#if defined(__GLIBCXX__) && (__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
+ __GLIBCXX__ == CR_GLIBCXX_4_6_4)
+# define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
+#endif
+
+#if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX)
+ template <typename T>
+ struct UnderlyingType {
+ using type = __underlying_type(T);
+ };
+#else
+ template <typename T>
+ using UnderlyingType = std::underlying_type<T>;
+#endif
+
+ template <typename T>
+ struct IsDawnBitmask {
+ static constexpr bool enable = false;
+ };
+
+ template <typename T, typename Enable = void>
+ struct LowerBitmask {
+ static constexpr bool enable = false;
+ };
+
+ template <typename T>
+ struct LowerBitmask<T, typename std::enable_if<IsDawnBitmask<T>::enable>::type> {
+ static constexpr bool enable = true;
+ using type = T;
+ constexpr static T Lower(T t) {
+ return t;
+ }
+ };
+
+ template <typename T>
+ struct BoolConvertible {
+ using Integral = typename UnderlyingType<T>::type;
+
+ constexpr BoolConvertible(Integral value) : value(value) {
+ }
+ constexpr operator bool() const {
+ return value != 0;
+ }
+ constexpr operator T() const {
+ return static_cast<T>(value);
+ }
+
+ Integral value;
+ };
+
+ template <typename T>
+ struct LowerBitmask<BoolConvertible<T>> {
+ static constexpr bool enable = true;
+ using type = T;
+ static constexpr type Lower(BoolConvertible<T> t) {
+ return t;
+ }
+ };
+
+ template <typename T>
+ constexpr bool HasZeroOrOneBits(T value) {
+ using Integral = typename UnderlyingType<T>::type;
+ return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
+ }
+
+ template <typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename UnderlyingType<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+ }
+
+ template <typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename UnderlyingType<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+ }
+
+ template <typename T1,
+ typename T2,
+ typename = typename std::enable_if<LowerBitmask<T1>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename UnderlyingType<T>::type;
+ return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
+ static_cast<Integral>(LowerBitmask<T2>::Lower(right));
+ }
+
+ template <typename T1>
+ constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
+ using T = typename LowerBitmask<T1>::type;
+ using Integral = typename UnderlyingType<T>::type;
+ return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
+ }
+
+ template <typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr T& operator&=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l & r;
+ return l;
+ }
+
+ template <typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr T& operator|=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l | r;
+ return l;
+ }
+
+ template <typename T,
+ typename T2,
+ typename = typename std::enable_if<IsDawnBitmask<T>::enable &&
+ LowerBitmask<T2>::enable>::type>
+ constexpr T& operator^=(T& l, T2 right) {
+ T r = LowerBitmask<T2>::Lower(right);
+ l = l ^ r;
+ return l;
+ }
+} // namespace dawn
+
+#endif // DAWN_ENUM_CLASS_BITMASKS_H_
diff --git a/chromium/third_party/dawn/src/include/dawn/dawn_export.h b/chromium/third_party/dawn/src/include/dawn/dawn_export.h
new file mode 100644
index 00000000000..d00c8fdb857
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn/dawn_export.h
@@ -0,0 +1,32 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWN_EXPORT_H_
+#define DAWN_EXPORT_H_
+
+#if defined(_WIN32)
+# if defined(DAWN_IMPLEMENTATION)
+# define DAWN_EXPORT __declspec(dllexport)
+# else
+# define DAWN_EXPORT __declspec(dllimport)
+# endif
+#else
+# if defined(DAWN_IMPLEMENTATION)
+# define DAWN_EXPORT __attribute__((visibility("default")))
+# else
+# define DAWN_EXPORT
+# endif
+#endif
+
+#endif // DAWN_EXPORT_H_
diff --git a/chromium/third_party/dawn/src/include/dawn/dawn_wsi.h b/chromium/third_party/dawn/src/include/dawn/dawn_wsi.h
new file mode 100644
index 00000000000..8e42b21fa0c
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn/dawn_wsi.h
@@ -0,0 +1,85 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWN_DAWN_WSI_H_
+#define DAWN_DAWN_WSI_H_
+
+#include <dawn/dawn.h>
+
+// Error message (or nullptr if there was no error)
+typedef const char* dawnSwapChainError;
+constexpr dawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
+
+typedef struct {
+ /// Backend-specific texture id/name/pointer
+ union {
+ void* ptr;
+ uint64_t u64;
+ uint32_t u32;
+ } texture;
+} dawnSwapChainNextTexture;
+
+typedef struct {
+ /// Initialize the swap chain implementation.
+ /// (*wsiContext) is one of dawnWSIContext{D3D12,Metal,GL}
+ void (*Init)(void* userData, void* wsiContext);
+
+ /// Destroy the swap chain implementation.
+ void (*Destroy)(void* userData);
+
+ /// Configure/reconfigure the swap chain.
+ dawnSwapChainError (*Configure)(void* userData,
+ dawnTextureFormat format,
+ dawnTextureUsageBit allowedUsage,
+ uint32_t width,
+ uint32_t height);
+
+ /// Acquire the next texture from the swap chain.
+ dawnSwapChainError (*GetNextTexture)(void* userData, dawnSwapChainNextTexture* nextTexture);
+
+ /// Present the last acquired texture to the screen.
+ dawnSwapChainError (*Present)(void* userData);
+
+ /// Each function is called with userData as its first argument.
+ void* userData;
+
+ /// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
+ dawnTextureUsageBit textureUsage;
+} dawnSwapChainImplementation;
+
+#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
+typedef struct {
+ dawnDevice device = nullptr;
+} dawnWSIContextD3D12;
+#endif
+
+#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
+# import <Metal/Metal.h>
+
+typedef struct {
+ id<MTLDevice> device = nil;
+} dawnWSIContextMetal;
+#endif
+
+#ifdef DAWN_ENABLE_BACKEND_OPENGL
+typedef struct {
+} dawnWSIContextGL;
+#endif
+
+#ifdef DAWN_ENABLE_BACKEND_VULKAN
+typedef struct {
+} dawnWSIContextVulkan;
+#endif
+
+#endif // DAWN_DAWN_WSI_H
diff --git a/chromium/third_party/dawn/src/include/dawn_native/D3D12Backend.h b/chromium/third_party/dawn/src/include/dawn_native/D3D12Backend.h
new file mode 100644
index 00000000000..ddc3f12fb32
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_native/D3D12Backend.h
@@ -0,0 +1,33 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_D3D12BACKEND_H_
+#define DAWNNATIVE_D3D12BACKEND_H_
+
+#include <dawn/dawn.h>
+#include <dawn/dawn_wsi.h>
+#include <dawn_native/dawn_native_export.h>
+
+#include <windows.h>
+
+namespace dawn_native { namespace d3d12 {
+ DAWN_NATIVE_EXPORT dawnDevice CreateDevice();
+
+ DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device,
+ HWND window);
+ DAWN_NATIVE_EXPORT dawnTextureFormat
+ GetNativeSwapChainPreferredFormat(const dawnSwapChainImplementation* swapChain);
+}} // namespace dawn_native::d3d12
+
+#endif // DAWNNATIVE_D3D12BACKEND_H_
diff --git a/chromium/third_party/dawn/src/include/dawn_native/DawnNative.h b/chromium/third_party/dawn/src/include/dawn_native/DawnNative.h
new file mode 100644
index 00000000000..f90dc9eaa6d
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_native/DawnNative.h
@@ -0,0 +1,37 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_DAWNNATIVE_H_
+#define DAWNNATIVE_DAWNNATIVE_H_
+
+#include <dawn/dawn.h>
+#include <dawn_native/dawn_native_export.h>
+
+#include <string>
+
+namespace dawn_native {
+ struct PCIInfo {
+ uint32_t deviceId = 0;
+ uint32_t vendorId = 0;
+ std::string name;
+ };
+
+ // Backend-agnostic API for dawn_native
+ DAWN_NATIVE_EXPORT dawnProcTable GetProcs();
+
+ DAWN_NATIVE_EXPORT const PCIInfo& GetPCIInfo(dawnDevice device);
+
+} // namespace dawn_native
+
+#endif // DAWNNATIVE_DAWNNATIVE_H_
diff --git a/chromium/third_party/dawn/src/include/dawn_native/MetalBackend.h b/chromium/third_party/dawn/src/include/dawn_native/MetalBackend.h
new file mode 100644
index 00000000000..758868d1f3a
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_native/MetalBackend.h
@@ -0,0 +1,31 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_METALBACKEND_H_
+#define DAWNNATIVE_METALBACKEND_H_
+
+#include <dawn/dawn.h>
+#include <dawn/dawn_wsi.h>
+#include <dawn_native/dawn_native_export.h>
+
+#import <Metal/Metal.h>
+#import <QuartzCore/CAMetalLayer.h>
+
+namespace dawn_native { namespace metal {
+ DAWN_NATIVE_EXPORT dawnDevice CreateDevice(id<MTLDevice> metalDevice);
+ DAWN_NATIVE_EXPORT void SetNextDrawable(dawnDevice device, id<CAMetalDrawable> drawable);
+ DAWN_NATIVE_EXPORT void Present(dawnDevice device);
+}} // namespace dawn_native::metal
+
+#endif // DAWNNATIVE_METALBACKEND_H_
diff --git a/chromium/third_party/dawn/src/include/dawn_native/NullBackend.h b/chromium/third_party/dawn/src/include/dawn_native/NullBackend.h
new file mode 100644
index 00000000000..be7c3e715e1
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_native/NullBackend.h
@@ -0,0 +1,25 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_NULLBACKEND_H_
+#define DAWNNATIVE_NULLBACKEND_H_
+
+#include <dawn/dawn.h>
+#include <dawn_native/dawn_native_export.h>
+
+namespace dawn_native { namespace null {
+ DAWN_NATIVE_EXPORT dawnDevice CreateDevice();
+}} // namespace dawn_native::null
+
+#endif // DAWNNATIVE_NULLBACKEND_H_
diff --git a/chromium/third_party/dawn/src/include/dawn_native/OpenGLBackend.h b/chromium/third_party/dawn/src/include/dawn_native/OpenGLBackend.h
new file mode 100644
index 00000000000..e31f7d38d5d
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_native/OpenGLBackend.h
@@ -0,0 +1,25 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_OPENGLBACKEND_H_
+#define DAWNNATIVE_OPENGLBACKEND_H_
+
+#include <dawn/dawn.h>
+#include <dawn_native/dawn_native_export.h>
+
+namespace dawn_native { namespace opengl {
+ DAWN_NATIVE_EXPORT dawnDevice CreateDevice(void* (*getProc)(const char*));
+}} // namespace dawn_native::opengl
+
+#endif // DAWNNATIVE_OPENGLBACKEND_H_
diff --git a/chromium/third_party/dawn/src/include/dawn_native/VulkanBackend.h b/chromium/third_party/dawn/src/include/dawn_native/VulkanBackend.h
new file mode 100644
index 00000000000..e52e0cec046
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_native/VulkanBackend.h
@@ -0,0 +1,38 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_VULKANBACKEND_H_
+#define DAWNNATIVE_VULKANBACKEND_H_
+
+#include <dawn/dawn.h>
+#include <dawn/dawn_wsi.h>
+#include <dawn_native/dawn_native_export.h>
+
+#include <vulkan/vulkan.h>
+
+#include <vector>
+
+namespace dawn_native { namespace vulkan {
+ DAWN_NATIVE_EXPORT dawnDevice
+ CreateDevice(const std::vector<const char*>& requiredInstanceExtensions);
+
+ DAWN_NATIVE_EXPORT VkInstance GetInstance(dawnDevice device);
+
+ DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device,
+ VkSurfaceKHR surface);
+ DAWN_NATIVE_EXPORT dawnTextureFormat
+ GetNativeSwapChainPreferredFormat(const dawnSwapChainImplementation* swapChain);
+}} // namespace dawn_native::vulkan
+
+#endif // DAWNNATIVE_VULKANBACKEND_H_
diff --git a/chromium/third_party/dawn/src/include/dawn_native/dawn_native_export.h b/chromium/third_party/dawn/src/include/dawn_native/dawn_native_export.h
new file mode 100644
index 00000000000..f2581679543
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_native/dawn_native_export.h
@@ -0,0 +1,32 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNNATIVE_EXPORT_H_
+#define DAWNNATIVE_EXPORT_H_
+
+#if defined(_WIN32)
+# if defined(DAWN_NATIVE_IMPLEMENTATION)
+# define DAWN_NATIVE_EXPORT __declspec(dllexport)
+# else
+# define DAWN_NATIVE_EXPORT __declspec(dllimport)
+# endif
+#else
+# if defined(DAWN_NATIVE_IMPLEMENTATION)
+# define DAWN_NATIVE_EXPORT __attribute__((visibility("default")))
+# else
+# define DAWN_NATIVE_EXPORT
+# endif
+#endif
+
+#endif // DAWNNATIVE_EXPORT_H_
diff --git a/chromium/third_party/dawn/src/include/dawn_wire/Wire.h b/chromium/third_party/dawn/src/include/dawn_wire/Wire.h
new file mode 100644
index 00000000000..f9cdd6ef0b1
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_wire/Wire.h
@@ -0,0 +1,47 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNWIRE_WIRE_H_
+#define DAWNWIRE_WIRE_H_
+
+#include <cstdint>
+
+#include "dawn/dawn.h"
+#include "dawn_wire/dawn_wire_export.h"
+
+namespace dawn_wire {
+
+ class DAWN_WIRE_EXPORT CommandSerializer {
+ public:
+ virtual ~CommandSerializer() = default;
+ virtual void* GetCmdSpace(size_t size) = 0;
+ virtual bool Flush() = 0;
+ };
+
+ class DAWN_WIRE_EXPORT CommandHandler {
+ public:
+ virtual ~CommandHandler() = default;
+ virtual const char* HandleCommands(const char* commands, size_t size) = 0;
+ };
+
+ DAWN_WIRE_EXPORT CommandHandler* NewClientDevice(dawnProcTable* procs,
+ dawnDevice* device,
+ CommandSerializer* serializer);
+ DAWN_WIRE_EXPORT CommandHandler* NewServerCommandHandler(dawnDevice device,
+ const dawnProcTable& procs,
+ CommandSerializer* serializer);
+
+} // namespace dawn_wire
+
+#endif // DAWNWIRE_WIRE_H_
diff --git a/chromium/third_party/dawn/src/include/dawn_wire/dawn_wire_export.h b/chromium/third_party/dawn/src/include/dawn_wire/dawn_wire_export.h
new file mode 100644
index 00000000000..d22376266d3
--- /dev/null
+++ b/chromium/third_party/dawn/src/include/dawn_wire/dawn_wire_export.h
@@ -0,0 +1,32 @@
+// Copyright 2018 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef DAWNWIRE_EXPORT_H_
+#define DAWNWIRE_EXPORT_H_
+
+#if defined(_WIN32)
+# if defined(DAWN_WIRE_IMPLEMENTATION)
+# define DAWN_WIRE_EXPORT __declspec(dllexport)
+# else
+# define DAWN_WIRE_EXPORT __declspec(dllimport)
+# endif
+#else
+# if defined(DAWN_WIRE_IMPLEMENTATION)
+# define DAWN_WIRE_EXPORT __attribute__((visibility("default")))
+# else
+# define DAWN_WIRE_EXPORT
+# endif
+#endif
+
+#endif // DAWNWIRE_EXPORT_H_
diff --git a/chromium/third_party/dawn/src/utils/BackendBinding.cpp b/chromium/third_party/dawn/src/utils/BackendBinding.cpp
new file mode 100644
index 00000000000..a3fcf255428
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/BackendBinding.cpp
@@ -0,0 +1,73 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "utils/BackendBinding.h"
+
+#include "common/Assert.h"
+
+namespace utils {
+
+#if defined(DAWN_ENABLE_BACKEND_D3D12)
+ BackendBinding* CreateD3D12Binding();
+#endif
+#if defined(DAWN_ENABLE_BACKEND_METAL)
+ BackendBinding* CreateMetalBinding();
+#endif
+#if defined(DAWN_ENABLE_BACKEND_NULL)
+ BackendBinding* CreateNullBinding();
+#endif
+#if defined(DAWN_ENABLE_BACKEND_OPENGL)
+ BackendBinding* CreateOpenGLBinding();
+#endif
+#if defined(DAWN_ENABLE_BACKEND_VULKAN)
+ BackendBinding* CreateVulkanBinding();
+#endif
+
+ void BackendBinding::SetWindow(GLFWwindow* window) {
+ mWindow = window;
+ }
+
+ BackendBinding* CreateBinding(BackendType type) {
+ switch (type) {
+#if defined(DAWN_ENABLE_BACKEND_D3D12)
+ case BackendType::D3D12:
+ return CreateD3D12Binding();
+#endif
+
+#if defined(DAWN_ENABLE_BACKEND_METAL)
+ case BackendType::Metal:
+ return CreateMetalBinding();
+#endif
+
+#if defined(DAWN_ENABLE_BACKEND_NULL)
+ case BackendType::Null:
+ return CreateNullBinding();
+#endif
+
+#if defined(DAWN_ENABLE_BACKEND_OPENGL)
+ case BackendType::OpenGL:
+ return CreateOpenGLBinding();
+#endif
+
+#if defined(DAWN_ENABLE_BACKEND_VULKAN)
+ case BackendType::Vulkan:
+ return CreateVulkanBinding();
+#endif
+
+ default:
+ return nullptr;
+ }
+ }
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/src/utils/BackendBinding.h b/chromium/third_party/dawn/src/utils/BackendBinding.h
new file mode 100644
index 00000000000..622f8d73602
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/BackendBinding.h
@@ -0,0 +1,53 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef UTILS_BACKENDBINDING_H_
+#define UTILS_BACKENDBINDING_H_
+
+#include <dawn/dawn_wsi.h>
+
+struct GLFWwindow;
+typedef struct dawnProcTable_s dawnProcTable;
+typedef struct dawnDeviceImpl* dawnDevice;
+
+namespace utils {
+
+ enum class BackendType {
+ D3D12,
+ Metal,
+ OpenGL,
+ Null,
+ Vulkan,
+ };
+
+ class BackendBinding {
+ public:
+ virtual ~BackendBinding() = default;
+
+ virtual void SetupGLFWWindowHints() = 0;
+ virtual dawnDevice CreateDevice() = 0;
+ virtual uint64_t GetSwapChainImplementation() = 0;
+ virtual dawnTextureFormat GetPreferredSwapChainTextureFormat() = 0;
+
+ void SetWindow(GLFWwindow* window);
+
+ protected:
+ GLFWwindow* mWindow = nullptr;
+ };
+
+ BackendBinding* CreateBinding(BackendType type);
+
+} // namespace utils
+
+#endif // UTILS_BACKENDBINDING_H_
diff --git a/chromium/third_party/dawn/src/utils/D3D12Binding.cpp b/chromium/third_party/dawn/src/utils/D3D12Binding.cpp
new file mode 100644
index 00000000000..7aa57228806
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/D3D12Binding.cpp
@@ -0,0 +1,60 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "utils/BackendBinding.h"
+
+#include "common/Assert.h"
+#include "dawn_native/D3D12Backend.h"
+
+#include "GLFW/glfw3.h"
+#define GLFW_EXPOSE_NATIVE_WIN32
+#include "GLFW/glfw3native.h"
+
+namespace utils {
+
+ class D3D12Binding : public BackendBinding {
+ public:
+ void SetupGLFWWindowHints() override {
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+ }
+
+ dawnDevice CreateDevice() override {
+ mBackendDevice = dawn_native::d3d12::CreateDevice();
+ return mBackendDevice;
+ }
+
+ uint64_t GetSwapChainImplementation() override {
+ if (mSwapchainImpl.userData == nullptr) {
+ HWND win32Window = glfwGetWin32Window(mWindow);
+ mSwapchainImpl =
+ dawn_native::d3d12::CreateNativeSwapChainImpl(mBackendDevice, win32Window);
+ }
+ return reinterpret_cast<uint64_t>(&mSwapchainImpl);
+ }
+
+ dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
+ ASSERT(mSwapchainImpl.userData != nullptr);
+ return dawn_native::d3d12::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
+ }
+
+ private:
+ dawnDevice mBackendDevice = nullptr;
+ dawnSwapChainImplementation mSwapchainImpl = {};
+ };
+
+ BackendBinding* CreateD3D12Binding() {
+ return new D3D12Binding;
+ }
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/src/utils/DawnHelpers.cpp b/chromium/third_party/dawn/src/utils/DawnHelpers.cpp
new file mode 100644
index 00000000000..e88a92d11c8
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/DawnHelpers.cpp
@@ -0,0 +1,227 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "utils/DawnHelpers.h"
+
+#include "common/Assert.h"
+
+#include <shaderc/shaderc.hpp>
+
+#include <cstring>
+#include <iomanip>
+#include <iostream>
+#include <sstream>
+
+namespace utils {
+
+ namespace {
+
+ shaderc_shader_kind ShadercShaderKind(dawn::ShaderStage stage) {
+ switch (stage) {
+ case dawn::ShaderStage::Vertex:
+ return shaderc_glsl_vertex_shader;
+ case dawn::ShaderStage::Fragment:
+ return shaderc_glsl_fragment_shader;
+ case dawn::ShaderStage::Compute:
+ return shaderc_glsl_compute_shader;
+ default:
+ UNREACHABLE();
+ }
+ }
+
+ dawn::ShaderModule CreateShaderModuleFromResult(
+ const dawn::Device& device,
+ const shaderc::SpvCompilationResult& result) {
+ // result.cend and result.cbegin return pointers to uint32_t.
+ const uint32_t* resultBegin = result.cbegin();
+ const uint32_t* resultEnd = result.cend();
+ // So this size is in units of sizeof(uint32_t).
+ ptrdiff_t resultSize = resultEnd - resultBegin;
+ // SetSource takes data as uint32_t*.
+
+ dawn::ShaderModuleDescriptor descriptor;
+ descriptor.codeSize = static_cast<uint32_t>(resultSize);
+ descriptor.code = result.cbegin();
+ return device.CreateShaderModule(&descriptor);
+ }
+
+ } // anonymous namespace
+
+ dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
+ dawn::ShaderStage stage,
+ const char* source) {
+ shaderc_shader_kind kind = ShadercShaderKind(stage);
+
+ shaderc::Compiler compiler;
+ auto result = compiler.CompileGlslToSpv(source, strlen(source), kind, "myshader?");
+ if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
+ std::cerr << result.GetErrorMessage();
+ return {};
+ }
+#ifdef DUMP_SPIRV_ASSEMBLY
+ {
+ shaderc::CompileOptions options;
+ auto resultAsm = compiler.CompileGlslToSpvAssembly(source, strlen(source), kind,
+ "myshader?", options);
+ size_t sizeAsm = (resultAsm.cend() - resultAsm.cbegin());
+
+ char* buffer = reinterpret_cast<char*>(malloc(sizeAsm + 1));
+ memcpy(buffer, resultAsm.cbegin(), sizeAsm);
+ buffer[sizeAsm] = '\0';
+ printf("SPIRV ASSEMBLY DUMP START\n%s\nSPIRV ASSEMBLY DUMP END\n", buffer);
+ free(buffer);
+ }
+#endif
+
+#ifdef DUMP_SPIRV_JS_ARRAY
+ printf("SPIRV JS ARRAY DUMP START\n");
+ for (size_t i = 0; i < size; i++) {
+ printf("%#010x", result.cbegin()[i]);
+ if ((i + 1) % 4 == 0) {
+ printf(",\n");
+ } else {
+ printf(", ");
+ }
+ }
+ printf("\n");
+ printf("SPIRV JS ARRAY DUMP END\n");
+#endif
+
+ return CreateShaderModuleFromResult(device, result);
+ }
+
+ dawn::ShaderModule CreateShaderModuleFromASM(const dawn::Device& device, const char* source) {
+ shaderc::Compiler compiler;
+ shaderc::SpvCompilationResult result = compiler.AssembleToSpv(source, strlen(source));
+ if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
+ std::cerr << result.GetErrorMessage();
+ return {};
+ }
+
+ return CreateShaderModuleFromResult(device, result);
+ }
+
+ dawn::Buffer CreateBufferFromData(const dawn::Device& device,
+ const void* data,
+ uint32_t size,
+ dawn::BufferUsageBit usage) {
+ dawn::BufferDescriptor descriptor;
+ descriptor.size = size;
+ descriptor.usage = usage | dawn::BufferUsageBit::TransferDst;
+
+ dawn::Buffer buffer = device.CreateBuffer(&descriptor);
+ buffer.SetSubData(0, size, reinterpret_cast<const uint8_t*>(data));
+ return buffer;
+ }
+
+ BasicRenderPass CreateBasicRenderPass(const dawn::Device& device,
+ uint32_t width,
+ uint32_t height) {
+ BasicRenderPass result;
+ result.width = width;
+ result.height = height;
+
+ result.colorFormat = dawn::TextureFormat::R8G8B8A8Unorm;
+ dawn::TextureDescriptor descriptor;
+ descriptor.dimension = dawn::TextureDimension::e2D;
+ descriptor.size.width = width;
+ descriptor.size.height = height;
+ descriptor.size.depth = 1;
+ descriptor.arrayLayer = 1;
+ descriptor.format = result.colorFormat;
+ descriptor.levelCount = 1;
+ descriptor.usage =
+ dawn::TextureUsageBit::OutputAttachment | dawn::TextureUsageBit::TransferSrc;
+ result.color = device.CreateTexture(&descriptor);
+
+ dawn::TextureView colorView = result.color.CreateDefaultTextureView();
+ result.renderPassInfo = device.CreateRenderPassDescriptorBuilder()
+ .SetColorAttachment(0, colorView, dawn::LoadOp::Clear)
+ .GetResult();
+
+ return result;
+ }
+
+ dawn::BufferCopyView CreateBufferCopyView(dawn::Buffer buffer,
+ uint32_t offset,
+ uint32_t rowPitch,
+ uint32_t imageHeight) {
+ dawn::BufferCopyView bufferCopyView;
+ bufferCopyView.buffer = buffer;
+ bufferCopyView.offset = offset;
+ bufferCopyView.rowPitch = rowPitch;
+ bufferCopyView.imageHeight = imageHeight;
+
+ return bufferCopyView;
+ }
+
+ dawn::TextureCopyView CreateTextureCopyView(dawn::Texture texture,
+ uint32_t level,
+ uint32_t slice,
+ dawn::Origin3D origin,
+ dawn::TextureAspect aspect) {
+ dawn::TextureCopyView textureCopyView;
+ textureCopyView.texture = texture;
+ textureCopyView.level = level;
+ textureCopyView.slice = slice;
+ textureCopyView.origin = origin;
+ textureCopyView.aspect = aspect;
+
+ return textureCopyView;
+ }
+
+ dawn::SamplerDescriptor GetDefaultSamplerDescriptor() {
+ dawn::SamplerDescriptor desc;
+
+ desc.minFilter = dawn::FilterMode::Linear;
+ desc.magFilter = dawn::FilterMode::Linear;
+ desc.mipmapFilter = dawn::FilterMode::Linear;
+ desc.addressModeU = dawn::AddressMode::Repeat;
+ desc.addressModeV = dawn::AddressMode::Repeat;
+ desc.addressModeW = dawn::AddressMode::Repeat;
+
+ return desc;
+ }
+
+ dawn::PipelineLayout MakeBasicPipelineLayout(const dawn::Device& device,
+ const dawn::BindGroupLayout* bindGroupLayout) {
+ dawn::PipelineLayoutDescriptor descriptor;
+ if (bindGroupLayout) {
+ descriptor.numBindGroupLayouts = 1;
+ descriptor.bindGroupLayouts = bindGroupLayout;
+ } else {
+ descriptor.numBindGroupLayouts = 0;
+ descriptor.bindGroupLayouts = nullptr;
+ }
+ return device.CreatePipelineLayout(&descriptor);
+ }
+
+ dawn::BindGroupLayout MakeBindGroupLayout(
+ const dawn::Device& device,
+ std::initializer_list<dawn::BindGroupBinding> bindingsInitializer) {
+ std::vector<dawn::BindGroupBinding> bindings;
+ dawn::ShaderStageBit kNoStages{};
+ for (const dawn::BindGroupBinding& binding : bindingsInitializer) {
+ if (binding.visibility != kNoStages) {
+ bindings.push_back(binding);
+ }
+ }
+
+ dawn::BindGroupLayoutDescriptor descriptor;
+ descriptor.numBindings = static_cast<uint32_t>(bindings.size());
+ descriptor.bindings = bindings.data();
+ return device.CreateBindGroupLayout(&descriptor);
+ }
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/src/utils/DawnHelpers.h b/chromium/third_party/dawn/src/utils/DawnHelpers.h
new file mode 100644
index 00000000000..e1e0ed04874
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/DawnHelpers.h
@@ -0,0 +1,68 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include <dawn/dawncpp.h>
+
+#include <initializer_list>
+
+namespace utils {
+
+ enum Expectation { Success, Failure };
+
+ dawn::ShaderModule CreateShaderModule(const dawn::Device& device,
+ dawn::ShaderStage stage,
+ const char* source);
+ dawn::ShaderModule CreateShaderModuleFromASM(const dawn::Device& device, const char* source);
+
+ dawn::Buffer CreateBufferFromData(const dawn::Device& device,
+ const void* data,
+ uint32_t size,
+ dawn::BufferUsageBit usage);
+
+ template <typename T>
+ dawn::Buffer CreateBufferFromData(const dawn::Device& device,
+ dawn::BufferUsageBit usage,
+ std::initializer_list<T> data) {
+ return CreateBufferFromData(device, data.begin(), uint32_t(sizeof(T) * data.size()), usage);
+ }
+
+ dawn::BufferCopyView CreateBufferCopyView(dawn::Buffer buffer,
+ uint32_t offset,
+ uint32_t rowPitch,
+ uint32_t imageHeight);
+ dawn::TextureCopyView CreateTextureCopyView(dawn::Texture texture,
+ uint32_t level,
+ uint32_t slice,
+ dawn::Origin3D origin,
+ dawn::TextureAspect aspect);
+
+ struct BasicRenderPass {
+ uint32_t width;
+ uint32_t height;
+ dawn::Texture color;
+ dawn::TextureFormat colorFormat;
+ dawn::RenderPassDescriptor renderPassInfo;
+ };
+ BasicRenderPass CreateBasicRenderPass(const dawn::Device& device,
+ uint32_t width,
+ uint32_t height);
+
+ dawn::SamplerDescriptor GetDefaultSamplerDescriptor();
+ dawn::PipelineLayout MakeBasicPipelineLayout(const dawn::Device& device,
+ const dawn::BindGroupLayout* bindGroupLayout);
+ dawn::BindGroupLayout MakeBindGroupLayout(
+ const dawn::Device& device,
+ std::initializer_list<dawn::BindGroupBinding> bindingsInitializer);
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/src/utils/MetalBinding.mm b/chromium/third_party/dawn/src/utils/MetalBinding.mm
new file mode 100644
index 00000000000..8eaba1712b0
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/MetalBinding.mm
@@ -0,0 +1,133 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "utils/BackendBinding.h"
+
+#include "common/Assert.h"
+#include "common/SwapChainUtils.h"
+#include "dawn_native/MetalBackend.h"
+
+#define GLFW_EXPOSE_NATIVE_COCOA
+#include "GLFW/glfw3.h"
+#include "GLFW/glfw3native.h"
+
+namespace utils {
+ class SwapChainImplMTL {
+ public:
+ using WSIContext = dawnWSIContextMetal;
+
+ SwapChainImplMTL(id nsWindow) : mNsWindow(nsWindow) {
+ }
+
+ ~SwapChainImplMTL() {
+ [mCurrentTexture release];
+ [mCurrentDrawable release];
+ }
+
+ void Init(dawnWSIContextMetal* ctx) {
+ mMtlDevice = ctx->device;
+ mCommandQueue = [mMtlDevice newCommandQueue];
+ }
+
+ dawnSwapChainError Configure(dawnTextureFormat format,
+ dawnTextureUsageBit,
+ uint32_t width,
+ uint32_t height) {
+ if (format != DAWN_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM) {
+ return "unsupported format";
+ }
+ ASSERT(width > 0);
+ ASSERT(height > 0);
+
+ NSView* contentView = [mNsWindow contentView];
+ [contentView setWantsLayer:YES];
+
+ CGSize size = {};
+ size.width = width;
+ size.height = height;
+
+ mLayer = [CAMetalLayer layer];
+ [mLayer setDevice:mMtlDevice];
+ [mLayer setPixelFormat:MTLPixelFormatBGRA8Unorm];
+ [mLayer setFramebufferOnly:YES];
+ [mLayer setDrawableSize:size];
+
+ [contentView setLayer:mLayer];
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
+ [mCurrentDrawable release];
+ mCurrentDrawable = [mLayer nextDrawable];
+ [mCurrentDrawable retain];
+
+ [mCurrentTexture release];
+ mCurrentTexture = mCurrentDrawable.texture;
+ [mCurrentTexture retain];
+
+ nextTexture->texture.ptr = reinterpret_cast<void*>(mCurrentTexture);
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError Present() {
+ id<MTLCommandBuffer> commandBuffer = [mCommandQueue commandBuffer];
+ [commandBuffer presentDrawable:mCurrentDrawable];
+ [commandBuffer commit];
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ private:
+ id mNsWindow = nil;
+ id<MTLDevice> mMtlDevice = nil;
+ id<MTLCommandQueue> mCommandQueue = nil;
+
+ CAMetalLayer* mLayer = nullptr;
+ id<CAMetalDrawable> mCurrentDrawable = nil;
+ id<MTLTexture> mCurrentTexture = nil;
+ };
+
+ class MetalBinding : public BackendBinding {
+ public:
+ void SetupGLFWWindowHints() override {
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+ }
+ dawnDevice CreateDevice() override {
+ mMetalDevice = MTLCreateSystemDefaultDevice();
+ return dawn_native::metal::CreateDevice(mMetalDevice);
+ }
+
+ uint64_t GetSwapChainImplementation() override {
+ if (mSwapchainImpl.userData == nullptr) {
+ mSwapchainImpl = CreateSwapChainImplementation(
+ new SwapChainImplMTL(glfwGetCocoaWindow(mWindow)));
+ }
+ return reinterpret_cast<uint64_t>(&mSwapchainImpl);
+ }
+
+ dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
+ return DAWN_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM;
+ }
+
+ private:
+ id<MTLDevice> mMetalDevice = nil;
+ dawnSwapChainImplementation mSwapchainImpl = {};
+ };
+
+ BackendBinding* CreateMetalBinding() {
+ return new MetalBinding;
+ }
+}
diff --git a/chromium/third_party/dawn/src/utils/NullBinding.cpp b/chromium/third_party/dawn/src/utils/NullBinding.cpp
new file mode 100644
index 00000000000..558531e33cd
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/NullBinding.cpp
@@ -0,0 +1,40 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "utils/BackendBinding.h"
+
+#include "dawn_native/NullBackend.h"
+
+namespace utils {
+
+ class NullBinding : public BackendBinding {
+ public:
+ void SetupGLFWWindowHints() override {
+ }
+ dawnDevice CreateDevice() override {
+ return dawn_native::null::CreateDevice();
+ }
+ uint64_t GetSwapChainImplementation() override {
+ return 0;
+ }
+ dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
+ return DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
+ }
+ };
+
+ BackendBinding* CreateNullBinding() {
+ return new NullBinding;
+ }
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/src/utils/OpenGLBinding.cpp b/chromium/third_party/dawn/src/utils/OpenGLBinding.cpp
new file mode 100644
index 00000000000..a0fbc002a60
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/OpenGLBinding.cpp
@@ -0,0 +1,139 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "utils/BackendBinding.h"
+
+#include "common/Assert.h"
+#include "common/Platform.h"
+#include "common/SwapChainUtils.h"
+#include "dawn/dawn_wsi.h"
+#include "dawn_native/OpenGLBackend.h"
+
+// Glad needs to be included before GLFW otherwise it complain that GL.h was already included
+#include "glad/glad.h"
+
+#include <cstdio>
+#include "GLFW/glfw3.h"
+
+namespace utils {
+ class SwapChainImplGL {
+ public:
+ using WSIContext = dawnWSIContextGL;
+
+ SwapChainImplGL(GLFWwindow* window) : mWindow(window) {
+ }
+
+ ~SwapChainImplGL() {
+ glDeleteTextures(1, &mBackTexture);
+ glDeleteFramebuffers(1, &mBackFBO);
+ }
+
+ void Init(dawnWSIContextGL*) {
+ glGenTextures(1, &mBackTexture);
+ glBindTexture(GL_TEXTURE_2D, mBackTexture);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
+
+ glGenFramebuffers(1, &mBackFBO);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO);
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+ mBackTexture, 0);
+ }
+
+ dawnSwapChainError Configure(dawnTextureFormat format,
+ dawnTextureUsageBit,
+ uint32_t width,
+ uint32_t height) {
+ if (format != DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
+ return "unsupported format";
+ }
+ ASSERT(width > 0);
+ ASSERT(height > 0);
+ mWidth = width;
+ mHeight = height;
+
+ glBindTexture(GL_TEXTURE_2D, mBackTexture);
+ // Reallocate the texture
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
+ nullptr);
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
+ nextTexture->texture.u32 = mBackTexture;
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError Present() {
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO);
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ glBlitFramebuffer(0, 0, mWidth, mHeight, 0, mHeight, mWidth, 0, GL_COLOR_BUFFER_BIT,
+ GL_NEAREST);
+ glfwSwapBuffers(mWindow);
+
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ private:
+ GLFWwindow* mWindow = nullptr;
+ uint32_t mWidth = 0;
+ uint32_t mHeight = 0;
+ GLuint mBackFBO = 0;
+ GLuint mBackTexture = 0;
+ };
+
+ class OpenGLBinding : public BackendBinding {
+ public:
+ void SetupGLFWWindowHints() override {
+#if defined(DAWN_PLATFORM_APPLE)
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1);
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
+ glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+#else
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
+ glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4);
+ glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
+ glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
+#endif
+ }
+ dawnDevice CreateDevice() override {
+ glfwMakeContextCurrent(mWindow);
+ // Load the GL entry points in our copy of the glad static library
+ gladLoadGLLoader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress));
+
+ return dawn_native::opengl::CreateDevice(
+ reinterpret_cast<void* (*)(const char*)>(glfwGetProcAddress));
+ }
+
+ uint64_t GetSwapChainImplementation() override {
+ if (mSwapchainImpl.userData == nullptr) {
+ mSwapchainImpl = CreateSwapChainImplementation(new SwapChainImplGL(mWindow));
+ }
+ return reinterpret_cast<uint64_t>(&mSwapchainImpl);
+ }
+
+ dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
+ return DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
+ }
+
+ private:
+ dawnSwapChainImplementation mSwapchainImpl = {};
+ };
+
+ BackendBinding* CreateOpenGLBinding() {
+ return new OpenGLBinding;
+ }
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/src/utils/SystemUtils.cpp b/chromium/third_party/dawn/src/utils/SystemUtils.cpp
new file mode 100644
index 00000000000..b72a2ca0584
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/SystemUtils.cpp
@@ -0,0 +1,39 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "common/Platform.h"
+
+#if defined(DAWN_PLATFORM_WINDOWS)
+# include <Windows.h>
+#elif defined(DAWN_PLATFORM_POSIX)
+# include <unistd.h>
+#else
+# error "Unsupported platform."
+#endif
+
+namespace utils {
+
+#if defined(DAWN_PLATFORM_WINDOWS)
+ void USleep(unsigned int usecs) {
+ Sleep(static_cast<DWORD>(usecs / 1000));
+ }
+#elif defined(DAWN_PLATFORM_POSIX)
+ void USleep(unsigned int usecs) {
+ usleep(usecs);
+ }
+#else
+# error "Implement USleep for your platform."
+#endif
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/src/utils/SystemUtils.h b/chromium/third_party/dawn/src/utils/SystemUtils.h
new file mode 100644
index 00000000000..465e0f66e77
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/SystemUtils.h
@@ -0,0 +1,18 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace utils {
+
+ void USleep(unsigned int usecs);
+}
diff --git a/chromium/third_party/dawn/src/utils/TerribleCommandBuffer.cpp b/chromium/third_party/dawn/src/utils/TerribleCommandBuffer.cpp
new file mode 100644
index 00000000000..77f86ec4b29
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/TerribleCommandBuffer.cpp
@@ -0,0 +1,60 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "utils/TerribleCommandBuffer.h"
+
+#include "common/Assert.h"
+
+namespace utils {
+
+ TerribleCommandBuffer::TerribleCommandBuffer() {
+ }
+
+ TerribleCommandBuffer::TerribleCommandBuffer(dawn_wire::CommandHandler* handler)
+ : mHandler(handler) {
+ }
+
+ void TerribleCommandBuffer::SetHandler(dawn_wire::CommandHandler* handler) {
+ mHandler = handler;
+ }
+
+ void* TerribleCommandBuffer::GetCmdSpace(size_t size) {
+ // TODO(kainino@chromium.org): Should we early-out if size is 0?
+ // (Here and/or in the caller?) It might be good to make the wire receiver get a nullptr
+ // instead of pointer to zero-sized allocation in mBuffer.
+
+ if (size > sizeof(mBuffer)) {
+ return nullptr;
+ }
+
+ char* result = &mBuffer[mOffset];
+ mOffset += size;
+
+ if (mOffset > sizeof(mBuffer)) {
+ if (!Flush()) {
+ return nullptr;
+ }
+ return GetCmdSpace(size);
+ }
+
+ return result;
+ }
+
+ bool TerribleCommandBuffer::Flush() {
+ bool success = mHandler->HandleCommands(mBuffer, mOffset) != nullptr;
+ mOffset = 0;
+ return success;
+ }
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/src/utils/TerribleCommandBuffer.h b/chromium/third_party/dawn/src/utils/TerribleCommandBuffer.h
new file mode 100644
index 00000000000..b5affc85530
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/TerribleCommandBuffer.h
@@ -0,0 +1,42 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef UTILS_TERRIBLE_COMMAND_BUFFER_H_
+#define UTILS_TERRIBLE_COMMAND_BUFFER_H_
+
+#include <vector>
+
+#include "dawn_wire/Wire.h"
+
+namespace utils {
+
+ class TerribleCommandBuffer : public dawn_wire::CommandSerializer {
+ public:
+ TerribleCommandBuffer();
+ TerribleCommandBuffer(dawn_wire::CommandHandler* handler);
+
+ void SetHandler(dawn_wire::CommandHandler* handler);
+
+ void* GetCmdSpace(size_t size) override;
+ bool Flush() override;
+
+ private:
+ dawn_wire::CommandHandler* mHandler = nullptr;
+ size_t mOffset = 0;
+ char mBuffer[10000000];
+ };
+
+} // namespace utils
+
+#endif // UTILS_TERRIBLE_COMMAND_BUFFER_H_
diff --git a/chromium/third_party/dawn/src/utils/VulkanBinding.cpp b/chromium/third_party/dawn/src/utils/VulkanBinding.cpp
new file mode 100644
index 00000000000..81068d332ad
--- /dev/null
+++ b/chromium/third_party/dawn/src/utils/VulkanBinding.cpp
@@ -0,0 +1,92 @@
+// Copyright 2017 The Dawn Authors
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "utils/BackendBinding.h"
+
+#include "common/Assert.h"
+#include "dawn_native/VulkanBackend.h"
+
+// Include GLFW after VulkanBackend so that it declares the Vulkan-specific functions
+#include "GLFW/glfw3.h"
+
+namespace utils {
+
+ class SwapChainImplVulkan {
+ public:
+ using WSIContext = dawnWSIContextVulkan;
+
+ SwapChainImplVulkan(GLFWwindow* /*window*/) {
+ }
+
+ ~SwapChainImplVulkan() {
+ }
+
+ void Init(dawnWSIContextVulkan*) {
+ }
+
+ dawnSwapChainError Configure(dawnTextureFormat, dawnTextureUsageBit, uint32_t, uint32_t) {
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture*) {
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+
+ dawnSwapChainError Present() {
+ return DAWN_SWAP_CHAIN_NO_ERROR;
+ }
+ };
+
+ class VulkanBinding : public BackendBinding {
+ public:
+ void SetupGLFWWindowHints() override {
+ glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
+ }
+ dawnDevice CreateDevice() override {
+ uint32_t extensionCount = 0;
+ const char** glfwInstanceExtensions =
+ glfwGetRequiredInstanceExtensions(&extensionCount);
+ std::vector<const char*> requiredExtensions(glfwInstanceExtensions,
+ glfwInstanceExtensions + extensionCount);
+
+ mDevice = dawn_native::vulkan::CreateDevice(requiredExtensions);
+ return mDevice;
+ }
+ uint64_t GetSwapChainImplementation() override {
+ if (mSwapchainImpl.userData == nullptr) {
+ VkSurfaceKHR surface = VK_NULL_HANDLE;
+ if (glfwCreateWindowSurface(dawn_native::vulkan::GetInstance(mDevice), mWindow,
+ nullptr, &surface) != VK_SUCCESS) {
+ ASSERT(false);
+ }
+
+ mSwapchainImpl = dawn_native::vulkan::CreateNativeSwapChainImpl(mDevice, surface);
+ }
+ return reinterpret_cast<uint64_t>(&mSwapchainImpl);
+ }
+ dawnTextureFormat GetPreferredSwapChainTextureFormat() override {
+ ASSERT(mSwapchainImpl.userData != nullptr);
+ return dawn_native::vulkan::GetNativeSwapChainPreferredFormat(&mSwapchainImpl);
+ }
+
+ private:
+ dawnDevice mDevice;
+ dawnSwapChainImplementation mSwapchainImpl = {};
+ };
+
+ BackendBinding* CreateVulkanBinding() {
+ return new VulkanBinding;
+ }
+
+} // namespace utils
diff --git a/chromium/third_party/dawn/third_party/BUILD.gn b/chromium/third_party/dawn/third_party/BUILD.gn
new file mode 100644
index 00000000000..62766a4556f
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/BUILD.gn
@@ -0,0 +1,361 @@
+# Copyright 2018 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import("../scripts/dawn_overrides_with_defaults.gni")
+import("../scripts/dawn_features.gni")
+import("//build_overrides/build.gni")
+
+if (build_with_chromium) {
+ import("//testing/libfuzzer/fuzzer_test.gni")
+}
+
+is_msvc = is_win && !is_clang
+
+###############################################################################
+# Third-party dependencies needed by libdawn_native
+###############################################################################
+
+# Glad
+config("glad_public") {
+ include_dirs = [ "glad/include" ]
+}
+
+static_library("glad") {
+ sources = [
+ "glad/include/KHR/khrplatform.h",
+ "glad/include/glad/glad.h",
+ "glad/src/glad.c",
+ ]
+
+ public_configs = [ ":glad_public" ]
+}
+
+# SPIRV-Cross
+spirv_cross_dir = dawn_spirv_cross_dir
+
+config("spirv_cross_public") {
+ include_dirs = [ "${spirv_cross_dir}/.." ]
+ defines = [ "SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" ]
+}
+
+static_library("spirv_cross") {
+ public_configs = [ ":spirv_cross_public" ]
+
+ if (!is_msvc) {
+ cflags_cc = [
+ "-Wno-implicit-fallthrough",
+ "-Wno-return-type",
+ "-Wno-sign-compare",
+ ]
+ }
+
+ sources = [
+ "${spirv_cross_dir}/GLSL.std.450.h",
+ "${spirv_cross_dir}/spirv.hpp",
+ "${spirv_cross_dir}/spirv_cfg.cpp",
+ "${spirv_cross_dir}/spirv_cfg.hpp",
+ "${spirv_cross_dir}/spirv_common.hpp",
+ "${spirv_cross_dir}/spirv_cross.cpp",
+ "${spirv_cross_dir}/spirv_cross.hpp",
+ ]
+
+ need_glsl_cross = dawn_enable_opengl
+
+ is_fuzzing = false
+ if (build_with_chromium) {
+ is_fuzzing = use_fuzzing_engine
+ }
+
+ if (dawn_enable_d3d12 || is_fuzzing) {
+ sources += [
+ "${spirv_cross_dir}/spirv_hlsl.cpp",
+ "${spirv_cross_dir}/spirv_hlsl.hpp",
+ ]
+ need_glsl_cross = true
+ }
+
+ if (dawn_enable_metal || is_fuzzing) {
+ sources += [
+ "${spirv_cross_dir}/spirv_msl.cpp",
+ "${spirv_cross_dir}/spirv_msl.hpp",
+ ]
+ need_glsl_cross = true
+ }
+
+ if (need_glsl_cross || is_fuzzing) {
+ sources += [
+ "${spirv_cross_dir}/spirv_glsl.cpp",
+ "${spirv_cross_dir}/spirv_glsl.hpp",
+ ]
+ }
+}
+
+# An empty Vulkan target to add the include dirs and list the sources
+# for the header inclusion check.
+config("vulkan_headers_public") {
+ include_dirs = [ "." ]
+}
+
+source_set("vulkan_headers") {
+ sources = [
+ "vulkan/vk_platform.h",
+ "vulkan/vulkan.h",
+ ]
+
+ public_configs = [ ":vulkan_headers_public" ]
+}
+
+###############################################################################
+# Gtest Gmock - Handle building inside and outside of Chromium.
+###############################################################################
+
+# When building outside of Chromium we need to define our own targets for GTest
+# and GMock. However when compiling inside of Chromium we need to reuse the
+# existing targets, both because Chromium has a special harness for swarming
+# and because otherwise the "gn check" fails.
+
+if (!build_with_chromium) {
+ # When we aren't in Chromium we define out own targets based on the location
+ # of the googletest repo.
+ googletest_dir = dawn_googletest_dir
+
+ config("gtest_config") {
+ include_dirs = [
+ "${googletest_dir}/googletest",
+ "${googletest_dir}/googletest/include",
+ ]
+ }
+
+ static_library("gtest") {
+ testonly = true
+ sources = [
+ "${googletest_dir}/googletest/src/gtest-all.cc",
+ ]
+ public_configs = [ ":gtest_config" ]
+ }
+
+ config("gmock_config") {
+ include_dirs = [
+ "${googletest_dir}/googlemock",
+ "${googletest_dir}/googlemock/include",
+ "${googletest_dir}/googletest/include",
+ ]
+ }
+
+ static_library("gmock") {
+ testonly = true
+ sources = [
+ "${googletest_dir}/googlemock/src/gmock-all.cc",
+ ]
+ public_configs = [ ":gmock_config" ]
+ }
+
+ group("gmock_and_gtest") {
+ testonly = true
+ public_deps = [
+ ":gmock",
+ ":gtest",
+ ]
+ }
+} else {
+ # When we are in Chromium we reuse its targets, and also add some deps that
+ # are needed to launch the test in swarming mode.
+ group("gmock_and_gtest") {
+ testonly = true
+ public_deps = [
+ "//base",
+ "//base/test:test_support",
+ "//testing/gmock",
+ "//testing/gtest",
+ ]
+ }
+}
+
+###############################################################################
+# GLFW - good enough build targets
+###############################################################################
+
+glfw_dir = dawn_glfw_dir
+
+config("glfw_public") {
+ include_dirs = [ "${glfw_dir}/include" ]
+
+ if (is_win) {
+ defines = [ "_GLFW_WIN32" ]
+ }
+
+ if (is_mac) {
+ defines = [ "_GLFW_COCOA" ]
+ }
+
+ if (is_linux) {
+ defines = [ "_GLFW_X11" ]
+ }
+}
+
+static_library("glfw") {
+ public_configs = [ ":glfw_public" ]
+
+ if (is_msvc) {
+ # nonstandard extension, function/data pointer conversion in expression
+ cflags_c = [ "/wd4152" ]
+ } else {
+ cflags_c = [ "-Wno-sign-compare" ]
+ }
+
+ sources = [
+ "${glfw_dir}/include/GLFW/glfw3.h",
+ "${glfw_dir}/include/GLFW/glfw3native.h",
+ "${glfw_dir}/src/context.c",
+ "${glfw_dir}/src/egl_context.c",
+ "${glfw_dir}/src/egl_context.h",
+ "${glfw_dir}/src/init.c",
+ "${glfw_dir}/src/input.c",
+ "${glfw_dir}/src/internal.h",
+ "${glfw_dir}/src/monitor.c",
+ "${glfw_dir}/src/osmesa_context.c",
+ "${glfw_dir}/src/osmesa_context.h",
+ "${glfw_dir}/src/vulkan.c",
+ "${glfw_dir}/src/window.c",
+ ]
+ libs = []
+
+ if (is_win) {
+ sources += [
+ "${glfw_dir}/src/wgl_context.c",
+ "${glfw_dir}/src/wgl_context.h",
+ "${glfw_dir}/src/win32_init.c",
+ "${glfw_dir}/src/win32_joystick.c",
+ "${glfw_dir}/src/win32_joystick.h",
+ "${glfw_dir}/src/win32_monitor.c",
+ "${glfw_dir}/src/win32_platform.h",
+ "${glfw_dir}/src/win32_time.c",
+ "${glfw_dir}/src/win32_thread.c",
+ "${glfw_dir}/src/win32_window.c",
+ ]
+ }
+
+ if (is_linux || is_mac) {
+ sources += [
+ "${glfw_dir}/src/posix_thread.c",
+ "${glfw_dir}/src/posix_thread.h",
+ ]
+ }
+
+ if (is_linux) {
+ sources += [
+ "${glfw_dir}/src/glx_context.c",
+ "${glfw_dir}/src/glx_context.h",
+ "${glfw_dir}/src/linux_joystick.c",
+ "${glfw_dir}/src/linux_joystick.h",
+ "${glfw_dir}/src/posix_time.c",
+ "${glfw_dir}/src/posix_time.h",
+ "${glfw_dir}/src/x11_init.c",
+ "${glfw_dir}/src/x11_monitor.c",
+ "${glfw_dir}/src/x11_platform.h",
+ "${glfw_dir}/src/x11_window.c",
+ "${glfw_dir}/src/xkb_unicode.c",
+ "${glfw_dir}/src/xkb_unicode.h",
+ ]
+
+ libs += [
+ "rt",
+ "dl",
+ "X11",
+ "Xcursor",
+ "Xinerama",
+ "Xrandr",
+ ]
+ }
+
+ if (is_mac) {
+ sources += [
+ "${glfw_dir}/src/cocoa_init.m",
+ "${glfw_dir}/src/cocoa_joystick.h",
+ "${glfw_dir}/src/cocoa_joystick.m",
+ "${glfw_dir}/src/cocoa_monitor.m",
+ "${glfw_dir}/src/cocoa_platform.h",
+ "${glfw_dir}/src/cocoa_time.c",
+ "${glfw_dir}/src/cocoa_window.m",
+ "${glfw_dir}/src/nsgl_context.h",
+ "${glfw_dir}/src/nsgl_context.m",
+ ]
+ libs += [
+ "Cocoa.framework",
+ "IOKit.framework",
+ "CoreFoundation.framework",
+ "CoreVideo.framework",
+ ]
+ cflags_objc = [
+ "-Wno-sign-compare",
+ "-Wno-unguarded-availability",
+ ]
+ }
+}
+
+###############################################################################
+# Header-only dependencies for samples
+###############################################################################
+
+if (dawn_standalone) {
+ # GLM
+ config("glm_public_config") {
+ include_dirs = [ "glm" ]
+ }
+ source_set("glm") {
+ public_configs = [ ":glm_public_config" ]
+ # GLM is header only but has too many files to list them.
+ }
+
+ # STB
+ config("stb_public_config") {
+ include_dirs = [ "stb" ]
+
+ if (!is_msvc) {
+ cflags_cc = [ "-Wno-implicit-fallthrough" ]
+ }
+ }
+ source_set("stb") {
+ public_configs = [ ":stb_public_config" ]
+ sources = [
+ "stb/stb_image.h",
+ ]
+ }
+
+ # PicoJSON
+ config("picojson_public_config") {
+ include_dirs = [ "." ]
+ }
+ source_set("picojson") {
+ public_configs = [ ":picojson_public_config" ]
+ sources = [
+ "picojson/picojson.h",
+ ]
+ }
+
+ # Tiny glTF Loader
+ config("tiny_gltf_loader_public_config") {
+ include_dirs = [ "." ]
+ }
+ source_set("tiny_gltf_loader") {
+ public_configs = [ ":tiny_gltf_loader_public_config" ]
+ public_deps = [
+ ":picojson",
+ ":stb",
+ ]
+ sources = [
+ "tinygltfloader/tiny_gltf_loader.h",
+ ]
+ }
+}
diff --git a/chromium/third_party/dawn/third_party/CMakeLists.txt b/chromium/third_party/dawn/third_party/CMakeLists.txt
new file mode 100644
index 00000000000..61e614c0c65
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/CMakeLists.txt
@@ -0,0 +1,151 @@
+# Copyright 2017 The Dawn Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# GLFW, only build the library
+set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
+set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
+set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
+set(GLFW_INSTALL OFF CACHE BOOL "" FORCE)
+add_subdirectory(glfw)
+DawnExternalTarget("third_party" glfw)
+
+# GoogleTest
+set(GTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googletest)
+set(GMOCK_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest/googlemock)
+add_library(gtest STATIC ${GTEST_DIR}/src/gtest-all.cc ${GMOCK_DIR}/src/gmock-all.cc)
+target_include_directories(gtest SYSTEM PUBLIC ${GTEST_DIR}/include ${GMOCK_DIR}/include)
+target_include_directories(gtest SYSTEM PRIVATE ${GTEST_DIR} ${GMOCK_DIR})
+find_package(Threads)
+target_link_libraries(gtest ${CMAKE_THREAD_LIBS_INIT})
+DawnExternalTarget("third_party" gtest)
+
+# Glad
+add_library(glad STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/glad/src/glad.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/glad/include/glad/glad.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/glad/include/KHR/khrplatform.h
+)
+set(GLAD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glad/include)
+set(GLAD_INCLUDE_DIR ${GLAD_INCLUDE_DIR} PARENT_SCOPE)
+target_include_directories(glad SYSTEM PUBLIC ${GLAD_INCLUDE_DIR})
+DawnExternalTarget("third_party" glad)
+
+# SPIRV-Tools
+set(SPIRV_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools/include PARENT_SCOPE)
+
+# ShaderC
+# Prevent SPIRV-Tools from using Werror as it has a warning on MSVC
+set(SPIRV_WERROR OFF CACHE BOOL "" FORCE)
+# Don't add unnecessary shaderc targets
+set(SHADERC_SKIP_TESTS ON)
+set(SHADERC_SKIP_INSTALL ON)
+# Remove unused glslang and spirv-tools parts
+# set(ENABLE_HLSL OFF CACHE BOOL "")
+set(ENABLE_OPT OFF CACHE BOOL "")
+set(ENABLE_GLSLANG_BINARIES OFF CACHE BOOL "")
+set(SKIP_GLSLANG_INSTALL ON CACHE BOOL "")
+set(SKIP_SPIRV_TOOLS_INSTALL ON CACHE BOOL "")
+set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "")
+# Help shaderc find the non-standard paths for its dependencies
+set(SHADERC_GOOGLE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/googletest CACHE STRING "Location of googletest source")
+set(SHADERC_GLSLANG_DIR "${CMAKE_CURRENT_SOURCE_DIR}/glslang" CACHE STRING "Location of glslang source")
+set(SHADERC_SPIRV_TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/spirv-tools CACHE STRING "Location of spirv-tools source")
+# Help shaderc find the python executable when run inside VS.
+find_package(PythonInterp REQUIRED)
+set(PYTHON_EXE ${PYTHON_EXECUTABLE})
+# Need to include this for spirv-tools to find it
+add_subdirectory(spirv-headers)
+add_subdirectory(shaderc)
+# Namespace the shaderc targets in a folder to avoid cluttering the
+# Visual Studio solution explorer
+set_target_properties(
+ add-copyright
+ build-version
+ check-copyright
+ glslc
+ glslc_exe
+ install-headers
+ shaderc
+ shaderc_shared
+ shaderc_util
+ shaderc_combined_genfile
+ shaderc-online-compile testdata
+ SPIRV-Headers-example
+ SPIRV-Headers-example-1.1
+ PROPERTIES FOLDER "third_party/shaderc"
+)
+# Remove a bunch of targets we don't need that are pulled by shaderc and glslang
+set_target_properties(
+ SPIRV-Headers-example-1.1
+ SPIRV-Headers-example
+ glslc_exe
+ SPIRV-Tools-link
+ SPVRemapper
+ shaderc
+ shaderc-online-compile
+ shaderc_combined_genfile
+ PROPERTIES EXCLUDE_FROM_ALL true
+)
+
+# SPIRV-Cross
+set(SPIRV_CROSS_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/GLSL.std.450.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_common.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cfg.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cfg.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cross.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_cross.hpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv.hpp
+)
+
+set(NEED_SPIRV_CROSS_GLSL OFF)
+if (DAWN_ENABLE_D3D12)
+ list(APPEND SPIRV_CROSS_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_hlsl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_hlsl.hpp
+ )
+ set(NEED_SPIRV_CROSS_GLSL ON)
+endif()
+
+if (DAWN_ENABLE_METAL)
+ list(APPEND SPIRV_CROSS_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_msl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_msl.hpp
+ )
+ set(NEED_SPIRV_CROSS_GLSL ON)
+endif()
+
+if (DAWN_ENABLE_OPENGL OR NEED_SPIRV_CROSS_GLSL)
+ list(APPEND SPIRV_CROSS_SOURCES
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_glsl.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/spirv-cross/spirv_glsl.hpp
+ )
+endif()
+
+add_library(spirv_cross STATIC ${SPIRV_CROSS_SOURCES})
+target_compile_definitions(spirv_cross PUBLIC SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS)
+set(SPIRV_CROSS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
+DawnExternalTarget("third_party" spirv_cross)
+
+# STB, used for stb_image
+set(STB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/stb PARENT_SCOPE)
+
+# glm matrix math library
+set(GLM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glm PARENT_SCOPE)
+
+# Tiny glTF loader library
+set(TINYGLTFLOADER_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
+
+# Vulkan headers
+set(VULKAN_HEADERS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
diff --git a/chromium/third_party/dawn/third_party/glad/include/KHR/khrplatform.h b/chromium/third_party/dawn/third_party/glad/include/KHR/khrplatform.h
new file mode 100644
index 00000000000..975bbffed67
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/glad/include/KHR/khrplatform.h
@@ -0,0 +1,282 @@
+#ifndef __khrplatform_h_
+#define __khrplatform_h_
+
+/*
+** Copyright (c) 2008-2018 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Khronos platform-specific types and definitions.
+ *
+ * The master copy of khrplatform.h is maintained in the Khronos EGL
+ * Registry repository at https://github.com/KhronosGroup/EGL-Registry
+ * The last semantic modification to khrplatform.h was at commit ID:
+ * 67a3e0864c2d75ea5287b9f3d2eb74a745936692
+ *
+ * Adopters may modify this file to suit their platform. Adopters are
+ * encouraged to submit platform specific modifications to the Khronos
+ * group so that they can be included in future versions of this file.
+ * Please submit changes by filing pull requests or issues on
+ * the EGL Registry repository linked above.
+ *
+ *
+ * See the Implementer's Guidelines for information about where this file
+ * should be located on your system and for more details of its use:
+ * http://www.khronos.org/registry/implementers_guide.pdf
+ *
+ * This file should be included as
+ * #include <KHR/khrplatform.h>
+ * by Khronos client API header files that use its types and defines.
+ *
+ * The types in khrplatform.h should only be used to define API-specific types.
+ *
+ * Types defined in khrplatform.h:
+ * khronos_int8_t signed 8 bit
+ * khronos_uint8_t unsigned 8 bit
+ * khronos_int16_t signed 16 bit
+ * khronos_uint16_t unsigned 16 bit
+ * khronos_int32_t signed 32 bit
+ * khronos_uint32_t unsigned 32 bit
+ * khronos_int64_t signed 64 bit
+ * khronos_uint64_t unsigned 64 bit
+ * khronos_intptr_t signed same number of bits as a pointer
+ * khronos_uintptr_t unsigned same number of bits as a pointer
+ * khronos_ssize_t signed size
+ * khronos_usize_t unsigned size
+ * khronos_float_t signed 32 bit floating point
+ * khronos_time_ns_t unsigned 64 bit time in nanoseconds
+ * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
+ * nanoseconds
+ * khronos_stime_nanoseconds_t signed time interval in nanoseconds
+ * khronos_boolean_enum_t enumerated boolean type. This should
+ * only be used as a base type when a client API's boolean type is
+ * an enum. Client APIs which use an integer or other type for
+ * booleans cannot use this as the base type for their boolean.
+ *
+ * Tokens defined in khrplatform.h:
+ *
+ * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
+ *
+ * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
+ * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
+ *
+ * Calling convention macros defined in this file:
+ * KHRONOS_APICALL
+ * KHRONOS_APIENTRY
+ * KHRONOS_APIATTRIBUTES
+ *
+ * These may be used in function prototypes as:
+ *
+ * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
+ * int arg1,
+ * int arg2) KHRONOS_APIATTRIBUTES;
+ */
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APICALL
+ *-------------------------------------------------------------------------
+ * This precedes the return type of the function in the function prototype.
+ */
+#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
+# define KHRONOS_APICALL __declspec(dllimport)
+#elif defined (__SYMBIAN32__)
+# define KHRONOS_APICALL IMPORT_C
+#elif defined(__ANDROID__)
+# define KHRONOS_APICALL __attribute__((visibility("default")))
+#else
+# define KHRONOS_APICALL
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIENTRY
+ *-------------------------------------------------------------------------
+ * This follows the return type of the function and precedes the function
+ * name in the function prototype.
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
+ /* Win32 but not WinCE */
+# define KHRONOS_APIENTRY __stdcall
+#else
+# define KHRONOS_APIENTRY
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIATTRIBUTES
+ *-------------------------------------------------------------------------
+ * This follows the closing parenthesis of the function prototype arguments.
+ */
+#if defined (__ARMCC_2__)
+#define KHRONOS_APIATTRIBUTES __softfp
+#else
+#define KHRONOS_APIATTRIBUTES
+#endif
+
+/*-------------------------------------------------------------------------
+ * basic type definitions
+ *-----------------------------------------------------------------------*/
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
+
+
+/*
+ * Using <stdint.h>
+ */
+#include <stdint.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__VMS ) || defined(__sgi)
+
+/*
+ * Using <inttypes.h>
+ */
+#include <inttypes.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
+
+/*
+ * Win32
+ */
+typedef __int32 khronos_int32_t;
+typedef unsigned __int32 khronos_uint32_t;
+typedef __int64 khronos_int64_t;
+typedef unsigned __int64 khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__sun__) || defined(__digital__)
+
+/*
+ * Sun or Digital
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#if defined(__arch64__) || defined(_LP64)
+typedef long int khronos_int64_t;
+typedef unsigned long int khronos_uint64_t;
+#else
+typedef long long int khronos_int64_t;
+typedef unsigned long long int khronos_uint64_t;
+#endif /* __arch64__ */
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif 0
+
+/*
+ * Hypothetical platform with no float or int64 support
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#define KHRONOS_SUPPORT_INT64 0
+#define KHRONOS_SUPPORT_FLOAT 0
+
+#else
+
+/*
+ * Generic fallback
+ */
+#include <stdint.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#endif
+
+
+/*
+ * Types that are (so far) the same on all platforms
+ */
+typedef signed char khronos_int8_t;
+typedef unsigned char khronos_uint8_t;
+typedef signed short int khronos_int16_t;
+typedef unsigned short int khronos_uint16_t;
+
+/*
+ * Types that differ between LLP64 and LP64 architectures - in LLP64,
+ * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
+ * to be the only LLP64 architecture in current use.
+ */
+#ifdef _WIN64
+typedef signed long long int khronos_intptr_t;
+typedef unsigned long long int khronos_uintptr_t;
+typedef signed long long int khronos_ssize_t;
+typedef unsigned long long int khronos_usize_t;
+#else
+typedef signed long int khronos_intptr_t;
+typedef unsigned long int khronos_uintptr_t;
+typedef signed long int khronos_ssize_t;
+typedef unsigned long int khronos_usize_t;
+#endif
+
+#if KHRONOS_SUPPORT_FLOAT
+/*
+ * Float type
+ */
+typedef float khronos_float_t;
+#endif
+
+#if KHRONOS_SUPPORT_INT64
+/* Time types
+ *
+ * These types can be used to represent a time interval in nanoseconds or
+ * an absolute Unadjusted System Time. Unadjusted System Time is the number
+ * of nanoseconds since some arbitrary system event (e.g. since the last
+ * time the system booted). The Unadjusted System Time is an unsigned
+ * 64 bit value that wraps back to 0 every 584 years. Time intervals
+ * may be either signed or unsigned.
+ */
+typedef khronos_uint64_t khronos_utime_nanoseconds_t;
+typedef khronos_int64_t khronos_stime_nanoseconds_t;
+#endif
+
+/*
+ * Dummy value used to pad enum types to 32 bits.
+ */
+#ifndef KHRONOS_MAX_ENUM
+#define KHRONOS_MAX_ENUM 0x7FFFFFFF
+#endif
+
+/*
+ * Enumerated boolean type
+ *
+ * Values other than zero should be considered to be true. Therefore
+ * comparisons should not be made against KHRONOS_TRUE.
+ */
+typedef enum {
+ KHRONOS_FALSE = 0,
+ KHRONOS_TRUE = 1,
+ KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
+} khronos_boolean_enum_t;
+
+#endif /* __khrplatform_h_ */
diff --git a/chromium/third_party/dawn/third_party/glad/include/glad/glad.h b/chromium/third_party/dawn/third_party/glad/include/glad/glad.h
new file mode 100644
index 00000000000..46e87987e2a
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/glad/include/glad/glad.h
@@ -0,0 +1,3691 @@
+/*
+
+ OpenGL loader generated by glad 0.1.26 on Wed Aug 1 16:13:04 2018.
+
+ Language/Generator: C/C++
+ Specification: gl
+ APIs: gl=4.5
+ Profile: core
+ Extensions:
+
+ Loader: True
+ Local files: False
+ Omit khrplatform: False
+
+ Commandline:
+ --profile="core" --api="gl=4.5" --generator="c" --spec="gl" --extensions=""
+ Online:
+ http://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gl%3D4.5
+*/
+
+
+#ifndef __glad_h_
+#define __glad_h_
+
+#ifdef __gl_h_
+#error OpenGL header already included, remove this include, glad already provides it
+#endif
+#define __gl_h_
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN 1
+#endif
+#ifndef NOMINMAX
+#define NOMINMAX 1
+#endif
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct gladGLversionStruct {
+ int major;
+ int minor;
+};
+
+typedef void* (* GLADloadproc)(const char *name);
+
+#ifndef GLAPI
+# if defined(GLAD_GLAPI_EXPORT)
+# if defined(_WIN32) || defined(__CYGWIN__)
+# if defined(GLAD_GLAPI_EXPORT_BUILD)
+# if defined(__GNUC__)
+# define GLAPI __attribute__ ((dllexport)) extern
+# else
+# define GLAPI __declspec(dllexport) extern
+# endif
+# else
+# if defined(__GNUC__)
+# define GLAPI __attribute__ ((dllimport)) extern
+# else
+# define GLAPI __declspec(dllimport) extern
+# endif
+# endif
+# elif defined(__GNUC__) && defined(GLAD_GLAPI_EXPORT_BUILD)
+# define GLAPI __attribute__ ((visibility ("default"))) extern
+# else
+# define GLAPI extern
+# endif
+# else
+# define GLAPI extern
+# endif
+#endif
+
+GLAPI struct gladGLversionStruct GLVersion;
+
+GLAPI int gladLoadGL(void);
+
+GLAPI int gladLoadGLLoader(GLADloadproc);
+
+#include <stddef.h>
+#include <KHR/khrplatform.h>
+#ifndef GLEXT_64_TYPES_DEFINED
+/* This code block is duplicated in glxext.h, so must be protected */
+#define GLEXT_64_TYPES_DEFINED
+/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
+/* (as used in the GL_EXT_timer_query extension). */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+#elif defined(__sun__) || defined(__digital__)
+#include <inttypes.h>
+#if defined(__STDC__)
+#if defined(__arch64__) || defined(_LP64)
+typedef long int int64_t;
+typedef unsigned long int uint64_t;
+#else
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#endif /* __arch64__ */
+#endif /* __STDC__ */
+#elif defined( __VMS ) || defined(__sgi)
+#include <inttypes.h>
+#elif defined(__SCO__) || defined(__USLC__)
+#include <stdint.h>
+#elif defined(__UNIXOS2__) || defined(__SOL64__)
+typedef long int int32_t;
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#elif defined(_WIN32) && defined(__GNUC__)
+#include <stdint.h>
+#elif defined(_WIN32)
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
+/* Fallback if nothing above works */
+#include <inttypes.h>
+#endif
+#endif
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef void GLvoid;
+typedef signed char GLbyte;
+typedef short GLshort;
+typedef int GLint;
+typedef int GLclampx;
+typedef unsigned char GLubyte;
+typedef unsigned short GLushort;
+typedef unsigned int GLuint;
+typedef int GLsizei;
+typedef float GLfloat;
+typedef float GLclampf;
+typedef double GLdouble;
+typedef double GLclampd;
+typedef void *GLeglClientBufferEXT;
+typedef void *GLeglImageOES;
+typedef char GLchar;
+typedef char GLcharARB;
+#ifdef __APPLE__
+typedef void *GLhandleARB;
+#else
+typedef unsigned int GLhandleARB;
+#endif
+typedef unsigned short GLhalfARB;
+typedef unsigned short GLhalf;
+typedef GLint GLfixed;
+typedef khronos_intptr_t GLintptr;
+typedef khronos_ssize_t GLsizeiptr;
+typedef int64_t GLint64;
+typedef uint64_t GLuint64;
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef long GLintptrARB;
+#else
+typedef ptrdiff_t GLintptrARB;
+#endif
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
+typedef long GLsizeiptrARB;
+#else
+typedef ptrdiff_t GLsizeiptrARB;
+#endif
+typedef int64_t GLint64EXT;
+typedef uint64_t GLuint64EXT;
+typedef struct __GLsync *GLsync;
+struct _cl_context;
+struct _cl_event;
+typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam);
+typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,void *userParam);
+typedef unsigned short GLhalfNV;
+typedef GLintptr GLvdpauSurfaceNV;
+typedef void (APIENTRY *GLVULKANPROCNV)(void);
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_FALSE 0
+#define GL_TRUE 1
+#define GL_POINTS 0x0000
+#define GL_LINES 0x0001
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_NEVER 0x0200
+#define GL_LESS 0x0201
+#define GL_EQUAL 0x0202
+#define GL_LEQUAL 0x0203
+#define GL_GREATER 0x0204
+#define GL_NOTEQUAL 0x0205
+#define GL_GEQUAL 0x0206
+#define GL_ALWAYS 0x0207
+#define GL_ZERO 0
+#define GL_ONE 1
+#define GL_SRC_COLOR 0x0300
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DST_ALPHA 0x0304
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_DST_COLOR 0x0306
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_SRC_ALPHA_SATURATE 0x0308
+#define GL_NONE 0
+#define GL_FRONT_LEFT 0x0400
+#define GL_FRONT_RIGHT 0x0401
+#define GL_BACK_LEFT 0x0402
+#define GL_BACK_RIGHT 0x0403
+#define GL_FRONT 0x0404
+#define GL_BACK 0x0405
+#define GL_LEFT 0x0406
+#define GL_RIGHT 0x0407
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_NO_ERROR 0
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVALID_OPERATION 0x0502
+#define GL_OUT_OF_MEMORY 0x0505
+#define GL_CW 0x0900
+#define GL_CCW 0x0901
+#define GL_POINT_SIZE 0x0B11
+#define GL_POINT_SIZE_RANGE 0x0B12
+#define GL_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_LINE_SMOOTH 0x0B20
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINE_WIDTH_RANGE 0x0B22
+#define GL_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_POLYGON_MODE 0x0B40
+#define GL_POLYGON_SMOOTH 0x0B41
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_FRONT_FACE 0x0B46
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_VIEWPORT 0x0BA2
+#define GL_DITHER 0x0BD0
+#define GL_BLEND_DST 0x0BE0
+#define GL_BLEND_SRC 0x0BE1
+#define GL_BLEND 0x0BE2
+#define GL_LOGIC_OP_MODE 0x0BF0
+#define GL_DRAW_BUFFER 0x0C01
+#define GL_READ_BUFFER 0x0C02
+#define GL_SCISSOR_BOX 0x0C10
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_DOUBLEBUFFER 0x0C32
+#define GL_STEREO 0x0C33
+#define GL_LINE_SMOOTH_HINT 0x0C52
+#define GL_POLYGON_SMOOTH_HINT 0x0C53
+#define GL_UNPACK_SWAP_BYTES 0x0CF0
+#define GL_UNPACK_LSB_FIRST 0x0CF1
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_PACK_SWAP_BYTES 0x0D00
+#define GL_PACK_LSB_FIRST 0x0D01
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_PACK_SKIP_ROWS 0x0D03
+#define GL_PACK_SKIP_PIXELS 0x0D04
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_TEXTURE_1D 0x0DE0
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_WIDTH 0x1000
+#define GL_TEXTURE_HEIGHT 0x1001
+#define GL_TEXTURE_BORDER_COLOR 0x1004
+#define GL_DONT_CARE 0x1100
+#define GL_FASTEST 0x1101
+#define GL_NICEST 0x1102
+#define GL_BYTE 0x1400
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_SHORT 0x1402
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_INT 0x1404
+#define GL_UNSIGNED_INT 0x1405
+#define GL_FLOAT 0x1406
+#define GL_CLEAR 0x1500
+#define GL_AND 0x1501
+#define GL_AND_REVERSE 0x1502
+#define GL_COPY 0x1503
+#define GL_AND_INVERTED 0x1504
+#define GL_NOOP 0x1505
+#define GL_XOR 0x1506
+#define GL_OR 0x1507
+#define GL_NOR 0x1508
+#define GL_EQUIV 0x1509
+#define GL_INVERT 0x150A
+#define GL_OR_REVERSE 0x150B
+#define GL_COPY_INVERTED 0x150C
+#define GL_OR_INVERTED 0x150D
+#define GL_NAND 0x150E
+#define GL_SET 0x150F
+#define GL_TEXTURE 0x1702
+#define GL_COLOR 0x1800
+#define GL_DEPTH 0x1801
+#define GL_STENCIL 0x1802
+#define GL_STENCIL_INDEX 0x1901
+#define GL_DEPTH_COMPONENT 0x1902
+#define GL_RED 0x1903
+#define GL_GREEN 0x1904
+#define GL_BLUE 0x1905
+#define GL_ALPHA 0x1906
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+#define GL_POINT 0x1B00
+#define GL_LINE 0x1B01
+#define GL_FILL 0x1B02
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_INCR 0x1E02
+#define GL_DECR 0x1E03
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+#define GL_VERSION 0x1F02
+#define GL_EXTENSIONS 0x1F03
+#define GL_NEAREST 0x2600
+#define GL_LINEAR 0x2601
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_REPEAT 0x2901
+#define GL_COLOR_LOGIC_OP 0x0BF2
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_POLYGON_OFFSET_POINT 0x2A01
+#define GL_POLYGON_OFFSET_LINE 0x2A02
+#define GL_POLYGON_OFFSET_FILL 0x8037
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_TEXTURE_BINDING_1D 0x8068
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
+#define GL_TEXTURE_RED_SIZE 0x805C
+#define GL_TEXTURE_GREEN_SIZE 0x805D
+#define GL_TEXTURE_BLUE_SIZE 0x805E
+#define GL_TEXTURE_ALPHA_SIZE 0x805F
+#define GL_DOUBLE 0x140A
+#define GL_PROXY_TEXTURE_1D 0x8063
+#define GL_PROXY_TEXTURE_2D 0x8064
+#define GL_R3_G3_B2 0x2A10
+#define GL_RGB4 0x804F
+#define GL_RGB5 0x8050
+#define GL_RGB8 0x8051
+#define GL_RGB10 0x8052
+#define GL_RGB12 0x8053
+#define GL_RGB16 0x8054
+#define GL_RGBA2 0x8055
+#define GL_RGBA4 0x8056
+#define GL_RGB5_A1 0x8057
+#define GL_RGBA8 0x8058
+#define GL_RGB10_A2 0x8059
+#define GL_RGBA12 0x805A
+#define GL_RGBA16 0x805B
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_BGR 0x80E0
+#define GL_BGRA 0x80E1
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_TEXTURE_COMPRESSED 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_CLAMP_TO_BORDER 0x812D
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_DEPTH_COMPONENT32 0x81A7
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_TEXTURE_LOD_BIAS 0x8501
+#define GL_INCR_WRAP 0x8507
+#define GL_DECR_WRAP 0x8508
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_BLEND_COLOR 0x8005
+#define GL_BLEND_EQUATION 0x8009
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_FUNC_ADD 0x8006
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+#define GL_QUERY_COUNTER_BITS 0x8864
+#define GL_CURRENT_QUERY 0x8865
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_READ_ONLY 0x88B8
+#define GL_WRITE_ONLY 0x88B9
+#define GL_READ_WRITE 0x88BA
+#define GL_BUFFER_ACCESS 0x88BB
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STREAM_READ 0x88E1
+#define GL_STREAM_COPY 0x88E2
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STATIC_READ 0x88E5
+#define GL_STATIC_COPY 0x88E6
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_SAMPLES_PASSED 0x8914
+#define GL_SRC1_ALPHA 0x8589
+#define GL_BLEND_EQUATION_RGB 0x8009
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_1D 0x8B5D
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_1D_SHADOW 0x8B61
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_DELETE_STATUS 0x8B80
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#define GL_PIXEL_PACK_BUFFER 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
+#define GL_FLOAT_MAT2x3 0x8B65
+#define GL_FLOAT_MAT2x4 0x8B66
+#define GL_FLOAT_MAT3x2 0x8B67
+#define GL_FLOAT_MAT3x4 0x8B68
+#define GL_FLOAT_MAT4x2 0x8B69
+#define GL_FLOAT_MAT4x3 0x8B6A
+#define GL_SRGB 0x8C40
+#define GL_SRGB8 0x8C41
+#define GL_SRGB_ALPHA 0x8C42
+#define GL_SRGB8_ALPHA8 0x8C43
+#define GL_COMPRESSED_SRGB 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
+#define GL_COMPARE_REF_TO_TEXTURE 0x884E
+#define GL_CLIP_DISTANCE0 0x3000
+#define GL_CLIP_DISTANCE1 0x3001
+#define GL_CLIP_DISTANCE2 0x3002
+#define GL_CLIP_DISTANCE3 0x3003
+#define GL_CLIP_DISTANCE4 0x3004
+#define GL_CLIP_DISTANCE5 0x3005
+#define GL_CLIP_DISTANCE6 0x3006
+#define GL_CLIP_DISTANCE7 0x3007
+#define GL_MAX_CLIP_DISTANCES 0x0D32
+#define GL_MAJOR_VERSION 0x821B
+#define GL_MINOR_VERSION 0x821C
+#define GL_NUM_EXTENSIONS 0x821D
+#define GL_CONTEXT_FLAGS 0x821E
+#define GL_COMPRESSED_RED 0x8225
+#define GL_COMPRESSED_RG 0x8226
+#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001
+#define GL_RGBA32F 0x8814
+#define GL_RGB32F 0x8815
+#define GL_RGBA16F 0x881A
+#define GL_RGB16F 0x881B
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
+#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
+#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
+#define GL_CLAMP_READ_COLOR 0x891C
+#define GL_FIXED_ONLY 0x891D
+#define GL_MAX_VARYING_COMPONENTS 0x8B4B
+#define GL_TEXTURE_1D_ARRAY 0x8C18
+#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
+#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
+#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
+#define GL_R11F_G11F_B10F 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
+#define GL_RGB9_E5 0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
+#define GL_TEXTURE_SHARED_SIZE 0x8C3F
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
+#define GL_PRIMITIVES_GENERATED 0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
+#define GL_RASTERIZER_DISCARD 0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS 0x8C8C
+#define GL_SEPARATE_ATTRIBS 0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
+#define GL_RGBA32UI 0x8D70
+#define GL_RGB32UI 0x8D71
+#define GL_RGBA16UI 0x8D76
+#define GL_RGB16UI 0x8D77
+#define GL_RGBA8UI 0x8D7C
+#define GL_RGB8UI 0x8D7D
+#define GL_RGBA32I 0x8D82
+#define GL_RGB32I 0x8D83
+#define GL_RGBA16I 0x8D88
+#define GL_RGB16I 0x8D89
+#define GL_RGBA8I 0x8D8E
+#define GL_RGB8I 0x8D8F
+#define GL_RED_INTEGER 0x8D94
+#define GL_GREEN_INTEGER 0x8D95
+#define GL_BLUE_INTEGER 0x8D96
+#define GL_RGB_INTEGER 0x8D98
+#define GL_RGBA_INTEGER 0x8D99
+#define GL_BGR_INTEGER 0x8D9A
+#define GL_BGRA_INTEGER 0x8D9B
+#define GL_SAMPLER_1D_ARRAY 0x8DC0
+#define GL_SAMPLER_2D_ARRAY 0x8DC1
+#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
+#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
+#define GL_UNSIGNED_INT_VEC2 0x8DC6
+#define GL_UNSIGNED_INT_VEC3 0x8DC7
+#define GL_UNSIGNED_INT_VEC4 0x8DC8
+#define GL_INT_SAMPLER_1D 0x8DC9
+#define GL_INT_SAMPLER_2D 0x8DCA
+#define GL_INT_SAMPLER_3D 0x8DCB
+#define GL_INT_SAMPLER_CUBE 0x8DCC
+#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
+#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
+#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
+#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
+#define GL_QUERY_WAIT 0x8E13
+#define GL_QUERY_NO_WAIT 0x8E14
+#define GL_QUERY_BY_REGION_WAIT 0x8E15
+#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
+#define GL_BUFFER_ACCESS_FLAGS 0x911F
+#define GL_BUFFER_MAP_LENGTH 0x9120
+#define GL_BUFFER_MAP_OFFSET 0x9121
+#define GL_DEPTH_COMPONENT32F 0x8CAC
+#define GL_DEPTH32F_STENCIL8 0x8CAD
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
+#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
+#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
+#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
+#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
+#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
+#define GL_FRAMEBUFFER_DEFAULT 0x8218
+#define GL_FRAMEBUFFER_UNDEFINED 0x8219
+#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+#define GL_DEPTH_STENCIL 0x84F9
+#define GL_UNSIGNED_INT_24_8 0x84FA
+#define GL_DEPTH24_STENCIL8 0x88F0
+#define GL_TEXTURE_STENCIL_SIZE 0x88F1
+#define GL_TEXTURE_RED_TYPE 0x8C10
+#define GL_TEXTURE_GREEN_TYPE 0x8C11
+#define GL_TEXTURE_BLUE_TYPE 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE 0x8C13
+#define GL_TEXTURE_DEPTH_TYPE 0x8C16
+#define GL_UNSIGNED_NORMALIZED 0x8C17
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_READ_FRAMEBUFFER 0x8CA8
+#define GL_DRAW_FRAMEBUFFER 0x8CA9
+#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
+#define GL_RENDERBUFFER_SAMPLES 0x8CAB
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_COLOR_ATTACHMENT1 0x8CE1
+#define GL_COLOR_ATTACHMENT2 0x8CE2
+#define GL_COLOR_ATTACHMENT3 0x8CE3
+#define GL_COLOR_ATTACHMENT4 0x8CE4
+#define GL_COLOR_ATTACHMENT5 0x8CE5
+#define GL_COLOR_ATTACHMENT6 0x8CE6
+#define GL_COLOR_ATTACHMENT7 0x8CE7
+#define GL_COLOR_ATTACHMENT8 0x8CE8
+#define GL_COLOR_ATTACHMENT9 0x8CE9
+#define GL_COLOR_ATTACHMENT10 0x8CEA
+#define GL_COLOR_ATTACHMENT11 0x8CEB
+#define GL_COLOR_ATTACHMENT12 0x8CEC
+#define GL_COLOR_ATTACHMENT13 0x8CED
+#define GL_COLOR_ATTACHMENT14 0x8CEE
+#define GL_COLOR_ATTACHMENT15 0x8CEF
+#define GL_COLOR_ATTACHMENT16 0x8CF0
+#define GL_COLOR_ATTACHMENT17 0x8CF1
+#define GL_COLOR_ATTACHMENT18 0x8CF2
+#define GL_COLOR_ATTACHMENT19 0x8CF3
+#define GL_COLOR_ATTACHMENT20 0x8CF4
+#define GL_COLOR_ATTACHMENT21 0x8CF5
+#define GL_COLOR_ATTACHMENT22 0x8CF6
+#define GL_COLOR_ATTACHMENT23 0x8CF7
+#define GL_COLOR_ATTACHMENT24 0x8CF8
+#define GL_COLOR_ATTACHMENT25 0x8CF9
+#define GL_COLOR_ATTACHMENT26 0x8CFA
+#define GL_COLOR_ATTACHMENT27 0x8CFB
+#define GL_COLOR_ATTACHMENT28 0x8CFC
+#define GL_COLOR_ATTACHMENT29 0x8CFD
+#define GL_COLOR_ATTACHMENT30 0x8CFE
+#define GL_COLOR_ATTACHMENT31 0x8CFF
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_STENCIL_INDEX1 0x8D46
+#define GL_STENCIL_INDEX4 0x8D47
+#define GL_STENCIL_INDEX8 0x8D48
+#define GL_STENCIL_INDEX16 0x8D49
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
+#define GL_MAX_SAMPLES 0x8D57
+#define GL_FRAMEBUFFER_SRGB 0x8DB9
+#define GL_HALF_FLOAT 0x140B
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+#define GL_COMPRESSED_RED_RGTC1 0x8DBB
+#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
+#define GL_COMPRESSED_RG_RGTC2 0x8DBD
+#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
+#define GL_RG 0x8227
+#define GL_RG_INTEGER 0x8228
+#define GL_R8 0x8229
+#define GL_R16 0x822A
+#define GL_RG8 0x822B
+#define GL_RG16 0x822C
+#define GL_R16F 0x822D
+#define GL_R32F 0x822E
+#define GL_RG16F 0x822F
+#define GL_RG32F 0x8230
+#define GL_R8I 0x8231
+#define GL_R8UI 0x8232
+#define GL_R16I 0x8233
+#define GL_R16UI 0x8234
+#define GL_R32I 0x8235
+#define GL_R32UI 0x8236
+#define GL_RG8I 0x8237
+#define GL_RG8UI 0x8238
+#define GL_RG16I 0x8239
+#define GL_RG16UI 0x823A
+#define GL_RG32I 0x823B
+#define GL_RG32UI 0x823C
+#define GL_VERTEX_ARRAY_BINDING 0x85B5
+#define GL_SAMPLER_2D_RECT 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW 0x8B64
+#define GL_SAMPLER_BUFFER 0x8DC2
+#define GL_INT_SAMPLER_2D_RECT 0x8DCD
+#define GL_INT_SAMPLER_BUFFER 0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT 0x8DD5
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8
+#define GL_TEXTURE_BUFFER 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER 0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D
+#define GL_TEXTURE_RECTANGLE 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE 0x84F8
+#define GL_R8_SNORM 0x8F94
+#define GL_RG8_SNORM 0x8F95
+#define GL_RGB8_SNORM 0x8F96
+#define GL_RGBA8_SNORM 0x8F97
+#define GL_R16_SNORM 0x8F98
+#define GL_RG16_SNORM 0x8F99
+#define GL_RGB16_SNORM 0x8F9A
+#define GL_RGBA16_SNORM 0x8F9B
+#define GL_SIGNED_NORMALIZED 0x8F9C
+#define GL_PRIMITIVE_RESTART 0x8F9D
+#define GL_PRIMITIVE_RESTART_INDEX 0x8F9E
+#define GL_COPY_READ_BUFFER 0x8F36
+#define GL_COPY_WRITE_BUFFER 0x8F37
+#define GL_UNIFORM_BUFFER 0x8A11
+#define GL_UNIFORM_BUFFER_BINDING 0x8A28
+#define GL_UNIFORM_BUFFER_START 0x8A29
+#define GL_UNIFORM_BUFFER_SIZE 0x8A2A
+#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B
+#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C
+#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D
+#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E
+#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F
+#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30
+#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31
+#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32
+#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33
+#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34
+#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35
+#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36
+#define GL_UNIFORM_TYPE 0x8A37
+#define GL_UNIFORM_SIZE 0x8A38
+#define GL_UNIFORM_NAME_LENGTH 0x8A39
+#define GL_UNIFORM_BLOCK_INDEX 0x8A3A
+#define GL_UNIFORM_OFFSET 0x8A3B
+#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C
+#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D
+#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E
+#define GL_UNIFORM_BLOCK_BINDING 0x8A3F
+#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40
+#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42
+#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER 0x8A45
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46
+#define GL_INVALID_INDEX 0xFFFFFFFF
+#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
+#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
+#define GL_LINES_ADJACENCY 0x000A
+#define GL_LINE_STRIP_ADJACENCY 0x000B
+#define GL_TRIANGLES_ADJACENCY 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
+#define GL_PROGRAM_POINT_SIZE 0x8642
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
+#define GL_GEOMETRY_SHADER 0x8DD9
+#define GL_GEOMETRY_VERTICES_OUT 0x8916
+#define GL_GEOMETRY_INPUT_TYPE 0x8917
+#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
+#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
+#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
+#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
+#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
+#define GL_CONTEXT_PROFILE_MASK 0x9126
+#define GL_DEPTH_CLAMP 0x864F
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
+#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
+#define GL_LAST_VERTEX_CONVENTION 0x8E4E
+#define GL_PROVOKING_VERTEX 0x8E4F
+#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
+#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
+#define GL_OBJECT_TYPE 0x9112
+#define GL_SYNC_CONDITION 0x9113
+#define GL_SYNC_STATUS 0x9114
+#define GL_SYNC_FLAGS 0x9115
+#define GL_SYNC_FENCE 0x9116
+#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
+#define GL_UNSIGNALED 0x9118
+#define GL_SIGNALED 0x9119
+#define GL_ALREADY_SIGNALED 0x911A
+#define GL_TIMEOUT_EXPIRED 0x911B
+#define GL_CONDITION_SATISFIED 0x911C
+#define GL_WAIT_FAILED 0x911D
+#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFF
+#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
+#define GL_SAMPLE_POSITION 0x8E50
+#define GL_SAMPLE_MASK 0x8E51
+#define GL_SAMPLE_MASK_VALUE 0x8E52
+#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
+#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
+#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
+#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
+#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
+#define GL_TEXTURE_SAMPLES 0x9106
+#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
+#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
+#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
+#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
+#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
+#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
+#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
+#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
+#define GL_MAX_INTEGER_SAMPLES 0x9110
+#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE
+#define GL_SRC1_COLOR 0x88F9
+#define GL_ONE_MINUS_SRC1_COLOR 0x88FA
+#define GL_ONE_MINUS_SRC1_ALPHA 0x88FB
+#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS 0x88FC
+#define GL_ANY_SAMPLES_PASSED 0x8C2F
+#define GL_SAMPLER_BINDING 0x8919
+#define GL_RGB10_A2UI 0x906F
+#define GL_TEXTURE_SWIZZLE_R 0x8E42
+#define GL_TEXTURE_SWIZZLE_G 0x8E43
+#define GL_TEXTURE_SWIZZLE_B 0x8E44
+#define GL_TEXTURE_SWIZZLE_A 0x8E45
+#define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
+#define GL_TIME_ELAPSED 0x88BF
+#define GL_TIMESTAMP 0x8E28
+#define GL_INT_2_10_10_10_REV 0x8D9F
+#define GL_SAMPLE_SHADING 0x8C36
+#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37
+#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E
+#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F
+#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B
+#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C
+#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D
+#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
+#define GL_DRAW_INDIRECT_BUFFER 0x8F3F
+#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43
+#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F
+#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A
+#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B
+#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C
+#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D
+#define GL_MAX_VERTEX_STREAMS 0x8E71
+#define GL_DOUBLE_VEC2 0x8FFC
+#define GL_DOUBLE_VEC3 0x8FFD
+#define GL_DOUBLE_VEC4 0x8FFE
+#define GL_DOUBLE_MAT2 0x8F46
+#define GL_DOUBLE_MAT3 0x8F47
+#define GL_DOUBLE_MAT4 0x8F48
+#define GL_DOUBLE_MAT2x3 0x8F49
+#define GL_DOUBLE_MAT2x4 0x8F4A
+#define GL_DOUBLE_MAT3x2 0x8F4B
+#define GL_DOUBLE_MAT3x4 0x8F4C
+#define GL_DOUBLE_MAT4x2 0x8F4D
+#define GL_DOUBLE_MAT4x3 0x8F4E
+#define GL_ACTIVE_SUBROUTINES 0x8DE5
+#define GL_ACTIVE_SUBROUTINE_UNIFORMS 0x8DE6
+#define GL_ACTIVE_SUBROUTINE_UNIFORM_LOCATIONS 0x8E47
+#define GL_ACTIVE_SUBROUTINE_MAX_LENGTH 0x8E48
+#define GL_ACTIVE_SUBROUTINE_UNIFORM_MAX_LENGTH 0x8E49
+#define GL_MAX_SUBROUTINES 0x8DE7
+#define GL_MAX_SUBROUTINE_UNIFORM_LOCATIONS 0x8DE8
+#define GL_NUM_COMPATIBLE_SUBROUTINES 0x8E4A
+#define GL_COMPATIBLE_SUBROUTINES 0x8E4B
+#define GL_PATCHES 0x000E
+#define GL_PATCH_VERTICES 0x8E72
+#define GL_PATCH_DEFAULT_INNER_LEVEL 0x8E73
+#define GL_PATCH_DEFAULT_OUTER_LEVEL 0x8E74
+#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75
+#define GL_TESS_GEN_MODE 0x8E76
+#define GL_TESS_GEN_SPACING 0x8E77
+#define GL_TESS_GEN_VERTEX_ORDER 0x8E78
+#define GL_TESS_GEN_POINT_MODE 0x8E79
+#define GL_ISOLINES 0x8E7A
+#define GL_QUADS 0x0007
+#define GL_FRACTIONAL_ODD 0x8E7B
+#define GL_FRACTIONAL_EVEN 0x8E7C
+#define GL_MAX_PATCH_VERTICES 0x8E7D
+#define GL_MAX_TESS_GEN_LEVEL 0x8E7E
+#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F
+#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80
+#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81
+#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82
+#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83
+#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84
+#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85
+#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86
+#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89
+#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A
+#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C
+#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D
+#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E
+#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER 0x84F0
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER 0x84F1
+#define GL_TESS_EVALUATION_SHADER 0x8E87
+#define GL_TESS_CONTROL_SHADER 0x8E88
+#define GL_TRANSFORM_FEEDBACK 0x8E22
+#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED 0x8E23
+#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25
+#define GL_MAX_TRANSFORM_FEEDBACK_BUFFERS 0x8E70
+#define GL_FIXED 0x140C
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B
+#define GL_LOW_FLOAT 0x8DF0
+#define GL_MEDIUM_FLOAT 0x8DF1
+#define GL_HIGH_FLOAT 0x8DF2
+#define GL_LOW_INT 0x8DF3
+#define GL_MEDIUM_INT 0x8DF4
+#define GL_HIGH_INT 0x8DF5
+#define GL_SHADER_COMPILER 0x8DFA
+#define GL_SHADER_BINARY_FORMATS 0x8DF8
+#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
+#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
+#define GL_MAX_VARYING_VECTORS 0x8DFC
+#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
+#define GL_RGB565 0x8D62
+#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257
+#define GL_PROGRAM_BINARY_LENGTH 0x8741
+#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE
+#define GL_PROGRAM_BINARY_FORMATS 0x87FF
+#define GL_VERTEX_SHADER_BIT 0x00000001
+#define GL_FRAGMENT_SHADER_BIT 0x00000002
+#define GL_GEOMETRY_SHADER_BIT 0x00000004
+#define GL_TESS_CONTROL_SHADER_BIT 0x00000008
+#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010
+#define GL_ALL_SHADER_BITS 0xFFFFFFFF
+#define GL_PROGRAM_SEPARABLE 0x8258
+#define GL_ACTIVE_PROGRAM 0x8259
+#define GL_PROGRAM_PIPELINE_BINDING 0x825A
+#define GL_MAX_VIEWPORTS 0x825B
+#define GL_VIEWPORT_SUBPIXEL_BITS 0x825C
+#define GL_VIEWPORT_BOUNDS_RANGE 0x825D
+#define GL_LAYER_PROVOKING_VERTEX 0x825E
+#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX 0x825F
+#define GL_UNDEFINED_VERTEX 0x8260
+#define GL_COPY_READ_BUFFER_BINDING 0x8F36
+#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37
+#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24
+#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23
+#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127
+#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
+#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129
+#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A
+#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B
+#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C
+#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D
+#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E
+#define GL_NUM_SAMPLE_COUNTS 0x9380
+#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC
+#define GL_ATOMIC_COUNTER_BUFFER 0x92C0
+#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1
+#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2
+#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3
+#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4
+#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5
+#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB
+#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF
+#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0
+#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1
+#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2
+#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3
+#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4
+#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5
+#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6
+#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7
+#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8
+#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC
+#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9
+#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA
+#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB
+#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
+#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
+#define GL_UNIFORM_BARRIER_BIT 0x00000004
+#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
+#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
+#define GL_COMMAND_BARRIER_BIT 0x00000040
+#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
+#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
+#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
+#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
+#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
+#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000
+#define GL_ALL_BARRIER_BITS 0xFFFFFFFF
+#define GL_MAX_IMAGE_UNITS 0x8F38
+#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39
+#define GL_IMAGE_BINDING_NAME 0x8F3A
+#define GL_IMAGE_BINDING_LEVEL 0x8F3B
+#define GL_IMAGE_BINDING_LAYERED 0x8F3C
+#define GL_IMAGE_BINDING_LAYER 0x8F3D
+#define GL_IMAGE_BINDING_ACCESS 0x8F3E
+#define GL_IMAGE_1D 0x904C
+#define GL_IMAGE_2D 0x904D
+#define GL_IMAGE_3D 0x904E
+#define GL_IMAGE_2D_RECT 0x904F
+#define GL_IMAGE_CUBE 0x9050
+#define GL_IMAGE_BUFFER 0x9051
+#define GL_IMAGE_1D_ARRAY 0x9052
+#define GL_IMAGE_2D_ARRAY 0x9053
+#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
+#define GL_IMAGE_2D_MULTISAMPLE 0x9055
+#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
+#define GL_INT_IMAGE_1D 0x9057
+#define GL_INT_IMAGE_2D 0x9058
+#define GL_INT_IMAGE_3D 0x9059
+#define GL_INT_IMAGE_2D_RECT 0x905A
+#define GL_INT_IMAGE_CUBE 0x905B
+#define GL_INT_IMAGE_BUFFER 0x905C
+#define GL_INT_IMAGE_1D_ARRAY 0x905D
+#define GL_INT_IMAGE_2D_ARRAY 0x905E
+#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
+#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
+#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
+#define GL_UNSIGNED_INT_IMAGE_1D 0x9062
+#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
+#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
+#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
+#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
+#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
+#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
+#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
+#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
+#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
+#define GL_MAX_IMAGE_SAMPLES 0x906D
+#define GL_IMAGE_BINDING_FORMAT 0x906E
+#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
+#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
+#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
+#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA
+#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB
+#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC
+#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD
+#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE
+#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF
+#define GL_COMPRESSED_RGBA_BPTC_UNORM 0x8E8C
+#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM 0x8E8D
+#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT 0x8E8E
+#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
+#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F
+#define GL_NUM_SHADING_LANGUAGE_VERSIONS 0x82E9
+#define GL_VERTEX_ATTRIB_ARRAY_LONG 0x874E
+#define GL_COMPRESSED_RGB8_ETC2 0x9274
+#define GL_COMPRESSED_SRGB8_ETC2 0x9275
+#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
+#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277
+#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
+#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279
+#define GL_COMPRESSED_R11_EAC 0x9270
+#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271
+#define GL_COMPRESSED_RG11_EAC 0x9272
+#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273
+#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69
+#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A
+#define GL_MAX_ELEMENT_INDEX 0x8D6B
+#define GL_COMPUTE_SHADER 0x91B9
+#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB
+#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC
+#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD
+#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262
+#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263
+#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264
+#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265
+#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266
+#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB
+#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE
+#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF
+#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267
+#define GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER 0x90EC
+#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER 0x90ED
+#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE
+#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF
+#define GL_COMPUTE_SHADER_BIT 0x00000020
+#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
+#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243
+#define GL_DEBUG_CALLBACK_FUNCTION 0x8244
+#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245
+#define GL_DEBUG_SOURCE_API 0x8246
+#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247
+#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248
+#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249
+#define GL_DEBUG_SOURCE_APPLICATION 0x824A
+#define GL_DEBUG_SOURCE_OTHER 0x824B
+#define GL_DEBUG_TYPE_ERROR 0x824C
+#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D
+#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E
+#define GL_DEBUG_TYPE_PORTABILITY 0x824F
+#define GL_DEBUG_TYPE_PERFORMANCE 0x8250
+#define GL_DEBUG_TYPE_OTHER 0x8251
+#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143
+#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144
+#define GL_DEBUG_LOGGED_MESSAGES 0x9145
+#define GL_DEBUG_SEVERITY_HIGH 0x9146
+#define GL_DEBUG_SEVERITY_MEDIUM 0x9147
+#define GL_DEBUG_SEVERITY_LOW 0x9148
+#define GL_DEBUG_TYPE_MARKER 0x8268
+#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269
+#define GL_DEBUG_TYPE_POP_GROUP 0x826A
+#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B
+#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C
+#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D
+#define GL_BUFFER 0x82E0
+#define GL_SHADER 0x82E1
+#define GL_PROGRAM 0x82E2
+#define GL_VERTEX_ARRAY 0x8074
+#define GL_QUERY 0x82E3
+#define GL_PROGRAM_PIPELINE 0x82E4
+#define GL_SAMPLER 0x82E6
+#define GL_MAX_LABEL_LENGTH 0x82E8
+#define GL_DEBUG_OUTPUT 0x92E0
+#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002
+#define GL_MAX_UNIFORM_LOCATIONS 0x826E
+#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310
+#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311
+#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312
+#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313
+#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314
+#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315
+#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316
+#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317
+#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318
+#define GL_INTERNALFORMAT_SUPPORTED 0x826F
+#define GL_INTERNALFORMAT_PREFERRED 0x8270
+#define GL_INTERNALFORMAT_RED_SIZE 0x8271
+#define GL_INTERNALFORMAT_GREEN_SIZE 0x8272
+#define GL_INTERNALFORMAT_BLUE_SIZE 0x8273
+#define GL_INTERNALFORMAT_ALPHA_SIZE 0x8274
+#define GL_INTERNALFORMAT_DEPTH_SIZE 0x8275
+#define GL_INTERNALFORMAT_STENCIL_SIZE 0x8276
+#define GL_INTERNALFORMAT_SHARED_SIZE 0x8277
+#define GL_INTERNALFORMAT_RED_TYPE 0x8278
+#define GL_INTERNALFORMAT_GREEN_TYPE 0x8279
+#define GL_INTERNALFORMAT_BLUE_TYPE 0x827A
+#define GL_INTERNALFORMAT_ALPHA_TYPE 0x827B
+#define GL_INTERNALFORMAT_DEPTH_TYPE 0x827C
+#define GL_INTERNALFORMAT_STENCIL_TYPE 0x827D
+#define GL_MAX_WIDTH 0x827E
+#define GL_MAX_HEIGHT 0x827F
+#define GL_MAX_DEPTH 0x8280
+#define GL_MAX_LAYERS 0x8281
+#define GL_MAX_COMBINED_DIMENSIONS 0x8282
+#define GL_COLOR_COMPONENTS 0x8283
+#define GL_DEPTH_COMPONENTS 0x8284
+#define GL_STENCIL_COMPONENTS 0x8285
+#define GL_COLOR_RENDERABLE 0x8286
+#define GL_DEPTH_RENDERABLE 0x8287
+#define GL_STENCIL_RENDERABLE 0x8288
+#define GL_FRAMEBUFFER_RENDERABLE 0x8289
+#define GL_FRAMEBUFFER_RENDERABLE_LAYERED 0x828A
+#define GL_FRAMEBUFFER_BLEND 0x828B
+#define GL_READ_PIXELS 0x828C
+#define GL_READ_PIXELS_FORMAT 0x828D
+#define GL_READ_PIXELS_TYPE 0x828E
+#define GL_TEXTURE_IMAGE_FORMAT 0x828F
+#define GL_TEXTURE_IMAGE_TYPE 0x8290
+#define GL_GET_TEXTURE_IMAGE_FORMAT 0x8291
+#define GL_GET_TEXTURE_IMAGE_TYPE 0x8292
+#define GL_MIPMAP 0x8293
+#define GL_MANUAL_GENERATE_MIPMAP 0x8294
+#define GL_AUTO_GENERATE_MIPMAP 0x8295
+#define GL_COLOR_ENCODING 0x8296
+#define GL_SRGB_READ 0x8297
+#define GL_SRGB_WRITE 0x8298
+#define GL_FILTER 0x829A
+#define GL_VERTEX_TEXTURE 0x829B
+#define GL_TESS_CONTROL_TEXTURE 0x829C
+#define GL_TESS_EVALUATION_TEXTURE 0x829D
+#define GL_GEOMETRY_TEXTURE 0x829E
+#define GL_FRAGMENT_TEXTURE 0x829F
+#define GL_COMPUTE_TEXTURE 0x82A0
+#define GL_TEXTURE_SHADOW 0x82A1
+#define GL_TEXTURE_GATHER 0x82A2
+#define GL_TEXTURE_GATHER_SHADOW 0x82A3
+#define GL_SHADER_IMAGE_LOAD 0x82A4
+#define GL_SHADER_IMAGE_STORE 0x82A5
+#define GL_SHADER_IMAGE_ATOMIC 0x82A6
+#define GL_IMAGE_TEXEL_SIZE 0x82A7
+#define GL_IMAGE_COMPATIBILITY_CLASS 0x82A8
+#define GL_IMAGE_PIXEL_FORMAT 0x82A9
+#define GL_IMAGE_PIXEL_TYPE 0x82AA
+#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_TEST 0x82AC
+#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_TEST 0x82AD
+#define GL_SIMULTANEOUS_TEXTURE_AND_DEPTH_WRITE 0x82AE
+#define GL_SIMULTANEOUS_TEXTURE_AND_STENCIL_WRITE 0x82AF
+#define GL_TEXTURE_COMPRESSED_BLOCK_WIDTH 0x82B1
+#define GL_TEXTURE_COMPRESSED_BLOCK_HEIGHT 0x82B2
+#define GL_TEXTURE_COMPRESSED_BLOCK_SIZE 0x82B3
+#define GL_CLEAR_BUFFER 0x82B4
+#define GL_TEXTURE_VIEW 0x82B5
+#define GL_VIEW_COMPATIBILITY_CLASS 0x82B6
+#define GL_FULL_SUPPORT 0x82B7
+#define GL_CAVEAT_SUPPORT 0x82B8
+#define GL_IMAGE_CLASS_4_X_32 0x82B9
+#define GL_IMAGE_CLASS_2_X_32 0x82BA
+#define GL_IMAGE_CLASS_1_X_32 0x82BB
+#define GL_IMAGE_CLASS_4_X_16 0x82BC
+#define GL_IMAGE_CLASS_2_X_16 0x82BD
+#define GL_IMAGE_CLASS_1_X_16 0x82BE
+#define GL_IMAGE_CLASS_4_X_8 0x82BF
+#define GL_IMAGE_CLASS_2_X_8 0x82C0
+#define GL_IMAGE_CLASS_1_X_8 0x82C1
+#define GL_IMAGE_CLASS_11_11_10 0x82C2
+#define GL_IMAGE_CLASS_10_10_10_2 0x82C3
+#define GL_VIEW_CLASS_128_BITS 0x82C4
+#define GL_VIEW_CLASS_96_BITS 0x82C5
+#define GL_VIEW_CLASS_64_BITS 0x82C6
+#define GL_VIEW_CLASS_48_BITS 0x82C7
+#define GL_VIEW_CLASS_32_BITS 0x82C8
+#define GL_VIEW_CLASS_24_BITS 0x82C9
+#define GL_VIEW_CLASS_16_BITS 0x82CA
+#define GL_VIEW_CLASS_8_BITS 0x82CB
+#define GL_VIEW_CLASS_S3TC_DXT1_RGB 0x82CC
+#define GL_VIEW_CLASS_S3TC_DXT1_RGBA 0x82CD
+#define GL_VIEW_CLASS_S3TC_DXT3_RGBA 0x82CE
+#define GL_VIEW_CLASS_S3TC_DXT5_RGBA 0x82CF
+#define GL_VIEW_CLASS_RGTC1_RED 0x82D0
+#define GL_VIEW_CLASS_RGTC2_RG 0x82D1
+#define GL_VIEW_CLASS_BPTC_UNORM 0x82D2
+#define GL_VIEW_CLASS_BPTC_FLOAT 0x82D3
+#define GL_UNIFORM 0x92E1
+#define GL_UNIFORM_BLOCK 0x92E2
+#define GL_PROGRAM_INPUT 0x92E3
+#define GL_PROGRAM_OUTPUT 0x92E4
+#define GL_BUFFER_VARIABLE 0x92E5
+#define GL_SHADER_STORAGE_BLOCK 0x92E6
+#define GL_VERTEX_SUBROUTINE 0x92E8
+#define GL_TESS_CONTROL_SUBROUTINE 0x92E9
+#define GL_TESS_EVALUATION_SUBROUTINE 0x92EA
+#define GL_GEOMETRY_SUBROUTINE 0x92EB
+#define GL_FRAGMENT_SUBROUTINE 0x92EC
+#define GL_COMPUTE_SUBROUTINE 0x92ED
+#define GL_VERTEX_SUBROUTINE_UNIFORM 0x92EE
+#define GL_TESS_CONTROL_SUBROUTINE_UNIFORM 0x92EF
+#define GL_TESS_EVALUATION_SUBROUTINE_UNIFORM 0x92F0
+#define GL_GEOMETRY_SUBROUTINE_UNIFORM 0x92F1
+#define GL_FRAGMENT_SUBROUTINE_UNIFORM 0x92F2
+#define GL_COMPUTE_SUBROUTINE_UNIFORM 0x92F3
+#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4
+#define GL_ACTIVE_RESOURCES 0x92F5
+#define GL_MAX_NAME_LENGTH 0x92F6
+#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7
+#define GL_MAX_NUM_COMPATIBLE_SUBROUTINES 0x92F8
+#define GL_NAME_LENGTH 0x92F9
+#define GL_TYPE 0x92FA
+#define GL_ARRAY_SIZE 0x92FB
+#define GL_OFFSET 0x92FC
+#define GL_BLOCK_INDEX 0x92FD
+#define GL_ARRAY_STRIDE 0x92FE
+#define GL_MATRIX_STRIDE 0x92FF
+#define GL_IS_ROW_MAJOR 0x9300
+#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301
+#define GL_BUFFER_BINDING 0x9302
+#define GL_BUFFER_DATA_SIZE 0x9303
+#define GL_NUM_ACTIVE_VARIABLES 0x9304
+#define GL_ACTIVE_VARIABLES 0x9305
+#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306
+#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307
+#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308
+#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309
+#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A
+#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B
+#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C
+#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D
+#define GL_LOCATION 0x930E
+#define GL_LOCATION_INDEX 0x930F
+#define GL_IS_PER_PATCH 0x92E7
+#define GL_SHADER_STORAGE_BUFFER 0x90D2
+#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3
+#define GL_SHADER_STORAGE_BUFFER_START 0x90D4
+#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5
+#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6
+#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7
+#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8
+#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9
+#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA
+#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB
+#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC
+#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD
+#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE
+#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF
+#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000
+#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39
+#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA
+#define GL_TEXTURE_BUFFER_OFFSET 0x919D
+#define GL_TEXTURE_BUFFER_SIZE 0x919E
+#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F
+#define GL_TEXTURE_VIEW_MIN_LEVEL 0x82DB
+#define GL_TEXTURE_VIEW_NUM_LEVELS 0x82DC
+#define GL_TEXTURE_VIEW_MIN_LAYER 0x82DD
+#define GL_TEXTURE_VIEW_NUM_LAYERS 0x82DE
+#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF
+#define GL_VERTEX_ATTRIB_BINDING 0x82D4
+#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5
+#define GL_VERTEX_BINDING_DIVISOR 0x82D6
+#define GL_VERTEX_BINDING_OFFSET 0x82D7
+#define GL_VERTEX_BINDING_STRIDE 0x82D8
+#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9
+#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA
+#define GL_VERTEX_BINDING_BUFFER 0x8F4F
+#define GL_DISPLAY_LIST 0x82E7
+#define GL_STACK_UNDERFLOW 0x0504
+#define GL_STACK_OVERFLOW 0x0503
+#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5
+#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221
+#define GL_TEXTURE_BUFFER_BINDING 0x8C2A
+#define GL_MAP_PERSISTENT_BIT 0x0040
+#define GL_MAP_COHERENT_BIT 0x0080
+#define GL_DYNAMIC_STORAGE_BIT 0x0100
+#define GL_CLIENT_STORAGE_BIT 0x0200
+#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT 0x00004000
+#define GL_BUFFER_IMMUTABLE_STORAGE 0x821F
+#define GL_BUFFER_STORAGE_FLAGS 0x8220
+#define GL_CLEAR_TEXTURE 0x9365
+#define GL_LOCATION_COMPONENT 0x934A
+#define GL_TRANSFORM_FEEDBACK_BUFFER_INDEX 0x934B
+#define GL_TRANSFORM_FEEDBACK_BUFFER_STRIDE 0x934C
+#define GL_QUERY_BUFFER 0x9192
+#define GL_QUERY_BUFFER_BARRIER_BIT 0x00008000
+#define GL_QUERY_BUFFER_BINDING 0x9193
+#define GL_QUERY_RESULT_NO_WAIT 0x9194
+#define GL_MIRROR_CLAMP_TO_EDGE 0x8743
+#define GL_CONTEXT_LOST 0x0507
+#define GL_NEGATIVE_ONE_TO_ONE 0x935E
+#define GL_ZERO_TO_ONE 0x935F
+#define GL_CLIP_ORIGIN 0x935C
+#define GL_CLIP_DEPTH_MODE 0x935D
+#define GL_QUERY_WAIT_INVERTED 0x8E17
+#define GL_QUERY_NO_WAIT_INVERTED 0x8E18
+#define GL_QUERY_BY_REGION_WAIT_INVERTED 0x8E19
+#define GL_QUERY_BY_REGION_NO_WAIT_INVERTED 0x8E1A
+#define GL_MAX_CULL_DISTANCES 0x82F9
+#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES 0x82FA
+#define GL_TEXTURE_TARGET 0x1006
+#define GL_QUERY_TARGET 0x82EA
+#define GL_GUILTY_CONTEXT_RESET 0x8253
+#define GL_INNOCENT_CONTEXT_RESET 0x8254
+#define GL_UNKNOWN_CONTEXT_RESET 0x8255
+#define GL_RESET_NOTIFICATION_STRATEGY 0x8256
+#define GL_LOSE_CONTEXT_ON_RESET 0x8252
+#define GL_NO_RESET_NOTIFICATION 0x8261
+#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004
+#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB
+#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC
+#ifndef GL_VERSION_1_0
+#define GL_VERSION_1_0 1
+GLAPI int GLAD_GL_VERSION_1_0;
+typedef void (APIENTRYP PFNGLCULLFACEPROC)(GLenum mode);
+GLAPI PFNGLCULLFACEPROC glad_glCullFace;
+#define glCullFace glad_glCullFace
+typedef void (APIENTRYP PFNGLFRONTFACEPROC)(GLenum mode);
+GLAPI PFNGLFRONTFACEPROC glad_glFrontFace;
+#define glFrontFace glad_glFrontFace
+typedef void (APIENTRYP PFNGLHINTPROC)(GLenum target, GLenum mode);
+GLAPI PFNGLHINTPROC glad_glHint;
+#define glHint glad_glHint
+typedef void (APIENTRYP PFNGLLINEWIDTHPROC)(GLfloat width);
+GLAPI PFNGLLINEWIDTHPROC glad_glLineWidth;
+#define glLineWidth glad_glLineWidth
+typedef void (APIENTRYP PFNGLPOINTSIZEPROC)(GLfloat size);
+GLAPI PFNGLPOINTSIZEPROC glad_glPointSize;
+#define glPointSize glad_glPointSize
+typedef void (APIENTRYP PFNGLPOLYGONMODEPROC)(GLenum face, GLenum mode);
+GLAPI PFNGLPOLYGONMODEPROC glad_glPolygonMode;
+#define glPolygonMode glad_glPolygonMode
+typedef void (APIENTRYP PFNGLSCISSORPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI PFNGLSCISSORPROC glad_glScissor;
+#define glScissor glad_glScissor
+typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC)(GLenum target, GLenum pname, GLfloat param);
+GLAPI PFNGLTEXPARAMETERFPROC glad_glTexParameterf;
+#define glTexParameterf glad_glTexParameterf
+typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC)(GLenum target, GLenum pname, const GLfloat *params);
+GLAPI PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv;
+#define glTexParameterfv glad_glTexParameterfv
+typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
+GLAPI PFNGLTEXPARAMETERIPROC glad_glTexParameteri;
+#define glTexParameteri glad_glTexParameteri
+typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC)(GLenum target, GLenum pname, const GLint *params);
+GLAPI PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv;
+#define glTexParameteriv glad_glTexParameteriv
+typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXIMAGE1DPROC glad_glTexImage1D;
+#define glTexImage1D glad_glTexImage1D
+typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXIMAGE2DPROC glad_glTexImage2D;
+#define glTexImage2D glad_glTexImage2D
+typedef void (APIENTRYP PFNGLDRAWBUFFERPROC)(GLenum buf);
+GLAPI PFNGLDRAWBUFFERPROC glad_glDrawBuffer;
+#define glDrawBuffer glad_glDrawBuffer
+typedef void (APIENTRYP PFNGLCLEARPROC)(GLbitfield mask);
+GLAPI PFNGLCLEARPROC glad_glClear;
+#define glClear glad_glClear
+typedef void (APIENTRYP PFNGLCLEARCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GLAPI PFNGLCLEARCOLORPROC glad_glClearColor;
+#define glClearColor glad_glClearColor
+typedef void (APIENTRYP PFNGLCLEARSTENCILPROC)(GLint s);
+GLAPI PFNGLCLEARSTENCILPROC glad_glClearStencil;
+#define glClearStencil glad_glClearStencil
+typedef void (APIENTRYP PFNGLCLEARDEPTHPROC)(GLdouble depth);
+GLAPI PFNGLCLEARDEPTHPROC glad_glClearDepth;
+#define glClearDepth glad_glClearDepth
+typedef void (APIENTRYP PFNGLSTENCILMASKPROC)(GLuint mask);
+GLAPI PFNGLSTENCILMASKPROC glad_glStencilMask;
+#define glStencilMask glad_glStencilMask
+typedef void (APIENTRYP PFNGLCOLORMASKPROC)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+GLAPI PFNGLCOLORMASKPROC glad_glColorMask;
+#define glColorMask glad_glColorMask
+typedef void (APIENTRYP PFNGLDEPTHMASKPROC)(GLboolean flag);
+GLAPI PFNGLDEPTHMASKPROC glad_glDepthMask;
+#define glDepthMask glad_glDepthMask
+typedef void (APIENTRYP PFNGLDISABLEPROC)(GLenum cap);
+GLAPI PFNGLDISABLEPROC glad_glDisable;
+#define glDisable glad_glDisable
+typedef void (APIENTRYP PFNGLENABLEPROC)(GLenum cap);
+GLAPI PFNGLENABLEPROC glad_glEnable;
+#define glEnable glad_glEnable
+typedef void (APIENTRYP PFNGLFINISHPROC)(void);
+GLAPI PFNGLFINISHPROC glad_glFinish;
+#define glFinish glad_glFinish
+typedef void (APIENTRYP PFNGLFLUSHPROC)(void);
+GLAPI PFNGLFLUSHPROC glad_glFlush;
+#define glFlush glad_glFlush
+typedef void (APIENTRYP PFNGLBLENDFUNCPROC)(GLenum sfactor, GLenum dfactor);
+GLAPI PFNGLBLENDFUNCPROC glad_glBlendFunc;
+#define glBlendFunc glad_glBlendFunc
+typedef void (APIENTRYP PFNGLLOGICOPPROC)(GLenum opcode);
+GLAPI PFNGLLOGICOPPROC glad_glLogicOp;
+#define glLogicOp glad_glLogicOp
+typedef void (APIENTRYP PFNGLSTENCILFUNCPROC)(GLenum func, GLint ref, GLuint mask);
+GLAPI PFNGLSTENCILFUNCPROC glad_glStencilFunc;
+#define glStencilFunc glad_glStencilFunc
+typedef void (APIENTRYP PFNGLSTENCILOPPROC)(GLenum fail, GLenum zfail, GLenum zpass);
+GLAPI PFNGLSTENCILOPPROC glad_glStencilOp;
+#define glStencilOp glad_glStencilOp
+typedef void (APIENTRYP PFNGLDEPTHFUNCPROC)(GLenum func);
+GLAPI PFNGLDEPTHFUNCPROC glad_glDepthFunc;
+#define glDepthFunc glad_glDepthFunc
+typedef void (APIENTRYP PFNGLPIXELSTOREFPROC)(GLenum pname, GLfloat param);
+GLAPI PFNGLPIXELSTOREFPROC glad_glPixelStoref;
+#define glPixelStoref glad_glPixelStoref
+typedef void (APIENTRYP PFNGLPIXELSTOREIPROC)(GLenum pname, GLint param);
+GLAPI PFNGLPIXELSTOREIPROC glad_glPixelStorei;
+#define glPixelStorei glad_glPixelStorei
+typedef void (APIENTRYP PFNGLREADBUFFERPROC)(GLenum src);
+GLAPI PFNGLREADBUFFERPROC glad_glReadBuffer;
+#define glReadBuffer glad_glReadBuffer
+typedef void (APIENTRYP PFNGLREADPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels);
+GLAPI PFNGLREADPIXELSPROC glad_glReadPixels;
+#define glReadPixels glad_glReadPixels
+typedef void (APIENTRYP PFNGLGETBOOLEANVPROC)(GLenum pname, GLboolean *data);
+GLAPI PFNGLGETBOOLEANVPROC glad_glGetBooleanv;
+#define glGetBooleanv glad_glGetBooleanv
+typedef void (APIENTRYP PFNGLGETDOUBLEVPROC)(GLenum pname, GLdouble *data);
+GLAPI PFNGLGETDOUBLEVPROC glad_glGetDoublev;
+#define glGetDoublev glad_glGetDoublev
+typedef GLenum (APIENTRYP PFNGLGETERRORPROC)(void);
+GLAPI PFNGLGETERRORPROC glad_glGetError;
+#define glGetError glad_glGetError
+typedef void (APIENTRYP PFNGLGETFLOATVPROC)(GLenum pname, GLfloat *data);
+GLAPI PFNGLGETFLOATVPROC glad_glGetFloatv;
+#define glGetFloatv glad_glGetFloatv
+typedef void (APIENTRYP PFNGLGETINTEGERVPROC)(GLenum pname, GLint *data);
+GLAPI PFNGLGETINTEGERVPROC glad_glGetIntegerv;
+#define glGetIntegerv glad_glGetIntegerv
+typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGPROC)(GLenum name);
+GLAPI PFNGLGETSTRINGPROC glad_glGetString;
+#define glGetString glad_glGetString
+typedef void (APIENTRYP PFNGLGETTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, void *pixels);
+GLAPI PFNGLGETTEXIMAGEPROC glad_glGetTexImage;
+#define glGetTexImage glad_glGetTexImage
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERFVPROC)(GLenum target, GLenum pname, GLfloat *params);
+GLAPI PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv;
+#define glGetTexParameterfv glad_glGetTexParameterfv
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params);
+GLAPI PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv;
+#define glGetTexParameteriv glad_glGetTexParameteriv
+typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC)(GLenum target, GLint level, GLenum pname, GLfloat *params);
+GLAPI PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv;
+#define glGetTexLevelParameterfv glad_glGetTexLevelParameterfv
+typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC)(GLenum target, GLint level, GLenum pname, GLint *params);
+GLAPI PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv;
+#define glGetTexLevelParameteriv glad_glGetTexLevelParameteriv
+typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC)(GLenum cap);
+GLAPI PFNGLISENABLEDPROC glad_glIsEnabled;
+#define glIsEnabled glad_glIsEnabled
+typedef void (APIENTRYP PFNGLDEPTHRANGEPROC)(GLdouble n, GLdouble f);
+GLAPI PFNGLDEPTHRANGEPROC glad_glDepthRange;
+#define glDepthRange glad_glDepthRange
+typedef void (APIENTRYP PFNGLVIEWPORTPROC)(GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI PFNGLVIEWPORTPROC glad_glViewport;
+#define glViewport glad_glViewport
+#endif
+#ifndef GL_VERSION_1_1
+#define GL_VERSION_1_1 1
+GLAPI int GLAD_GL_VERSION_1_1;
+typedef void (APIENTRYP PFNGLDRAWARRAYSPROC)(GLenum mode, GLint first, GLsizei count);
+GLAPI PFNGLDRAWARRAYSPROC glad_glDrawArrays;
+#define glDrawArrays glad_glDrawArrays
+typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices);
+GLAPI PFNGLDRAWELEMENTSPROC glad_glDrawElements;
+#define glDrawElements glad_glDrawElements
+typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC)(GLfloat factor, GLfloat units);
+GLAPI PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset;
+#define glPolygonOffset glad_glPolygonOffset
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+GLAPI PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D;
+#define glCopyTexImage1D glad_glCopyTexImage1D
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+GLAPI PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D;
+#define glCopyTexImage2D glad_glCopyTexImage2D
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D;
+#define glCopyTexSubImage1D glad_glCopyTexSubImage1D
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D;
+#define glCopyTexSubImage2D glad_glCopyTexSubImage2D
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D;
+#define glTexSubImage1D glad_glTexSubImage1D
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D;
+#define glTexSubImage2D glad_glTexSubImage2D
+typedef void (APIENTRYP PFNGLBINDTEXTUREPROC)(GLenum target, GLuint texture);
+GLAPI PFNGLBINDTEXTUREPROC glad_glBindTexture;
+#define glBindTexture glad_glBindTexture
+typedef void (APIENTRYP PFNGLDELETETEXTURESPROC)(GLsizei n, const GLuint *textures);
+GLAPI PFNGLDELETETEXTURESPROC glad_glDeleteTextures;
+#define glDeleteTextures glad_glDeleteTextures
+typedef void (APIENTRYP PFNGLGENTEXTURESPROC)(GLsizei n, GLuint *textures);
+GLAPI PFNGLGENTEXTURESPROC glad_glGenTextures;
+#define glGenTextures glad_glGenTextures
+typedef GLboolean (APIENTRYP PFNGLISTEXTUREPROC)(GLuint texture);
+GLAPI PFNGLISTEXTUREPROC glad_glIsTexture;
+#define glIsTexture glad_glIsTexture
+#endif
+#ifndef GL_VERSION_1_2
+#define GL_VERSION_1_2 1
+GLAPI int GLAD_GL_VERSION_1_2;
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices);
+GLAPI PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements;
+#define glDrawRangeElements glad_glDrawRangeElements
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXIMAGE3DPROC glad_glTexImage3D;
+#define glTexImage3D glad_glTexImage3D
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D;
+#define glTexSubImage3D glad_glTexSubImage3D
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D;
+#define glCopyTexSubImage3D glad_glCopyTexSubImage3D
+#endif
+#ifndef GL_VERSION_1_3
+#define GL_VERSION_1_3 1
+GLAPI int GLAD_GL_VERSION_1_3;
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC)(GLenum texture);
+GLAPI PFNGLACTIVETEXTUREPROC glad_glActiveTexture;
+#define glActiveTexture glad_glActiveTexture
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC)(GLfloat value, GLboolean invert);
+GLAPI PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage;
+#define glSampleCoverage glad_glSampleCoverage
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D;
+#define glCompressedTexImage3D glad_glCompressedTexImage3D
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D;
+#define glCompressedTexImage2D glad_glCompressedTexImage2D
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D;
+#define glCompressedTexImage1D glad_glCompressedTexImage1D
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D;
+#define glCompressedTexSubImage3D glad_glCompressedTexSubImage3D
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D;
+#define glCompressedTexSubImage2D glad_glCompressedTexSubImage2D
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D;
+#define glCompressedTexSubImage1D glad_glCompressedTexSubImage1D
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint level, void *img);
+GLAPI PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage;
+#define glGetCompressedTexImage glad_glGetCompressedTexImage
+#endif
+#ifndef GL_VERSION_1_4
+#define GL_VERSION_1_4 1
+GLAPI int GLAD_GL_VERSION_1_4;
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+GLAPI PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate;
+#define glBlendFuncSeparate glad_glBlendFuncSeparate
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC)(GLenum mode, const GLint *first, const GLsizei *count, GLsizei drawcount);
+GLAPI PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays;
+#define glMultiDrawArrays glad_glMultiDrawArrays
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC)(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount);
+GLAPI PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements;
+#define glMultiDrawElements glad_glMultiDrawElements
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC)(GLenum pname, GLfloat param);
+GLAPI PFNGLPOINTPARAMETERFPROC glad_glPointParameterf;
+#define glPointParameterf glad_glPointParameterf
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC)(GLenum pname, const GLfloat *params);
+GLAPI PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv;
+#define glPointParameterfv glad_glPointParameterfv
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC)(GLenum pname, GLint param);
+GLAPI PFNGLPOINTPARAMETERIPROC glad_glPointParameteri;
+#define glPointParameteri glad_glPointParameteri
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC)(GLenum pname, const GLint *params);
+GLAPI PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv;
+#define glPointParameteriv glad_glPointParameteriv
+typedef void (APIENTRYP PFNGLBLENDCOLORPROC)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+GLAPI PFNGLBLENDCOLORPROC glad_glBlendColor;
+#define glBlendColor glad_glBlendColor
+typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC)(GLenum mode);
+GLAPI PFNGLBLENDEQUATIONPROC glad_glBlendEquation;
+#define glBlendEquation glad_glBlendEquation
+#endif
+#ifndef GL_VERSION_1_5
+#define GL_VERSION_1_5 1
+GLAPI int GLAD_GL_VERSION_1_5;
+typedef void (APIENTRYP PFNGLGENQUERIESPROC)(GLsizei n, GLuint *ids);
+GLAPI PFNGLGENQUERIESPROC glad_glGenQueries;
+#define glGenQueries glad_glGenQueries
+typedef void (APIENTRYP PFNGLDELETEQUERIESPROC)(GLsizei n, const GLuint *ids);
+GLAPI PFNGLDELETEQUERIESPROC glad_glDeleteQueries;
+#define glDeleteQueries glad_glDeleteQueries
+typedef GLboolean (APIENTRYP PFNGLISQUERYPROC)(GLuint id);
+GLAPI PFNGLISQUERYPROC glad_glIsQuery;
+#define glIsQuery glad_glIsQuery
+typedef void (APIENTRYP PFNGLBEGINQUERYPROC)(GLenum target, GLuint id);
+GLAPI PFNGLBEGINQUERYPROC glad_glBeginQuery;
+#define glBeginQuery glad_glBeginQuery
+typedef void (APIENTRYP PFNGLENDQUERYPROC)(GLenum target);
+GLAPI PFNGLENDQUERYPROC glad_glEndQuery;
+#define glEndQuery glad_glEndQuery
+typedef void (APIENTRYP PFNGLGETQUERYIVPROC)(GLenum target, GLenum pname, GLint *params);
+GLAPI PFNGLGETQUERYIVPROC glad_glGetQueryiv;
+#define glGetQueryiv glad_glGetQueryiv
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC)(GLuint id, GLenum pname, GLint *params);
+GLAPI PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv;
+#define glGetQueryObjectiv glad_glGetQueryObjectiv
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC)(GLuint id, GLenum pname, GLuint *params);
+GLAPI PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv;
+#define glGetQueryObjectuiv glad_glGetQueryObjectuiv
+typedef void (APIENTRYP PFNGLBINDBUFFERPROC)(GLenum target, GLuint buffer);
+GLAPI PFNGLBINDBUFFERPROC glad_glBindBuffer;
+#define glBindBuffer glad_glBindBuffer
+typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC)(GLsizei n, const GLuint *buffers);
+GLAPI PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers;
+#define glDeleteBuffers glad_glDeleteBuffers
+typedef void (APIENTRYP PFNGLGENBUFFERSPROC)(GLsizei n, GLuint *buffers);
+GLAPI PFNGLGENBUFFERSPROC glad_glGenBuffers;
+#define glGenBuffers glad_glGenBuffers
+typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC)(GLuint buffer);
+GLAPI PFNGLISBUFFERPROC glad_glIsBuffer;
+#define glIsBuffer glad_glIsBuffer
+typedef void (APIENTRYP PFNGLBUFFERDATAPROC)(GLenum target, GLsizeiptr size, const void *data, GLenum usage);
+GLAPI PFNGLBUFFERDATAPROC glad_glBufferData;
+#define glBufferData glad_glBufferData
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, const void *data);
+GLAPI PFNGLBUFFERSUBDATAPROC glad_glBufferSubData;
+#define glBufferSubData glad_glBufferSubData
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC)(GLenum target, GLintptr offset, GLsizeiptr size, void *data);
+GLAPI PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData;
+#define glGetBufferSubData glad_glGetBufferSubData
+typedef void * (APIENTRYP PFNGLMAPBUFFERPROC)(GLenum target, GLenum access);
+GLAPI PFNGLMAPBUFFERPROC glad_glMapBuffer;
+#define glMapBuffer glad_glMapBuffer
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC)(GLenum target);
+GLAPI PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer;
+#define glUnmapBuffer glad_glUnmapBuffer
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params);
+GLAPI PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv;
+#define glGetBufferParameteriv glad_glGetBufferParameteriv
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC)(GLenum target, GLenum pname, void **params);
+GLAPI PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv;
+#define glGetBufferPointerv glad_glGetBufferPointerv
+#endif
+#ifndef GL_VERSION_2_0
+#define GL_VERSION_2_0 1
+GLAPI int GLAD_GL_VERSION_2_0;
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC)(GLenum modeRGB, GLenum modeAlpha);
+GLAPI PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate;
+#define glBlendEquationSeparate glad_glBlendEquationSeparate
+typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC)(GLsizei n, const GLenum *bufs);
+GLAPI PFNGLDRAWBUFFERSPROC glad_glDrawBuffers;
+#define glDrawBuffers glad_glDrawBuffers
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC)(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+GLAPI PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate;
+#define glStencilOpSeparate glad_glStencilOpSeparate
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC)(GLenum face, GLenum func, GLint ref, GLuint mask);
+GLAPI PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate;
+#define glStencilFuncSeparate glad_glStencilFuncSeparate
+typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC)(GLenum face, GLuint mask);
+GLAPI PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate;
+#define glStencilMaskSeparate glad_glStencilMaskSeparate
+typedef void (APIENTRYP PFNGLATTACHSHADERPROC)(GLuint program, GLuint shader);
+GLAPI PFNGLATTACHSHADERPROC glad_glAttachShader;
+#define glAttachShader glad_glAttachShader
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC)(GLuint program, GLuint index, const GLchar *name);
+GLAPI PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation;
+#define glBindAttribLocation glad_glBindAttribLocation
+typedef void (APIENTRYP PFNGLCOMPILESHADERPROC)(GLuint shader);
+GLAPI PFNGLCOMPILESHADERPROC glad_glCompileShader;
+#define glCompileShader glad_glCompileShader
+typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC)(void);
+GLAPI PFNGLCREATEPROGRAMPROC glad_glCreateProgram;
+#define glCreateProgram glad_glCreateProgram
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC)(GLenum type);
+GLAPI PFNGLCREATESHADERPROC glad_glCreateShader;
+#define glCreateShader glad_glCreateShader
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC)(GLuint program);
+GLAPI PFNGLDELETEPROGRAMPROC glad_glDeleteProgram;
+#define glDeleteProgram glad_glDeleteProgram
+typedef void (APIENTRYP PFNGLDELETESHADERPROC)(GLuint shader);
+GLAPI PFNGLDELETESHADERPROC glad_glDeleteShader;
+#define glDeleteShader glad_glDeleteShader
+typedef void (APIENTRYP PFNGLDETACHSHADERPROC)(GLuint program, GLuint shader);
+GLAPI PFNGLDETACHSHADERPROC glad_glDetachShader;
+#define glDetachShader glad_glDetachShader
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+GLAPI PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray;
+#define glDisableVertexAttribArray glad_glDisableVertexAttribArray
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC)(GLuint index);
+GLAPI PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray;
+#define glEnableVertexAttribArray glad_glEnableVertexAttribArray
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GLAPI PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib;
+#define glGetActiveAttrib glad_glGetActiveAttrib
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+GLAPI PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform;
+#define glGetActiveUniform glad_glGetActiveUniform
+typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC)(GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders);
+GLAPI PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders;
+#define glGetAttachedShaders glad_glGetAttachedShaders
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC)(GLuint program, const GLchar *name);
+GLAPI PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation;
+#define glGetAttribLocation glad_glGetAttribLocation
+typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC)(GLuint program, GLenum pname, GLint *params);
+GLAPI PFNGLGETPROGRAMIVPROC glad_glGetProgramiv;
+#define glGetProgramiv glad_glGetProgramiv
+typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC)(GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GLAPI PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog;
+#define glGetProgramInfoLog glad_glGetProgramInfoLog
+typedef void (APIENTRYP PFNGLGETSHADERIVPROC)(GLuint shader, GLenum pname, GLint *params);
+GLAPI PFNGLGETSHADERIVPROC glad_glGetShaderiv;
+#define glGetShaderiv glad_glGetShaderiv
+typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GLAPI PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog;
+#define glGetShaderInfoLog glad_glGetShaderInfoLog
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC)(GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+GLAPI PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource;
+#define glGetShaderSource glad_glGetShaderSource
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC)(GLuint program, const GLchar *name);
+GLAPI PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation;
+#define glGetUniformLocation glad_glGetUniformLocation
+typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC)(GLuint program, GLint location, GLfloat *params);
+GLAPI PFNGLGETUNIFORMFVPROC glad_glGetUniformfv;
+#define glGetUniformfv glad_glGetUniformfv
+typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC)(GLuint program, GLint location, GLint *params);
+GLAPI PFNGLGETUNIFORMIVPROC glad_glGetUniformiv;
+#define glGetUniformiv glad_glGetUniformiv
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC)(GLuint index, GLenum pname, GLdouble *params);
+GLAPI PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv;
+#define glGetVertexAttribdv glad_glGetVertexAttribdv
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC)(GLuint index, GLenum pname, GLfloat *params);
+GLAPI PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv;
+#define glGetVertexAttribfv glad_glGetVertexAttribfv
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC)(GLuint index, GLenum pname, GLint *params);
+GLAPI PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv;
+#define glGetVertexAttribiv glad_glGetVertexAttribiv
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC)(GLuint index, GLenum pname, void **pointer);
+GLAPI PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv;
+#define glGetVertexAttribPointerv glad_glGetVertexAttribPointerv
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC)(GLuint program);
+GLAPI PFNGLISPROGRAMPROC glad_glIsProgram;
+#define glIsProgram glad_glIsProgram
+typedef GLboolean (APIENTRYP PFNGLISSHADERPROC)(GLuint shader);
+GLAPI PFNGLISSHADERPROC glad_glIsShader;
+#define glIsShader glad_glIsShader
+typedef void (APIENTRYP PFNGLLINKPROGRAMPROC)(GLuint program);
+GLAPI PFNGLLINKPROGRAMPROC glad_glLinkProgram;
+#define glLinkProgram glad_glLinkProgram
+typedef void (APIENTRYP PFNGLSHADERSOURCEPROC)(GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length);
+GLAPI PFNGLSHADERSOURCEPROC glad_glShaderSource;
+#define glShaderSource glad_glShaderSource
+typedef void (APIENTRYP PFNGLUSEPROGRAMPROC)(GLuint program);
+GLAPI PFNGLUSEPROGRAMPROC glad_glUseProgram;
+#define glUseProgram glad_glUseProgram
+typedef void (APIENTRYP PFNGLUNIFORM1FPROC)(GLint location, GLfloat v0);
+GLAPI PFNGLUNIFORM1FPROC glad_glUniform1f;
+#define glUniform1f glad_glUniform1f
+typedef void (APIENTRYP PFNGLUNIFORM2FPROC)(GLint location, GLfloat v0, GLfloat v1);
+GLAPI PFNGLUNIFORM2FPROC glad_glUniform2f;
+#define glUniform2f glad_glUniform2f
+typedef void (APIENTRYP PFNGLUNIFORM3FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI PFNGLUNIFORM3FPROC glad_glUniform3f;
+#define glUniform3f glad_glUniform3f
+typedef void (APIENTRYP PFNGLUNIFORM4FPROC)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI PFNGLUNIFORM4FPROC glad_glUniform4f;
+#define glUniform4f glad_glUniform4f
+typedef void (APIENTRYP PFNGLUNIFORM1IPROC)(GLint location, GLint v0);
+GLAPI PFNGLUNIFORM1IPROC glad_glUniform1i;
+#define glUniform1i glad_glUniform1i
+typedef void (APIENTRYP PFNGLUNIFORM2IPROC)(GLint location, GLint v0, GLint v1);
+GLAPI PFNGLUNIFORM2IPROC glad_glUniform2i;
+#define glUniform2i glad_glUniform2i
+typedef void (APIENTRYP PFNGLUNIFORM3IPROC)(GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI PFNGLUNIFORM3IPROC glad_glUniform3i;
+#define glUniform3i glad_glUniform3i
+typedef void (APIENTRYP PFNGLUNIFORM4IPROC)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI PFNGLUNIFORM4IPROC glad_glUniform4i;
+#define glUniform4i glad_glUniform4i
+typedef void (APIENTRYP PFNGLUNIFORM1FVPROC)(GLint location, GLsizei count, const GLfloat *value);
+GLAPI PFNGLUNIFORM1FVPROC glad_glUniform1fv;
+#define glUniform1fv glad_glUniform1fv
+typedef void (APIENTRYP PFNGLUNIFORM2FVPROC)(GLint location, GLsizei count, const GLfloat *value);
+GLAPI PFNGLUNIFORM2FVPROC glad_glUniform2fv;
+#define glUniform2fv glad_glUniform2fv
+typedef void (APIENTRYP PFNGLUNIFORM3FVPROC)(GLint location, GLsizei count, const GLfloat *value);
+GLAPI PFNGLUNIFORM3FVPROC glad_glUniform3fv;
+#define glUniform3fv glad_glUniform3fv
+typedef void (APIENTRYP PFNGLUNIFORM4FVPROC)(GLint location, GLsizei count, const GLfloat *value);
+GLAPI PFNGLUNIFORM4FVPROC glad_glUniform4fv;
+#define glUniform4fv glad_glUniform4fv
+typedef void (APIENTRYP PFNGLUNIFORM1IVPROC)(GLint location, GLsizei count, const GLint *value);
+GLAPI PFNGLUNIFORM1IVPROC glad_glUniform1iv;
+#define glUniform1iv glad_glUniform1iv
+typedef void (APIENTRYP PFNGLUNIFORM2IVPROC)(GLint location, GLsizei count, const GLint *value);
+GLAPI PFNGLUNIFORM2IVPROC glad_glUniform2iv;
+#define glUniform2iv glad_glUniform2iv
+typedef void (APIENTRYP PFNGLUNIFORM3IVPROC)(GLint location, GLsizei count, const GLint *value);
+GLAPI PFNGLUNIFORM3IVPROC glad_glUniform3iv;
+#define glUniform3iv glad_glUniform3iv
+typedef void (APIENTRYP PFNGLUNIFORM4IVPROC)(GLint location, GLsizei count, const GLint *value);
+GLAPI PFNGLUNIFORM4IVPROC glad_glUniform4iv;
+#define glUniform4iv glad_glUniform4iv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv;
+#define glUniformMatrix2fv glad_glUniformMatrix2fv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv;
+#define glUniformMatrix3fv glad_glUniformMatrix3fv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv;
+#define glUniformMatrix4fv glad_glUniformMatrix4fv
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC)(GLuint program);
+GLAPI PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram;
+#define glValidateProgram glad_glValidateProgram
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC)(GLuint index, GLdouble x);
+GLAPI PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d;
+#define glVertexAttrib1d glad_glVertexAttrib1d
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC)(GLuint index, const GLdouble *v);
+GLAPI PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv;
+#define glVertexAttrib1dv glad_glVertexAttrib1dv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC)(GLuint index, GLfloat x);
+GLAPI PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f;
+#define glVertexAttrib1f glad_glVertexAttrib1f
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC)(GLuint index, const GLfloat *v);
+GLAPI PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv;
+#define glVertexAttrib1fv glad_glVertexAttrib1fv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC)(GLuint index, GLshort x);
+GLAPI PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s;
+#define glVertexAttrib1s glad_glVertexAttrib1s
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC)(GLuint index, const GLshort *v);
+GLAPI PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv;
+#define glVertexAttrib1sv glad_glVertexAttrib1sv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC)(GLuint index, GLdouble x, GLdouble y);
+GLAPI PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d;
+#define glVertexAttrib2d glad_glVertexAttrib2d
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC)(GLuint index, const GLdouble *v);
+GLAPI PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv;
+#define glVertexAttrib2dv glad_glVertexAttrib2dv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC)(GLuint index, GLfloat x, GLfloat y);
+GLAPI PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f;
+#define glVertexAttrib2f glad_glVertexAttrib2f
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC)(GLuint index, const GLfloat *v);
+GLAPI PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv;
+#define glVertexAttrib2fv glad_glVertexAttrib2fv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC)(GLuint index, GLshort x, GLshort y);
+GLAPI PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s;
+#define glVertexAttrib2s glad_glVertexAttrib2s
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC)(GLuint index, const GLshort *v);
+GLAPI PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv;
+#define glVertexAttrib2sv glad_glVertexAttrib2sv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d;
+#define glVertexAttrib3d glad_glVertexAttrib3d
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC)(GLuint index, const GLdouble *v);
+GLAPI PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv;
+#define glVertexAttrib3dv glad_glVertexAttrib3dv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+GLAPI PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f;
+#define glVertexAttrib3f glad_glVertexAttrib3f
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC)(GLuint index, const GLfloat *v);
+GLAPI PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv;
+#define glVertexAttrib3fv glad_glVertexAttrib3fv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC)(GLuint index, GLshort x, GLshort y, GLshort z);
+GLAPI PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s;
+#define glVertexAttrib3s glad_glVertexAttrib3s
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC)(GLuint index, const GLshort *v);
+GLAPI PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv;
+#define glVertexAttrib3sv glad_glVertexAttrib3sv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC)(GLuint index, const GLbyte *v);
+GLAPI PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv;
+#define glVertexAttrib4Nbv glad_glVertexAttrib4Nbv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC)(GLuint index, const GLint *v);
+GLAPI PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv;
+#define glVertexAttrib4Niv glad_glVertexAttrib4Niv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC)(GLuint index, const GLshort *v);
+GLAPI PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv;
+#define glVertexAttrib4Nsv glad_glVertexAttrib4Nsv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+GLAPI PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub;
+#define glVertexAttrib4Nub glad_glVertexAttrib4Nub
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC)(GLuint index, const GLubyte *v);
+GLAPI PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv;
+#define glVertexAttrib4Nubv glad_glVertexAttrib4Nubv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC)(GLuint index, const GLuint *v);
+GLAPI PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv;
+#define glVertexAttrib4Nuiv glad_glVertexAttrib4Nuiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC)(GLuint index, const GLushort *v);
+GLAPI PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv;
+#define glVertexAttrib4Nusv glad_glVertexAttrib4Nusv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC)(GLuint index, const GLbyte *v);
+GLAPI PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv;
+#define glVertexAttrib4bv glad_glVertexAttrib4bv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d;
+#define glVertexAttrib4d glad_glVertexAttrib4d
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC)(GLuint index, const GLdouble *v);
+GLAPI PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv;
+#define glVertexAttrib4dv glad_glVertexAttrib4dv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+GLAPI PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f;
+#define glVertexAttrib4f glad_glVertexAttrib4f
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC)(GLuint index, const GLfloat *v);
+GLAPI PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv;
+#define glVertexAttrib4fv glad_glVertexAttrib4fv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC)(GLuint index, const GLint *v);
+GLAPI PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv;
+#define glVertexAttrib4iv glad_glVertexAttrib4iv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+GLAPI PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s;
+#define glVertexAttrib4s glad_glVertexAttrib4s
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC)(GLuint index, const GLshort *v);
+GLAPI PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv;
+#define glVertexAttrib4sv glad_glVertexAttrib4sv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC)(GLuint index, const GLubyte *v);
+GLAPI PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv;
+#define glVertexAttrib4ubv glad_glVertexAttrib4ubv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC)(GLuint index, const GLuint *v);
+GLAPI PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv;
+#define glVertexAttrib4uiv glad_glVertexAttrib4uiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC)(GLuint index, const GLushort *v);
+GLAPI PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv;
+#define glVertexAttrib4usv glad_glVertexAttrib4usv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer);
+GLAPI PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer;
+#define glVertexAttribPointer glad_glVertexAttribPointer
+#endif
+#ifndef GL_VERSION_2_1
+#define GL_VERSION_2_1 1
+GLAPI int GLAD_GL_VERSION_2_1;
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv;
+#define glUniformMatrix2x3fv glad_glUniformMatrix2x3fv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv;
+#define glUniformMatrix3x2fv glad_glUniformMatrix3x2fv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv;
+#define glUniformMatrix2x4fv glad_glUniformMatrix2x4fv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv;
+#define glUniformMatrix4x2fv glad_glUniformMatrix4x2fv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv;
+#define glUniformMatrix3x4fv glad_glUniformMatrix3x4fv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv;
+#define glUniformMatrix4x3fv glad_glUniformMatrix4x3fv
+#endif
+#ifndef GL_VERSION_3_0
+#define GL_VERSION_3_0 1
+GLAPI int GLAD_GL_VERSION_3_0;
+typedef void (APIENTRYP PFNGLCOLORMASKIPROC)(GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+GLAPI PFNGLCOLORMASKIPROC glad_glColorMaski;
+#define glColorMaski glad_glColorMaski
+typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC)(GLenum target, GLuint index, GLboolean *data);
+GLAPI PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v;
+#define glGetBooleani_v glad_glGetBooleani_v
+typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC)(GLenum target, GLuint index, GLint *data);
+GLAPI PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v;
+#define glGetIntegeri_v glad_glGetIntegeri_v
+typedef void (APIENTRYP PFNGLENABLEIPROC)(GLenum target, GLuint index);
+GLAPI PFNGLENABLEIPROC glad_glEnablei;
+#define glEnablei glad_glEnablei
+typedef void (APIENTRYP PFNGLDISABLEIPROC)(GLenum target, GLuint index);
+GLAPI PFNGLDISABLEIPROC glad_glDisablei;
+#define glDisablei glad_glDisablei
+typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC)(GLenum target, GLuint index);
+GLAPI PFNGLISENABLEDIPROC glad_glIsEnabledi;
+#define glIsEnabledi glad_glIsEnabledi
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC)(GLenum primitiveMode);
+GLAPI PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback;
+#define glBeginTransformFeedback glad_glBeginTransformFeedback
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC)(void);
+GLAPI PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback;
+#define glEndTransformFeedback glad_glEndTransformFeedback
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC)(GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange;
+#define glBindBufferRange glad_glBindBufferRange
+typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC)(GLenum target, GLuint index, GLuint buffer);
+GLAPI PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase;
+#define glBindBufferBase glad_glBindBufferBase
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC)(GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode);
+GLAPI PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings;
+#define glTransformFeedbackVaryings glad_glTransformFeedbackVaryings
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+GLAPI PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying;
+#define glGetTransformFeedbackVarying glad_glGetTransformFeedbackVarying
+typedef void (APIENTRYP PFNGLCLAMPCOLORPROC)(GLenum target, GLenum clamp);
+GLAPI PFNGLCLAMPCOLORPROC glad_glClampColor;
+#define glClampColor glad_glClampColor
+typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC)(GLuint id, GLenum mode);
+GLAPI PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender;
+#define glBeginConditionalRender glad_glBeginConditionalRender
+typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC)(void);
+GLAPI PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender;
+#define glEndConditionalRender glad_glEndConditionalRender
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);
+GLAPI PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer;
+#define glVertexAttribIPointer glad_glVertexAttribIPointer
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC)(GLuint index, GLenum pname, GLint *params);
+GLAPI PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv;
+#define glGetVertexAttribIiv glad_glGetVertexAttribIiv
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC)(GLuint index, GLenum pname, GLuint *params);
+GLAPI PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv;
+#define glGetVertexAttribIuiv glad_glGetVertexAttribIuiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC)(GLuint index, GLint x);
+GLAPI PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i;
+#define glVertexAttribI1i glad_glVertexAttribI1i
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC)(GLuint index, GLint x, GLint y);
+GLAPI PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i;
+#define glVertexAttribI2i glad_glVertexAttribI2i
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC)(GLuint index, GLint x, GLint y, GLint z);
+GLAPI PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i;
+#define glVertexAttribI3i glad_glVertexAttribI3i
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC)(GLuint index, GLint x, GLint y, GLint z, GLint w);
+GLAPI PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i;
+#define glVertexAttribI4i glad_glVertexAttribI4i
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC)(GLuint index, GLuint x);
+GLAPI PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui;
+#define glVertexAttribI1ui glad_glVertexAttribI1ui
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC)(GLuint index, GLuint x, GLuint y);
+GLAPI PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui;
+#define glVertexAttribI2ui glad_glVertexAttribI2ui
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z);
+GLAPI PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui;
+#define glVertexAttribI3ui glad_glVertexAttribI3ui
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+GLAPI PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui;
+#define glVertexAttribI4ui glad_glVertexAttribI4ui
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC)(GLuint index, const GLint *v);
+GLAPI PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv;
+#define glVertexAttribI1iv glad_glVertexAttribI1iv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC)(GLuint index, const GLint *v);
+GLAPI PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv;
+#define glVertexAttribI2iv glad_glVertexAttribI2iv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC)(GLuint index, const GLint *v);
+GLAPI PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv;
+#define glVertexAttribI3iv glad_glVertexAttribI3iv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC)(GLuint index, const GLint *v);
+GLAPI PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv;
+#define glVertexAttribI4iv glad_glVertexAttribI4iv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC)(GLuint index, const GLuint *v);
+GLAPI PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv;
+#define glVertexAttribI1uiv glad_glVertexAttribI1uiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC)(GLuint index, const GLuint *v);
+GLAPI PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv;
+#define glVertexAttribI2uiv glad_glVertexAttribI2uiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC)(GLuint index, const GLuint *v);
+GLAPI PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv;
+#define glVertexAttribI3uiv glad_glVertexAttribI3uiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC)(GLuint index, const GLuint *v);
+GLAPI PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv;
+#define glVertexAttribI4uiv glad_glVertexAttribI4uiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC)(GLuint index, const GLbyte *v);
+GLAPI PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv;
+#define glVertexAttribI4bv glad_glVertexAttribI4bv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC)(GLuint index, const GLshort *v);
+GLAPI PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv;
+#define glVertexAttribI4sv glad_glVertexAttribI4sv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC)(GLuint index, const GLubyte *v);
+GLAPI PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv;
+#define glVertexAttribI4ubv glad_glVertexAttribI4ubv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC)(GLuint index, const GLushort *v);
+GLAPI PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv;
+#define glVertexAttribI4usv glad_glVertexAttribI4usv
+typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC)(GLuint program, GLint location, GLuint *params);
+GLAPI PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv;
+#define glGetUniformuiv glad_glGetUniformuiv
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC)(GLuint program, GLuint color, const GLchar *name);
+GLAPI PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation;
+#define glBindFragDataLocation glad_glBindFragDataLocation
+typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC)(GLuint program, const GLchar *name);
+GLAPI PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation;
+#define glGetFragDataLocation glad_glGetFragDataLocation
+typedef void (APIENTRYP PFNGLUNIFORM1UIPROC)(GLint location, GLuint v0);
+GLAPI PFNGLUNIFORM1UIPROC glad_glUniform1ui;
+#define glUniform1ui glad_glUniform1ui
+typedef void (APIENTRYP PFNGLUNIFORM2UIPROC)(GLint location, GLuint v0, GLuint v1);
+GLAPI PFNGLUNIFORM2UIPROC glad_glUniform2ui;
+#define glUniform2ui glad_glUniform2ui
+typedef void (APIENTRYP PFNGLUNIFORM3UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI PFNGLUNIFORM3UIPROC glad_glUniform3ui;
+#define glUniform3ui glad_glUniform3ui
+typedef void (APIENTRYP PFNGLUNIFORM4UIPROC)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI PFNGLUNIFORM4UIPROC glad_glUniform4ui;
+#define glUniform4ui glad_glUniform4ui
+typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC)(GLint location, GLsizei count, const GLuint *value);
+GLAPI PFNGLUNIFORM1UIVPROC glad_glUniform1uiv;
+#define glUniform1uiv glad_glUniform1uiv
+typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC)(GLint location, GLsizei count, const GLuint *value);
+GLAPI PFNGLUNIFORM2UIVPROC glad_glUniform2uiv;
+#define glUniform2uiv glad_glUniform2uiv
+typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC)(GLint location, GLsizei count, const GLuint *value);
+GLAPI PFNGLUNIFORM3UIVPROC glad_glUniform3uiv;
+#define glUniform3uiv glad_glUniform3uiv
+typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC)(GLint location, GLsizei count, const GLuint *value);
+GLAPI PFNGLUNIFORM4UIVPROC glad_glUniform4uiv;
+#define glUniform4uiv glad_glUniform4uiv
+typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, const GLint *params);
+GLAPI PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv;
+#define glTexParameterIiv glad_glTexParameterIiv
+typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, const GLuint *params);
+GLAPI PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv;
+#define glTexParameterIuiv glad_glTexParameterIuiv
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC)(GLenum target, GLenum pname, GLint *params);
+GLAPI PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv;
+#define glGetTexParameterIiv glad_glGetTexParameterIiv
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC)(GLenum target, GLenum pname, GLuint *params);
+GLAPI PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv;
+#define glGetTexParameterIuiv glad_glGetTexParameterIuiv
+typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC)(GLenum buffer, GLint drawbuffer, const GLint *value);
+GLAPI PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv;
+#define glClearBufferiv glad_glClearBufferiv
+typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC)(GLenum buffer, GLint drawbuffer, const GLuint *value);
+GLAPI PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv;
+#define glClearBufferuiv glad_glClearBufferuiv
+typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC)(GLenum buffer, GLint drawbuffer, const GLfloat *value);
+GLAPI PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv;
+#define glClearBufferfv glad_glClearBufferfv
+typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC)(GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+GLAPI PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi;
+#define glClearBufferfi glad_glClearBufferfi
+typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC)(GLenum name, GLuint index);
+GLAPI PFNGLGETSTRINGIPROC glad_glGetStringi;
+#define glGetStringi glad_glGetStringi
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC)(GLuint renderbuffer);
+GLAPI PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer;
+#define glIsRenderbuffer glad_glIsRenderbuffer
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC)(GLenum target, GLuint renderbuffer);
+GLAPI PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer;
+#define glBindRenderbuffer glad_glBindRenderbuffer
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC)(GLsizei n, const GLuint *renderbuffers);
+GLAPI PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers;
+#define glDeleteRenderbuffers glad_glDeleteRenderbuffers
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers);
+GLAPI PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers;
+#define glGenRenderbuffers glad_glGenRenderbuffers
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage;
+#define glRenderbufferStorage glad_glRenderbufferStorage
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params);
+GLAPI PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv;
+#define glGetRenderbufferParameteriv glad_glGetRenderbufferParameteriv
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC)(GLuint framebuffer);
+GLAPI PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer;
+#define glIsFramebuffer glad_glIsFramebuffer
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC)(GLenum target, GLuint framebuffer);
+GLAPI PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer;
+#define glBindFramebuffer glad_glBindFramebuffer
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC)(GLsizei n, const GLuint *framebuffers);
+GLAPI PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers;
+#define glDeleteFramebuffers glad_glDeleteFramebuffers
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers);
+GLAPI PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers;
+#define glGenFramebuffers glad_glGenFramebuffers
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC)(GLenum target);
+GLAPI PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus;
+#define glCheckFramebufferStatus glad_glCheckFramebufferStatus
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D;
+#define glFramebufferTexture1D glad_glFramebufferTexture1D
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+GLAPI PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D;
+#define glFramebufferTexture2D glad_glFramebufferTexture2D
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+GLAPI PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D;
+#define glFramebufferTexture3D glad_glFramebufferTexture3D
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GLAPI PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer;
+#define glFramebufferRenderbuffer glad_glFramebufferRenderbuffer
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLenum target, GLenum attachment, GLenum pname, GLint *params);
+GLAPI PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv;
+#define glGetFramebufferAttachmentParameteriv glad_glGetFramebufferAttachmentParameteriv
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC)(GLenum target);
+GLAPI PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap;
+#define glGenerateMipmap glad_glGenerateMipmap
+typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+GLAPI PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer;
+#define glBlitFramebuffer glad_glBlitFramebuffer
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample;
+#define glRenderbufferStorageMultisample glad_glRenderbufferStorageMultisample
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GLAPI PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer;
+#define glFramebufferTextureLayer glad_glFramebufferTextureLayer
+typedef void * (APIENTRYP PFNGLMAPBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GLAPI PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange;
+#define glMapBufferRange glad_glMapBufferRange
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC)(GLenum target, GLintptr offset, GLsizeiptr length);
+GLAPI PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange;
+#define glFlushMappedBufferRange glad_glFlushMappedBufferRange
+typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC)(GLuint array);
+GLAPI PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray;
+#define glBindVertexArray glad_glBindVertexArray
+typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC)(GLsizei n, const GLuint *arrays);
+GLAPI PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays;
+#define glDeleteVertexArrays glad_glDeleteVertexArrays
+typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC)(GLsizei n, GLuint *arrays);
+GLAPI PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays;
+#define glGenVertexArrays glad_glGenVertexArrays
+typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC)(GLuint array);
+GLAPI PFNGLISVERTEXARRAYPROC glad_glIsVertexArray;
+#define glIsVertexArray glad_glIsVertexArray
+#endif
+#ifndef GL_VERSION_3_1
+#define GL_VERSION_3_1 1
+GLAPI int GLAD_GL_VERSION_3_1;
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount);
+GLAPI PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced;
+#define glDrawArraysInstanced glad_glDrawArraysInstanced
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount);
+GLAPI PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced;
+#define glDrawElementsInstanced glad_glDrawElementsInstanced
+typedef void (APIENTRYP PFNGLTEXBUFFERPROC)(GLenum target, GLenum internalformat, GLuint buffer);
+GLAPI PFNGLTEXBUFFERPROC glad_glTexBuffer;
+#define glTexBuffer glad_glTexBuffer
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC)(GLuint index);
+GLAPI PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex;
+#define glPrimitiveRestartIndex glad_glPrimitiveRestartIndex
+typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+GLAPI PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData;
+#define glCopyBufferSubData glad_glCopyBufferSubData
+typedef void (APIENTRYP PFNGLGETUNIFORMINDICESPROC)(GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices);
+GLAPI PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices;
+#define glGetUniformIndices glad_glGetUniformIndices
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC)(GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params);
+GLAPI PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv;
+#define glGetActiveUniformsiv glad_glGetActiveUniformsiv
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMNAMEPROC)(GLuint program, GLuint uniformIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformName);
+GLAPI PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName;
+#define glGetActiveUniformName glad_glGetActiveUniformName
+typedef GLuint (APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC)(GLuint program, const GLchar *uniformBlockName);
+GLAPI PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex;
+#define glGetUniformBlockIndex glad_glGetUniformBlockIndex
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC)(GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params);
+GLAPI PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv;
+#define glGetActiveUniformBlockiv glad_glGetActiveUniformBlockiv
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)(GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName);
+GLAPI PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName;
+#define glGetActiveUniformBlockName glad_glGetActiveUniformBlockName
+typedef void (APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC)(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
+GLAPI PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding;
+#define glUniformBlockBinding glad_glUniformBlockBinding
+#endif
+#ifndef GL_VERSION_3_2
+#define GL_VERSION_3_2 1
+GLAPI int GLAD_GL_VERSION_3_2;
+typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+GLAPI PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex;
+#define glDrawElementsBaseVertex glad_glDrawElementsBaseVertex
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex);
+GLAPI PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex;
+#define glDrawRangeElementsBaseVertex glad_glDrawRangeElementsBaseVertex
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex);
+GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex;
+#define glDrawElementsInstancedBaseVertex glad_glDrawElementsInstancedBaseVertex
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)(GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex);
+GLAPI PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex;
+#define glMultiDrawElementsBaseVertex glad_glMultiDrawElementsBaseVertex
+typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC)(GLenum mode);
+GLAPI PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex;
+#define glProvokingVertex glad_glProvokingVertex
+typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC)(GLenum condition, GLbitfield flags);
+GLAPI PFNGLFENCESYNCPROC glad_glFenceSync;
+#define glFenceSync glad_glFenceSync
+typedef GLboolean (APIENTRYP PFNGLISSYNCPROC)(GLsync sync);
+GLAPI PFNGLISSYNCPROC glad_glIsSync;
+#define glIsSync glad_glIsSync
+typedef void (APIENTRYP PFNGLDELETESYNCPROC)(GLsync sync);
+GLAPI PFNGLDELETESYNCPROC glad_glDeleteSync;
+#define glDeleteSync glad_glDeleteSync
+typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
+GLAPI PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync;
+#define glClientWaitSync glad_glClientWaitSync
+typedef void (APIENTRYP PFNGLWAITSYNCPROC)(GLsync sync, GLbitfield flags, GLuint64 timeout);
+GLAPI PFNGLWAITSYNCPROC glad_glWaitSync;
+#define glWaitSync glad_glWaitSync
+typedef void (APIENTRYP PFNGLGETINTEGER64VPROC)(GLenum pname, GLint64 *data);
+GLAPI PFNGLGETINTEGER64VPROC glad_glGetInteger64v;
+#define glGetInteger64v glad_glGetInteger64v
+typedef void (APIENTRYP PFNGLGETSYNCIVPROC)(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
+GLAPI PFNGLGETSYNCIVPROC glad_glGetSynciv;
+#define glGetSynciv glad_glGetSynciv
+typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC)(GLenum target, GLuint index, GLint64 *data);
+GLAPI PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v;
+#define glGetInteger64i_v glad_glGetInteger64i_v
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC)(GLenum target, GLenum pname, GLint64 *params);
+GLAPI PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v;
+#define glGetBufferParameteri64v glad_glGetBufferParameteri64v
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC)(GLenum target, GLenum attachment, GLuint texture, GLint level);
+GLAPI PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture;
+#define glFramebufferTexture glad_glFramebufferTexture
+typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample;
+#define glTexImage2DMultisample glad_glTexImage2DMultisample
+typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+GLAPI PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample;
+#define glTexImage3DMultisample glad_glTexImage3DMultisample
+typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC)(GLenum pname, GLuint index, GLfloat *val);
+GLAPI PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv;
+#define glGetMultisamplefv glad_glGetMultisamplefv
+typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC)(GLuint maskNumber, GLbitfield mask);
+GLAPI PFNGLSAMPLEMASKIPROC glad_glSampleMaski;
+#define glSampleMaski glad_glSampleMaski
+#endif
+#ifndef GL_VERSION_3_3
+#define GL_VERSION_3_3 1
+GLAPI int GLAD_GL_VERSION_3_3;
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)(GLuint program, GLuint colorNumber, GLuint index, const GLchar *name);
+GLAPI PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed;
+#define glBindFragDataLocationIndexed glad_glBindFragDataLocationIndexed
+typedef GLint (APIENTRYP PFNGLGETFRAGDATAINDEXPROC)(GLuint program, const GLchar *name);
+GLAPI PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex;
+#define glGetFragDataIndex glad_glGetFragDataIndex
+typedef void (APIENTRYP PFNGLGENSAMPLERSPROC)(GLsizei count, GLuint *samplers);
+GLAPI PFNGLGENSAMPLERSPROC glad_glGenSamplers;
+#define glGenSamplers glad_glGenSamplers
+typedef void (APIENTRYP PFNGLDELETESAMPLERSPROC)(GLsizei count, const GLuint *samplers);
+GLAPI PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers;
+#define glDeleteSamplers glad_glDeleteSamplers
+typedef GLboolean (APIENTRYP PFNGLISSAMPLERPROC)(GLuint sampler);
+GLAPI PFNGLISSAMPLERPROC glad_glIsSampler;
+#define glIsSampler glad_glIsSampler
+typedef void (APIENTRYP PFNGLBINDSAMPLERPROC)(GLuint unit, GLuint sampler);
+GLAPI PFNGLBINDSAMPLERPROC glad_glBindSampler;
+#define glBindSampler glad_glBindSampler
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIPROC)(GLuint sampler, GLenum pname, GLint param);
+GLAPI PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri;
+#define glSamplerParameteri glad_glSamplerParameteri
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, const GLint *param);
+GLAPI PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv;
+#define glSamplerParameteriv glad_glSamplerParameteriv
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFPROC)(GLuint sampler, GLenum pname, GLfloat param);
+GLAPI PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf;
+#define glSamplerParameterf glad_glSamplerParameterf
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, const GLfloat *param);
+GLAPI PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv;
+#define glSamplerParameterfv glad_glSamplerParameterfv
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, const GLint *param);
+GLAPI PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv;
+#define glSamplerParameterIiv glad_glSamplerParameterIiv
+typedef void (APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, const GLuint *param);
+GLAPI PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv;
+#define glSamplerParameterIuiv glad_glSamplerParameterIuiv
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC)(GLuint sampler, GLenum pname, GLint *params);
+GLAPI PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv;
+#define glGetSamplerParameteriv glad_glGetSamplerParameteriv
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC)(GLuint sampler, GLenum pname, GLint *params);
+GLAPI PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv;
+#define glGetSamplerParameterIiv glad_glGetSamplerParameterIiv
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC)(GLuint sampler, GLenum pname, GLfloat *params);
+GLAPI PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv;
+#define glGetSamplerParameterfv glad_glGetSamplerParameterfv
+typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC)(GLuint sampler, GLenum pname, GLuint *params);
+GLAPI PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv;
+#define glGetSamplerParameterIuiv glad_glGetSamplerParameterIuiv
+typedef void (APIENTRYP PFNGLQUERYCOUNTERPROC)(GLuint id, GLenum target);
+GLAPI PFNGLQUERYCOUNTERPROC glad_glQueryCounter;
+#define glQueryCounter glad_glQueryCounter
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VPROC)(GLuint id, GLenum pname, GLint64 *params);
+GLAPI PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v;
+#define glGetQueryObjecti64v glad_glGetQueryObjecti64v
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VPROC)(GLuint id, GLenum pname, GLuint64 *params);
+GLAPI PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v;
+#define glGetQueryObjectui64v glad_glGetQueryObjectui64v
+typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC)(GLuint index, GLuint divisor);
+GLAPI PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor;
+#define glVertexAttribDivisor glad_glVertexAttribDivisor
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui;
+#define glVertexAttribP1ui glad_glVertexAttribP1ui
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP1UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv;
+#define glVertexAttribP1uiv glad_glVertexAttribP1uiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui;
+#define glVertexAttribP2ui glad_glVertexAttribP2ui
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP2UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv;
+#define glVertexAttribP2uiv glad_glVertexAttribP2uiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui;
+#define glVertexAttribP3ui glad_glVertexAttribP3ui
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP3UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv;
+#define glVertexAttribP3uiv glad_glVertexAttribP3uiv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIPROC)(GLuint index, GLenum type, GLboolean normalized, GLuint value);
+GLAPI PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui;
+#define glVertexAttribP4ui glad_glVertexAttribP4ui
+typedef void (APIENTRYP PFNGLVERTEXATTRIBP4UIVPROC)(GLuint index, GLenum type, GLboolean normalized, const GLuint *value);
+GLAPI PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv;
+#define glVertexAttribP4uiv glad_glVertexAttribP4uiv
+typedef void (APIENTRYP PFNGLVERTEXP2UIPROC)(GLenum type, GLuint value);
+GLAPI PFNGLVERTEXP2UIPROC glad_glVertexP2ui;
+#define glVertexP2ui glad_glVertexP2ui
+typedef void (APIENTRYP PFNGLVERTEXP2UIVPROC)(GLenum type, const GLuint *value);
+GLAPI PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv;
+#define glVertexP2uiv glad_glVertexP2uiv
+typedef void (APIENTRYP PFNGLVERTEXP3UIPROC)(GLenum type, GLuint value);
+GLAPI PFNGLVERTEXP3UIPROC glad_glVertexP3ui;
+#define glVertexP3ui glad_glVertexP3ui
+typedef void (APIENTRYP PFNGLVERTEXP3UIVPROC)(GLenum type, const GLuint *value);
+GLAPI PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv;
+#define glVertexP3uiv glad_glVertexP3uiv
+typedef void (APIENTRYP PFNGLVERTEXP4UIPROC)(GLenum type, GLuint value);
+GLAPI PFNGLVERTEXP4UIPROC glad_glVertexP4ui;
+#define glVertexP4ui glad_glVertexP4ui
+typedef void (APIENTRYP PFNGLVERTEXP4UIVPROC)(GLenum type, const GLuint *value);
+GLAPI PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv;
+#define glVertexP4uiv glad_glVertexP4uiv
+typedef void (APIENTRYP PFNGLTEXCOORDP1UIPROC)(GLenum type, GLuint coords);
+GLAPI PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui;
+#define glTexCoordP1ui glad_glTexCoordP1ui
+typedef void (APIENTRYP PFNGLTEXCOORDP1UIVPROC)(GLenum type, const GLuint *coords);
+GLAPI PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv;
+#define glTexCoordP1uiv glad_glTexCoordP1uiv
+typedef void (APIENTRYP PFNGLTEXCOORDP2UIPROC)(GLenum type, GLuint coords);
+GLAPI PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui;
+#define glTexCoordP2ui glad_glTexCoordP2ui
+typedef void (APIENTRYP PFNGLTEXCOORDP2UIVPROC)(GLenum type, const GLuint *coords);
+GLAPI PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv;
+#define glTexCoordP2uiv glad_glTexCoordP2uiv
+typedef void (APIENTRYP PFNGLTEXCOORDP3UIPROC)(GLenum type, GLuint coords);
+GLAPI PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui;
+#define glTexCoordP3ui glad_glTexCoordP3ui
+typedef void (APIENTRYP PFNGLTEXCOORDP3UIVPROC)(GLenum type, const GLuint *coords);
+GLAPI PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv;
+#define glTexCoordP3uiv glad_glTexCoordP3uiv
+typedef void (APIENTRYP PFNGLTEXCOORDP4UIPROC)(GLenum type, GLuint coords);
+GLAPI PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui;
+#define glTexCoordP4ui glad_glTexCoordP4ui
+typedef void (APIENTRYP PFNGLTEXCOORDP4UIVPROC)(GLenum type, const GLuint *coords);
+GLAPI PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv;
+#define glTexCoordP4uiv glad_glTexCoordP4uiv
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIPROC)(GLenum texture, GLenum type, GLuint coords);
+GLAPI PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui;
+#define glMultiTexCoordP1ui glad_glMultiTexCoordP1ui
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP1UIVPROC)(GLenum texture, GLenum type, const GLuint *coords);
+GLAPI PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv;
+#define glMultiTexCoordP1uiv glad_glMultiTexCoordP1uiv
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIPROC)(GLenum texture, GLenum type, GLuint coords);
+GLAPI PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui;
+#define glMultiTexCoordP2ui glad_glMultiTexCoordP2ui
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP2UIVPROC)(GLenum texture, GLenum type, const GLuint *coords);
+GLAPI PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv;
+#define glMultiTexCoordP2uiv glad_glMultiTexCoordP2uiv
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIPROC)(GLenum texture, GLenum type, GLuint coords);
+GLAPI PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui;
+#define glMultiTexCoordP3ui glad_glMultiTexCoordP3ui
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP3UIVPROC)(GLenum texture, GLenum type, const GLuint *coords);
+GLAPI PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv;
+#define glMultiTexCoordP3uiv glad_glMultiTexCoordP3uiv
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIPROC)(GLenum texture, GLenum type, GLuint coords);
+GLAPI PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui;
+#define glMultiTexCoordP4ui glad_glMultiTexCoordP4ui
+typedef void (APIENTRYP PFNGLMULTITEXCOORDP4UIVPROC)(GLenum texture, GLenum type, const GLuint *coords);
+GLAPI PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv;
+#define glMultiTexCoordP4uiv glad_glMultiTexCoordP4uiv
+typedef void (APIENTRYP PFNGLNORMALP3UIPROC)(GLenum type, GLuint coords);
+GLAPI PFNGLNORMALP3UIPROC glad_glNormalP3ui;
+#define glNormalP3ui glad_glNormalP3ui
+typedef void (APIENTRYP PFNGLNORMALP3UIVPROC)(GLenum type, const GLuint *coords);
+GLAPI PFNGLNORMALP3UIVPROC glad_glNormalP3uiv;
+#define glNormalP3uiv glad_glNormalP3uiv
+typedef void (APIENTRYP PFNGLCOLORP3UIPROC)(GLenum type, GLuint color);
+GLAPI PFNGLCOLORP3UIPROC glad_glColorP3ui;
+#define glColorP3ui glad_glColorP3ui
+typedef void (APIENTRYP PFNGLCOLORP3UIVPROC)(GLenum type, const GLuint *color);
+GLAPI PFNGLCOLORP3UIVPROC glad_glColorP3uiv;
+#define glColorP3uiv glad_glColorP3uiv
+typedef void (APIENTRYP PFNGLCOLORP4UIPROC)(GLenum type, GLuint color);
+GLAPI PFNGLCOLORP4UIPROC glad_glColorP4ui;
+#define glColorP4ui glad_glColorP4ui
+typedef void (APIENTRYP PFNGLCOLORP4UIVPROC)(GLenum type, const GLuint *color);
+GLAPI PFNGLCOLORP4UIVPROC glad_glColorP4uiv;
+#define glColorP4uiv glad_glColorP4uiv
+typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIPROC)(GLenum type, GLuint color);
+GLAPI PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui;
+#define glSecondaryColorP3ui glad_glSecondaryColorP3ui
+typedef void (APIENTRYP PFNGLSECONDARYCOLORP3UIVPROC)(GLenum type, const GLuint *color);
+GLAPI PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv;
+#define glSecondaryColorP3uiv glad_glSecondaryColorP3uiv
+#endif
+#ifndef GL_VERSION_4_0
+#define GL_VERSION_4_0 1
+GLAPI int GLAD_GL_VERSION_4_0;
+typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC)(GLfloat value);
+GLAPI PFNGLMINSAMPLESHADINGPROC glad_glMinSampleShading;
+#define glMinSampleShading glad_glMinSampleShading
+typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC)(GLuint buf, GLenum mode);
+GLAPI PFNGLBLENDEQUATIONIPROC glad_glBlendEquationi;
+#define glBlendEquationi glad_glBlendEquationi
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC)(GLuint buf, GLenum modeRGB, GLenum modeAlpha);
+GLAPI PFNGLBLENDEQUATIONSEPARATEIPROC glad_glBlendEquationSeparatei;
+#define glBlendEquationSeparatei glad_glBlendEquationSeparatei
+typedef void (APIENTRYP PFNGLBLENDFUNCIPROC)(GLuint buf, GLenum src, GLenum dst);
+GLAPI PFNGLBLENDFUNCIPROC glad_glBlendFunci;
+#define glBlendFunci glad_glBlendFunci
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC)(GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
+GLAPI PFNGLBLENDFUNCSEPARATEIPROC glad_glBlendFuncSeparatei;
+#define glBlendFuncSeparatei glad_glBlendFuncSeparatei
+typedef void (APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC)(GLenum mode, const void *indirect);
+GLAPI PFNGLDRAWARRAYSINDIRECTPROC glad_glDrawArraysIndirect;
+#define glDrawArraysIndirect glad_glDrawArraysIndirect
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void *indirect);
+GLAPI PFNGLDRAWELEMENTSINDIRECTPROC glad_glDrawElementsIndirect;
+#define glDrawElementsIndirect glad_glDrawElementsIndirect
+typedef void (APIENTRYP PFNGLUNIFORM1DPROC)(GLint location, GLdouble x);
+GLAPI PFNGLUNIFORM1DPROC glad_glUniform1d;
+#define glUniform1d glad_glUniform1d
+typedef void (APIENTRYP PFNGLUNIFORM2DPROC)(GLint location, GLdouble x, GLdouble y);
+GLAPI PFNGLUNIFORM2DPROC glad_glUniform2d;
+#define glUniform2d glad_glUniform2d
+typedef void (APIENTRYP PFNGLUNIFORM3DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z);
+GLAPI PFNGLUNIFORM3DPROC glad_glUniform3d;
+#define glUniform3d glad_glUniform3d
+typedef void (APIENTRYP PFNGLUNIFORM4DPROC)(GLint location, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI PFNGLUNIFORM4DPROC glad_glUniform4d;
+#define glUniform4d glad_glUniform4d
+typedef void (APIENTRYP PFNGLUNIFORM1DVPROC)(GLint location, GLsizei count, const GLdouble *value);
+GLAPI PFNGLUNIFORM1DVPROC glad_glUniform1dv;
+#define glUniform1dv glad_glUniform1dv
+typedef void (APIENTRYP PFNGLUNIFORM2DVPROC)(GLint location, GLsizei count, const GLdouble *value);
+GLAPI PFNGLUNIFORM2DVPROC glad_glUniform2dv;
+#define glUniform2dv glad_glUniform2dv
+typedef void (APIENTRYP PFNGLUNIFORM3DVPROC)(GLint location, GLsizei count, const GLdouble *value);
+GLAPI PFNGLUNIFORM3DVPROC glad_glUniform3dv;
+#define glUniform3dv glad_glUniform3dv
+typedef void (APIENTRYP PFNGLUNIFORM4DVPROC)(GLint location, GLsizei count, const GLdouble *value);
+GLAPI PFNGLUNIFORM4DVPROC glad_glUniform4dv;
+#define glUniform4dv glad_glUniform4dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX2DVPROC glad_glUniformMatrix2dv;
+#define glUniformMatrix2dv glad_glUniformMatrix2dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX3DVPROC glad_glUniformMatrix3dv;
+#define glUniformMatrix3dv glad_glUniformMatrix3dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX4DVPROC glad_glUniformMatrix4dv;
+#define glUniformMatrix4dv glad_glUniformMatrix4dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX2X3DVPROC glad_glUniformMatrix2x3dv;
+#define glUniformMatrix2x3dv glad_glUniformMatrix2x3dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX2X4DVPROC glad_glUniformMatrix2x4dv;
+#define glUniformMatrix2x4dv glad_glUniformMatrix2x4dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX3X2DVPROC glad_glUniformMatrix3x2dv;
+#define glUniformMatrix3x2dv glad_glUniformMatrix3x2dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX3X4DVPROC glad_glUniformMatrix3x4dv;
+#define glUniformMatrix3x4dv glad_glUniformMatrix3x4dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX4X2DVPROC glad_glUniformMatrix4x2dv;
+#define glUniformMatrix4x2dv glad_glUniformMatrix4x2dv
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3DVPROC)(GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLUNIFORMMATRIX4X3DVPROC glad_glUniformMatrix4x3dv;
+#define glUniformMatrix4x3dv glad_glUniformMatrix4x3dv
+typedef void (APIENTRYP PFNGLGETUNIFORMDVPROC)(GLuint program, GLint location, GLdouble *params);
+GLAPI PFNGLGETUNIFORMDVPROC glad_glGetUniformdv;
+#define glGetUniformdv glad_glGetUniformdv
+typedef GLint (APIENTRYP PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)(GLuint program, GLenum shadertype, const GLchar *name);
+GLAPI PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC glad_glGetSubroutineUniformLocation;
+#define glGetSubroutineUniformLocation glad_glGetSubroutineUniformLocation
+typedef GLuint (APIENTRYP PFNGLGETSUBROUTINEINDEXPROC)(GLuint program, GLenum shadertype, const GLchar *name);
+GLAPI PFNGLGETSUBROUTINEINDEXPROC glad_glGetSubroutineIndex;
+#define glGetSubroutineIndex glad_glGetSubroutineIndex
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)(GLuint program, GLenum shadertype, GLuint index, GLenum pname, GLint *values);
+GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_glGetActiveSubroutineUniformiv;
+#define glGetActiveSubroutineUniformiv glad_glGetActiveSubroutineUniformiv
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+GLAPI PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_glGetActiveSubroutineUniformName;
+#define glGetActiveSubroutineUniformName glad_glGetActiveSubroutineUniformName
+typedef void (APIENTRYP PFNGLGETACTIVESUBROUTINENAMEPROC)(GLuint program, GLenum shadertype, GLuint index, GLsizei bufsize, GLsizei *length, GLchar *name);
+GLAPI PFNGLGETACTIVESUBROUTINENAMEPROC glad_glGetActiveSubroutineName;
+#define glGetActiveSubroutineName glad_glGetActiveSubroutineName
+typedef void (APIENTRYP PFNGLUNIFORMSUBROUTINESUIVPROC)(GLenum shadertype, GLsizei count, const GLuint *indices);
+GLAPI PFNGLUNIFORMSUBROUTINESUIVPROC glad_glUniformSubroutinesuiv;
+#define glUniformSubroutinesuiv glad_glUniformSubroutinesuiv
+typedef void (APIENTRYP PFNGLGETUNIFORMSUBROUTINEUIVPROC)(GLenum shadertype, GLint location, GLuint *params);
+GLAPI PFNGLGETUNIFORMSUBROUTINEUIVPROC glad_glGetUniformSubroutineuiv;
+#define glGetUniformSubroutineuiv glad_glGetUniformSubroutineuiv
+typedef void (APIENTRYP PFNGLGETPROGRAMSTAGEIVPROC)(GLuint program, GLenum shadertype, GLenum pname, GLint *values);
+GLAPI PFNGLGETPROGRAMSTAGEIVPROC glad_glGetProgramStageiv;
+#define glGetProgramStageiv glad_glGetProgramStageiv
+typedef void (APIENTRYP PFNGLPATCHPARAMETERIPROC)(GLenum pname, GLint value);
+GLAPI PFNGLPATCHPARAMETERIPROC glad_glPatchParameteri;
+#define glPatchParameteri glad_glPatchParameteri
+typedef void (APIENTRYP PFNGLPATCHPARAMETERFVPROC)(GLenum pname, const GLfloat *values);
+GLAPI PFNGLPATCHPARAMETERFVPROC glad_glPatchParameterfv;
+#define glPatchParameterfv glad_glPatchParameterfv
+typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC)(GLenum target, GLuint id);
+GLAPI PFNGLBINDTRANSFORMFEEDBACKPROC glad_glBindTransformFeedback;
+#define glBindTransformFeedback glad_glBindTransformFeedback
+typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC)(GLsizei n, const GLuint *ids);
+GLAPI PFNGLDELETETRANSFORMFEEDBACKSPROC glad_glDeleteTransformFeedbacks;
+#define glDeleteTransformFeedbacks glad_glDeleteTransformFeedbacks
+typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint *ids);
+GLAPI PFNGLGENTRANSFORMFEEDBACKSPROC glad_glGenTransformFeedbacks;
+#define glGenTransformFeedbacks glad_glGenTransformFeedbacks
+typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC)(GLuint id);
+GLAPI PFNGLISTRANSFORMFEEDBACKPROC glad_glIsTransformFeedback;
+#define glIsTransformFeedback glad_glIsTransformFeedback
+typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC)(void);
+GLAPI PFNGLPAUSETRANSFORMFEEDBACKPROC glad_glPauseTransformFeedback;
+#define glPauseTransformFeedback glad_glPauseTransformFeedback
+typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC)(void);
+GLAPI PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback;
+#define glResumeTransformFeedback glad_glResumeTransformFeedback
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKPROC)(GLenum mode, GLuint id);
+GLAPI PFNGLDRAWTRANSFORMFEEDBACKPROC glad_glDrawTransformFeedback;
+#define glDrawTransformFeedback glad_glDrawTransformFeedback
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)(GLenum mode, GLuint id, GLuint stream);
+GLAPI PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC glad_glDrawTransformFeedbackStream;
+#define glDrawTransformFeedbackStream glad_glDrawTransformFeedbackStream
+typedef void (APIENTRYP PFNGLBEGINQUERYINDEXEDPROC)(GLenum target, GLuint index, GLuint id);
+GLAPI PFNGLBEGINQUERYINDEXEDPROC glad_glBeginQueryIndexed;
+#define glBeginQueryIndexed glad_glBeginQueryIndexed
+typedef void (APIENTRYP PFNGLENDQUERYINDEXEDPROC)(GLenum target, GLuint index);
+GLAPI PFNGLENDQUERYINDEXEDPROC glad_glEndQueryIndexed;
+#define glEndQueryIndexed glad_glEndQueryIndexed
+typedef void (APIENTRYP PFNGLGETQUERYINDEXEDIVPROC)(GLenum target, GLuint index, GLenum pname, GLint *params);
+GLAPI PFNGLGETQUERYINDEXEDIVPROC glad_glGetQueryIndexediv;
+#define glGetQueryIndexediv glad_glGetQueryIndexediv
+#endif
+#ifndef GL_VERSION_4_1
+#define GL_VERSION_4_1 1
+GLAPI int GLAD_GL_VERSION_4_1;
+typedef void (APIENTRYP PFNGLRELEASESHADERCOMPILERPROC)(void);
+GLAPI PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler;
+#define glReleaseShaderCompiler glad_glReleaseShaderCompiler
+typedef void (APIENTRYP PFNGLSHADERBINARYPROC)(GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length);
+GLAPI PFNGLSHADERBINARYPROC glad_glShaderBinary;
+#define glShaderBinary glad_glShaderBinary
+typedef void (APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC)(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision);
+GLAPI PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat;
+#define glGetShaderPrecisionFormat glad_glGetShaderPrecisionFormat
+typedef void (APIENTRYP PFNGLDEPTHRANGEFPROC)(GLfloat n, GLfloat f);
+GLAPI PFNGLDEPTHRANGEFPROC glad_glDepthRangef;
+#define glDepthRangef glad_glDepthRangef
+typedef void (APIENTRYP PFNGLCLEARDEPTHFPROC)(GLfloat d);
+GLAPI PFNGLCLEARDEPTHFPROC glad_glClearDepthf;
+#define glClearDepthf glad_glClearDepthf
+typedef void (APIENTRYP PFNGLGETPROGRAMBINARYPROC)(GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary);
+GLAPI PFNGLGETPROGRAMBINARYPROC glad_glGetProgramBinary;
+#define glGetProgramBinary glad_glGetProgramBinary
+typedef void (APIENTRYP PFNGLPROGRAMBINARYPROC)(GLuint program, GLenum binaryFormat, const void *binary, GLsizei length);
+GLAPI PFNGLPROGRAMBINARYPROC glad_glProgramBinary;
+#define glProgramBinary glad_glProgramBinary
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC)(GLuint program, GLenum pname, GLint value);
+GLAPI PFNGLPROGRAMPARAMETERIPROC glad_glProgramParameteri;
+#define glProgramParameteri glad_glProgramParameteri
+typedef void (APIENTRYP PFNGLUSEPROGRAMSTAGESPROC)(GLuint pipeline, GLbitfield stages, GLuint program);
+GLAPI PFNGLUSEPROGRAMSTAGESPROC glad_glUseProgramStages;
+#define glUseProgramStages glad_glUseProgramStages
+typedef void (APIENTRYP PFNGLACTIVESHADERPROGRAMPROC)(GLuint pipeline, GLuint program);
+GLAPI PFNGLACTIVESHADERPROGRAMPROC glad_glActiveShaderProgram;
+#define glActiveShaderProgram glad_glActiveShaderProgram
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROGRAMVPROC)(GLenum type, GLsizei count, const GLchar *const*strings);
+GLAPI PFNGLCREATESHADERPROGRAMVPROC glad_glCreateShaderProgramv;
+#define glCreateShaderProgramv glad_glCreateShaderProgramv
+typedef void (APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC)(GLuint pipeline);
+GLAPI PFNGLBINDPROGRAMPIPELINEPROC glad_glBindProgramPipeline;
+#define glBindProgramPipeline glad_glBindProgramPipeline
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC)(GLsizei n, const GLuint *pipelines);
+GLAPI PFNGLDELETEPROGRAMPIPELINESPROC glad_glDeleteProgramPipelines;
+#define glDeleteProgramPipelines glad_glDeleteProgramPipelines
+typedef void (APIENTRYP PFNGLGENPROGRAMPIPELINESPROC)(GLsizei n, GLuint *pipelines);
+GLAPI PFNGLGENPROGRAMPIPELINESPROC glad_glGenProgramPipelines;
+#define glGenProgramPipelines glad_glGenProgramPipelines
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPIPELINEPROC)(GLuint pipeline);
+GLAPI PFNGLISPROGRAMPIPELINEPROC glad_glIsProgramPipeline;
+#define glIsProgramPipeline glad_glIsProgramPipeline
+typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC)(GLuint pipeline, GLenum pname, GLint *params);
+GLAPI PFNGLGETPROGRAMPIPELINEIVPROC glad_glGetProgramPipelineiv;
+#define glGetProgramPipelineiv glad_glGetProgramPipelineiv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IPROC)(GLuint program, GLint location, GLint v0);
+GLAPI PFNGLPROGRAMUNIFORM1IPROC glad_glProgramUniform1i;
+#define glProgramUniform1i glad_glProgramUniform1i
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI PFNGLPROGRAMUNIFORM1IVPROC glad_glProgramUniform1iv;
+#define glProgramUniform1iv glad_glProgramUniform1iv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FPROC)(GLuint program, GLint location, GLfloat v0);
+GLAPI PFNGLPROGRAMUNIFORM1FPROC glad_glProgramUniform1f;
+#define glProgramUniform1f glad_glProgramUniform1f
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORM1FVPROC glad_glProgramUniform1fv;
+#define glProgramUniform1fv glad_glProgramUniform1fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DPROC)(GLuint program, GLint location, GLdouble v0);
+GLAPI PFNGLPROGRAMUNIFORM1DPROC glad_glProgramUniform1d;
+#define glProgramUniform1d glad_glProgramUniform1d
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORM1DVPROC glad_glProgramUniform1dv;
+#define glProgramUniform1dv glad_glProgramUniform1dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC)(GLuint program, GLint location, GLuint v0);
+GLAPI PFNGLPROGRAMUNIFORM1UIPROC glad_glProgramUniform1ui;
+#define glProgramUniform1ui glad_glProgramUniform1ui
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI PFNGLPROGRAMUNIFORM1UIVPROC glad_glProgramUniform1uiv;
+#define glProgramUniform1uiv glad_glProgramUniform1uiv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IPROC)(GLuint program, GLint location, GLint v0, GLint v1);
+GLAPI PFNGLPROGRAMUNIFORM2IPROC glad_glProgramUniform2i;
+#define glProgramUniform2i glad_glProgramUniform2i
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI PFNGLPROGRAMUNIFORM2IVPROC glad_glProgramUniform2iv;
+#define glProgramUniform2iv glad_glProgramUniform2iv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1);
+GLAPI PFNGLPROGRAMUNIFORM2FPROC glad_glProgramUniform2f;
+#define glProgramUniform2f glad_glProgramUniform2f
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORM2FVPROC glad_glProgramUniform2fv;
+#define glProgramUniform2fv glad_glProgramUniform2fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1);
+GLAPI PFNGLPROGRAMUNIFORM2DPROC glad_glProgramUniform2d;
+#define glProgramUniform2d glad_glProgramUniform2d
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORM2DVPROC glad_glProgramUniform2dv;
+#define glProgramUniform2dv glad_glProgramUniform2dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1);
+GLAPI PFNGLPROGRAMUNIFORM2UIPROC glad_glProgramUniform2ui;
+#define glProgramUniform2ui glad_glProgramUniform2ui
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI PFNGLPROGRAMUNIFORM2UIVPROC glad_glProgramUniform2uiv;
+#define glProgramUniform2uiv glad_glProgramUniform2uiv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+GLAPI PFNGLPROGRAMUNIFORM3IPROC glad_glProgramUniform3i;
+#define glProgramUniform3i glad_glProgramUniform3i
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI PFNGLPROGRAMUNIFORM3IVPROC glad_glProgramUniform3iv;
+#define glProgramUniform3iv glad_glProgramUniform3iv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+GLAPI PFNGLPROGRAMUNIFORM3FPROC glad_glProgramUniform3f;
+#define glProgramUniform3f glad_glProgramUniform3f
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORM3FVPROC glad_glProgramUniform3fv;
+#define glProgramUniform3fv glad_glProgramUniform3fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2);
+GLAPI PFNGLPROGRAMUNIFORM3DPROC glad_glProgramUniform3d;
+#define glProgramUniform3d glad_glProgramUniform3d
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORM3DVPROC glad_glProgramUniform3dv;
+#define glProgramUniform3dv glad_glProgramUniform3dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+GLAPI PFNGLPROGRAMUNIFORM3UIPROC glad_glProgramUniform3ui;
+#define glProgramUniform3ui glad_glProgramUniform3ui
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI PFNGLPROGRAMUNIFORM3UIVPROC glad_glProgramUniform3uiv;
+#define glProgramUniform3uiv glad_glProgramUniform3uiv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IPROC)(GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+GLAPI PFNGLPROGRAMUNIFORM4IPROC glad_glProgramUniform4i;
+#define glProgramUniform4i glad_glProgramUniform4i
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC)(GLuint program, GLint location, GLsizei count, const GLint *value);
+GLAPI PFNGLPROGRAMUNIFORM4IVPROC glad_glProgramUniform4iv;
+#define glProgramUniform4iv glad_glProgramUniform4iv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FPROC)(GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+GLAPI PFNGLPROGRAMUNIFORM4FPROC glad_glProgramUniform4f;
+#define glProgramUniform4f glad_glProgramUniform4f
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC)(GLuint program, GLint location, GLsizei count, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORM4FVPROC glad_glProgramUniform4fv;
+#define glProgramUniform4fv glad_glProgramUniform4fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DPROC)(GLuint program, GLint location, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3);
+GLAPI PFNGLPROGRAMUNIFORM4DPROC glad_glProgramUniform4d;
+#define glProgramUniform4d glad_glProgramUniform4d
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4DVPROC)(GLuint program, GLint location, GLsizei count, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORM4DVPROC glad_glProgramUniform4dv;
+#define glProgramUniform4dv glad_glProgramUniform4dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC)(GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+GLAPI PFNGLPROGRAMUNIFORM4UIPROC glad_glProgramUniform4ui;
+#define glProgramUniform4ui glad_glProgramUniform4ui
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC)(GLuint program, GLint location, GLsizei count, const GLuint *value);
+GLAPI PFNGLPROGRAMUNIFORM4UIVPROC glad_glProgramUniform4uiv;
+#define glProgramUniform4uiv glad_glProgramUniform4uiv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX2FVPROC glad_glProgramUniformMatrix2fv;
+#define glProgramUniformMatrix2fv glad_glProgramUniformMatrix2fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX3FVPROC glad_glProgramUniformMatrix3fv;
+#define glProgramUniformMatrix3fv glad_glProgramUniformMatrix3fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX4FVPROC glad_glProgramUniformMatrix4fv;
+#define glProgramUniformMatrix4fv glad_glProgramUniformMatrix4fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX2DVPROC glad_glProgramUniformMatrix2dv;
+#define glProgramUniformMatrix2dv glad_glProgramUniformMatrix2dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX3DVPROC glad_glProgramUniformMatrix3dv;
+#define glProgramUniformMatrix3dv glad_glProgramUniformMatrix3dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX4DVPROC glad_glProgramUniformMatrix4dv;
+#define glProgramUniformMatrix4dv glad_glProgramUniformMatrix4dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glad_glProgramUniformMatrix2x3fv;
+#define glProgramUniformMatrix2x3fv glad_glProgramUniformMatrix2x3fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glad_glProgramUniformMatrix3x2fv;
+#define glProgramUniformMatrix3x2fv glad_glProgramUniformMatrix3x2fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glad_glProgramUniformMatrix2x4fv;
+#define glProgramUniformMatrix2x4fv glad_glProgramUniformMatrix2x4fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glad_glProgramUniformMatrix4x2fv;
+#define glProgramUniformMatrix4x2fv glad_glProgramUniformMatrix4x2fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glad_glProgramUniformMatrix3x4fv;
+#define glProgramUniformMatrix3x4fv glad_glProgramUniformMatrix3x4fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glad_glProgramUniformMatrix4x3fv;
+#define glProgramUniformMatrix4x3fv glad_glProgramUniformMatrix4x3fv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC glad_glProgramUniformMatrix2x3dv;
+#define glProgramUniformMatrix2x3dv glad_glProgramUniformMatrix2x3dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC glad_glProgramUniformMatrix3x2dv;
+#define glProgramUniformMatrix3x2dv glad_glProgramUniformMatrix3x2dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC glad_glProgramUniformMatrix2x4dv;
+#define glProgramUniformMatrix2x4dv glad_glProgramUniformMatrix2x4dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC glad_glProgramUniformMatrix4x2dv;
+#define glProgramUniformMatrix4x2dv glad_glProgramUniformMatrix4x2dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC glad_glProgramUniformMatrix3x4dv;
+#define glProgramUniformMatrix3x4dv glad_glProgramUniformMatrix3x4dv
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)(GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLdouble *value);
+GLAPI PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC glad_glProgramUniformMatrix4x3dv;
+#define glProgramUniformMatrix4x3dv glad_glProgramUniformMatrix4x3dv
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC)(GLuint pipeline);
+GLAPI PFNGLVALIDATEPROGRAMPIPELINEPROC glad_glValidateProgramPipeline;
+#define glValidateProgramPipeline glad_glValidateProgramPipeline
+typedef void (APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC)(GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+GLAPI PFNGLGETPROGRAMPIPELINEINFOLOGPROC glad_glGetProgramPipelineInfoLog;
+#define glGetProgramPipelineInfoLog glad_glGetProgramPipelineInfoLog
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DPROC)(GLuint index, GLdouble x);
+GLAPI PFNGLVERTEXATTRIBL1DPROC glad_glVertexAttribL1d;
+#define glVertexAttribL1d glad_glVertexAttribL1d
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DPROC)(GLuint index, GLdouble x, GLdouble y);
+GLAPI PFNGLVERTEXATTRIBL2DPROC glad_glVertexAttribL2d;
+#define glVertexAttribL2d glad_glVertexAttribL2d
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z);
+GLAPI PFNGLVERTEXATTRIBL3DPROC glad_glVertexAttribL3d;
+#define glVertexAttribL3d glad_glVertexAttribL3d
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DPROC)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+GLAPI PFNGLVERTEXATTRIBL4DPROC glad_glVertexAttribL4d;
+#define glVertexAttribL4d glad_glVertexAttribL4d
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL1DVPROC)(GLuint index, const GLdouble *v);
+GLAPI PFNGLVERTEXATTRIBL1DVPROC glad_glVertexAttribL1dv;
+#define glVertexAttribL1dv glad_glVertexAttribL1dv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL2DVPROC)(GLuint index, const GLdouble *v);
+GLAPI PFNGLVERTEXATTRIBL2DVPROC glad_glVertexAttribL2dv;
+#define glVertexAttribL2dv glad_glVertexAttribL2dv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL3DVPROC)(GLuint index, const GLdouble *v);
+GLAPI PFNGLVERTEXATTRIBL3DVPROC glad_glVertexAttribL3dv;
+#define glVertexAttribL3dv glad_glVertexAttribL3dv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBL4DVPROC)(GLuint index, const GLdouble *v);
+GLAPI PFNGLVERTEXATTRIBL4DVPROC glad_glVertexAttribL4dv;
+#define glVertexAttribL4dv glad_glVertexAttribL4dv
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLPOINTERPROC)(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer);
+GLAPI PFNGLVERTEXATTRIBLPOINTERPROC glad_glVertexAttribLPointer;
+#define glVertexAttribLPointer glad_glVertexAttribLPointer
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBLDVPROC)(GLuint index, GLenum pname, GLdouble *params);
+GLAPI PFNGLGETVERTEXATTRIBLDVPROC glad_glGetVertexAttribLdv;
+#define glGetVertexAttribLdv glad_glGetVertexAttribLdv
+typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC)(GLuint first, GLsizei count, const GLfloat *v);
+GLAPI PFNGLVIEWPORTARRAYVPROC glad_glViewportArrayv;
+#define glViewportArrayv glad_glViewportArrayv
+typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC)(GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
+GLAPI PFNGLVIEWPORTINDEXEDFPROC glad_glViewportIndexedf;
+#define glViewportIndexedf glad_glViewportIndexedf
+typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC)(GLuint index, const GLfloat *v);
+GLAPI PFNGLVIEWPORTINDEXEDFVPROC glad_glViewportIndexedfv;
+#define glViewportIndexedfv glad_glViewportIndexedfv
+typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC)(GLuint first, GLsizei count, const GLint *v);
+GLAPI PFNGLSCISSORARRAYVPROC glad_glScissorArrayv;
+#define glScissorArrayv glad_glScissorArrayv
+typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC)(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
+GLAPI PFNGLSCISSORINDEXEDPROC glad_glScissorIndexed;
+#define glScissorIndexed glad_glScissorIndexed
+typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC)(GLuint index, const GLint *v);
+GLAPI PFNGLSCISSORINDEXEDVPROC glad_glScissorIndexedv;
+#define glScissorIndexedv glad_glScissorIndexedv
+typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC)(GLuint first, GLsizei count, const GLdouble *v);
+GLAPI PFNGLDEPTHRANGEARRAYVPROC glad_glDepthRangeArrayv;
+#define glDepthRangeArrayv glad_glDepthRangeArrayv
+typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC)(GLuint index, GLdouble n, GLdouble f);
+GLAPI PFNGLDEPTHRANGEINDEXEDPROC glad_glDepthRangeIndexed;
+#define glDepthRangeIndexed glad_glDepthRangeIndexed
+typedef void (APIENTRYP PFNGLGETFLOATI_VPROC)(GLenum target, GLuint index, GLfloat *data);
+GLAPI PFNGLGETFLOATI_VPROC glad_glGetFloati_v;
+#define glGetFloati_v glad_glGetFloati_v
+typedef void (APIENTRYP PFNGLGETDOUBLEI_VPROC)(GLenum target, GLuint index, GLdouble *data);
+GLAPI PFNGLGETDOUBLEI_VPROC glad_glGetDoublei_v;
+#define glGetDoublei_v glad_glGetDoublei_v
+#endif
+#ifndef GL_VERSION_4_2
+#define GL_VERSION_4_2 1
+GLAPI int GLAD_GL_VERSION_4_2;
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance);
+GLAPI PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC glad_glDrawArraysInstancedBaseInstance;
+#define glDrawArraysInstancedBaseInstance glad_glDrawArraysInstancedBaseInstance
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance);
+GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC glad_glDrawElementsInstancedBaseInstance;
+#define glDrawElementsInstancedBaseInstance glad_glDrawElementsInstancedBaseInstance
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance);
+GLAPI PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_glDrawElementsInstancedBaseVertexBaseInstance;
+#define glDrawElementsInstancedBaseVertexBaseInstance glad_glDrawElementsInstancedBaseVertexBaseInstance
+typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
+GLAPI PFNGLGETINTERNALFORMATIVPROC glad_glGetInternalformativ;
+#define glGetInternalformativ glad_glGetInternalformativ
+typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)(GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
+GLAPI PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC glad_glGetActiveAtomicCounterBufferiv;
+#define glGetActiveAtomicCounterBufferiv glad_glGetActiveAtomicCounterBufferiv
+typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC)(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
+GLAPI PFNGLBINDIMAGETEXTUREPROC glad_glBindImageTexture;
+#define glBindImageTexture glad_glBindImageTexture
+typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC)(GLbitfield barriers);
+GLAPI PFNGLMEMORYBARRIERPROC glad_glMemoryBarrier;
+#define glMemoryBarrier glad_glMemoryBarrier
+typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
+GLAPI PFNGLTEXSTORAGE1DPROC glad_glTexStorage1D;
+#define glTexStorage1D glad_glTexStorage1D
+typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI PFNGLTEXSTORAGE2DPROC glad_glTexStorage2D;
+#define glTexStorage2D glad_glTexStorage2D
+typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC)(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GLAPI PFNGLTEXSTORAGE3DPROC glad_glTexStorage3D;
+#define glTexStorage3D glad_glTexStorage3D
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)(GLenum mode, GLuint id, GLsizei instancecount);
+GLAPI PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC glad_glDrawTransformFeedbackInstanced;
+#define glDrawTransformFeedbackInstanced glad_glDrawTransformFeedbackInstanced
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)(GLenum mode, GLuint id, GLuint stream, GLsizei instancecount);
+GLAPI PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC glad_glDrawTransformFeedbackStreamInstanced;
+#define glDrawTransformFeedbackStreamInstanced glad_glDrawTransformFeedbackStreamInstanced
+#endif
+#ifndef GL_VERSION_4_3
+#define GL_VERSION_4_3 1
+GLAPI int GLAD_GL_VERSION_4_3;
+typedef void (APIENTRYP PFNGLCLEARBUFFERDATAPROC)(GLenum target, GLenum internalformat, GLenum format, GLenum type, const void *data);
+GLAPI PFNGLCLEARBUFFERDATAPROC glad_glClearBufferData;
+#define glClearBufferData glad_glClearBufferData
+typedef void (APIENTRYP PFNGLCLEARBUFFERSUBDATAPROC)(GLenum target, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
+GLAPI PFNGLCLEARBUFFERSUBDATAPROC glad_glClearBufferSubData;
+#define glClearBufferSubData glad_glClearBufferSubData
+typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEPROC)(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z);
+GLAPI PFNGLDISPATCHCOMPUTEPROC glad_glDispatchCompute;
+#define glDispatchCompute glad_glDispatchCompute
+typedef void (APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC)(GLintptr indirect);
+GLAPI PFNGLDISPATCHCOMPUTEINDIRECTPROC glad_glDispatchComputeIndirect;
+#define glDispatchComputeIndirect glad_glDispatchComputeIndirect
+typedef void (APIENTRYP PFNGLCOPYIMAGESUBDATAPROC)(GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth);
+GLAPI PFNGLCOPYIMAGESUBDATAPROC glad_glCopyImageSubData;
+#define glCopyImageSubData glad_glCopyImageSubData
+typedef void (APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC)(GLenum target, GLenum pname, GLint param);
+GLAPI PFNGLFRAMEBUFFERPARAMETERIPROC glad_glFramebufferParameteri;
+#define glFramebufferParameteri glad_glFramebufferParameteri
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC)(GLenum target, GLenum pname, GLint *params);
+GLAPI PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_glGetFramebufferParameteriv;
+#define glGetFramebufferParameteriv glad_glGetFramebufferParameteriv
+typedef void (APIENTRYP PFNGLGETINTERNALFORMATI64VPROC)(GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint64 *params);
+GLAPI PFNGLGETINTERNALFORMATI64VPROC glad_glGetInternalformati64v;
+#define glGetInternalformati64v glad_glGetInternalformati64v
+typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
+GLAPI PFNGLINVALIDATETEXSUBIMAGEPROC glad_glInvalidateTexSubImage;
+#define glInvalidateTexSubImage glad_glInvalidateTexSubImage
+typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC)(GLuint texture, GLint level);
+GLAPI PFNGLINVALIDATETEXIMAGEPROC glad_glInvalidateTexImage;
+#define glInvalidateTexImage glad_glInvalidateTexImage
+typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length);
+GLAPI PFNGLINVALIDATEBUFFERSUBDATAPROC glad_glInvalidateBufferSubData;
+#define glInvalidateBufferSubData glad_glInvalidateBufferSubData
+typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer);
+GLAPI PFNGLINVALIDATEBUFFERDATAPROC glad_glInvalidateBufferData;
+#define glInvalidateBufferData glad_glInvalidateBufferData
+typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum *attachments);
+GLAPI PFNGLINVALIDATEFRAMEBUFFERPROC glad_glInvalidateFramebuffer;
+#define glInvalidateFramebuffer glad_glInvalidateFramebuffer
+typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC)(GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI PFNGLINVALIDATESUBFRAMEBUFFERPROC glad_glInvalidateSubFramebuffer;
+#define glInvalidateSubFramebuffer glad_glInvalidateSubFramebuffer
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTPROC)(GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride);
+GLAPI PFNGLMULTIDRAWARRAYSINDIRECTPROC glad_glMultiDrawArraysIndirect;
+#define glMultiDrawArraysIndirect glad_glMultiDrawArraysIndirect
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTPROC)(GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride);
+GLAPI PFNGLMULTIDRAWELEMENTSINDIRECTPROC glad_glMultiDrawElementsIndirect;
+#define glMultiDrawElementsIndirect glad_glMultiDrawElementsIndirect
+typedef void (APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC)(GLuint program, GLenum programInterface, GLenum pname, GLint *params);
+GLAPI PFNGLGETPROGRAMINTERFACEIVPROC glad_glGetProgramInterfaceiv;
+#define glGetProgramInterfaceiv glad_glGetProgramInterfaceiv
+typedef GLuint (APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC)(GLuint program, GLenum programInterface, const GLchar *name);
+GLAPI PFNGLGETPROGRAMRESOURCEINDEXPROC glad_glGetProgramResourceIndex;
+#define glGetProgramResourceIndex glad_glGetProgramResourceIndex
+typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name);
+GLAPI PFNGLGETPROGRAMRESOURCENAMEPROC glad_glGetProgramResourceName;
+#define glGetProgramResourceName glad_glGetProgramResourceName
+typedef void (APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC)(GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params);
+GLAPI PFNGLGETPROGRAMRESOURCEIVPROC glad_glGetProgramResourceiv;
+#define glGetProgramResourceiv glad_glGetProgramResourceiv
+typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC)(GLuint program, GLenum programInterface, const GLchar *name);
+GLAPI PFNGLGETPROGRAMRESOURCELOCATIONPROC glad_glGetProgramResourceLocation;
+#define glGetProgramResourceLocation glad_glGetProgramResourceLocation
+typedef GLint (APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)(GLuint program, GLenum programInterface, const GLchar *name);
+GLAPI PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC glad_glGetProgramResourceLocationIndex;
+#define glGetProgramResourceLocationIndex glad_glGetProgramResourceLocationIndex
+typedef void (APIENTRYP PFNGLSHADERSTORAGEBLOCKBINDINGPROC)(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding);
+GLAPI PFNGLSHADERSTORAGEBLOCKBINDINGPROC glad_glShaderStorageBlockBinding;
+#define glShaderStorageBlockBinding glad_glShaderStorageBlockBinding
+typedef void (APIENTRYP PFNGLTEXBUFFERRANGEPROC)(GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI PFNGLTEXBUFFERRANGEPROC glad_glTexBufferRange;
+#define glTexBufferRange glad_glTexBufferRange
+typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI PFNGLTEXSTORAGE2DMULTISAMPLEPROC glad_glTexStorage2DMultisample;
+#define glTexStorage2DMultisample glad_glTexStorage2DMultisample
+typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC)(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+GLAPI PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_glTexStorage3DMultisample;
+#define glTexStorage3DMultisample glad_glTexStorage3DMultisample
+typedef void (APIENTRYP PFNGLTEXTUREVIEWPROC)(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers);
+GLAPI PFNGLTEXTUREVIEWPROC glad_glTextureView;
+#define glTextureView glad_glTextureView
+typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERPROC)(GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+GLAPI PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer;
+#define glBindVertexBuffer glad_glBindVertexBuffer
+typedef void (APIENTRYP PFNGLVERTEXATTRIBFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+GLAPI PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat;
+#define glVertexAttribFormat glad_glVertexAttribFormat
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat;
+#define glVertexAttribIFormat glad_glVertexAttribIFormat
+typedef void (APIENTRYP PFNGLVERTEXATTRIBLFORMATPROC)(GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat;
+#define glVertexAttribLFormat glad_glVertexAttribLFormat
+typedef void (APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC)(GLuint attribindex, GLuint bindingindex);
+GLAPI PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding;
+#define glVertexAttribBinding glad_glVertexAttribBinding
+typedef void (APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC)(GLuint bindingindex, GLuint divisor);
+GLAPI PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor;
+#define glVertexBindingDivisor glad_glVertexBindingDivisor
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC)(GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled);
+GLAPI PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl;
+#define glDebugMessageControl glad_glDebugMessageControl
+typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf);
+GLAPI PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert;
+#define glDebugMessageInsert glad_glDebugMessageInsert
+typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC)(GLDEBUGPROC callback, const void *userParam);
+GLAPI PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback;
+#define glDebugMessageCallback glad_glDebugMessageCallback
+typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC)(GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog);
+GLAPI PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog;
+#define glGetDebugMessageLog glad_glGetDebugMessageLog
+typedef void (APIENTRYP PFNGLPUSHDEBUGGROUPPROC)(GLenum source, GLuint id, GLsizei length, const GLchar *message);
+GLAPI PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup;
+#define glPushDebugGroup glad_glPushDebugGroup
+typedef void (APIENTRYP PFNGLPOPDEBUGGROUPPROC)(void);
+GLAPI PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup;
+#define glPopDebugGroup glad_glPopDebugGroup
+typedef void (APIENTRYP PFNGLOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei length, const GLchar *label);
+GLAPI PFNGLOBJECTLABELPROC glad_glObjectLabel;
+#define glObjectLabel glad_glObjectLabel
+typedef void (APIENTRYP PFNGLGETOBJECTLABELPROC)(GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label);
+GLAPI PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel;
+#define glGetObjectLabel glad_glGetObjectLabel
+typedef void (APIENTRYP PFNGLOBJECTPTRLABELPROC)(const void *ptr, GLsizei length, const GLchar *label);
+GLAPI PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel;
+#define glObjectPtrLabel glad_glObjectPtrLabel
+typedef void (APIENTRYP PFNGLGETOBJECTPTRLABELPROC)(const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label);
+GLAPI PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel;
+#define glGetObjectPtrLabel glad_glGetObjectPtrLabel
+typedef void (APIENTRYP PFNGLGETPOINTERVPROC)(GLenum pname, void **params);
+GLAPI PFNGLGETPOINTERVPROC glad_glGetPointerv;
+#define glGetPointerv glad_glGetPointerv
+#endif
+#ifndef GL_VERSION_4_4
+#define GL_VERSION_4_4 1
+GLAPI int GLAD_GL_VERSION_4_4;
+typedef void (APIENTRYP PFNGLBUFFERSTORAGEPROC)(GLenum target, GLsizeiptr size, const void *data, GLbitfield flags);
+GLAPI PFNGLBUFFERSTORAGEPROC glad_glBufferStorage;
+#define glBufferStorage glad_glBufferStorage
+typedef void (APIENTRYP PFNGLCLEARTEXIMAGEPROC)(GLuint texture, GLint level, GLenum format, GLenum type, const void *data);
+GLAPI PFNGLCLEARTEXIMAGEPROC glad_glClearTexImage;
+#define glClearTexImage glad_glClearTexImage
+typedef void (APIENTRYP PFNGLCLEARTEXSUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
+GLAPI PFNGLCLEARTEXSUBIMAGEPROC glad_glClearTexSubImage;
+#define glClearTexSubImage glad_glClearTexSubImage
+typedef void (APIENTRYP PFNGLBINDBUFFERSBASEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint *buffers);
+GLAPI PFNGLBINDBUFFERSBASEPROC glad_glBindBuffersBase;
+#define glBindBuffersBase glad_glBindBuffersBase
+typedef void (APIENTRYP PFNGLBINDBUFFERSRANGEPROC)(GLenum target, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizeiptr *sizes);
+GLAPI PFNGLBINDBUFFERSRANGEPROC glad_glBindBuffersRange;
+#define glBindBuffersRange glad_glBindBuffersRange
+typedef void (APIENTRYP PFNGLBINDTEXTURESPROC)(GLuint first, GLsizei count, const GLuint *textures);
+GLAPI PFNGLBINDTEXTURESPROC glad_glBindTextures;
+#define glBindTextures glad_glBindTextures
+typedef void (APIENTRYP PFNGLBINDSAMPLERSPROC)(GLuint first, GLsizei count, const GLuint *samplers);
+GLAPI PFNGLBINDSAMPLERSPROC glad_glBindSamplers;
+#define glBindSamplers glad_glBindSamplers
+typedef void (APIENTRYP PFNGLBINDIMAGETEXTURESPROC)(GLuint first, GLsizei count, const GLuint *textures);
+GLAPI PFNGLBINDIMAGETEXTURESPROC glad_glBindImageTextures;
+#define glBindImageTextures glad_glBindImageTextures
+typedef void (APIENTRYP PFNGLBINDVERTEXBUFFERSPROC)(GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);
+GLAPI PFNGLBINDVERTEXBUFFERSPROC glad_glBindVertexBuffers;
+#define glBindVertexBuffers glad_glBindVertexBuffers
+#endif
+#ifndef GL_VERSION_4_5
+#define GL_VERSION_4_5 1
+GLAPI int GLAD_GL_VERSION_4_5;
+typedef void (APIENTRYP PFNGLCLIPCONTROLPROC)(GLenum origin, GLenum depth);
+GLAPI PFNGLCLIPCONTROLPROC glad_glClipControl;
+#define glClipControl glad_glClipControl
+typedef void (APIENTRYP PFNGLCREATETRANSFORMFEEDBACKSPROC)(GLsizei n, GLuint *ids);
+GLAPI PFNGLCREATETRANSFORMFEEDBACKSPROC glad_glCreateTransformFeedbacks;
+#define glCreateTransformFeedbacks glad_glCreateTransformFeedbacks
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC)(GLuint xfb, GLuint index, GLuint buffer);
+GLAPI PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC glad_glTransformFeedbackBufferBase;
+#define glTransformFeedbackBufferBase glad_glTransformFeedbackBufferBase
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC)(GLuint xfb, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC glad_glTransformFeedbackBufferRange;
+#define glTransformFeedbackBufferRange glad_glTransformFeedbackBufferRange
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKIVPROC)(GLuint xfb, GLenum pname, GLint *param);
+GLAPI PFNGLGETTRANSFORMFEEDBACKIVPROC glad_glGetTransformFeedbackiv;
+#define glGetTransformFeedbackiv glad_glGetTransformFeedbackiv
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI_VPROC)(GLuint xfb, GLenum pname, GLuint index, GLint *param);
+GLAPI PFNGLGETTRANSFORMFEEDBACKI_VPROC glad_glGetTransformFeedbacki_v;
+#define glGetTransformFeedbacki_v glad_glGetTransformFeedbacki_v
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKI64_VPROC)(GLuint xfb, GLenum pname, GLuint index, GLint64 *param);
+GLAPI PFNGLGETTRANSFORMFEEDBACKI64_VPROC glad_glGetTransformFeedbacki64_v;
+#define glGetTransformFeedbacki64_v glad_glGetTransformFeedbacki64_v
+typedef void (APIENTRYP PFNGLCREATEBUFFERSPROC)(GLsizei n, GLuint *buffers);
+GLAPI PFNGLCREATEBUFFERSPROC glad_glCreateBuffers;
+#define glCreateBuffers glad_glCreateBuffers
+typedef void (APIENTRYP PFNGLNAMEDBUFFERSTORAGEPROC)(GLuint buffer, GLsizeiptr size, const void *data, GLbitfield flags);
+GLAPI PFNGLNAMEDBUFFERSTORAGEPROC glad_glNamedBufferStorage;
+#define glNamedBufferStorage glad_glNamedBufferStorage
+typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAPROC)(GLuint buffer, GLsizeiptr size, const void *data, GLenum usage);
+GLAPI PFNGLNAMEDBUFFERDATAPROC glad_glNamedBufferData;
+#define glNamedBufferData glad_glNamedBufferData
+typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, const void *data);
+GLAPI PFNGLNAMEDBUFFERSUBDATAPROC glad_glNamedBufferSubData;
+#define glNamedBufferSubData glad_glNamedBufferSubData
+typedef void (APIENTRYP PFNGLCOPYNAMEDBUFFERSUBDATAPROC)(GLuint readBuffer, GLuint writeBuffer, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size);
+GLAPI PFNGLCOPYNAMEDBUFFERSUBDATAPROC glad_glCopyNamedBufferSubData;
+#define glCopyNamedBufferSubData glad_glCopyNamedBufferSubData
+typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERDATAPROC)(GLuint buffer, GLenum internalformat, GLenum format, GLenum type, const void *data);
+GLAPI PFNGLCLEARNAMEDBUFFERDATAPROC glad_glClearNamedBufferData;
+#define glClearNamedBufferData glad_glClearNamedBufferData
+typedef void (APIENTRYP PFNGLCLEARNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLenum internalformat, GLintptr offset, GLsizeiptr size, GLenum format, GLenum type, const void *data);
+GLAPI PFNGLCLEARNAMEDBUFFERSUBDATAPROC glad_glClearNamedBufferSubData;
+#define glClearNamedBufferSubData glad_glClearNamedBufferSubData
+typedef void * (APIENTRYP PFNGLMAPNAMEDBUFFERPROC)(GLuint buffer, GLenum access);
+GLAPI PFNGLMAPNAMEDBUFFERPROC glad_glMapNamedBuffer;
+#define glMapNamedBuffer glad_glMapNamedBuffer
+typedef void * (APIENTRYP PFNGLMAPNAMEDBUFFERRANGEPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length, GLbitfield access);
+GLAPI PFNGLMAPNAMEDBUFFERRANGEPROC glad_glMapNamedBufferRange;
+#define glMapNamedBufferRange glad_glMapNamedBufferRange
+typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFERPROC)(GLuint buffer);
+GLAPI PFNGLUNMAPNAMEDBUFFERPROC glad_glUnmapNamedBuffer;
+#define glUnmapNamedBuffer glad_glUnmapNamedBuffer
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC)(GLuint buffer, GLintptr offset, GLsizeiptr length);
+GLAPI PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glad_glFlushMappedNamedBufferRange;
+#define glFlushMappedNamedBufferRange glad_glFlushMappedNamedBufferRange
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVPROC)(GLuint buffer, GLenum pname, GLint *params);
+GLAPI PFNGLGETNAMEDBUFFERPARAMETERIVPROC glad_glGetNamedBufferParameteriv;
+#define glGetNamedBufferParameteriv glad_glGetNamedBufferParameteriv
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERI64VPROC)(GLuint buffer, GLenum pname, GLint64 *params);
+GLAPI PFNGLGETNAMEDBUFFERPARAMETERI64VPROC glad_glGetNamedBufferParameteri64v;
+#define glGetNamedBufferParameteri64v glad_glGetNamedBufferParameteri64v
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVPROC)(GLuint buffer, GLenum pname, void **params);
+GLAPI PFNGLGETNAMEDBUFFERPOINTERVPROC glad_glGetNamedBufferPointerv;
+#define glGetNamedBufferPointerv glad_glGetNamedBufferPointerv
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAPROC)(GLuint buffer, GLintptr offset, GLsizeiptr size, void *data);
+GLAPI PFNGLGETNAMEDBUFFERSUBDATAPROC glad_glGetNamedBufferSubData;
+#define glGetNamedBufferSubData glad_glGetNamedBufferSubData
+typedef void (APIENTRYP PFNGLCREATEFRAMEBUFFERSPROC)(GLsizei n, GLuint *framebuffers);
+GLAPI PFNGLCREATEFRAMEBUFFERSPROC glad_glCreateFramebuffers;
+#define glCreateFramebuffers glad_glCreateFramebuffers
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC)(GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+GLAPI PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC glad_glNamedFramebufferRenderbuffer;
+#define glNamedFramebufferRenderbuffer glad_glNamedFramebufferRenderbuffer
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC)(GLuint framebuffer, GLenum pname, GLint param);
+GLAPI PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC glad_glNamedFramebufferParameteri;
+#define glNamedFramebufferParameteri glad_glNamedFramebufferParameteri
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREPROC)(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
+GLAPI PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glad_glNamedFramebufferTexture;
+#define glNamedFramebufferTexture glad_glNamedFramebufferTexture
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC)(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
+GLAPI PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC glad_glNamedFramebufferTextureLayer;
+#define glNamedFramebufferTextureLayer glad_glNamedFramebufferTextureLayer
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC)(GLuint framebuffer, GLenum buf);
+GLAPI PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC glad_glNamedFramebufferDrawBuffer;
+#define glNamedFramebufferDrawBuffer glad_glNamedFramebufferDrawBuffer
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC)(GLuint framebuffer, GLsizei n, const GLenum *bufs);
+GLAPI PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC glad_glNamedFramebufferDrawBuffers;
+#define glNamedFramebufferDrawBuffers glad_glNamedFramebufferDrawBuffers
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC)(GLuint framebuffer, GLenum src);
+GLAPI PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC glad_glNamedFramebufferReadBuffer;
+#define glNamedFramebufferReadBuffer glad_glNamedFramebufferReadBuffer
+typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC)(GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments);
+GLAPI PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC glad_glInvalidateNamedFramebufferData;
+#define glInvalidateNamedFramebufferData glad_glInvalidateNamedFramebufferData
+typedef void (APIENTRYP PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC)(GLuint framebuffer, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC glad_glInvalidateNamedFramebufferSubData;
+#define glInvalidateNamedFramebufferSubData glad_glInvalidateNamedFramebufferSubData
+typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERIVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLint *value);
+GLAPI PFNGLCLEARNAMEDFRAMEBUFFERIVPROC glad_glClearNamedFramebufferiv;
+#define glClearNamedFramebufferiv glad_glClearNamedFramebufferiv
+typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLuint *value);
+GLAPI PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC glad_glClearNamedFramebufferuiv;
+#define glClearNamedFramebufferuiv glad_glClearNamedFramebufferuiv
+typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFVPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, const GLfloat *value);
+GLAPI PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glad_glClearNamedFramebufferfv;
+#define glClearNamedFramebufferfv glad_glClearNamedFramebufferfv
+typedef void (APIENTRYP PFNGLCLEARNAMEDFRAMEBUFFERFIPROC)(GLuint framebuffer, GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+GLAPI PFNGLCLEARNAMEDFRAMEBUFFERFIPROC glad_glClearNamedFramebufferfi;
+#define glClearNamedFramebufferfi glad_glClearNamedFramebufferfi
+typedef void (APIENTRYP PFNGLBLITNAMEDFRAMEBUFFERPROC)(GLuint readFramebuffer, GLuint drawFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+GLAPI PFNGLBLITNAMEDFRAMEBUFFERPROC glad_glBlitNamedFramebuffer;
+#define glBlitNamedFramebuffer glad_glBlitNamedFramebuffer
+typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC)(GLuint framebuffer, GLenum target);
+GLAPI PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glad_glCheckNamedFramebufferStatus;
+#define glCheckNamedFramebufferStatus glad_glCheckNamedFramebufferStatus
+typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC)(GLuint framebuffer, GLenum pname, GLint *param);
+GLAPI PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC glad_glGetNamedFramebufferParameteriv;
+#define glGetNamedFramebufferParameteriv glad_glGetNamedFramebufferParameteriv
+typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC)(GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
+GLAPI PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetNamedFramebufferAttachmentParameteriv;
+#define glGetNamedFramebufferAttachmentParameteriv glad_glGetNamedFramebufferAttachmentParameteriv
+typedef void (APIENTRYP PFNGLCREATERENDERBUFFERSPROC)(GLsizei n, GLuint *renderbuffers);
+GLAPI PFNGLCREATERENDERBUFFERSPROC glad_glCreateRenderbuffers;
+#define glCreateRenderbuffers glad_glCreateRenderbuffers
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEPROC)(GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI PFNGLNAMEDRENDERBUFFERSTORAGEPROC glad_glNamedRenderbufferStorage;
+#define glNamedRenderbufferStorage glad_glNamedRenderbufferStorage
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC)(GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glNamedRenderbufferStorageMultisample;
+#define glNamedRenderbufferStorageMultisample glad_glNamedRenderbufferStorageMultisample
+typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC)(GLuint renderbuffer, GLenum pname, GLint *params);
+GLAPI PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC glad_glGetNamedRenderbufferParameteriv;
+#define glGetNamedRenderbufferParameteriv glad_glGetNamedRenderbufferParameteriv
+typedef void (APIENTRYP PFNGLCREATETEXTURESPROC)(GLenum target, GLsizei n, GLuint *textures);
+GLAPI PFNGLCREATETEXTURESPROC glad_glCreateTextures;
+#define glCreateTextures glad_glCreateTextures
+typedef void (APIENTRYP PFNGLTEXTUREBUFFERPROC)(GLuint texture, GLenum internalformat, GLuint buffer);
+GLAPI PFNGLTEXTUREBUFFERPROC glad_glTextureBuffer;
+#define glTextureBuffer glad_glTextureBuffer
+typedef void (APIENTRYP PFNGLTEXTUREBUFFERRANGEPROC)(GLuint texture, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size);
+GLAPI PFNGLTEXTUREBUFFERRANGEPROC glad_glTextureBufferRange;
+#define glTextureBufferRange glad_glTextureBufferRange
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width);
+GLAPI PFNGLTEXTURESTORAGE1DPROC glad_glTextureStorage1D;
+#define glTextureStorage1D glad_glTextureStorage1D
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
+GLAPI PFNGLTEXTURESTORAGE2DPROC glad_glTextureStorage2D;
+#define glTextureStorage2D glad_glTextureStorage2D
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DPROC)(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
+GLAPI PFNGLTEXTURESTORAGE3DPROC glad_glTextureStorage3D;
+#define glTextureStorage3D glad_glTextureStorage3D
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC)(GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
+GLAPI PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC glad_glTextureStorage2DMultisample;
+#define glTextureStorage2DMultisample glad_glTextureStorage2DMultisample
+typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC)(GLuint texture, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
+GLAPI PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC glad_glTextureStorage3DMultisample;
+#define glTextureStorage3DMultisample glad_glTextureStorage3DMultisample
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXTURESUBIMAGE1DPROC glad_glTextureSubImage1D;
+#define glTextureSubImage1D glad_glTextureSubImage1D
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXTURESUBIMAGE2DPROC glad_glTextureSubImage2D;
+#define glTextureSubImage2D glad_glTextureSubImage2D
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels);
+GLAPI PFNGLTEXTURESUBIMAGE3DPROC glad_glTextureSubImage3D;
+#define glTextureSubImage3D glad_glTextureSubImage3D
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC glad_glCompressedTextureSubImage1D;
+#define glCompressedTextureSubImage1D glad_glCompressedTextureSubImage1D
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC glad_glCompressedTextureSubImage2D;
+#define glCompressedTextureSubImage2D glad_glCompressedTextureSubImage2D
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data);
+GLAPI PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC glad_glCompressedTextureSubImage3D;
+#define glCompressedTextureSubImage3D glad_glCompressedTextureSubImage3D
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DPROC)(GLuint texture, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+GLAPI PFNGLCOPYTEXTURESUBIMAGE1DPROC glad_glCopyTextureSubImage1D;
+#define glCopyTextureSubImage1D glad_glCopyTextureSubImage1D
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI PFNGLCOPYTEXTURESUBIMAGE2DPROC glad_glCopyTextureSubImage2D;
+#define glCopyTextureSubImage2D glad_glCopyTextureSubImage2D
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+GLAPI PFNGLCOPYTEXTURESUBIMAGE3DPROC glad_glCopyTextureSubImage3D;
+#define glCopyTextureSubImage3D glad_glCopyTextureSubImage3D
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFPROC)(GLuint texture, GLenum pname, GLfloat param);
+GLAPI PFNGLTEXTUREPARAMETERFPROC glad_glTextureParameterf;
+#define glTextureParameterf glad_glTextureParameterf
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVPROC)(GLuint texture, GLenum pname, const GLfloat *param);
+GLAPI PFNGLTEXTUREPARAMETERFVPROC glad_glTextureParameterfv;
+#define glTextureParameterfv glad_glTextureParameterfv
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIPROC)(GLuint texture, GLenum pname, GLint param);
+GLAPI PFNGLTEXTUREPARAMETERIPROC glad_glTextureParameteri;
+#define glTextureParameteri glad_glTextureParameteri
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVPROC)(GLuint texture, GLenum pname, const GLint *params);
+GLAPI PFNGLTEXTUREPARAMETERIIVPROC glad_glTextureParameterIiv;
+#define glTextureParameterIiv glad_glTextureParameterIiv
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVPROC)(GLuint texture, GLenum pname, const GLuint *params);
+GLAPI PFNGLTEXTUREPARAMETERIUIVPROC glad_glTextureParameterIuiv;
+#define glTextureParameterIuiv glad_glTextureParameterIuiv
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVPROC)(GLuint texture, GLenum pname, const GLint *param);
+GLAPI PFNGLTEXTUREPARAMETERIVPROC glad_glTextureParameteriv;
+#define glTextureParameteriv glad_glTextureParameteriv
+typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPPROC)(GLuint texture);
+GLAPI PFNGLGENERATETEXTUREMIPMAPPROC glad_glGenerateTextureMipmap;
+#define glGenerateTextureMipmap glad_glGenerateTextureMipmap
+typedef void (APIENTRYP PFNGLBINDTEXTUREUNITPROC)(GLuint unit, GLuint texture);
+GLAPI PFNGLBINDTEXTUREUNITPROC glad_glBindTextureUnit;
+#define glBindTextureUnit glad_glBindTextureUnit
+typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEPROC)(GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);
+GLAPI PFNGLGETTEXTUREIMAGEPROC glad_glGetTextureImage;
+#define glGetTextureImage glad_glGetTextureImage
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC)(GLuint texture, GLint level, GLsizei bufSize, void *pixels);
+GLAPI PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC glad_glGetCompressedTextureImage;
+#define glGetCompressedTextureImage glad_glGetCompressedTextureImage
+typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVPROC)(GLuint texture, GLint level, GLenum pname, GLfloat *params);
+GLAPI PFNGLGETTEXTURELEVELPARAMETERFVPROC glad_glGetTextureLevelParameterfv;
+#define glGetTextureLevelParameterfv glad_glGetTextureLevelParameterfv
+typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVPROC)(GLuint texture, GLint level, GLenum pname, GLint *params);
+GLAPI PFNGLGETTEXTURELEVELPARAMETERIVPROC glad_glGetTextureLevelParameteriv;
+#define glGetTextureLevelParameteriv glad_glGetTextureLevelParameteriv
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVPROC)(GLuint texture, GLenum pname, GLfloat *params);
+GLAPI PFNGLGETTEXTUREPARAMETERFVPROC glad_glGetTextureParameterfv;
+#define glGetTextureParameterfv glad_glGetTextureParameterfv
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVPROC)(GLuint texture, GLenum pname, GLint *params);
+GLAPI PFNGLGETTEXTUREPARAMETERIIVPROC glad_glGetTextureParameterIiv;
+#define glGetTextureParameterIiv glad_glGetTextureParameterIiv
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVPROC)(GLuint texture, GLenum pname, GLuint *params);
+GLAPI PFNGLGETTEXTUREPARAMETERIUIVPROC glad_glGetTextureParameterIuiv;
+#define glGetTextureParameterIuiv glad_glGetTextureParameterIuiv
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVPROC)(GLuint texture, GLenum pname, GLint *params);
+GLAPI PFNGLGETTEXTUREPARAMETERIVPROC glad_glGetTextureParameteriv;
+#define glGetTextureParameteriv glad_glGetTextureParameteriv
+typedef void (APIENTRYP PFNGLCREATEVERTEXARRAYSPROC)(GLsizei n, GLuint *arrays);
+GLAPI PFNGLCREATEVERTEXARRAYSPROC glad_glCreateVertexArrays;
+#define glCreateVertexArrays glad_glCreateVertexArrays
+typedef void (APIENTRYP PFNGLDISABLEVERTEXARRAYATTRIBPROC)(GLuint vaobj, GLuint index);
+GLAPI PFNGLDISABLEVERTEXARRAYATTRIBPROC glad_glDisableVertexArrayAttrib;
+#define glDisableVertexArrayAttrib glad_glDisableVertexArrayAttrib
+typedef void (APIENTRYP PFNGLENABLEVERTEXARRAYATTRIBPROC)(GLuint vaobj, GLuint index);
+GLAPI PFNGLENABLEVERTEXARRAYATTRIBPROC glad_glEnableVertexArrayAttrib;
+#define glEnableVertexArrayAttrib glad_glEnableVertexArrayAttrib
+typedef void (APIENTRYP PFNGLVERTEXARRAYELEMENTBUFFERPROC)(GLuint vaobj, GLuint buffer);
+GLAPI PFNGLVERTEXARRAYELEMENTBUFFERPROC glad_glVertexArrayElementBuffer;
+#define glVertexArrayElementBuffer glad_glVertexArrayElementBuffer
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERPROC)(GLuint vaobj, GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride);
+GLAPI PFNGLVERTEXARRAYVERTEXBUFFERPROC glad_glVertexArrayVertexBuffer;
+#define glVertexArrayVertexBuffer glad_glVertexArrayVertexBuffer
+typedef void (APIENTRYP PFNGLVERTEXARRAYVERTEXBUFFERSPROC)(GLuint vaobj, GLuint first, GLsizei count, const GLuint *buffers, const GLintptr *offsets, const GLsizei *strides);
+GLAPI PFNGLVERTEXARRAYVERTEXBUFFERSPROC glad_glVertexArrayVertexBuffers;
+#define glVertexArrayVertexBuffers glad_glVertexArrayVertexBuffers
+typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBBINDINGPROC)(GLuint vaobj, GLuint attribindex, GLuint bindingindex);
+GLAPI PFNGLVERTEXARRAYATTRIBBINDINGPROC glad_glVertexArrayAttribBinding;
+#define glVertexArrayAttribBinding glad_glVertexArrayAttribBinding
+typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset);
+GLAPI PFNGLVERTEXARRAYATTRIBFORMATPROC glad_glVertexArrayAttribFormat;
+#define glVertexArrayAttribFormat glad_glVertexArrayAttribFormat
+typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBIFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI PFNGLVERTEXARRAYATTRIBIFORMATPROC glad_glVertexArrayAttribIFormat;
+#define glVertexArrayAttribIFormat glad_glVertexArrayAttribIFormat
+typedef void (APIENTRYP PFNGLVERTEXARRAYATTRIBLFORMATPROC)(GLuint vaobj, GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset);
+GLAPI PFNGLVERTEXARRAYATTRIBLFORMATPROC glad_glVertexArrayAttribLFormat;
+#define glVertexArrayAttribLFormat glad_glVertexArrayAttribLFormat
+typedef void (APIENTRYP PFNGLVERTEXARRAYBINDINGDIVISORPROC)(GLuint vaobj, GLuint bindingindex, GLuint divisor);
+GLAPI PFNGLVERTEXARRAYBINDINGDIVISORPROC glad_glVertexArrayBindingDivisor;
+#define glVertexArrayBindingDivisor glad_glVertexArrayBindingDivisor
+typedef void (APIENTRYP PFNGLGETVERTEXARRAYIVPROC)(GLuint vaobj, GLenum pname, GLint *param);
+GLAPI PFNGLGETVERTEXARRAYIVPROC glad_glGetVertexArrayiv;
+#define glGetVertexArrayiv glad_glGetVertexArrayiv
+typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXEDIVPROC)(GLuint vaobj, GLuint index, GLenum pname, GLint *param);
+GLAPI PFNGLGETVERTEXARRAYINDEXEDIVPROC glad_glGetVertexArrayIndexediv;
+#define glGetVertexArrayIndexediv glad_glGetVertexArrayIndexediv
+typedef void (APIENTRYP PFNGLGETVERTEXARRAYINDEXED64IVPROC)(GLuint vaobj, GLuint index, GLenum pname, GLint64 *param);
+GLAPI PFNGLGETVERTEXARRAYINDEXED64IVPROC glad_glGetVertexArrayIndexed64iv;
+#define glGetVertexArrayIndexed64iv glad_glGetVertexArrayIndexed64iv
+typedef void (APIENTRYP PFNGLCREATESAMPLERSPROC)(GLsizei n, GLuint *samplers);
+GLAPI PFNGLCREATESAMPLERSPROC glad_glCreateSamplers;
+#define glCreateSamplers glad_glCreateSamplers
+typedef void (APIENTRYP PFNGLCREATEPROGRAMPIPELINESPROC)(GLsizei n, GLuint *pipelines);
+GLAPI PFNGLCREATEPROGRAMPIPELINESPROC glad_glCreateProgramPipelines;
+#define glCreateProgramPipelines glad_glCreateProgramPipelines
+typedef void (APIENTRYP PFNGLCREATEQUERIESPROC)(GLenum target, GLsizei n, GLuint *ids);
+GLAPI PFNGLCREATEQUERIESPROC glad_glCreateQueries;
+#define glCreateQueries glad_glCreateQueries
+typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTI64VPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);
+GLAPI PFNGLGETQUERYBUFFEROBJECTI64VPROC glad_glGetQueryBufferObjecti64v;
+#define glGetQueryBufferObjecti64v glad_glGetQueryBufferObjecti64v
+typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTIVPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);
+GLAPI PFNGLGETQUERYBUFFEROBJECTIVPROC glad_glGetQueryBufferObjectiv;
+#define glGetQueryBufferObjectiv glad_glGetQueryBufferObjectiv
+typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUI64VPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);
+GLAPI PFNGLGETQUERYBUFFEROBJECTUI64VPROC glad_glGetQueryBufferObjectui64v;
+#define glGetQueryBufferObjectui64v glad_glGetQueryBufferObjectui64v
+typedef void (APIENTRYP PFNGLGETQUERYBUFFEROBJECTUIVPROC)(GLuint id, GLuint buffer, GLenum pname, GLintptr offset);
+GLAPI PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_glGetQueryBufferObjectuiv;
+#define glGetQueryBufferObjectuiv glad_glGetQueryBufferObjectuiv
+typedef void (APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC)(GLbitfield barriers);
+GLAPI PFNGLMEMORYBARRIERBYREGIONPROC glad_glMemoryBarrierByRegion;
+#define glMemoryBarrierByRegion glad_glMemoryBarrierByRegion
+typedef void (APIENTRYP PFNGLGETTEXTURESUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLsizei bufSize, void *pixels);
+GLAPI PFNGLGETTEXTURESUBIMAGEPROC glad_glGetTextureSubImage;
+#define glGetTextureSubImage glad_glGetTextureSubImage
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei bufSize, void *pixels);
+GLAPI PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC glad_glGetCompressedTextureSubImage;
+#define glGetCompressedTextureSubImage glad_glGetCompressedTextureSubImage
+typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC)(void);
+GLAPI PFNGLGETGRAPHICSRESETSTATUSPROC glad_glGetGraphicsResetStatus;
+#define glGetGraphicsResetStatus glad_glGetGraphicsResetStatus
+typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEPROC)(GLenum target, GLint lod, GLsizei bufSize, void *pixels);
+GLAPI PFNGLGETNCOMPRESSEDTEXIMAGEPROC glad_glGetnCompressedTexImage;
+#define glGetnCompressedTexImage glad_glGetnCompressedTexImage
+typedef void (APIENTRYP PFNGLGETNTEXIMAGEPROC)(GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels);
+GLAPI PFNGLGETNTEXIMAGEPROC glad_glGetnTexImage;
+#define glGetnTexImage glad_glGetnTexImage
+typedef void (APIENTRYP PFNGLGETNUNIFORMDVPROC)(GLuint program, GLint location, GLsizei bufSize, GLdouble *params);
+GLAPI PFNGLGETNUNIFORMDVPROC glad_glGetnUniformdv;
+#define glGetnUniformdv glad_glGetnUniformdv
+typedef void (APIENTRYP PFNGLGETNUNIFORMFVPROC)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
+GLAPI PFNGLGETNUNIFORMFVPROC glad_glGetnUniformfv;
+#define glGetnUniformfv glad_glGetnUniformfv
+typedef void (APIENTRYP PFNGLGETNUNIFORMIVPROC)(GLuint program, GLint location, GLsizei bufSize, GLint *params);
+GLAPI PFNGLGETNUNIFORMIVPROC glad_glGetnUniformiv;
+#define glGetnUniformiv glad_glGetnUniformiv
+typedef void (APIENTRYP PFNGLGETNUNIFORMUIVPROC)(GLuint program, GLint location, GLsizei bufSize, GLuint *params);
+GLAPI PFNGLGETNUNIFORMUIVPROC glad_glGetnUniformuiv;
+#define glGetnUniformuiv glad_glGetnUniformuiv
+typedef void (APIENTRYP PFNGLREADNPIXELSPROC)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data);
+GLAPI PFNGLREADNPIXELSPROC glad_glReadnPixels;
+#define glReadnPixels glad_glReadnPixels
+typedef void (APIENTRYP PFNGLGETNMAPDVPROC)(GLenum target, GLenum query, GLsizei bufSize, GLdouble *v);
+GLAPI PFNGLGETNMAPDVPROC glad_glGetnMapdv;
+#define glGetnMapdv glad_glGetnMapdv
+typedef void (APIENTRYP PFNGLGETNMAPFVPROC)(GLenum target, GLenum query, GLsizei bufSize, GLfloat *v);
+GLAPI PFNGLGETNMAPFVPROC glad_glGetnMapfv;
+#define glGetnMapfv glad_glGetnMapfv
+typedef void (APIENTRYP PFNGLGETNMAPIVPROC)(GLenum target, GLenum query, GLsizei bufSize, GLint *v);
+GLAPI PFNGLGETNMAPIVPROC glad_glGetnMapiv;
+#define glGetnMapiv glad_glGetnMapiv
+typedef void (APIENTRYP PFNGLGETNPIXELMAPFVPROC)(GLenum map, GLsizei bufSize, GLfloat *values);
+GLAPI PFNGLGETNPIXELMAPFVPROC glad_glGetnPixelMapfv;
+#define glGetnPixelMapfv glad_glGetnPixelMapfv
+typedef void (APIENTRYP PFNGLGETNPIXELMAPUIVPROC)(GLenum map, GLsizei bufSize, GLuint *values);
+GLAPI PFNGLGETNPIXELMAPUIVPROC glad_glGetnPixelMapuiv;
+#define glGetnPixelMapuiv glad_glGetnPixelMapuiv
+typedef void (APIENTRYP PFNGLGETNPIXELMAPUSVPROC)(GLenum map, GLsizei bufSize, GLushort *values);
+GLAPI PFNGLGETNPIXELMAPUSVPROC glad_glGetnPixelMapusv;
+#define glGetnPixelMapusv glad_glGetnPixelMapusv
+typedef void (APIENTRYP PFNGLGETNPOLYGONSTIPPLEPROC)(GLsizei bufSize, GLubyte *pattern);
+GLAPI PFNGLGETNPOLYGONSTIPPLEPROC glad_glGetnPolygonStipple;
+#define glGetnPolygonStipple glad_glGetnPolygonStipple
+typedef void (APIENTRYP PFNGLGETNCOLORTABLEPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *table);
+GLAPI PFNGLGETNCOLORTABLEPROC glad_glGetnColorTable;
+#define glGetnColorTable glad_glGetnColorTable
+typedef void (APIENTRYP PFNGLGETNCONVOLUTIONFILTERPROC)(GLenum target, GLenum format, GLenum type, GLsizei bufSize, void *image);
+GLAPI PFNGLGETNCONVOLUTIONFILTERPROC glad_glGetnConvolutionFilter;
+#define glGetnConvolutionFilter glad_glGetnConvolutionFilter
+typedef void (APIENTRYP PFNGLGETNSEPARABLEFILTERPROC)(GLenum target, GLenum format, GLenum type, GLsizei rowBufSize, void *row, GLsizei columnBufSize, void *column, void *span);
+GLAPI PFNGLGETNSEPARABLEFILTERPROC glad_glGetnSeparableFilter;
+#define glGetnSeparableFilter glad_glGetnSeparableFilter
+typedef void (APIENTRYP PFNGLGETNHISTOGRAMPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);
+GLAPI PFNGLGETNHISTOGRAMPROC glad_glGetnHistogram;
+#define glGetnHistogram glad_glGetnHistogram
+typedef void (APIENTRYP PFNGLGETNMINMAXPROC)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLsizei bufSize, void *values);
+GLAPI PFNGLGETNMINMAXPROC glad_glGetnMinmax;
+#define glGetnMinmax glad_glGetnMinmax
+typedef void (APIENTRYP PFNGLTEXTUREBARRIERPROC)(void);
+GLAPI PFNGLTEXTUREBARRIERPROC glad_glTextureBarrier;
+#define glTextureBarrier glad_glTextureBarrier
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/chromium/third_party/dawn/third_party/glad/src/glad.c b/chromium/third_party/dawn/third_party/glad/src/glad.c
new file mode 100644
index 00000000000..60e128fd0af
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/glad/src/glad.c
@@ -0,0 +1,1814 @@
+/*
+
+ OpenGL loader generated by glad 0.1.26 on Wed Aug 1 16:13:04 2018.
+
+ Language/Generator: C/C++
+ Specification: gl
+ APIs: gl=4.5
+ Profile: core
+ Extensions:
+
+ Loader: True
+ Local files: False
+ Omit khrplatform: False
+
+ Commandline:
+ --profile="core" --api="gl=4.5" --generator="c" --spec="gl" --extensions=""
+ Online:
+ http://glad.dav1d.de/#profile=core&language=c&specification=gl&loader=on&api=gl%3D4.5
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glad/glad.h>
+
+static void* get_proc(const char *namez);
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+#include <windows.h>
+static HMODULE libGL;
+
+typedef void* (APIENTRYP PFNWGLGETPROCADDRESSPROC_PRIVATE)(const char*);
+static PFNWGLGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
+
+#ifdef _MSC_VER
+#ifdef __has_include
+ #if __has_include(<winapifamily.h>)
+ #define HAVE_WINAPIFAMILY 1
+ #endif
+#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
+ #define HAVE_WINAPIFAMILY 1
+#endif
+#endif
+
+#ifdef HAVE_WINAPIFAMILY
+ #include <winapifamily.h>
+ #if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+ #define IS_UWP 1
+ #endif
+#endif
+
+static
+int open_gl(void) {
+#ifndef IS_UWP
+ libGL = LoadLibraryW(L"opengl32.dll");
+ if(libGL != NULL) {
+ void (* tmp)(void);
+ tmp = (void(*)(void)) GetProcAddress(libGL, "wglGetProcAddress");
+ gladGetProcAddressPtr = (PFNWGLGETPROCADDRESSPROC_PRIVATE) tmp;
+ return gladGetProcAddressPtr != NULL;
+ }
+#endif
+
+ return 0;
+}
+
+static
+void close_gl(void) {
+ if(libGL != NULL) {
+ FreeLibrary((HMODULE) libGL);
+ libGL = NULL;
+ }
+}
+#else
+#include <dlfcn.h>
+static void* libGL;
+
+#ifndef __APPLE__
+typedef void* (APIENTRYP PFNGLXGETPROCADDRESSPROC_PRIVATE)(const char*);
+static PFNGLXGETPROCADDRESSPROC_PRIVATE gladGetProcAddressPtr;
+#endif
+
+static
+int open_gl(void) {
+#ifdef __APPLE__
+ static const char *NAMES[] = {
+ "../Frameworks/OpenGL.framework/OpenGL",
+ "/Library/Frameworks/OpenGL.framework/OpenGL",
+ "/System/Library/Frameworks/OpenGL.framework/OpenGL",
+ "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL"
+ };
+#else
+ static const char *NAMES[] = {"libGL.so.1", "libGL.so"};
+#endif
+
+ unsigned int index = 0;
+ for(index = 0; index < (sizeof(NAMES) / sizeof(NAMES[0])); index++) {
+ libGL = dlopen(NAMES[index], RTLD_NOW | RTLD_GLOBAL);
+
+ if(libGL != NULL) {
+#ifdef __APPLE__
+ return 1;
+#else
+ gladGetProcAddressPtr = (PFNGLXGETPROCADDRESSPROC_PRIVATE)dlsym(libGL,
+ "glXGetProcAddressARB");
+ return gladGetProcAddressPtr != NULL;
+#endif
+ }
+ }
+
+ return 0;
+}
+
+static
+void close_gl(void) {
+ if(libGL != NULL) {
+ dlclose(libGL);
+ libGL = NULL;
+ }
+}
+#endif
+
+static
+void* get_proc(const char *namez) {
+ void* result = NULL;
+ if(libGL == NULL) return NULL;
+
+#ifndef __APPLE__
+ if(gladGetProcAddressPtr != NULL) {
+ result = gladGetProcAddressPtr(namez);
+ }
+#endif
+ if(result == NULL) {
+#if defined(_WIN32) || defined(__CYGWIN__)
+ result = (void*)GetProcAddress((HMODULE) libGL, namez);
+#else
+ result = dlsym(libGL, namez);
+#endif
+ }
+
+ return result;
+}
+
+int gladLoadGL(void) {
+ int status = 0;
+
+ if(open_gl()) {
+ status = gladLoadGLLoader(&get_proc);
+ close_gl();
+ }
+
+ return status;
+}
+
+struct gladGLversionStruct GLVersion = { 0, 0 };
+
+#if defined(GL_ES_VERSION_3_0) || defined(GL_VERSION_3_0)
+#define _GLAD_IS_SOME_NEW_VERSION 1
+#endif
+
+static int max_loaded_major;
+static int max_loaded_minor;
+
+static const char *exts = NULL;
+static int num_exts_i = 0;
+static char **exts_i = NULL;
+
+static int get_exts(void) {
+#ifdef _GLAD_IS_SOME_NEW_VERSION
+ if(max_loaded_major < 3) {
+#endif
+ exts = (const char *)glGetString(GL_EXTENSIONS);
+#ifdef _GLAD_IS_SOME_NEW_VERSION
+ } else {
+ unsigned int index;
+
+ num_exts_i = 0;
+ glGetIntegerv(GL_NUM_EXTENSIONS, &num_exts_i);
+ if (num_exts_i > 0) {
+ exts_i = (char **)realloc((void *)exts_i, (size_t)num_exts_i * (sizeof *exts_i));
+ }
+
+ if (exts_i == NULL) {
+ return 0;
+ }
+
+ for(index = 0; index < (unsigned)num_exts_i; index++) {
+ const char *gl_str_tmp = (const char*)glGetStringi(GL_EXTENSIONS, index);
+ size_t len = strlen(gl_str_tmp);
+
+ char *local_str = (char*)malloc((len+1) * sizeof(char));
+ if(local_str != NULL) {
+ memcpy(local_str, gl_str_tmp, (len+1) * sizeof(char));
+ }
+ exts_i[index] = local_str;
+ }
+ }
+#endif
+ return 1;
+}
+
+static void free_exts(void) {
+ if (exts_i != NULL) {
+ int index;
+ for(index = 0; index < num_exts_i; index++) {
+ free((char *)exts_i[index]);
+ }
+ free((void *)exts_i);
+ exts_i = NULL;
+ }
+}
+
+static int has_ext(const char *ext) {
+#ifdef _GLAD_IS_SOME_NEW_VERSION
+ if(max_loaded_major < 3) {
+#endif
+ const char *extensions;
+ const char *loc;
+ const char *terminator;
+ extensions = exts;
+ if(extensions == NULL || ext == NULL) {
+ return 0;
+ }
+
+ while(1) {
+ loc = strstr(extensions, ext);
+ if(loc == NULL) {
+ return 0;
+ }
+
+ terminator = loc + strlen(ext);
+ if((loc == extensions || *(loc - 1) == ' ') &&
+ (*terminator == ' ' || *terminator == '\0')) {
+ return 1;
+ }
+ extensions = terminator;
+ }
+#ifdef _GLAD_IS_SOME_NEW_VERSION
+ } else {
+ int index;
+ if(exts_i == NULL) return 0;
+ for(index = 0; index < num_exts_i; index++) {
+ const char *e = exts_i[index];
+
+ if(exts_i[index] != NULL && strcmp(e, ext) == 0) {
+ return 1;
+ }
+ }
+ }
+#endif
+
+ return 0;
+}
+int GLAD_GL_VERSION_1_0 = 0;
+int GLAD_GL_VERSION_1_1 = 0;
+int GLAD_GL_VERSION_1_2 = 0;
+int GLAD_GL_VERSION_1_3 = 0;
+int GLAD_GL_VERSION_1_4 = 0;
+int GLAD_GL_VERSION_1_5 = 0;
+int GLAD_GL_VERSION_2_0 = 0;
+int GLAD_GL_VERSION_2_1 = 0;
+int GLAD_GL_VERSION_3_0 = 0;
+int GLAD_GL_VERSION_3_1 = 0;
+int GLAD_GL_VERSION_3_2 = 0;
+int GLAD_GL_VERSION_3_3 = 0;
+int GLAD_GL_VERSION_4_0 = 0;
+int GLAD_GL_VERSION_4_1 = 0;
+int GLAD_GL_VERSION_4_2 = 0;
+int GLAD_GL_VERSION_4_3 = 0;
+int GLAD_GL_VERSION_4_4 = 0;
+int GLAD_GL_VERSION_4_5 = 0;
+PFNGLCOPYTEXIMAGE1DPROC glad_glCopyTexImage1D = NULL;
+PFNGLVERTEXATTRIBI3UIPROC glad_glVertexAttribI3ui = NULL;
+PFNGLVERTEXARRAYELEMENTBUFFERPROC glad_glVertexArrayElementBuffer = NULL;
+PFNGLSTENCILMASKSEPARATEPROC glad_glStencilMaskSeparate = NULL;
+PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC glad_glTextureStorage3DMultisample = NULL;
+PFNGLTEXTUREPARAMETERFVPROC glad_glTextureParameterfv = NULL;
+PFNGLMINSAMPLESHADINGPROC glad_glMinSampleShading = NULL;
+PFNGLFRAMEBUFFERRENDERBUFFERPROC glad_glFramebufferRenderbuffer = NULL;
+PFNGLUNIFORMSUBROUTINESUIVPROC glad_glUniformSubroutinesuiv = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC glad_glCompressedTexSubImage3D = NULL;
+PFNGLTEXCOORDP3UIVPROC glad_glTexCoordP3uiv = NULL;
+PFNGLGETDOUBLEI_VPROC glad_glGetDoublei_v = NULL;
+PFNGLVERTEXATTRIB1SVPROC glad_glVertexAttrib1sv = NULL;
+PFNGLVERTEXARRAYVERTEXBUFFERSPROC glad_glVertexArrayVertexBuffers = NULL;
+PFNGLBINDSAMPLERPROC glad_glBindSampler = NULL;
+PFNGLLINEWIDTHPROC glad_glLineWidth = NULL;
+PFNGLCOLORP3UIVPROC glad_glColorP3uiv = NULL;
+PFNGLGETINTEGERI_VPROC glad_glGetIntegeri_v = NULL;
+PFNGLCOMPILESHADERPROC glad_glCompileShader = NULL;
+PFNGLGETTRANSFORMFEEDBACKVARYINGPROC glad_glGetTransformFeedbackVarying = NULL;
+PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC glad_glCompressedTextureSubImage3D = NULL;
+PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC glad_glGetCompressedTextureImage = NULL;
+PFNGLGETNMAPFVPROC glad_glGetnMapfv = NULL;
+PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC glad_glTransformFeedbackBufferRange = NULL;
+PFNGLGETTEXTUREIMAGEPROC glad_glGetTextureImage = NULL;
+PFNGLDEPTHRANGEFPROC glad_glDepthRangef = NULL;
+PFNGLVERTEXATTRIBIPOINTERPROC glad_glVertexAttribIPointer = NULL;
+PFNGLMULTITEXCOORDP3UIPROC glad_glMultiTexCoordP3ui = NULL;
+PFNGLGETNAMEDBUFFERPARAMETERIVPROC glad_glGetNamedBufferParameteriv = NULL;
+PFNGLVERTEXP4UIPROC glad_glVertexP4ui = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC glad_glDrawElementsInstancedBaseInstance = NULL;
+PFNGLENABLEIPROC glad_glEnablei = NULL;
+PFNGLVERTEXATTRIBP4UIPROC glad_glVertexAttribP4ui = NULL;
+PFNGLCREATESHADERPROC glad_glCreateShader = NULL;
+PFNGLISBUFFERPROC glad_glIsBuffer = NULL;
+PFNGLGETMULTISAMPLEFVPROC glad_glGetMultisamplefv = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2DVPROC glad_glProgramUniformMatrix2dv = NULL;
+PFNGLGENRENDERBUFFERSPROC glad_glGenRenderbuffers = NULL;
+PFNGLCOPYTEXSUBIMAGE2DPROC glad_glCopyTexSubImage2D = NULL;
+PFNGLCOMPRESSEDTEXIMAGE2DPROC glad_glCompressedTexImage2D = NULL;
+PFNGLVERTEXATTRIB1FPROC glad_glVertexAttrib1f = NULL;
+PFNGLBLENDFUNCSEPARATEPROC glad_glBlendFuncSeparate = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4FVPROC glad_glProgramUniformMatrix4fv = NULL;
+PFNGLCLEARNAMEDFRAMEBUFFERFIPROC glad_glClearNamedFramebufferfi = NULL;
+PFNGLGETQUERYBUFFEROBJECTUIVPROC glad_glGetQueryBufferObjectuiv = NULL;
+PFNGLHINTPROC glad_glHint = NULL;
+PFNGLVERTEXATTRIB1SPROC glad_glVertexAttrib1s = NULL;
+PFNGLSAMPLEMASKIPROC glad_glSampleMaski = NULL;
+PFNGLVERTEXP2UIPROC glad_glVertexP2ui = NULL;
+PFNGLUNIFORMMATRIX3X2FVPROC glad_glUniformMatrix3x2fv = NULL;
+PFNGLDEBUGMESSAGECONTROLPROC glad_glDebugMessageControl = NULL;
+PFNGLPOINTSIZEPROC glad_glPointSize = NULL;
+PFNGLBINDTEXTUREUNITPROC glad_glBindTextureUnit = NULL;
+PFNGLVERTEXATTRIB2DVPROC glad_glVertexAttrib2dv = NULL;
+PFNGLDELETEPROGRAMPROC glad_glDeleteProgram = NULL;
+PFNGLVERTEXATTRIB4NUIVPROC glad_glVertexAttrib4Nuiv = NULL;
+PFNGLTEXSTORAGE2DPROC glad_glTexStorage2D = NULL;
+PFNGLRENDERBUFFERSTORAGEPROC glad_glRenderbufferStorage = NULL;
+PFNGLWAITSYNCPROC glad_glWaitSync = NULL;
+PFNGLUNIFORMMATRIX4X3FVPROC glad_glUniformMatrix4x3fv = NULL;
+PFNGLUNIFORM3IPROC glad_glUniform3i = NULL;
+PFNGLCLEARBUFFERFVPROC glad_glClearBufferfv = NULL;
+PFNGLPROGRAMUNIFORM1UIPROC glad_glProgramUniform1ui = NULL;
+PFNGLBLENDEQUATIONSEPARATEIPROC glad_glBlendEquationSeparatei = NULL;
+PFNGLGETNMAPIVPROC glad_glGetnMapiv = NULL;
+PFNGLTEXTUREBARRIERPROC glad_glTextureBarrier = NULL;
+PFNGLUNIFORM3DPROC glad_glUniform3d = NULL;
+PFNGLUNIFORM3FPROC glad_glUniform3f = NULL;
+PFNGLVERTEXATTRIB4UBVPROC glad_glVertexAttrib4ubv = NULL;
+PFNGLGETBUFFERPARAMETERIVPROC glad_glGetBufferParameteriv = NULL;
+PFNGLTEXCOORDP2UIPROC glad_glTexCoordP2ui = NULL;
+PFNGLCOLORMASKIPROC glad_glColorMaski = NULL;
+PFNGLCLEARBUFFERFIPROC glad_glClearBufferfi = NULL;
+PFNGLDRAWARRAYSINDIRECTPROC glad_glDrawArraysIndirect = NULL;
+PFNGLGENVERTEXARRAYSPROC glad_glGenVertexArrays = NULL;
+PFNGLPAUSETRANSFORMFEEDBACKPROC glad_glPauseTransformFeedback = NULL;
+PFNGLMULTITEXCOORDP2UIPROC glad_glMultiTexCoordP2ui = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC glad_glProgramUniformMatrix3x2dv = NULL;
+PFNGLCOPYNAMEDBUFFERSUBDATAPROC glad_glCopyNamedBufferSubData = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC glad_glProgramUniformMatrix3x2fv = NULL;
+PFNGLGETSAMPLERPARAMETERIIVPROC glad_glGetSamplerParameterIiv = NULL;
+PFNGLGETFRAGDATAINDEXPROC glad_glGetFragDataIndex = NULL;
+PFNGLVERTEXATTRIBL4DPROC glad_glVertexAttribL4d = NULL;
+PFNGLBINDIMAGETEXTUREPROC glad_glBindImageTexture = NULL;
+PFNGLTEXTUREPARAMETERIVPROC glad_glTextureParameteriv = NULL;
+PFNGLGETQUERYBUFFEROBJECTI64VPROC glad_glGetQueryBufferObjecti64v = NULL;
+PFNGLGETVERTEXATTRIBDVPROC glad_glGetVertexAttribdv = NULL;
+PFNGLACTIVESHADERPROGRAMPROC glad_glActiveShaderProgram = NULL;
+PFNGLUNIFORMMATRIX3X4FVPROC glad_glUniformMatrix3x4fv = NULL;
+PFNGLUNIFORMMATRIX3DVPROC glad_glUniformMatrix3dv = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC glad_glProgramUniformMatrix3x4dv = NULL;
+PFNGLNAMEDFRAMEBUFFERTEXTUREPROC glad_glNamedFramebufferTexture = NULL;
+PFNGLGETTEXTUREPARAMETERFVPROC glad_glGetTextureParameterfv = NULL;
+PFNGLINVALIDATEBUFFERSUBDATAPROC glad_glInvalidateBufferSubData = NULL;
+PFNGLRESUMETRANSFORMFEEDBACKPROC glad_glResumeTransformFeedback = NULL;
+PFNGLMULTITEXCOORDP4UIPROC glad_glMultiTexCoordP4ui = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC glad_glProgramUniformMatrix4x3fv = NULL;
+PFNGLVIEWPORTARRAYVPROC glad_glViewportArrayv = NULL;
+PFNGLDELETEFRAMEBUFFERSPROC glad_glDeleteFramebuffers = NULL;
+PFNGLDRAWARRAYSPROC glad_glDrawArrays = NULL;
+PFNGLUNIFORM1UIPROC glad_glUniform1ui = NULL;
+PFNGLPROGRAMUNIFORM2UIVPROC glad_glProgramUniform2uiv = NULL;
+PFNGLVERTEXATTRIBI2IPROC glad_glVertexAttribI2i = NULL;
+PFNGLTEXCOORDP3UIPROC glad_glTexCoordP3ui = NULL;
+PFNGLVERTEXATTRIB3DPROC glad_glVertexAttrib3d = NULL;
+PFNGLCLEARPROC glad_glClear = NULL;
+PFNGLPROGRAMPARAMETERIPROC glad_glProgramParameteri = NULL;
+PFNGLGETACTIVEUNIFORMNAMEPROC glad_glGetActiveUniformName = NULL;
+PFNGLMEMORYBARRIERPROC glad_glMemoryBarrier = NULL;
+PFNGLGETGRAPHICSRESETSTATUSPROC glad_glGetGraphicsResetStatus = NULL;
+PFNGLISENABLEDPROC glad_glIsEnabled = NULL;
+PFNGLSTENCILOPPROC glad_glStencilOp = NULL;
+PFNGLFRAMEBUFFERTEXTURE2DPROC glad_glFramebufferTexture2D = NULL;
+PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetFramebufferAttachmentParameteriv = NULL;
+PFNGLVERTEXATTRIB4NUBPROC glad_glVertexAttrib4Nub = NULL;
+PFNGLMAPNAMEDBUFFERRANGEPROC glad_glMapNamedBufferRange = NULL;
+PFNGLGETFRAGDATALOCATIONPROC glad_glGetFragDataLocation = NULL;
+PFNGLGETTEXTUREPARAMETERIIVPROC glad_glGetTextureParameterIiv = NULL;
+PFNGLTEXIMAGE1DPROC glad_glTexImage1D = NULL;
+PFNGLTEXPARAMETERIVPROC glad_glTexParameteriv = NULL;
+PFNGLVERTEXARRAYATTRIBIFORMATPROC glad_glVertexArrayAttribIFormat = NULL;
+PFNGLVERTEXARRAYVERTEXBUFFERPROC glad_glVertexArrayVertexBuffer = NULL;
+PFNGLGETTEXIMAGEPROC glad_glGetTexImage = NULL;
+PFNGLGETQUERYOBJECTI64VPROC glad_glGetQueryObjecti64v = NULL;
+PFNGLGENFRAMEBUFFERSPROC glad_glGenFramebuffers = NULL;
+PFNGLCREATETEXTURESPROC glad_glCreateTextures = NULL;
+PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC glad_glTransformFeedbackBufferBase = NULL;
+PFNGLCLEARTEXSUBIMAGEPROC glad_glClearTexSubImage = NULL;
+PFNGLGETATTACHEDSHADERSPROC glad_glGetAttachedShaders = NULL;
+PFNGLISRENDERBUFFERPROC glad_glIsRenderbuffer = NULL;
+PFNGLDELETEVERTEXARRAYSPROC glad_glDeleteVertexArrays = NULL;
+PFNGLBINDVERTEXBUFFERSPROC glad_glBindVertexBuffers = NULL;
+PFNGLPROGRAMUNIFORM1UIVPROC glad_glProgramUniform1uiv = NULL;
+PFNGLISVERTEXARRAYPROC glad_glIsVertexArray = NULL;
+PFNGLDISABLEVERTEXATTRIBARRAYPROC glad_glDisableVertexAttribArray = NULL;
+PFNGLPROGRAMUNIFORM2IVPROC glad_glProgramUniform2iv = NULL;
+PFNGLGETQUERYIVPROC glad_glGetQueryiv = NULL;
+PFNGLGETTRANSFORMFEEDBACKIVPROC glad_glGetTransformFeedbackiv = NULL;
+PFNGLBLITNAMEDFRAMEBUFFERPROC glad_glBlitNamedFramebuffer = NULL;
+PFNGLVERTEXARRAYATTRIBLFORMATPROC glad_glVertexArrayAttribLFormat = NULL;
+PFNGLCREATEQUERIESPROC glad_glCreateQueries = NULL;
+PFNGLGETSAMPLERPARAMETERFVPROC glad_glGetSamplerParameterfv = NULL;
+PFNGLSHADERSTORAGEBLOCKBINDINGPROC glad_glShaderStorageBlockBinding = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC glad_glProgramUniformMatrix4x2dv = NULL;
+PFNGLGETUNIFORMINDICESPROC glad_glGetUniformIndices = NULL;
+PFNGLISSHADERPROC glad_glIsShader = NULL;
+PFNGLVERTEXATTRIBI4UBVPROC glad_glVertexAttribI4ubv = NULL;
+PFNGLBEGINQUERYINDEXEDPROC glad_glBeginQueryIndexed = NULL;
+PFNGLPOINTPARAMETERIVPROC glad_glPointParameteriv = NULL;
+PFNGLENABLEPROC glad_glEnable = NULL;
+PFNGLGETACTIVEUNIFORMSIVPROC glad_glGetActiveUniformsiv = NULL;
+PFNGLVERTEXARRAYATTRIBBINDINGPROC glad_glVertexArrayAttribBinding = NULL;
+PFNGLTEXTURESTORAGE1DPROC glad_glTextureStorage1D = NULL;
+PFNGLMEMORYBARRIERBYREGIONPROC glad_glMemoryBarrierByRegion = NULL;
+PFNGLBLENDEQUATIONIPROC glad_glBlendEquationi = NULL;
+PFNGLGETATTRIBLOCATIONPROC glad_glGetAttribLocation = NULL;
+PFNGLVERTEXATTRIB4DVPROC glad_glVertexAttrib4dv = NULL;
+PFNGLGETTEXTUREPARAMETERIVPROC glad_glGetTextureParameteriv = NULL;
+PFNGLGETPROGRAMINTERFACEIVPROC glad_glGetProgramInterfaceiv = NULL;
+PFNGLUNIFORM2DVPROC glad_glUniform2dv = NULL;
+PFNGLMAPNAMEDBUFFERPROC glad_glMapNamedBuffer = NULL;
+PFNGLMULTITEXCOORDP3UIVPROC glad_glMultiTexCoordP3uiv = NULL;
+PFNGLVERTEXATTRIBP3UIPROC glad_glVertexAttribP3ui = NULL;
+PFNGLVERTEXATTRIBL1DVPROC glad_glVertexAttribL1dv = NULL;
+PFNGLTEXTUREBUFFERRANGEPROC glad_glTextureBufferRange = NULL;
+PFNGLGETNUNIFORMDVPROC glad_glGetnUniformdv = NULL;
+PFNGLPROGRAMUNIFORM3UIPROC glad_glProgramUniform3ui = NULL;
+PFNGLGETPOINTERVPROC glad_glGetPointerv = NULL;
+PFNGLVERTEXBINDINGDIVISORPROC glad_glVertexBindingDivisor = NULL;
+PFNGLGETUNIFORMFVPROC glad_glGetUniformfv = NULL;
+PFNGLGETUNIFORMUIVPROC glad_glGetUniformuiv = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC glad_glProgramUniformMatrix2x3fv = NULL;
+PFNGLGETVERTEXATTRIBIIVPROC glad_glGetVertexAttribIiv = NULL;
+PFNGLVERTEXARRAYBINDINGDIVISORPROC glad_glVertexArrayBindingDivisor = NULL;
+PFNGLDRAWBUFFERPROC glad_glDrawBuffer = NULL;
+PFNGLENDQUERYINDEXEDPROC glad_glEndQueryIndexed = NULL;
+PFNGLGETNPIXELMAPUSVPROC glad_glGetnPixelMapusv = NULL;
+PFNGLCLEARBUFFERUIVPROC glad_glClearBufferuiv = NULL;
+PFNGLDRAWELEMENTSINSTANCEDPROC glad_glDrawElementsInstanced = NULL;
+PFNGLPROGRAMUNIFORM1IPROC glad_glProgramUniform1i = NULL;
+PFNGLPATCHPARAMETERIPROC glad_glPatchParameteri = NULL;
+PFNGLPROGRAMUNIFORM1DPROC glad_glProgramUniform1d = NULL;
+PFNGLPROGRAMUNIFORM1FPROC glad_glProgramUniform1f = NULL;
+PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC glad_glGetNamedFramebufferParameteriv = NULL;
+PFNGLFLUSHPROC glad_glFlush = NULL;
+PFNGLGETRENDERBUFFERPARAMETERIVPROC glad_glGetRenderbufferParameteriv = NULL;
+PFNGLPROGRAMUNIFORM3IVPROC glad_glProgramUniform3iv = NULL;
+PFNGLGETDEBUGMESSAGELOGPROC glad_glGetDebugMessageLog = NULL;
+PFNGLNAMEDRENDERBUFFERSTORAGEPROC glad_glNamedRenderbufferStorage = NULL;
+PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC glad_glGetNamedFramebufferAttachmentParameteriv = NULL;
+PFNGLGETVERTEXATTRIBPOINTERVPROC glad_glGetVertexAttribPointerv = NULL;
+PFNGLFENCESYNCPROC glad_glFenceSync = NULL;
+PFNGLCOLORP3UIPROC glad_glColorP3ui = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC glad_glDrawElementsInstancedBaseVertexBaseInstance = NULL;
+PFNGLVERTEXATTRIB3SVPROC glad_glVertexAttrib3sv = NULL;
+PFNGLBEGINCONDITIONALRENDERPROC glad_glBeginConditionalRender = NULL;
+PFNGLVALIDATEPROGRAMPIPELINEPROC glad_glValidateProgramPipeline = NULL;
+PFNGLGETNMINMAXPROC glad_glGetnMinmax = NULL;
+PFNGLGETTEXLEVELPARAMETERIVPROC glad_glGetTexLevelParameteriv = NULL;
+PFNGLMULTITEXCOORDP4UIVPROC glad_glMultiTexCoordP4uiv = NULL;
+PFNGLTEXSTORAGE3DMULTISAMPLEPROC glad_glTexStorage3DMultisample = NULL;
+PFNGLSTENCILFUNCSEPARATEPROC glad_glStencilFuncSeparate = NULL;
+PFNGLDISABLEVERTEXARRAYATTRIBPROC glad_glDisableVertexArrayAttrib = NULL;
+PFNGLGENSAMPLERSPROC glad_glGenSamplers = NULL;
+PFNGLCLAMPCOLORPROC glad_glClampColor = NULL;
+PFNGLUNIFORM4IVPROC glad_glUniform4iv = NULL;
+PFNGLCLEARSTENCILPROC glad_glClearStencil = NULL;
+PFNGLTEXCOORDP1UIVPROC glad_glTexCoordP1uiv = NULL;
+PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC glad_glGetNamedRenderbufferParameteriv = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC glad_glDrawTransformFeedbackInstanced = NULL;
+PFNGLGENTEXTURESPROC glad_glGenTextures = NULL;
+PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC glad_glTextureStorage2DMultisample = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKPROC glad_glDrawTransformFeedback = NULL;
+PFNGLUNIFORM1DVPROC glad_glUniform1dv = NULL;
+PFNGLGETTEXPARAMETERIUIVPROC glad_glGetTexParameterIuiv = NULL;
+PFNGLGETTRANSFORMFEEDBACKI_VPROC glad_glGetTransformFeedbacki_v = NULL;
+PFNGLVERTEXATTRIB4NBVPROC glad_glVertexAttrib4Nbv = NULL;
+PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC glad_glClearNamedFramebufferuiv = NULL;
+PFNGLISSYNCPROC glad_glIsSync = NULL;
+PFNGLCLEARNAMEDFRAMEBUFFERIVPROC glad_glClearNamedFramebufferiv = NULL;
+PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC glad_glGetActiveUniformBlockName = NULL;
+PFNGLUNIFORM2IPROC glad_glUniform2i = NULL;
+PFNGLUNIFORM2FPROC glad_glUniform2f = NULL;
+PFNGLUNIFORM2DPROC glad_glUniform2d = NULL;
+PFNGLTEXCOORDP4UIPROC glad_glTexCoordP4ui = NULL;
+PFNGLGETPROGRAMIVPROC glad_glGetProgramiv = NULL;
+PFNGLVERTEXATTRIBPOINTERPROC glad_glVertexAttribPointer = NULL;
+PFNGLFRAMEBUFFERTEXTURELAYERPROC glad_glFramebufferTextureLayer = NULL;
+PFNGLPROGRAMUNIFORM4FVPROC glad_glProgramUniform4fv = NULL;
+PFNGLGETOBJECTPTRLABELPROC glad_glGetObjectPtrLabel = NULL;
+PFNGLTEXTUREPARAMETERIPROC glad_glTextureParameteri = NULL;
+PFNGLTEXTUREPARAMETERFPROC glad_glTextureParameterf = NULL;
+PFNGLFLUSHMAPPEDBUFFERRANGEPROC glad_glFlushMappedBufferRange = NULL;
+PFNGLPROGRAMUNIFORM2FVPROC glad_glProgramUniform2fv = NULL;
+PFNGLUNIFORMMATRIX2X3DVPROC glad_glUniformMatrix2x3dv = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4DVPROC glad_glProgramUniformMatrix4dv = NULL;
+PFNGLVERTEXATTRIBL3DPROC glad_glVertexAttribL3d = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC glad_glProgramUniformMatrix2x4dv = NULL;
+PFNGLDISPATCHCOMPUTEPROC glad_glDispatchCompute = NULL;
+PFNGLGENQUERIESPROC glad_glGenQueries = NULL;
+PFNGLVERTEXATTRIBP1UIPROC glad_glVertexAttribP1ui = NULL;
+PFNGLTEXSUBIMAGE3DPROC glad_glTexSubImage3D = NULL;
+PFNGLGETINTEGER64I_VPROC glad_glGetInteger64i_v = NULL;
+PFNGLDELETESAMPLERSPROC glad_glDeleteSamplers = NULL;
+PFNGLCOPYTEXIMAGE2DPROC glad_glCopyTexImage2D = NULL;
+PFNGLGETTEXTURESUBIMAGEPROC glad_glGetTextureSubImage = NULL;
+PFNGLBLITFRAMEBUFFERPROC glad_glBlitFramebuffer = NULL;
+PFNGLISENABLEDIPROC glad_glIsEnabledi = NULL;
+PFNGLBINDBUFFERSRANGEPROC glad_glBindBuffersRange = NULL;
+PFNGLSECONDARYCOLORP3UIPROC glad_glSecondaryColorP3ui = NULL;
+PFNGLBINDFRAGDATALOCATIONINDEXEDPROC glad_glBindFragDataLocationIndexed = NULL;
+PFNGLCOPYIMAGESUBDATAPROC glad_glCopyImageSubData = NULL;
+PFNGLUNIFORM2IVPROC glad_glUniform2iv = NULL;
+PFNGLVERTEXATTRIB1FVPROC glad_glVertexAttrib1fv = NULL;
+PFNGLUNIFORM4UIVPROC glad_glUniform4uiv = NULL;
+PFNGLPROGRAMUNIFORM2DVPROC glad_glProgramUniform2dv = NULL;
+PFNGLTEXTURESUBIMAGE3DPROC glad_glTextureSubImage3D = NULL;
+PFNGLFRAMEBUFFERTEXTURE1DPROC glad_glFramebufferTexture1D = NULL;
+PFNGLGETSHADERIVPROC glad_glGetShaderiv = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3FVPROC glad_glProgramUniformMatrix3fv = NULL;
+PFNGLOBJECTPTRLABELPROC glad_glObjectPtrLabel = NULL;
+PFNGLINVALIDATEFRAMEBUFFERPROC glad_glInvalidateFramebuffer = NULL;
+PFNGLBINDTEXTURESPROC glad_glBindTextures = NULL;
+PFNGLBINDFRAGDATALOCATIONPROC glad_glBindFragDataLocation = NULL;
+PFNGLNAMEDBUFFERSTORAGEPROC glad_glNamedBufferStorage = NULL;
+PFNGLSCISSORARRAYVPROC glad_glScissorArrayv = NULL;
+PFNGLPOLYGONOFFSETPROC glad_glPolygonOffset = NULL;
+PFNGLGETDOUBLEVPROC glad_glGetDoublev = NULL;
+PFNGLVERTEXATTRIB1DPROC glad_glVertexAttrib1d = NULL;
+PFNGLUNIFORM4DVPROC glad_glUniform4dv = NULL;
+PFNGLPROGRAMUNIFORM3DVPROC glad_glProgramUniform3dv = NULL;
+PFNGLGETUNIFORMIVPROC glad_glGetUniformiv = NULL;
+PFNGLINVALIDATEBUFFERDATAPROC glad_glInvalidateBufferData = NULL;
+PFNGLGETNCOLORTABLEPROC glad_glGetnColorTable = NULL;
+PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC glad_glCompressedTextureSubImage1D = NULL;
+PFNGLMULTITEXCOORDP1UIVPROC glad_glMultiTexCoordP1uiv = NULL;
+PFNGLUNIFORM3FVPROC glad_glUniform3fv = NULL;
+PFNGLMULTIDRAWELEMENTSINDIRECTPROC glad_glMultiDrawElementsIndirect = NULL;
+PFNGLDEPTHRANGEPROC glad_glDepthRange = NULL;
+PFNGLINVALIDATESUBFRAMEBUFFERPROC glad_glInvalidateSubFramebuffer = NULL;
+PFNGLMAPBUFFERPROC glad_glMapBuffer = NULL;
+PFNGLCLEARTEXIMAGEPROC glad_glClearTexImage = NULL;
+PFNGLVERTEXATTRIBLFORMATPROC glad_glVertexAttribLFormat = NULL;
+PFNGLCOMPRESSEDTEXIMAGE3DPROC glad_glCompressedTexImage3D = NULL;
+PFNGLDELETESYNCPROC glad_glDeleteSync = NULL;
+PFNGLCOPYTEXSUBIMAGE3DPROC glad_glCopyTexSubImage3D = NULL;
+PFNGLGETTRANSFORMFEEDBACKI64_VPROC glad_glGetTransformFeedbacki64_v = NULL;
+PFNGLUNIFORMMATRIX4DVPROC glad_glUniformMatrix4dv = NULL;
+PFNGLGETVERTEXATTRIBIVPROC glad_glGetVertexAttribiv = NULL;
+PFNGLUNIFORMMATRIX4X2DVPROC glad_glUniformMatrix4x2dv = NULL;
+PFNGLMULTIDRAWELEMENTSPROC glad_glMultiDrawElements = NULL;
+PFNGLVERTEXATTRIB3FVPROC glad_glVertexAttrib3fv = NULL;
+PFNGLUNIFORM3IVPROC glad_glUniform3iv = NULL;
+PFNGLPOLYGONMODEPROC glad_glPolygonMode = NULL;
+PFNGLDRAWBUFFERSPROC glad_glDrawBuffers = NULL;
+PFNGLGETNHISTOGRAMPROC glad_glGetnHistogram = NULL;
+PFNGLGETACTIVEUNIFORMBLOCKIVPROC glad_glGetActiveUniformBlockiv = NULL;
+PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC glad_glNamedFramebufferReadBuffer = NULL;
+PFNGLPROGRAMUNIFORM4IVPROC glad_glProgramUniform4iv = NULL;
+PFNGLGETPROGRAMBINARYPROC glad_glGetProgramBinary = NULL;
+PFNGLUSEPROGRAMPROC glad_glUseProgram = NULL;
+PFNGLGETPROGRAMINFOLOGPROC glad_glGetProgramInfoLog = NULL;
+PFNGLBINDTRANSFORMFEEDBACKPROC glad_glBindTransformFeedback = NULL;
+PFNGLBINDVERTEXARRAYPROC glad_glBindVertexArray = NULL;
+PFNGLDELETEBUFFERSPROC glad_glDeleteBuffers = NULL;
+PFNGLGENERATETEXTUREMIPMAPPROC glad_glGenerateTextureMipmap = NULL;
+PFNGLSAMPLERPARAMETERIIVPROC glad_glSamplerParameterIiv = NULL;
+PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC glad_glMultiDrawElementsBaseVertex = NULL;
+PFNGLNAMEDBUFFERSUBDATAPROC glad_glNamedBufferSubData = NULL;
+PFNGLTEXTURESTORAGE2DPROC glad_glTextureStorage2D = NULL;
+PFNGLGETNCONVOLUTIONFILTERPROC glad_glGetnConvolutionFilter = NULL;
+PFNGLUNIFORM2UIVPROC glad_glUniform2uiv = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC glad_glCompressedTexSubImage1D = NULL;
+PFNGLFINISHPROC glad_glFinish = NULL;
+PFNGLDEPTHRANGEINDEXEDPROC glad_glDepthRangeIndexed = NULL;
+PFNGLDELETESHADERPROC glad_glDeleteShader = NULL;
+PFNGLGETINTERNALFORMATI64VPROC glad_glGetInternalformati64v = NULL;
+PFNGLCOPYTEXTURESUBIMAGE1DPROC glad_glCopyTextureSubImage1D = NULL;
+PFNGLPUSHDEBUGGROUPPROC glad_glPushDebugGroup = NULL;
+PFNGLVERTEXATTRIB4NSVPROC glad_glVertexAttrib4Nsv = NULL;
+PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC glad_glGetProgramResourceLocationIndex = NULL;
+PFNGLTEXTUREPARAMETERIUIVPROC glad_glTextureParameterIuiv = NULL;
+PFNGLVIEWPORTPROC glad_glViewport = NULL;
+PFNGLUNIFORM1UIVPROC glad_glUniform1uiv = NULL;
+PFNGLTRANSFORMFEEDBACKVARYINGSPROC glad_glTransformFeedbackVaryings = NULL;
+PFNGLUNIFORM2UIPROC glad_glUniform2ui = NULL;
+PFNGLGETNMAPDVPROC glad_glGetnMapdv = NULL;
+PFNGLDEBUGMESSAGECALLBACKPROC glad_glDebugMessageCallback = NULL;
+PFNGLVERTEXATTRIBI3IPROC glad_glVertexAttribI3i = NULL;
+PFNGLINVALIDATETEXIMAGEPROC glad_glInvalidateTexImage = NULL;
+PFNGLVERTEXATTRIBFORMATPROC glad_glVertexAttribFormat = NULL;
+PFNGLCLEARDEPTHPROC glad_glClearDepth = NULL;
+PFNGLVERTEXATTRIBI4USVPROC glad_glVertexAttribI4usv = NULL;
+PFNGLTEXPARAMETERFPROC glad_glTexParameterf = NULL;
+PFNGLVERTEXATTRIBBINDINGPROC glad_glVertexAttribBinding = NULL;
+PFNGLTEXPARAMETERIPROC glad_glTexParameteri = NULL;
+PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC glad_glGetActiveSubroutineUniformiv = NULL;
+PFNGLGETSHADERSOURCEPROC glad_glGetShaderSource = NULL;
+PFNGLGETNTEXIMAGEPROC glad_glGetnTexImage = NULL;
+PFNGLTEXBUFFERPROC glad_glTexBuffer = NULL;
+PFNGLPIXELSTOREIPROC glad_glPixelStorei = NULL;
+PFNGLVALIDATEPROGRAMPROC glad_glValidateProgram = NULL;
+PFNGLPIXELSTOREFPROC glad_glPixelStoref = NULL;
+PFNGLCREATEBUFFERSPROC glad_glCreateBuffers = NULL;
+PFNGLGETBOOLEANI_VPROC glad_glGetBooleani_v = NULL;
+PFNGLCLIPCONTROLPROC glad_glClipControl = NULL;
+PFNGLMULTITEXCOORDP2UIVPROC glad_glMultiTexCoordP2uiv = NULL;
+PFNGLGENPROGRAMPIPELINESPROC glad_glGenProgramPipelines = NULL;
+PFNGLGETINTERNALFORMATIVPROC glad_glGetInternalformativ = NULL;
+PFNGLCOPYTEXTURESUBIMAGE3DPROC glad_glCopyTextureSubImage3D = NULL;
+PFNGLVERTEXATTRIBP1UIVPROC glad_glVertexAttribP1uiv = NULL;
+PFNGLLINKPROGRAMPROC glad_glLinkProgram = NULL;
+PFNGLBINDTEXTUREPROC glad_glBindTexture = NULL;
+PFNGLMULTIDRAWARRAYSINDIRECTPROC glad_glMultiDrawArraysIndirect = NULL;
+PFNGLGETOBJECTLABELPROC glad_glGetObjectLabel = NULL;
+PFNGLGETPROGRAMPIPELINEINFOLOGPROC glad_glGetProgramPipelineInfoLog = NULL;
+PFNGLGETSTRINGPROC glad_glGetString = NULL;
+PFNGLVERTEXATTRIBP2UIVPROC glad_glVertexAttribP2uiv = NULL;
+PFNGLDETACHSHADERPROC glad_glDetachShader = NULL;
+PFNGLPROGRAMUNIFORM3IPROC glad_glProgramUniform3i = NULL;
+PFNGLUNIFORMMATRIX3X4DVPROC glad_glUniformMatrix3x4dv = NULL;
+PFNGLENDQUERYPROC glad_glEndQuery = NULL;
+PFNGLNORMALP3UIPROC glad_glNormalP3ui = NULL;
+PFNGLFRAMEBUFFERPARAMETERIPROC glad_glFramebufferParameteri = NULL;
+PFNGLGETPROGRAMRESOURCENAMEPROC glad_glGetProgramResourceName = NULL;
+PFNGLUNIFORMMATRIX4X3DVPROC glad_glUniformMatrix4x3dv = NULL;
+PFNGLDEPTHRANGEARRAYVPROC glad_glDepthRangeArrayv = NULL;
+PFNGLVERTEXATTRIBI2UIPROC glad_glVertexAttribI2ui = NULL;
+PFNGLGETPROGRAMRESOURCELOCATIONPROC glad_glGetProgramResourceLocation = NULL;
+PFNGLDELETETEXTURESPROC glad_glDeleteTextures = NULL;
+PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC glad_glGetActiveAtomicCounterBufferiv = NULL;
+PFNGLSTENCILOPSEPARATEPROC glad_glStencilOpSeparate = NULL;
+PFNGLDELETEQUERIESPROC glad_glDeleteQueries = NULL;
+PFNGLNORMALP3UIVPROC glad_glNormalP3uiv = NULL;
+PFNGLVERTEXATTRIB4FPROC glad_glVertexAttrib4f = NULL;
+PFNGLVERTEXATTRIB4DPROC glad_glVertexAttrib4d = NULL;
+PFNGLVIEWPORTINDEXEDFVPROC glad_glViewportIndexedfv = NULL;
+PFNGLBINDBUFFERSBASEPROC glad_glBindBuffersBase = NULL;
+PFNGLVERTEXATTRIBL4DVPROC glad_glVertexAttribL4dv = NULL;
+PFNGLGETTEXPARAMETERIVPROC glad_glGetTexParameteriv = NULL;
+PFNGLCREATEVERTEXARRAYSPROC glad_glCreateVertexArrays = NULL;
+PFNGLPROGRAMUNIFORM1DVPROC glad_glProgramUniform1dv = NULL;
+PFNGLVERTEXATTRIB4SPROC glad_glVertexAttrib4s = NULL;
+PFNGLDRAWELEMENTSBASEVERTEXPROC glad_glDrawElementsBaseVertex = NULL;
+PFNGLSAMPLECOVERAGEPROC glad_glSampleCoverage = NULL;
+PFNGLSAMPLERPARAMETERIPROC glad_glSamplerParameteri = NULL;
+PFNGLCLEARBUFFERSUBDATAPROC glad_glClearBufferSubData = NULL;
+PFNGLSAMPLERPARAMETERFPROC glad_glSamplerParameterf = NULL;
+PFNGLTEXSTORAGE1DPROC glad_glTexStorage1D = NULL;
+PFNGLUNIFORM1FPROC glad_glUniform1f = NULL;
+PFNGLGETVERTEXATTRIBFVPROC glad_glGetVertexAttribfv = NULL;
+PFNGLUNIFORM1DPROC glad_glUniform1d = NULL;
+PFNGLGETCOMPRESSEDTEXIMAGEPROC glad_glGetCompressedTexImage = NULL;
+PFNGLGETNCOMPRESSEDTEXIMAGEPROC glad_glGetnCompressedTexImage = NULL;
+PFNGLUNIFORM1IPROC glad_glUniform1i = NULL;
+PFNGLGETACTIVEATTRIBPROC glad_glGetActiveAttrib = NULL;
+PFNGLTEXSUBIMAGE2DPROC glad_glTexSubImage2D = NULL;
+PFNGLDISABLEPROC glad_glDisable = NULL;
+PFNGLLOGICOPPROC glad_glLogicOp = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC glad_glProgramUniformMatrix3x4fv = NULL;
+PFNGLGETTEXTUREPARAMETERIUIVPROC glad_glGetTextureParameterIuiv = NULL;
+PFNGLPROGRAMUNIFORM4UIVPROC glad_glProgramUniform4uiv = NULL;
+PFNGLUNIFORM4UIPROC glad_glUniform4ui = NULL;
+PFNGLCOPYTEXTURESUBIMAGE2DPROC glad_glCopyTextureSubImage2D = NULL;
+PFNGLBINDFRAMEBUFFERPROC glad_glBindFramebuffer = NULL;
+PFNGLCULLFACEPROC glad_glCullFace = NULL;
+PFNGLPROGRAMUNIFORM4IPROC glad_glProgramUniform4i = NULL;
+PFNGLPROGRAMUNIFORM4FPROC glad_glProgramUniform4f = NULL;
+PFNGLVIEWPORTINDEXEDFPROC glad_glViewportIndexedf = NULL;
+PFNGLPROGRAMUNIFORM4DPROC glad_glProgramUniform4d = NULL;
+PFNGLTEXTUREPARAMETERIIVPROC glad_glTextureParameterIiv = NULL;
+PFNGLGETSTRINGIPROC glad_glGetStringi = NULL;
+PFNGLTEXTURESUBIMAGE2DPROC glad_glTextureSubImage2D = NULL;
+PFNGLSCISSORINDEXEDPROC glad_glScissorIndexed = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC glad_glDrawTransformFeedbackStream = NULL;
+PFNGLATTACHSHADERPROC glad_glAttachShader = NULL;
+PFNGLQUERYCOUNTERPROC glad_glQueryCounter = NULL;
+PFNGLPROVOKINGVERTEXPROC glad_glProvokingVertex = NULL;
+PFNGLSHADERBINARYPROC glad_glShaderBinary = NULL;
+PFNGLUNMAPNAMEDBUFFERPROC glad_glUnmapNamedBuffer = NULL;
+PFNGLDRAWELEMENTSPROC glad_glDrawElements = NULL;
+PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glNamedRenderbufferStorageMultisample = NULL;
+PFNGLVERTEXATTRIBI4SVPROC glad_glVertexAttribI4sv = NULL;
+PFNGLCLEARNAMEDBUFFERDATAPROC glad_glClearNamedBufferData = NULL;
+PFNGLUNIFORM1IVPROC glad_glUniform1iv = NULL;
+PFNGLCREATESHADERPROGRAMVPROC glad_glCreateShaderProgramv = NULL;
+PFNGLGETQUERYOBJECTIVPROC glad_glGetQueryObjectiv = NULL;
+PFNGLREADBUFFERPROC glad_glReadBuffer = NULL;
+PFNGLTEXPARAMETERIUIVPROC glad_glTexParameterIuiv = NULL;
+PFNGLDRAWARRAYSINSTANCEDPROC glad_glDrawArraysInstanced = NULL;
+PFNGLGENERATEMIPMAPPROC glad_glGenerateMipmap = NULL;
+PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC glad_glCompressedTextureSubImage2D = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2FVPROC glad_glProgramUniformMatrix2fv = NULL;
+PFNGLSAMPLERPARAMETERIVPROC glad_glSamplerParameteriv = NULL;
+PFNGLVERTEXATTRIB3FPROC glad_glVertexAttrib3f = NULL;
+PFNGLVERTEXATTRIB4UIVPROC glad_glVertexAttrib4uiv = NULL;
+PFNGLPOINTPARAMETERIPROC glad_glPointParameteri = NULL;
+PFNGLBLENDCOLORPROC glad_glBlendColor = NULL;
+PFNGLSAMPLERPARAMETERIUIVPROC glad_glSamplerParameterIuiv = NULL;
+PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC glad_glCheckNamedFramebufferStatus = NULL;
+PFNGLUNMAPBUFFERPROC glad_glUnmapBuffer = NULL;
+PFNGLPOINTPARAMETERFPROC glad_glPointParameterf = NULL;
+PFNGLPROGRAMUNIFORM1IVPROC glad_glProgramUniform1iv = NULL;
+PFNGLGETVERTEXARRAYIVPROC glad_glGetVertexArrayiv = NULL;
+PFNGLVERTEXATTRIB3SPROC glad_glVertexAttrib3s = NULL;
+PFNGLBINDRENDERBUFFERPROC glad_glBindRenderbuffer = NULL;
+PFNGLVERTEXATTRIBP4UIVPROC glad_glVertexAttribP4uiv = NULL;
+PFNGLGETPROGRAMSTAGEIVPROC glad_glGetProgramStageiv = NULL;
+PFNGLISPROGRAMPROC glad_glIsProgram = NULL;
+PFNGLVERTEXATTRIB4BVPROC glad_glVertexAttrib4bv = NULL;
+PFNGLTEXTURESTORAGE3DPROC glad_glTextureStorage3D = NULL;
+PFNGLUNIFORMMATRIX3X2DVPROC glad_glUniformMatrix3x2dv = NULL;
+PFNGLVERTEXATTRIB4FVPROC glad_glVertexAttrib4fv = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC glad_glProgramUniformMatrix2x3dv = NULL;
+PFNGLISTRANSFORMFEEDBACKPROC glad_glIsTransformFeedback = NULL;
+PFNGLUNIFORM4IPROC glad_glUniform4i = NULL;
+PFNGLACTIVETEXTUREPROC glad_glActiveTexture = NULL;
+PFNGLENABLEVERTEXATTRIBARRAYPROC glad_glEnableVertexAttribArray = NULL;
+PFNGLISPROGRAMPIPELINEPROC glad_glIsProgramPipeline = NULL;
+PFNGLREADPIXELSPROC glad_glReadPixels = NULL;
+PFNGLVERTEXATTRIBI3IVPROC glad_glVertexAttribI3iv = NULL;
+PFNGLUNIFORM4FPROC glad_glUniform4f = NULL;
+PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC glad_glRenderbufferStorageMultisample = NULL;
+PFNGLCREATEPROGRAMPIPELINESPROC glad_glCreateProgramPipelines = NULL;
+PFNGLUNIFORMMATRIX3FVPROC glad_glUniformMatrix3fv = NULL;
+PFNGLVERTEXATTRIBLPOINTERPROC glad_glVertexAttribLPointer = NULL;
+PFNGLGETNUNIFORMFVPROC glad_glGetnUniformfv = NULL;
+PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glad_glDrawElementsInstancedBaseVertex = NULL;
+PFNGLVERTEXATTRIBL2DVPROC glad_glVertexAttribL2dv = NULL;
+PFNGLENABLEVERTEXARRAYATTRIBPROC glad_glEnableVertexArrayAttrib = NULL;
+PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC glad_glDrawTransformFeedbackStreamInstanced = NULL;
+PFNGLGETACTIVESUBROUTINENAMEPROC glad_glGetActiveSubroutineName = NULL;
+PFNGLVERTEXATTRIBL2DPROC glad_glVertexAttribL2d = NULL;
+PFNGLSTENCILFUNCPROC glad_glStencilFunc = NULL;
+PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC glad_glInvalidateNamedFramebufferData = NULL;
+PFNGLPOPDEBUGGROUPPROC glad_glPopDebugGroup = NULL;
+PFNGLUNIFORMBLOCKBINDINGPROC glad_glUniformBlockBinding = NULL;
+PFNGLGETVERTEXARRAYINDEXEDIVPROC glad_glGetVertexArrayIndexediv = NULL;
+PFNGLCOLORP4UIPROC glad_glColorP4ui = NULL;
+PFNGLUSEPROGRAMSTAGESPROC glad_glUseProgramStages = NULL;
+PFNGLPROGRAMUNIFORM3FPROC glad_glProgramUniform3f = NULL;
+PFNGLPROGRAMUNIFORM3DPROC glad_glProgramUniform3d = NULL;
+PFNGLVERTEXATTRIBI4IVPROC glad_glVertexAttribI4iv = NULL;
+PFNGLGETPROGRAMPIPELINEIVPROC glad_glGetProgramPipelineiv = NULL;
+PFNGLTEXSTORAGE3DPROC glad_glTexStorage3D = NULL;
+PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC glad_glNamedFramebufferDrawBuffer = NULL;
+PFNGLGETQUERYINDEXEDIVPROC glad_glGetQueryIndexediv = NULL;
+PFNGLGETSHADERINFOLOGPROC glad_glGetShaderInfoLog = NULL;
+PFNGLOBJECTLABELPROC glad_glObjectLabel = NULL;
+PFNGLVERTEXATTRIBI4IPROC glad_glVertexAttribI4i = NULL;
+PFNGLGETBUFFERSUBDATAPROC glad_glGetBufferSubData = NULL;
+PFNGLGETVERTEXATTRIBLDVPROC glad_glGetVertexAttribLdv = NULL;
+PFNGLGETNUNIFORMUIVPROC glad_glGetnUniformuiv = NULL;
+PFNGLGETQUERYBUFFEROBJECTIVPROC glad_glGetQueryBufferObjectiv = NULL;
+PFNGLBLENDEQUATIONSEPARATEPROC glad_glBlendEquationSeparate = NULL;
+PFNGLVERTEXATTRIBI1UIPROC glad_glVertexAttribI1ui = NULL;
+PFNGLGENBUFFERSPROC glad_glGenBuffers = NULL;
+PFNGLGETSUBROUTINEINDEXPROC glad_glGetSubroutineIndex = NULL;
+PFNGLVERTEXATTRIB2SVPROC glad_glVertexAttrib2sv = NULL;
+PFNGLGETNPOLYGONSTIPPLEPROC glad_glGetnPolygonStipple = NULL;
+PFNGLBLENDFUNCPROC glad_glBlendFunc = NULL;
+PFNGLCREATEPROGRAMPROC glad_glCreateProgram = NULL;
+PFNGLTEXIMAGE3DPROC glad_glTexImage3D = NULL;
+PFNGLISFRAMEBUFFERPROC glad_glIsFramebuffer = NULL;
+PFNGLCLEARNAMEDFRAMEBUFFERFVPROC glad_glClearNamedFramebufferfv = NULL;
+PFNGLGETNAMEDBUFFERSUBDATAPROC glad_glGetNamedBufferSubData = NULL;
+PFNGLPRIMITIVERESTARTINDEXPROC glad_glPrimitiveRestartIndex = NULL;
+PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC glad_glFlushMappedNamedBufferRange = NULL;
+PFNGLINVALIDATETEXSUBIMAGEPROC glad_glInvalidateTexSubImage = NULL;
+PFNGLBINDIMAGETEXTURESPROC glad_glBindImageTextures = NULL;
+PFNGLGETINTEGER64VPROC glad_glGetInteger64v = NULL;
+PFNGLBINDPROGRAMPIPELINEPROC glad_glBindProgramPipeline = NULL;
+PFNGLSCISSORPROC glad_glScissor = NULL;
+PFNGLTEXCOORDP4UIVPROC glad_glTexCoordP4uiv = NULL;
+PFNGLGETBOOLEANVPROC glad_glGetBooleanv = NULL;
+PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC glad_glNamedFramebufferRenderbuffer = NULL;
+PFNGLVERTEXP2UIVPROC glad_glVertexP2uiv = NULL;
+PFNGLUNIFORM3UIVPROC glad_glUniform3uiv = NULL;
+PFNGLCLEARCOLORPROC glad_glClearColor = NULL;
+PFNGLVERTEXATTRIB4NIVPROC glad_glVertexAttrib4Niv = NULL;
+PFNGLCLEARBUFFERIVPROC glad_glClearBufferiv = NULL;
+PFNGLGETBUFFERPARAMETERI64VPROC glad_glGetBufferParameteri64v = NULL;
+PFNGLPROGRAMUNIFORM4DVPROC glad_glProgramUniform4dv = NULL;
+PFNGLCOLORP4UIVPROC glad_glColorP4uiv = NULL;
+PFNGLGETTEXTURELEVELPARAMETERIVPROC glad_glGetTextureLevelParameteriv = NULL;
+PFNGLGETNUNIFORMIVPROC glad_glGetnUniformiv = NULL;
+PFNGLVERTEXATTRIBI2UIVPROC glad_glVertexAttribI2uiv = NULL;
+PFNGLUNIFORM3UIPROC glad_glUniform3ui = NULL;
+PFNGLPROGRAMUNIFORM3UIVPROC glad_glProgramUniform3uiv = NULL;
+PFNGLVERTEXATTRIBI4UIVPROC glad_glVertexAttribI4uiv = NULL;
+PFNGLPOINTPARAMETERFVPROC glad_glPointParameterfv = NULL;
+PFNGLUNIFORM2FVPROC glad_glUniform2fv = NULL;
+PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC glad_glGetActiveSubroutineUniformName = NULL;
+PFNGLGETPROGRAMRESOURCEINDEXPROC glad_glGetProgramResourceIndex = NULL;
+PFNGLDRAWELEMENTSINDIRECTPROC glad_glDrawElementsIndirect = NULL;
+PFNGLGETTEXTURELEVELPARAMETERFVPROC glad_glGetTextureLevelParameterfv = NULL;
+PFNGLGETNAMEDBUFFERPOINTERVPROC glad_glGetNamedBufferPointerv = NULL;
+PFNGLDISPATCHCOMPUTEINDIRECTPROC glad_glDispatchComputeIndirect = NULL;
+PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC glad_glInvalidateNamedFramebufferSubData = NULL;
+PFNGLGETSAMPLERPARAMETERIUIVPROC glad_glGetSamplerParameterIuiv = NULL;
+PFNGLBINDBUFFERRANGEPROC glad_glBindBufferRange = NULL;
+PFNGLTEXTURESUBIMAGE1DPROC glad_glTextureSubImage1D = NULL;
+PFNGLVERTEXATTRIBL3DVPROC glad_glVertexAttribL3dv = NULL;
+PFNGLGETUNIFORMDVPROC glad_glGetUniformdv = NULL;
+PFNGLGETQUERYBUFFEROBJECTUI64VPROC glad_glGetQueryBufferObjectui64v = NULL;
+PFNGLCLEARDEPTHFPROC glad_glClearDepthf = NULL;
+PFNGLCREATERENDERBUFFERSPROC glad_glCreateRenderbuffers = NULL;
+PFNGLUNIFORMMATRIX2X3FVPROC glad_glUniformMatrix2x3fv = NULL;
+PFNGLGENTRANSFORMFEEDBACKSPROC glad_glGenTransformFeedbacks = NULL;
+PFNGLGETVERTEXATTRIBIUIVPROC glad_glGetVertexAttribIuiv = NULL;
+PFNGLVERTEXATTRIB4NUSVPROC glad_glVertexAttrib4Nusv = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC glad_glProgramUniformMatrix4x3dv = NULL;
+PFNGLDEPTHFUNCPROC glad_glDepthFunc = NULL;
+PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC glad_glCompressedTexSubImage2D = NULL;
+PFNGLPROGRAMBINARYPROC glad_glProgramBinary = NULL;
+PFNGLVERTEXATTRIBI4BVPROC glad_glVertexAttribI4bv = NULL;
+PFNGLGETTEXPARAMETERFVPROC glad_glGetTexParameterfv = NULL;
+PFNGLMULTITEXCOORDP1UIPROC glad_glMultiTexCoordP1ui = NULL;
+PFNGLBUFFERSTORAGEPROC glad_glBufferStorage = NULL;
+PFNGLCLIENTWAITSYNCPROC glad_glClientWaitSync = NULL;
+PFNGLVERTEXATTRIBI4UIPROC glad_glVertexAttribI4ui = NULL;
+PFNGLGETFLOATI_VPROC glad_glGetFloati_v = NULL;
+PFNGLCOLORMASKPROC glad_glColorMask = NULL;
+PFNGLTEXTUREBUFFERPROC glad_glTextureBuffer = NULL;
+PFNGLTEXPARAMETERIIVPROC glad_glTexParameterIiv = NULL;
+PFNGLBLENDEQUATIONPROC glad_glBlendEquation = NULL;
+PFNGLGETUNIFORMLOCATIONPROC glad_glGetUniformLocation = NULL;
+PFNGLUNIFORMMATRIX2X4DVPROC glad_glUniformMatrix2x4dv = NULL;
+PFNGLVERTEXARRAYATTRIBFORMATPROC glad_glVertexArrayAttribFormat = NULL;
+PFNGLREADNPIXELSPROC glad_glReadnPixels = NULL;
+PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC glad_glNamedFramebufferDrawBuffers = NULL;
+PFNGLENDTRANSFORMFEEDBACKPROC glad_glEndTransformFeedback = NULL;
+PFNGLVERTEXATTRIB4USVPROC glad_glVertexAttrib4usv = NULL;
+PFNGLGETUNIFORMSUBROUTINEUIVPROC glad_glGetUniformSubroutineuiv = NULL;
+PFNGLUNIFORM4FVPROC glad_glUniform4fv = NULL;
+PFNGLBINDVERTEXBUFFERPROC glad_glBindVertexBuffer = NULL;
+PFNGLDEBUGMESSAGEINSERTPROC glad_glDebugMessageInsert = NULL;
+PFNGLCREATESAMPLERSPROC glad_glCreateSamplers = NULL;
+PFNGLGETPROGRAMRESOURCEIVPROC glad_glGetProgramResourceiv = NULL;
+PFNGLCLEARBUFFERDATAPROC glad_glClearBufferData = NULL;
+PFNGLBEGINTRANSFORMFEEDBACKPROC glad_glBeginTransformFeedback = NULL;
+PFNGLVERTEXATTRIBI1IVPROC glad_glVertexAttribI1iv = NULL;
+PFNGLISSAMPLERPROC glad_glIsSampler = NULL;
+PFNGLVERTEXP3UIPROC glad_glVertexP3ui = NULL;
+PFNGLVERTEXATTRIBDIVISORPROC glad_glVertexAttribDivisor = NULL;
+PFNGLBINDSAMPLERSPROC glad_glBindSamplers = NULL;
+PFNGLCOMPRESSEDTEXIMAGE1DPROC glad_glCompressedTexImage1D = NULL;
+PFNGLDELETETRANSFORMFEEDBACKSPROC glad_glDeleteTransformFeedbacks = NULL;
+PFNGLCOPYTEXSUBIMAGE1DPROC glad_glCopyTexSubImage1D = NULL;
+PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC glad_glDrawRangeElementsBaseVertex = NULL;
+PFNGLCHECKFRAMEBUFFERSTATUSPROC glad_glCheckFramebufferStatus = NULL;
+PFNGLENDCONDITIONALRENDERPROC glad_glEndConditionalRender = NULL;
+PFNGLVERTEXP3UIVPROC glad_glVertexP3uiv = NULL;
+PFNGLBINDATTRIBLOCATIONPROC glad_glBindAttribLocation = NULL;
+PFNGLUNIFORMMATRIX4X2FVPROC glad_glUniformMatrix4x2fv = NULL;
+PFNGLUNIFORMMATRIX2DVPROC glad_glUniformMatrix2dv = NULL;
+PFNGLBLENDFUNCIPROC glad_glBlendFunci = NULL;
+PFNGLVERTEXATTRIB1DVPROC glad_glVertexAttrib1dv = NULL;
+PFNGLDRAWRANGEELEMENTSPROC glad_glDrawRangeElements = NULL;
+PFNGLGETQUERYOBJECTUIVPROC glad_glGetQueryObjectuiv = NULL;
+PFNGLBINDBUFFERBASEPROC glad_glBindBufferBase = NULL;
+PFNGLBUFFERSUBDATAPROC glad_glBufferSubData = NULL;
+PFNGLVERTEXATTRIB4IVPROC glad_glVertexAttrib4iv = NULL;
+PFNGLMAPBUFFERRANGEPROC glad_glMapBufferRange = NULL;
+PFNGLFRAMEBUFFERTEXTUREPROC glad_glFramebufferTexture = NULL;
+PFNGLBLENDFUNCSEPARATEIPROC glad_glBlendFuncSeparatei = NULL;
+PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC glad_glProgramUniformMatrix4x2fv = NULL;
+PFNGLVERTEXATTRIBL1DPROC glad_glVertexAttribL1d = NULL;
+PFNGLMULTIDRAWARRAYSPROC glad_glMultiDrawArrays = NULL;
+PFNGLVERTEXP4UIVPROC glad_glVertexP4uiv = NULL;
+PFNGLVERTEXATTRIBI2IVPROC glad_glVertexAttribI2iv = NULL;
+PFNGLGETSHADERPRECISIONFORMATPROC glad_glGetShaderPrecisionFormat = NULL;
+PFNGLTEXTUREVIEWPROC glad_glTextureView = NULL;
+PFNGLDISABLEIPROC glad_glDisablei = NULL;
+PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC glad_glProgramUniformMatrix2x4fv = NULL;
+PFNGLSHADERSOURCEPROC glad_glShaderSource = NULL;
+PFNGLGETNSEPARABLEFILTERPROC glad_glGetnSeparableFilter = NULL;
+PFNGLDELETERENDERBUFFERSPROC glad_glDeleteRenderbuffers = NULL;
+PFNGLVERTEXATTRIBI3UIVPROC glad_glVertexAttribI3uiv = NULL;
+PFNGLRELEASESHADERCOMPILERPROC glad_glReleaseShaderCompiler = NULL;
+PFNGLVERTEXATTRIBIFORMATPROC glad_glVertexAttribIFormat = NULL;
+PFNGLCREATEFRAMEBUFFERSPROC glad_glCreateFramebuffers = NULL;
+PFNGLGETSYNCIVPROC glad_glGetSynciv = NULL;
+PFNGLGETNPIXELMAPFVPROC glad_glGetnPixelMapfv = NULL;
+PFNGLTEXCOORDP2UIVPROC glad_glTexCoordP2uiv = NULL;
+PFNGLPATCHPARAMETERFVPROC glad_glPatchParameterfv = NULL;
+PFNGLPROGRAMUNIFORM2IPROC glad_glProgramUniform2i = NULL;
+PFNGLGETNAMEDBUFFERPARAMETERI64VPROC glad_glGetNamedBufferParameteri64v = NULL;
+PFNGLBEGINQUERYPROC glad_glBeginQuery = NULL;
+PFNGLUNIFORMMATRIX4FVPROC glad_glUniformMatrix4fv = NULL;
+PFNGLBINDBUFFERPROC glad_glBindBuffer = NULL;
+PFNGLTEXSTORAGE2DMULTISAMPLEPROC glad_glTexStorage2DMultisample = NULL;
+PFNGLPROGRAMUNIFORM2DPROC glad_glProgramUniform2d = NULL;
+PFNGLPROGRAMUNIFORM2FPROC glad_glProgramUniform2f = NULL;
+PFNGLUNIFORMMATRIX2FVPROC glad_glUniformMatrix2fv = NULL;
+PFNGLUNIFORMMATRIX2X4FVPROC glad_glUniformMatrix2x4fv = NULL;
+PFNGLBUFFERDATAPROC glad_glBufferData = NULL;
+PFNGLGETTEXPARAMETERIIVPROC glad_glGetTexParameterIiv = NULL;
+PFNGLTEXCOORDP1UIPROC glad_glTexCoordP1ui = NULL;
+PFNGLGETERRORPROC glad_glGetError = NULL;
+PFNGLCREATETRANSFORMFEEDBACKSPROC glad_glCreateTransformFeedbacks = NULL;
+PFNGLVERTEXATTRIBP2UIPROC glad_glVertexAttribP2ui = NULL;
+PFNGLGETFLOATVPROC glad_glGetFloatv = NULL;
+PFNGLTEXSUBIMAGE1DPROC glad_glTexSubImage1D = NULL;
+PFNGLVERTEXATTRIB2FVPROC glad_glVertexAttrib2fv = NULL;
+PFNGLGETTEXLEVELPARAMETERFVPROC glad_glGetTexLevelParameterfv = NULL;
+PFNGLVERTEXATTRIBI1IPROC glad_glVertexAttribI1i = NULL;
+PFNGLVERTEXATTRIBP3UIVPROC glad_glVertexAttribP3uiv = NULL;
+PFNGLUNIFORM4DPROC glad_glUniform4d = NULL;
+PFNGLSECONDARYCOLORP3UIVPROC glad_glSecondaryColorP3uiv = NULL;
+PFNGLGETINTEGERVPROC glad_glGetIntegerv = NULL;
+PFNGLGETVERTEXARRAYINDEXED64IVPROC glad_glGetVertexArrayIndexed64iv = NULL;
+PFNGLGETBUFFERPOINTERVPROC glad_glGetBufferPointerv = NULL;
+PFNGLPROGRAMUNIFORMMATRIX3DVPROC glad_glProgramUniformMatrix3dv = NULL;
+PFNGLFRAMEBUFFERTEXTURE3DPROC glad_glFramebufferTexture3D = NULL;
+PFNGLISQUERYPROC glad_glIsQuery = NULL;
+PFNGLPROGRAMUNIFORM2UIPROC glad_glProgramUniform2ui = NULL;
+PFNGLPROGRAMUNIFORM4UIPROC glad_glProgramUniform4ui = NULL;
+PFNGLVERTEXATTRIB4SVPROC glad_glVertexAttrib4sv = NULL;
+PFNGLTEXIMAGE2DPROC glad_glTexImage2D = NULL;
+PFNGLSTENCILMASKPROC glad_glStencilMask = NULL;
+PFNGLSAMPLERPARAMETERFVPROC glad_glSamplerParameterfv = NULL;
+PFNGLISTEXTUREPROC glad_glIsTexture = NULL;
+PFNGLNAMEDBUFFERDATAPROC glad_glNamedBufferData = NULL;
+PFNGLUNIFORM1FVPROC glad_glUniform1fv = NULL;
+PFNGLVERTEXATTRIB4NUBVPROC glad_glVertexAttrib4Nubv = NULL;
+PFNGLCLEARNAMEDBUFFERSUBDATAPROC glad_glClearNamedBufferSubData = NULL;
+PFNGLTEXPARAMETERFVPROC glad_glTexParameterfv = NULL;
+PFNGLSCISSORINDEXEDVPROC glad_glScissorIndexedv = NULL;
+PFNGLUNIFORM3DVPROC glad_glUniform3dv = NULL;
+PFNGLGETNPIXELMAPUIVPROC glad_glGetnPixelMapuiv = NULL;
+PFNGLPROGRAMUNIFORM3FVPROC glad_glProgramUniform3fv = NULL;
+PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC glad_glGetSubroutineUniformLocation = NULL;
+PFNGLGETFRAMEBUFFERPARAMETERIVPROC glad_glGetFramebufferParameteriv = NULL;
+PFNGLGETSAMPLERPARAMETERIVPROC glad_glGetSamplerParameteriv = NULL;
+PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC glad_glGetCompressedTextureSubImage = NULL;
+PFNGLCOPYBUFFERSUBDATAPROC glad_glCopyBufferSubData = NULL;
+PFNGLVERTEXATTRIBI1UIVPROC glad_glVertexAttribI1uiv = NULL;
+PFNGLVERTEXATTRIB2DPROC glad_glVertexAttrib2d = NULL;
+PFNGLVERTEXATTRIB2FPROC glad_glVertexAttrib2f = NULL;
+PFNGLVERTEXATTRIB3DVPROC glad_glVertexAttrib3dv = NULL;
+PFNGLGETQUERYOBJECTUI64VPROC glad_glGetQueryObjectui64v = NULL;
+PFNGLDEPTHMASKPROC glad_glDepthMask = NULL;
+PFNGLVERTEXATTRIB2SPROC glad_glVertexAttrib2s = NULL;
+PFNGLTEXIMAGE3DMULTISAMPLEPROC glad_glTexImage3DMultisample = NULL;
+PFNGLPROGRAMUNIFORM1FVPROC glad_glProgramUniform1fv = NULL;
+PFNGLGETUNIFORMBLOCKINDEXPROC glad_glGetUniformBlockIndex = NULL;
+PFNGLTEXIMAGE2DMULTISAMPLEPROC glad_glTexImage2DMultisample = NULL;
+PFNGLGETACTIVEUNIFORMPROC glad_glGetActiveUniform = NULL;
+PFNGLFRONTFACEPROC glad_glFrontFace = NULL;
+PFNGLTEXBUFFERRANGEPROC glad_glTexBufferRange = NULL;
+PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC glad_glNamedFramebufferTextureLayer = NULL;
+PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC glad_glNamedFramebufferParameteri = NULL;
+PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC glad_glDrawArraysInstancedBaseInstance = NULL;
+PFNGLDELETEPROGRAMPIPELINESPROC glad_glDeleteProgramPipelines = NULL;
+static void load_GL_VERSION_1_0(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_1_0) return;
+ glad_glCullFace = (PFNGLCULLFACEPROC)load("glCullFace");
+ glad_glFrontFace = (PFNGLFRONTFACEPROC)load("glFrontFace");
+ glad_glHint = (PFNGLHINTPROC)load("glHint");
+ glad_glLineWidth = (PFNGLLINEWIDTHPROC)load("glLineWidth");
+ glad_glPointSize = (PFNGLPOINTSIZEPROC)load("glPointSize");
+ glad_glPolygonMode = (PFNGLPOLYGONMODEPROC)load("glPolygonMode");
+ glad_glScissor = (PFNGLSCISSORPROC)load("glScissor");
+ glad_glTexParameterf = (PFNGLTEXPARAMETERFPROC)load("glTexParameterf");
+ glad_glTexParameterfv = (PFNGLTEXPARAMETERFVPROC)load("glTexParameterfv");
+ glad_glTexParameteri = (PFNGLTEXPARAMETERIPROC)load("glTexParameteri");
+ glad_glTexParameteriv = (PFNGLTEXPARAMETERIVPROC)load("glTexParameteriv");
+ glad_glTexImage1D = (PFNGLTEXIMAGE1DPROC)load("glTexImage1D");
+ glad_glTexImage2D = (PFNGLTEXIMAGE2DPROC)load("glTexImage2D");
+ glad_glDrawBuffer = (PFNGLDRAWBUFFERPROC)load("glDrawBuffer");
+ glad_glClear = (PFNGLCLEARPROC)load("glClear");
+ glad_glClearColor = (PFNGLCLEARCOLORPROC)load("glClearColor");
+ glad_glClearStencil = (PFNGLCLEARSTENCILPROC)load("glClearStencil");
+ glad_glClearDepth = (PFNGLCLEARDEPTHPROC)load("glClearDepth");
+ glad_glStencilMask = (PFNGLSTENCILMASKPROC)load("glStencilMask");
+ glad_glColorMask = (PFNGLCOLORMASKPROC)load("glColorMask");
+ glad_glDepthMask = (PFNGLDEPTHMASKPROC)load("glDepthMask");
+ glad_glDisable = (PFNGLDISABLEPROC)load("glDisable");
+ glad_glEnable = (PFNGLENABLEPROC)load("glEnable");
+ glad_glFinish = (PFNGLFINISHPROC)load("glFinish");
+ glad_glFlush = (PFNGLFLUSHPROC)load("glFlush");
+ glad_glBlendFunc = (PFNGLBLENDFUNCPROC)load("glBlendFunc");
+ glad_glLogicOp = (PFNGLLOGICOPPROC)load("glLogicOp");
+ glad_glStencilFunc = (PFNGLSTENCILFUNCPROC)load("glStencilFunc");
+ glad_glStencilOp = (PFNGLSTENCILOPPROC)load("glStencilOp");
+ glad_glDepthFunc = (PFNGLDEPTHFUNCPROC)load("glDepthFunc");
+ glad_glPixelStoref = (PFNGLPIXELSTOREFPROC)load("glPixelStoref");
+ glad_glPixelStorei = (PFNGLPIXELSTOREIPROC)load("glPixelStorei");
+ glad_glReadBuffer = (PFNGLREADBUFFERPROC)load("glReadBuffer");
+ glad_glReadPixels = (PFNGLREADPIXELSPROC)load("glReadPixels");
+ glad_glGetBooleanv = (PFNGLGETBOOLEANVPROC)load("glGetBooleanv");
+ glad_glGetDoublev = (PFNGLGETDOUBLEVPROC)load("glGetDoublev");
+ glad_glGetError = (PFNGLGETERRORPROC)load("glGetError");
+ glad_glGetFloatv = (PFNGLGETFLOATVPROC)load("glGetFloatv");
+ glad_glGetIntegerv = (PFNGLGETINTEGERVPROC)load("glGetIntegerv");
+ glad_glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
+ glad_glGetTexImage = (PFNGLGETTEXIMAGEPROC)load("glGetTexImage");
+ glad_glGetTexParameterfv = (PFNGLGETTEXPARAMETERFVPROC)load("glGetTexParameterfv");
+ glad_glGetTexParameteriv = (PFNGLGETTEXPARAMETERIVPROC)load("glGetTexParameteriv");
+ glad_glGetTexLevelParameterfv = (PFNGLGETTEXLEVELPARAMETERFVPROC)load("glGetTexLevelParameterfv");
+ glad_glGetTexLevelParameteriv = (PFNGLGETTEXLEVELPARAMETERIVPROC)load("glGetTexLevelParameteriv");
+ glad_glIsEnabled = (PFNGLISENABLEDPROC)load("glIsEnabled");
+ glad_glDepthRange = (PFNGLDEPTHRANGEPROC)load("glDepthRange");
+ glad_glViewport = (PFNGLVIEWPORTPROC)load("glViewport");
+}
+static void load_GL_VERSION_1_1(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_1_1) return;
+ glad_glDrawArrays = (PFNGLDRAWARRAYSPROC)load("glDrawArrays");
+ glad_glDrawElements = (PFNGLDRAWELEMENTSPROC)load("glDrawElements");
+ glad_glPolygonOffset = (PFNGLPOLYGONOFFSETPROC)load("glPolygonOffset");
+ glad_glCopyTexImage1D = (PFNGLCOPYTEXIMAGE1DPROC)load("glCopyTexImage1D");
+ glad_glCopyTexImage2D = (PFNGLCOPYTEXIMAGE2DPROC)load("glCopyTexImage2D");
+ glad_glCopyTexSubImage1D = (PFNGLCOPYTEXSUBIMAGE1DPROC)load("glCopyTexSubImage1D");
+ glad_glCopyTexSubImage2D = (PFNGLCOPYTEXSUBIMAGE2DPROC)load("glCopyTexSubImage2D");
+ glad_glTexSubImage1D = (PFNGLTEXSUBIMAGE1DPROC)load("glTexSubImage1D");
+ glad_glTexSubImage2D = (PFNGLTEXSUBIMAGE2DPROC)load("glTexSubImage2D");
+ glad_glBindTexture = (PFNGLBINDTEXTUREPROC)load("glBindTexture");
+ glad_glDeleteTextures = (PFNGLDELETETEXTURESPROC)load("glDeleteTextures");
+ glad_glGenTextures = (PFNGLGENTEXTURESPROC)load("glGenTextures");
+ glad_glIsTexture = (PFNGLISTEXTUREPROC)load("glIsTexture");
+}
+static void load_GL_VERSION_1_2(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_1_2) return;
+ glad_glDrawRangeElements = (PFNGLDRAWRANGEELEMENTSPROC)load("glDrawRangeElements");
+ glad_glTexImage3D = (PFNGLTEXIMAGE3DPROC)load("glTexImage3D");
+ glad_glTexSubImage3D = (PFNGLTEXSUBIMAGE3DPROC)load("glTexSubImage3D");
+ glad_glCopyTexSubImage3D = (PFNGLCOPYTEXSUBIMAGE3DPROC)load("glCopyTexSubImage3D");
+}
+static void load_GL_VERSION_1_3(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_1_3) return;
+ glad_glActiveTexture = (PFNGLACTIVETEXTUREPROC)load("glActiveTexture");
+ glad_glSampleCoverage = (PFNGLSAMPLECOVERAGEPROC)load("glSampleCoverage");
+ glad_glCompressedTexImage3D = (PFNGLCOMPRESSEDTEXIMAGE3DPROC)load("glCompressedTexImage3D");
+ glad_glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC)load("glCompressedTexImage2D");
+ glad_glCompressedTexImage1D = (PFNGLCOMPRESSEDTEXIMAGE1DPROC)load("glCompressedTexImage1D");
+ glad_glCompressedTexSubImage3D = (PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC)load("glCompressedTexSubImage3D");
+ glad_glCompressedTexSubImage2D = (PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC)load("glCompressedTexSubImage2D");
+ glad_glCompressedTexSubImage1D = (PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC)load("glCompressedTexSubImage1D");
+ glad_glGetCompressedTexImage = (PFNGLGETCOMPRESSEDTEXIMAGEPROC)load("glGetCompressedTexImage");
+}
+static void load_GL_VERSION_1_4(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_1_4) return;
+ glad_glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)load("glBlendFuncSeparate");
+ glad_glMultiDrawArrays = (PFNGLMULTIDRAWARRAYSPROC)load("glMultiDrawArrays");
+ glad_glMultiDrawElements = (PFNGLMULTIDRAWELEMENTSPROC)load("glMultiDrawElements");
+ glad_glPointParameterf = (PFNGLPOINTPARAMETERFPROC)load("glPointParameterf");
+ glad_glPointParameterfv = (PFNGLPOINTPARAMETERFVPROC)load("glPointParameterfv");
+ glad_glPointParameteri = (PFNGLPOINTPARAMETERIPROC)load("glPointParameteri");
+ glad_glPointParameteriv = (PFNGLPOINTPARAMETERIVPROC)load("glPointParameteriv");
+ glad_glBlendColor = (PFNGLBLENDCOLORPROC)load("glBlendColor");
+ glad_glBlendEquation = (PFNGLBLENDEQUATIONPROC)load("glBlendEquation");
+}
+static void load_GL_VERSION_1_5(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_1_5) return;
+ glad_glGenQueries = (PFNGLGENQUERIESPROC)load("glGenQueries");
+ glad_glDeleteQueries = (PFNGLDELETEQUERIESPROC)load("glDeleteQueries");
+ glad_glIsQuery = (PFNGLISQUERYPROC)load("glIsQuery");
+ glad_glBeginQuery = (PFNGLBEGINQUERYPROC)load("glBeginQuery");
+ glad_glEndQuery = (PFNGLENDQUERYPROC)load("glEndQuery");
+ glad_glGetQueryiv = (PFNGLGETQUERYIVPROC)load("glGetQueryiv");
+ glad_glGetQueryObjectiv = (PFNGLGETQUERYOBJECTIVPROC)load("glGetQueryObjectiv");
+ glad_glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVPROC)load("glGetQueryObjectuiv");
+ glad_glBindBuffer = (PFNGLBINDBUFFERPROC)load("glBindBuffer");
+ glad_glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)load("glDeleteBuffers");
+ glad_glGenBuffers = (PFNGLGENBUFFERSPROC)load("glGenBuffers");
+ glad_glIsBuffer = (PFNGLISBUFFERPROC)load("glIsBuffer");
+ glad_glBufferData = (PFNGLBUFFERDATAPROC)load("glBufferData");
+ glad_glBufferSubData = (PFNGLBUFFERSUBDATAPROC)load("glBufferSubData");
+ glad_glGetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)load("glGetBufferSubData");
+ glad_glMapBuffer = (PFNGLMAPBUFFERPROC)load("glMapBuffer");
+ glad_glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)load("glUnmapBuffer");
+ glad_glGetBufferParameteriv = (PFNGLGETBUFFERPARAMETERIVPROC)load("glGetBufferParameteriv");
+ glad_glGetBufferPointerv = (PFNGLGETBUFFERPOINTERVPROC)load("glGetBufferPointerv");
+}
+static void load_GL_VERSION_2_0(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_2_0) return;
+ glad_glBlendEquationSeparate = (PFNGLBLENDEQUATIONSEPARATEPROC)load("glBlendEquationSeparate");
+ glad_glDrawBuffers = (PFNGLDRAWBUFFERSPROC)load("glDrawBuffers");
+ glad_glStencilOpSeparate = (PFNGLSTENCILOPSEPARATEPROC)load("glStencilOpSeparate");
+ glad_glStencilFuncSeparate = (PFNGLSTENCILFUNCSEPARATEPROC)load("glStencilFuncSeparate");
+ glad_glStencilMaskSeparate = (PFNGLSTENCILMASKSEPARATEPROC)load("glStencilMaskSeparate");
+ glad_glAttachShader = (PFNGLATTACHSHADERPROC)load("glAttachShader");
+ glad_glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)load("glBindAttribLocation");
+ glad_glCompileShader = (PFNGLCOMPILESHADERPROC)load("glCompileShader");
+ glad_glCreateProgram = (PFNGLCREATEPROGRAMPROC)load("glCreateProgram");
+ glad_glCreateShader = (PFNGLCREATESHADERPROC)load("glCreateShader");
+ glad_glDeleteProgram = (PFNGLDELETEPROGRAMPROC)load("glDeleteProgram");
+ glad_glDeleteShader = (PFNGLDELETESHADERPROC)load("glDeleteShader");
+ glad_glDetachShader = (PFNGLDETACHSHADERPROC)load("glDetachShader");
+ glad_glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC)load("glDisableVertexAttribArray");
+ glad_glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)load("glEnableVertexAttribArray");
+ glad_glGetActiveAttrib = (PFNGLGETACTIVEATTRIBPROC)load("glGetActiveAttrib");
+ glad_glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)load("glGetActiveUniform");
+ glad_glGetAttachedShaders = (PFNGLGETATTACHEDSHADERSPROC)load("glGetAttachedShaders");
+ glad_glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)load("glGetAttribLocation");
+ glad_glGetProgramiv = (PFNGLGETPROGRAMIVPROC)load("glGetProgramiv");
+ glad_glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)load("glGetProgramInfoLog");
+ glad_glGetShaderiv = (PFNGLGETSHADERIVPROC)load("glGetShaderiv");
+ glad_glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)load("glGetShaderInfoLog");
+ glad_glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)load("glGetShaderSource");
+ glad_glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)load("glGetUniformLocation");
+ glad_glGetUniformfv = (PFNGLGETUNIFORMFVPROC)load("glGetUniformfv");
+ glad_glGetUniformiv = (PFNGLGETUNIFORMIVPROC)load("glGetUniformiv");
+ glad_glGetVertexAttribdv = (PFNGLGETVERTEXATTRIBDVPROC)load("glGetVertexAttribdv");
+ glad_glGetVertexAttribfv = (PFNGLGETVERTEXATTRIBFVPROC)load("glGetVertexAttribfv");
+ glad_glGetVertexAttribiv = (PFNGLGETVERTEXATTRIBIVPROC)load("glGetVertexAttribiv");
+ glad_glGetVertexAttribPointerv = (PFNGLGETVERTEXATTRIBPOINTERVPROC)load("glGetVertexAttribPointerv");
+ glad_glIsProgram = (PFNGLISPROGRAMPROC)load("glIsProgram");
+ glad_glIsShader = (PFNGLISSHADERPROC)load("glIsShader");
+ glad_glLinkProgram = (PFNGLLINKPROGRAMPROC)load("glLinkProgram");
+ glad_glShaderSource = (PFNGLSHADERSOURCEPROC)load("glShaderSource");
+ glad_glUseProgram = (PFNGLUSEPROGRAMPROC)load("glUseProgram");
+ glad_glUniform1f = (PFNGLUNIFORM1FPROC)load("glUniform1f");
+ glad_glUniform2f = (PFNGLUNIFORM2FPROC)load("glUniform2f");
+ glad_glUniform3f = (PFNGLUNIFORM3FPROC)load("glUniform3f");
+ glad_glUniform4f = (PFNGLUNIFORM4FPROC)load("glUniform4f");
+ glad_glUniform1i = (PFNGLUNIFORM1IPROC)load("glUniform1i");
+ glad_glUniform2i = (PFNGLUNIFORM2IPROC)load("glUniform2i");
+ glad_glUniform3i = (PFNGLUNIFORM3IPROC)load("glUniform3i");
+ glad_glUniform4i = (PFNGLUNIFORM4IPROC)load("glUniform4i");
+ glad_glUniform1fv = (PFNGLUNIFORM1FVPROC)load("glUniform1fv");
+ glad_glUniform2fv = (PFNGLUNIFORM2FVPROC)load("glUniform2fv");
+ glad_glUniform3fv = (PFNGLUNIFORM3FVPROC)load("glUniform3fv");
+ glad_glUniform4fv = (PFNGLUNIFORM4FVPROC)load("glUniform4fv");
+ glad_glUniform1iv = (PFNGLUNIFORM1IVPROC)load("glUniform1iv");
+ glad_glUniform2iv = (PFNGLUNIFORM2IVPROC)load("glUniform2iv");
+ glad_glUniform3iv = (PFNGLUNIFORM3IVPROC)load("glUniform3iv");
+ glad_glUniform4iv = (PFNGLUNIFORM4IVPROC)load("glUniform4iv");
+ glad_glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)load("glUniformMatrix2fv");
+ glad_glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)load("glUniformMatrix3fv");
+ glad_glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)load("glUniformMatrix4fv");
+ glad_glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)load("glValidateProgram");
+ glad_glVertexAttrib1d = (PFNGLVERTEXATTRIB1DPROC)load("glVertexAttrib1d");
+ glad_glVertexAttrib1dv = (PFNGLVERTEXATTRIB1DVPROC)load("glVertexAttrib1dv");
+ glad_glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)load("glVertexAttrib1f");
+ glad_glVertexAttrib1fv = (PFNGLVERTEXATTRIB1FVPROC)load("glVertexAttrib1fv");
+ glad_glVertexAttrib1s = (PFNGLVERTEXATTRIB1SPROC)load("glVertexAttrib1s");
+ glad_glVertexAttrib1sv = (PFNGLVERTEXATTRIB1SVPROC)load("glVertexAttrib1sv");
+ glad_glVertexAttrib2d = (PFNGLVERTEXATTRIB2DPROC)load("glVertexAttrib2d");
+ glad_glVertexAttrib2dv = (PFNGLVERTEXATTRIB2DVPROC)load("glVertexAttrib2dv");
+ glad_glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)load("glVertexAttrib2f");
+ glad_glVertexAttrib2fv = (PFNGLVERTEXATTRIB2FVPROC)load("glVertexAttrib2fv");
+ glad_glVertexAttrib2s = (PFNGLVERTEXATTRIB2SPROC)load("glVertexAttrib2s");
+ glad_glVertexAttrib2sv = (PFNGLVERTEXATTRIB2SVPROC)load("glVertexAttrib2sv");
+ glad_glVertexAttrib3d = (PFNGLVERTEXATTRIB3DPROC)load("glVertexAttrib3d");
+ glad_glVertexAttrib3dv = (PFNGLVERTEXATTRIB3DVPROC)load("glVertexAttrib3dv");
+ glad_glVertexAttrib3f = (PFNGLVERTEXATTRIB3FPROC)load("glVertexAttrib3f");
+ glad_glVertexAttrib3fv = (PFNGLVERTEXATTRIB3FVPROC)load("glVertexAttrib3fv");
+ glad_glVertexAttrib3s = (PFNGLVERTEXATTRIB3SPROC)load("glVertexAttrib3s");
+ glad_glVertexAttrib3sv = (PFNGLVERTEXATTRIB3SVPROC)load("glVertexAttrib3sv");
+ glad_glVertexAttrib4Nbv = (PFNGLVERTEXATTRIB4NBVPROC)load("glVertexAttrib4Nbv");
+ glad_glVertexAttrib4Niv = (PFNGLVERTEXATTRIB4NIVPROC)load("glVertexAttrib4Niv");
+ glad_glVertexAttrib4Nsv = (PFNGLVERTEXATTRIB4NSVPROC)load("glVertexAttrib4Nsv");
+ glad_glVertexAttrib4Nub = (PFNGLVERTEXATTRIB4NUBPROC)load("glVertexAttrib4Nub");
+ glad_glVertexAttrib4Nubv = (PFNGLVERTEXATTRIB4NUBVPROC)load("glVertexAttrib4Nubv");
+ glad_glVertexAttrib4Nuiv = (PFNGLVERTEXATTRIB4NUIVPROC)load("glVertexAttrib4Nuiv");
+ glad_glVertexAttrib4Nusv = (PFNGLVERTEXATTRIB4NUSVPROC)load("glVertexAttrib4Nusv");
+ glad_glVertexAttrib4bv = (PFNGLVERTEXATTRIB4BVPROC)load("glVertexAttrib4bv");
+ glad_glVertexAttrib4d = (PFNGLVERTEXATTRIB4DPROC)load("glVertexAttrib4d");
+ glad_glVertexAttrib4dv = (PFNGLVERTEXATTRIB4DVPROC)load("glVertexAttrib4dv");
+ glad_glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)load("glVertexAttrib4f");
+ glad_glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)load("glVertexAttrib4fv");
+ glad_glVertexAttrib4iv = (PFNGLVERTEXATTRIB4IVPROC)load("glVertexAttrib4iv");
+ glad_glVertexAttrib4s = (PFNGLVERTEXATTRIB4SPROC)load("glVertexAttrib4s");
+ glad_glVertexAttrib4sv = (PFNGLVERTEXATTRIB4SVPROC)load("glVertexAttrib4sv");
+ glad_glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)load("glVertexAttrib4ubv");
+ glad_glVertexAttrib4uiv = (PFNGLVERTEXATTRIB4UIVPROC)load("glVertexAttrib4uiv");
+ glad_glVertexAttrib4usv = (PFNGLVERTEXATTRIB4USVPROC)load("glVertexAttrib4usv");
+ glad_glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)load("glVertexAttribPointer");
+}
+static void load_GL_VERSION_2_1(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_2_1) return;
+ glad_glUniformMatrix2x3fv = (PFNGLUNIFORMMATRIX2X3FVPROC)load("glUniformMatrix2x3fv");
+ glad_glUniformMatrix3x2fv = (PFNGLUNIFORMMATRIX3X2FVPROC)load("glUniformMatrix3x2fv");
+ glad_glUniformMatrix2x4fv = (PFNGLUNIFORMMATRIX2X4FVPROC)load("glUniformMatrix2x4fv");
+ glad_glUniformMatrix4x2fv = (PFNGLUNIFORMMATRIX4X2FVPROC)load("glUniformMatrix4x2fv");
+ glad_glUniformMatrix3x4fv = (PFNGLUNIFORMMATRIX3X4FVPROC)load("glUniformMatrix3x4fv");
+ glad_glUniformMatrix4x3fv = (PFNGLUNIFORMMATRIX4X3FVPROC)load("glUniformMatrix4x3fv");
+}
+static void load_GL_VERSION_3_0(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_3_0) return;
+ glad_glColorMaski = (PFNGLCOLORMASKIPROC)load("glColorMaski");
+ glad_glGetBooleani_v = (PFNGLGETBOOLEANI_VPROC)load("glGetBooleani_v");
+ glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
+ glad_glEnablei = (PFNGLENABLEIPROC)load("glEnablei");
+ glad_glDisablei = (PFNGLDISABLEIPROC)load("glDisablei");
+ glad_glIsEnabledi = (PFNGLISENABLEDIPROC)load("glIsEnabledi");
+ glad_glBeginTransformFeedback = (PFNGLBEGINTRANSFORMFEEDBACKPROC)load("glBeginTransformFeedback");
+ glad_glEndTransformFeedback = (PFNGLENDTRANSFORMFEEDBACKPROC)load("glEndTransformFeedback");
+ glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
+ glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
+ glad_glTransformFeedbackVaryings = (PFNGLTRANSFORMFEEDBACKVARYINGSPROC)load("glTransformFeedbackVaryings");
+ glad_glGetTransformFeedbackVarying = (PFNGLGETTRANSFORMFEEDBACKVARYINGPROC)load("glGetTransformFeedbackVarying");
+ glad_glClampColor = (PFNGLCLAMPCOLORPROC)load("glClampColor");
+ glad_glBeginConditionalRender = (PFNGLBEGINCONDITIONALRENDERPROC)load("glBeginConditionalRender");
+ glad_glEndConditionalRender = (PFNGLENDCONDITIONALRENDERPROC)load("glEndConditionalRender");
+ glad_glVertexAttribIPointer = (PFNGLVERTEXATTRIBIPOINTERPROC)load("glVertexAttribIPointer");
+ glad_glGetVertexAttribIiv = (PFNGLGETVERTEXATTRIBIIVPROC)load("glGetVertexAttribIiv");
+ glad_glGetVertexAttribIuiv = (PFNGLGETVERTEXATTRIBIUIVPROC)load("glGetVertexAttribIuiv");
+ glad_glVertexAttribI1i = (PFNGLVERTEXATTRIBI1IPROC)load("glVertexAttribI1i");
+ glad_glVertexAttribI2i = (PFNGLVERTEXATTRIBI2IPROC)load("glVertexAttribI2i");
+ glad_glVertexAttribI3i = (PFNGLVERTEXATTRIBI3IPROC)load("glVertexAttribI3i");
+ glad_glVertexAttribI4i = (PFNGLVERTEXATTRIBI4IPROC)load("glVertexAttribI4i");
+ glad_glVertexAttribI1ui = (PFNGLVERTEXATTRIBI1UIPROC)load("glVertexAttribI1ui");
+ glad_glVertexAttribI2ui = (PFNGLVERTEXATTRIBI2UIPROC)load("glVertexAttribI2ui");
+ glad_glVertexAttribI3ui = (PFNGLVERTEXATTRIBI3UIPROC)load("glVertexAttribI3ui");
+ glad_glVertexAttribI4ui = (PFNGLVERTEXATTRIBI4UIPROC)load("glVertexAttribI4ui");
+ glad_glVertexAttribI1iv = (PFNGLVERTEXATTRIBI1IVPROC)load("glVertexAttribI1iv");
+ glad_glVertexAttribI2iv = (PFNGLVERTEXATTRIBI2IVPROC)load("glVertexAttribI2iv");
+ glad_glVertexAttribI3iv = (PFNGLVERTEXATTRIBI3IVPROC)load("glVertexAttribI3iv");
+ glad_glVertexAttribI4iv = (PFNGLVERTEXATTRIBI4IVPROC)load("glVertexAttribI4iv");
+ glad_glVertexAttribI1uiv = (PFNGLVERTEXATTRIBI1UIVPROC)load("glVertexAttribI1uiv");
+ glad_glVertexAttribI2uiv = (PFNGLVERTEXATTRIBI2UIVPROC)load("glVertexAttribI2uiv");
+ glad_glVertexAttribI3uiv = (PFNGLVERTEXATTRIBI3UIVPROC)load("glVertexAttribI3uiv");
+ glad_glVertexAttribI4uiv = (PFNGLVERTEXATTRIBI4UIVPROC)load("glVertexAttribI4uiv");
+ glad_glVertexAttribI4bv = (PFNGLVERTEXATTRIBI4BVPROC)load("glVertexAttribI4bv");
+ glad_glVertexAttribI4sv = (PFNGLVERTEXATTRIBI4SVPROC)load("glVertexAttribI4sv");
+ glad_glVertexAttribI4ubv = (PFNGLVERTEXATTRIBI4UBVPROC)load("glVertexAttribI4ubv");
+ glad_glVertexAttribI4usv = (PFNGLVERTEXATTRIBI4USVPROC)load("glVertexAttribI4usv");
+ glad_glGetUniformuiv = (PFNGLGETUNIFORMUIVPROC)load("glGetUniformuiv");
+ glad_glBindFragDataLocation = (PFNGLBINDFRAGDATALOCATIONPROC)load("glBindFragDataLocation");
+ glad_glGetFragDataLocation = (PFNGLGETFRAGDATALOCATIONPROC)load("glGetFragDataLocation");
+ glad_glUniform1ui = (PFNGLUNIFORM1UIPROC)load("glUniform1ui");
+ glad_glUniform2ui = (PFNGLUNIFORM2UIPROC)load("glUniform2ui");
+ glad_glUniform3ui = (PFNGLUNIFORM3UIPROC)load("glUniform3ui");
+ glad_glUniform4ui = (PFNGLUNIFORM4UIPROC)load("glUniform4ui");
+ glad_glUniform1uiv = (PFNGLUNIFORM1UIVPROC)load("glUniform1uiv");
+ glad_glUniform2uiv = (PFNGLUNIFORM2UIVPROC)load("glUniform2uiv");
+ glad_glUniform3uiv = (PFNGLUNIFORM3UIVPROC)load("glUniform3uiv");
+ glad_glUniform4uiv = (PFNGLUNIFORM4UIVPROC)load("glUniform4uiv");
+ glad_glTexParameterIiv = (PFNGLTEXPARAMETERIIVPROC)load("glTexParameterIiv");
+ glad_glTexParameterIuiv = (PFNGLTEXPARAMETERIUIVPROC)load("glTexParameterIuiv");
+ glad_glGetTexParameterIiv = (PFNGLGETTEXPARAMETERIIVPROC)load("glGetTexParameterIiv");
+ glad_glGetTexParameterIuiv = (PFNGLGETTEXPARAMETERIUIVPROC)load("glGetTexParameterIuiv");
+ glad_glClearBufferiv = (PFNGLCLEARBUFFERIVPROC)load("glClearBufferiv");
+ glad_glClearBufferuiv = (PFNGLCLEARBUFFERUIVPROC)load("glClearBufferuiv");
+ glad_glClearBufferfv = (PFNGLCLEARBUFFERFVPROC)load("glClearBufferfv");
+ glad_glClearBufferfi = (PFNGLCLEARBUFFERFIPROC)load("glClearBufferfi");
+ glad_glGetStringi = (PFNGLGETSTRINGIPROC)load("glGetStringi");
+ glad_glIsRenderbuffer = (PFNGLISRENDERBUFFERPROC)load("glIsRenderbuffer");
+ glad_glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)load("glBindRenderbuffer");
+ glad_glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)load("glDeleteRenderbuffers");
+ glad_glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)load("glGenRenderbuffers");
+ glad_glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)load("glRenderbufferStorage");
+ glad_glGetRenderbufferParameteriv = (PFNGLGETRENDERBUFFERPARAMETERIVPROC)load("glGetRenderbufferParameteriv");
+ glad_glIsFramebuffer = (PFNGLISFRAMEBUFFERPROC)load("glIsFramebuffer");
+ glad_glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)load("glBindFramebuffer");
+ glad_glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)load("glDeleteFramebuffers");
+ glad_glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)load("glGenFramebuffers");
+ glad_glCheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSPROC)load("glCheckFramebufferStatus");
+ glad_glFramebufferTexture1D = (PFNGLFRAMEBUFFERTEXTURE1DPROC)load("glFramebufferTexture1D");
+ glad_glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)load("glFramebufferTexture2D");
+ glad_glFramebufferTexture3D = (PFNGLFRAMEBUFFERTEXTURE3DPROC)load("glFramebufferTexture3D");
+ glad_glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)load("glFramebufferRenderbuffer");
+ glad_glGetFramebufferAttachmentParameteriv = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetFramebufferAttachmentParameteriv");
+ glad_glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC)load("glGenerateMipmap");
+ glad_glBlitFramebuffer = (PFNGLBLITFRAMEBUFFERPROC)load("glBlitFramebuffer");
+ glad_glRenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glRenderbufferStorageMultisample");
+ glad_glFramebufferTextureLayer = (PFNGLFRAMEBUFFERTEXTURELAYERPROC)load("glFramebufferTextureLayer");
+ glad_glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)load("glMapBufferRange");
+ glad_glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)load("glFlushMappedBufferRange");
+ glad_glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC)load("glBindVertexArray");
+ glad_glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC)load("glDeleteVertexArrays");
+ glad_glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC)load("glGenVertexArrays");
+ glad_glIsVertexArray = (PFNGLISVERTEXARRAYPROC)load("glIsVertexArray");
+}
+static void load_GL_VERSION_3_1(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_3_1) return;
+ glad_glDrawArraysInstanced = (PFNGLDRAWARRAYSINSTANCEDPROC)load("glDrawArraysInstanced");
+ glad_glDrawElementsInstanced = (PFNGLDRAWELEMENTSINSTANCEDPROC)load("glDrawElementsInstanced");
+ glad_glTexBuffer = (PFNGLTEXBUFFERPROC)load("glTexBuffer");
+ glad_glPrimitiveRestartIndex = (PFNGLPRIMITIVERESTARTINDEXPROC)load("glPrimitiveRestartIndex");
+ glad_glCopyBufferSubData = (PFNGLCOPYBUFFERSUBDATAPROC)load("glCopyBufferSubData");
+ glad_glGetUniformIndices = (PFNGLGETUNIFORMINDICESPROC)load("glGetUniformIndices");
+ glad_glGetActiveUniformsiv = (PFNGLGETACTIVEUNIFORMSIVPROC)load("glGetActiveUniformsiv");
+ glad_glGetActiveUniformName = (PFNGLGETACTIVEUNIFORMNAMEPROC)load("glGetActiveUniformName");
+ glad_glGetUniformBlockIndex = (PFNGLGETUNIFORMBLOCKINDEXPROC)load("glGetUniformBlockIndex");
+ glad_glGetActiveUniformBlockiv = (PFNGLGETACTIVEUNIFORMBLOCKIVPROC)load("glGetActiveUniformBlockiv");
+ glad_glGetActiveUniformBlockName = (PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC)load("glGetActiveUniformBlockName");
+ glad_glUniformBlockBinding = (PFNGLUNIFORMBLOCKBINDINGPROC)load("glUniformBlockBinding");
+ glad_glBindBufferRange = (PFNGLBINDBUFFERRANGEPROC)load("glBindBufferRange");
+ glad_glBindBufferBase = (PFNGLBINDBUFFERBASEPROC)load("glBindBufferBase");
+ glad_glGetIntegeri_v = (PFNGLGETINTEGERI_VPROC)load("glGetIntegeri_v");
+}
+static void load_GL_VERSION_3_2(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_3_2) return;
+ glad_glDrawElementsBaseVertex = (PFNGLDRAWELEMENTSBASEVERTEXPROC)load("glDrawElementsBaseVertex");
+ glad_glDrawRangeElementsBaseVertex = (PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC)load("glDrawRangeElementsBaseVertex");
+ glad_glDrawElementsInstancedBaseVertex = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC)load("glDrawElementsInstancedBaseVertex");
+ glad_glMultiDrawElementsBaseVertex = (PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC)load("glMultiDrawElementsBaseVertex");
+ glad_glProvokingVertex = (PFNGLPROVOKINGVERTEXPROC)load("glProvokingVertex");
+ glad_glFenceSync = (PFNGLFENCESYNCPROC)load("glFenceSync");
+ glad_glIsSync = (PFNGLISSYNCPROC)load("glIsSync");
+ glad_glDeleteSync = (PFNGLDELETESYNCPROC)load("glDeleteSync");
+ glad_glClientWaitSync = (PFNGLCLIENTWAITSYNCPROC)load("glClientWaitSync");
+ glad_glWaitSync = (PFNGLWAITSYNCPROC)load("glWaitSync");
+ glad_glGetInteger64v = (PFNGLGETINTEGER64VPROC)load("glGetInteger64v");
+ glad_glGetSynciv = (PFNGLGETSYNCIVPROC)load("glGetSynciv");
+ glad_glGetInteger64i_v = (PFNGLGETINTEGER64I_VPROC)load("glGetInteger64i_v");
+ glad_glGetBufferParameteri64v = (PFNGLGETBUFFERPARAMETERI64VPROC)load("glGetBufferParameteri64v");
+ glad_glFramebufferTexture = (PFNGLFRAMEBUFFERTEXTUREPROC)load("glFramebufferTexture");
+ glad_glTexImage2DMultisample = (PFNGLTEXIMAGE2DMULTISAMPLEPROC)load("glTexImage2DMultisample");
+ glad_glTexImage3DMultisample = (PFNGLTEXIMAGE3DMULTISAMPLEPROC)load("glTexImage3DMultisample");
+ glad_glGetMultisamplefv = (PFNGLGETMULTISAMPLEFVPROC)load("glGetMultisamplefv");
+ glad_glSampleMaski = (PFNGLSAMPLEMASKIPROC)load("glSampleMaski");
+}
+static void load_GL_VERSION_3_3(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_3_3) return;
+ glad_glBindFragDataLocationIndexed = (PFNGLBINDFRAGDATALOCATIONINDEXEDPROC)load("glBindFragDataLocationIndexed");
+ glad_glGetFragDataIndex = (PFNGLGETFRAGDATAINDEXPROC)load("glGetFragDataIndex");
+ glad_glGenSamplers = (PFNGLGENSAMPLERSPROC)load("glGenSamplers");
+ glad_glDeleteSamplers = (PFNGLDELETESAMPLERSPROC)load("glDeleteSamplers");
+ glad_glIsSampler = (PFNGLISSAMPLERPROC)load("glIsSampler");
+ glad_glBindSampler = (PFNGLBINDSAMPLERPROC)load("glBindSampler");
+ glad_glSamplerParameteri = (PFNGLSAMPLERPARAMETERIPROC)load("glSamplerParameteri");
+ glad_glSamplerParameteriv = (PFNGLSAMPLERPARAMETERIVPROC)load("glSamplerParameteriv");
+ glad_glSamplerParameterf = (PFNGLSAMPLERPARAMETERFPROC)load("glSamplerParameterf");
+ glad_glSamplerParameterfv = (PFNGLSAMPLERPARAMETERFVPROC)load("glSamplerParameterfv");
+ glad_glSamplerParameterIiv = (PFNGLSAMPLERPARAMETERIIVPROC)load("glSamplerParameterIiv");
+ glad_glSamplerParameterIuiv = (PFNGLSAMPLERPARAMETERIUIVPROC)load("glSamplerParameterIuiv");
+ glad_glGetSamplerParameteriv = (PFNGLGETSAMPLERPARAMETERIVPROC)load("glGetSamplerParameteriv");
+ glad_glGetSamplerParameterIiv = (PFNGLGETSAMPLERPARAMETERIIVPROC)load("glGetSamplerParameterIiv");
+ glad_glGetSamplerParameterfv = (PFNGLGETSAMPLERPARAMETERFVPROC)load("glGetSamplerParameterfv");
+ glad_glGetSamplerParameterIuiv = (PFNGLGETSAMPLERPARAMETERIUIVPROC)load("glGetSamplerParameterIuiv");
+ glad_glQueryCounter = (PFNGLQUERYCOUNTERPROC)load("glQueryCounter");
+ glad_glGetQueryObjecti64v = (PFNGLGETQUERYOBJECTI64VPROC)load("glGetQueryObjecti64v");
+ glad_glGetQueryObjectui64v = (PFNGLGETQUERYOBJECTUI64VPROC)load("glGetQueryObjectui64v");
+ glad_glVertexAttribDivisor = (PFNGLVERTEXATTRIBDIVISORPROC)load("glVertexAttribDivisor");
+ glad_glVertexAttribP1ui = (PFNGLVERTEXATTRIBP1UIPROC)load("glVertexAttribP1ui");
+ glad_glVertexAttribP1uiv = (PFNGLVERTEXATTRIBP1UIVPROC)load("glVertexAttribP1uiv");
+ glad_glVertexAttribP2ui = (PFNGLVERTEXATTRIBP2UIPROC)load("glVertexAttribP2ui");
+ glad_glVertexAttribP2uiv = (PFNGLVERTEXATTRIBP2UIVPROC)load("glVertexAttribP2uiv");
+ glad_glVertexAttribP3ui = (PFNGLVERTEXATTRIBP3UIPROC)load("glVertexAttribP3ui");
+ glad_glVertexAttribP3uiv = (PFNGLVERTEXATTRIBP3UIVPROC)load("glVertexAttribP3uiv");
+ glad_glVertexAttribP4ui = (PFNGLVERTEXATTRIBP4UIPROC)load("glVertexAttribP4ui");
+ glad_glVertexAttribP4uiv = (PFNGLVERTEXATTRIBP4UIVPROC)load("glVertexAttribP4uiv");
+ glad_glVertexP2ui = (PFNGLVERTEXP2UIPROC)load("glVertexP2ui");
+ glad_glVertexP2uiv = (PFNGLVERTEXP2UIVPROC)load("glVertexP2uiv");
+ glad_glVertexP3ui = (PFNGLVERTEXP3UIPROC)load("glVertexP3ui");
+ glad_glVertexP3uiv = (PFNGLVERTEXP3UIVPROC)load("glVertexP3uiv");
+ glad_glVertexP4ui = (PFNGLVERTEXP4UIPROC)load("glVertexP4ui");
+ glad_glVertexP4uiv = (PFNGLVERTEXP4UIVPROC)load("glVertexP4uiv");
+ glad_glTexCoordP1ui = (PFNGLTEXCOORDP1UIPROC)load("glTexCoordP1ui");
+ glad_glTexCoordP1uiv = (PFNGLTEXCOORDP1UIVPROC)load("glTexCoordP1uiv");
+ glad_glTexCoordP2ui = (PFNGLTEXCOORDP2UIPROC)load("glTexCoordP2ui");
+ glad_glTexCoordP2uiv = (PFNGLTEXCOORDP2UIVPROC)load("glTexCoordP2uiv");
+ glad_glTexCoordP3ui = (PFNGLTEXCOORDP3UIPROC)load("glTexCoordP3ui");
+ glad_glTexCoordP3uiv = (PFNGLTEXCOORDP3UIVPROC)load("glTexCoordP3uiv");
+ glad_glTexCoordP4ui = (PFNGLTEXCOORDP4UIPROC)load("glTexCoordP4ui");
+ glad_glTexCoordP4uiv = (PFNGLTEXCOORDP4UIVPROC)load("glTexCoordP4uiv");
+ glad_glMultiTexCoordP1ui = (PFNGLMULTITEXCOORDP1UIPROC)load("glMultiTexCoordP1ui");
+ glad_glMultiTexCoordP1uiv = (PFNGLMULTITEXCOORDP1UIVPROC)load("glMultiTexCoordP1uiv");
+ glad_glMultiTexCoordP2ui = (PFNGLMULTITEXCOORDP2UIPROC)load("glMultiTexCoordP2ui");
+ glad_glMultiTexCoordP2uiv = (PFNGLMULTITEXCOORDP2UIVPROC)load("glMultiTexCoordP2uiv");
+ glad_glMultiTexCoordP3ui = (PFNGLMULTITEXCOORDP3UIPROC)load("glMultiTexCoordP3ui");
+ glad_glMultiTexCoordP3uiv = (PFNGLMULTITEXCOORDP3UIVPROC)load("glMultiTexCoordP3uiv");
+ glad_glMultiTexCoordP4ui = (PFNGLMULTITEXCOORDP4UIPROC)load("glMultiTexCoordP4ui");
+ glad_glMultiTexCoordP4uiv = (PFNGLMULTITEXCOORDP4UIVPROC)load("glMultiTexCoordP4uiv");
+ glad_glNormalP3ui = (PFNGLNORMALP3UIPROC)load("glNormalP3ui");
+ glad_glNormalP3uiv = (PFNGLNORMALP3UIVPROC)load("glNormalP3uiv");
+ glad_glColorP3ui = (PFNGLCOLORP3UIPROC)load("glColorP3ui");
+ glad_glColorP3uiv = (PFNGLCOLORP3UIVPROC)load("glColorP3uiv");
+ glad_glColorP4ui = (PFNGLCOLORP4UIPROC)load("glColorP4ui");
+ glad_glColorP4uiv = (PFNGLCOLORP4UIVPROC)load("glColorP4uiv");
+ glad_glSecondaryColorP3ui = (PFNGLSECONDARYCOLORP3UIPROC)load("glSecondaryColorP3ui");
+ glad_glSecondaryColorP3uiv = (PFNGLSECONDARYCOLORP3UIVPROC)load("glSecondaryColorP3uiv");
+}
+static void load_GL_VERSION_4_0(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_4_0) return;
+ glad_glMinSampleShading = (PFNGLMINSAMPLESHADINGPROC)load("glMinSampleShading");
+ glad_glBlendEquationi = (PFNGLBLENDEQUATIONIPROC)load("glBlendEquationi");
+ glad_glBlendEquationSeparatei = (PFNGLBLENDEQUATIONSEPARATEIPROC)load("glBlendEquationSeparatei");
+ glad_glBlendFunci = (PFNGLBLENDFUNCIPROC)load("glBlendFunci");
+ glad_glBlendFuncSeparatei = (PFNGLBLENDFUNCSEPARATEIPROC)load("glBlendFuncSeparatei");
+ glad_glDrawArraysIndirect = (PFNGLDRAWARRAYSINDIRECTPROC)load("glDrawArraysIndirect");
+ glad_glDrawElementsIndirect = (PFNGLDRAWELEMENTSINDIRECTPROC)load("glDrawElementsIndirect");
+ glad_glUniform1d = (PFNGLUNIFORM1DPROC)load("glUniform1d");
+ glad_glUniform2d = (PFNGLUNIFORM2DPROC)load("glUniform2d");
+ glad_glUniform3d = (PFNGLUNIFORM3DPROC)load("glUniform3d");
+ glad_glUniform4d = (PFNGLUNIFORM4DPROC)load("glUniform4d");
+ glad_glUniform1dv = (PFNGLUNIFORM1DVPROC)load("glUniform1dv");
+ glad_glUniform2dv = (PFNGLUNIFORM2DVPROC)load("glUniform2dv");
+ glad_glUniform3dv = (PFNGLUNIFORM3DVPROC)load("glUniform3dv");
+ glad_glUniform4dv = (PFNGLUNIFORM4DVPROC)load("glUniform4dv");
+ glad_glUniformMatrix2dv = (PFNGLUNIFORMMATRIX2DVPROC)load("glUniformMatrix2dv");
+ glad_glUniformMatrix3dv = (PFNGLUNIFORMMATRIX3DVPROC)load("glUniformMatrix3dv");
+ glad_glUniformMatrix4dv = (PFNGLUNIFORMMATRIX4DVPROC)load("glUniformMatrix4dv");
+ glad_glUniformMatrix2x3dv = (PFNGLUNIFORMMATRIX2X3DVPROC)load("glUniformMatrix2x3dv");
+ glad_glUniformMatrix2x4dv = (PFNGLUNIFORMMATRIX2X4DVPROC)load("glUniformMatrix2x4dv");
+ glad_glUniformMatrix3x2dv = (PFNGLUNIFORMMATRIX3X2DVPROC)load("glUniformMatrix3x2dv");
+ glad_glUniformMatrix3x4dv = (PFNGLUNIFORMMATRIX3X4DVPROC)load("glUniformMatrix3x4dv");
+ glad_glUniformMatrix4x2dv = (PFNGLUNIFORMMATRIX4X2DVPROC)load("glUniformMatrix4x2dv");
+ glad_glUniformMatrix4x3dv = (PFNGLUNIFORMMATRIX4X3DVPROC)load("glUniformMatrix4x3dv");
+ glad_glGetUniformdv = (PFNGLGETUNIFORMDVPROC)load("glGetUniformdv");
+ glad_glGetSubroutineUniformLocation = (PFNGLGETSUBROUTINEUNIFORMLOCATIONPROC)load("glGetSubroutineUniformLocation");
+ glad_glGetSubroutineIndex = (PFNGLGETSUBROUTINEINDEXPROC)load("glGetSubroutineIndex");
+ glad_glGetActiveSubroutineUniformiv = (PFNGLGETACTIVESUBROUTINEUNIFORMIVPROC)load("glGetActiveSubroutineUniformiv");
+ glad_glGetActiveSubroutineUniformName = (PFNGLGETACTIVESUBROUTINEUNIFORMNAMEPROC)load("glGetActiveSubroutineUniformName");
+ glad_glGetActiveSubroutineName = (PFNGLGETACTIVESUBROUTINENAMEPROC)load("glGetActiveSubroutineName");
+ glad_glUniformSubroutinesuiv = (PFNGLUNIFORMSUBROUTINESUIVPROC)load("glUniformSubroutinesuiv");
+ glad_glGetUniformSubroutineuiv = (PFNGLGETUNIFORMSUBROUTINEUIVPROC)load("glGetUniformSubroutineuiv");
+ glad_glGetProgramStageiv = (PFNGLGETPROGRAMSTAGEIVPROC)load("glGetProgramStageiv");
+ glad_glPatchParameteri = (PFNGLPATCHPARAMETERIPROC)load("glPatchParameteri");
+ glad_glPatchParameterfv = (PFNGLPATCHPARAMETERFVPROC)load("glPatchParameterfv");
+ glad_glBindTransformFeedback = (PFNGLBINDTRANSFORMFEEDBACKPROC)load("glBindTransformFeedback");
+ glad_glDeleteTransformFeedbacks = (PFNGLDELETETRANSFORMFEEDBACKSPROC)load("glDeleteTransformFeedbacks");
+ glad_glGenTransformFeedbacks = (PFNGLGENTRANSFORMFEEDBACKSPROC)load("glGenTransformFeedbacks");
+ glad_glIsTransformFeedback = (PFNGLISTRANSFORMFEEDBACKPROC)load("glIsTransformFeedback");
+ glad_glPauseTransformFeedback = (PFNGLPAUSETRANSFORMFEEDBACKPROC)load("glPauseTransformFeedback");
+ glad_glResumeTransformFeedback = (PFNGLRESUMETRANSFORMFEEDBACKPROC)load("glResumeTransformFeedback");
+ glad_glDrawTransformFeedback = (PFNGLDRAWTRANSFORMFEEDBACKPROC)load("glDrawTransformFeedback");
+ glad_glDrawTransformFeedbackStream = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMPROC)load("glDrawTransformFeedbackStream");
+ glad_glBeginQueryIndexed = (PFNGLBEGINQUERYINDEXEDPROC)load("glBeginQueryIndexed");
+ glad_glEndQueryIndexed = (PFNGLENDQUERYINDEXEDPROC)load("glEndQueryIndexed");
+ glad_glGetQueryIndexediv = (PFNGLGETQUERYINDEXEDIVPROC)load("glGetQueryIndexediv");
+}
+static void load_GL_VERSION_4_1(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_4_1) return;
+ glad_glReleaseShaderCompiler = (PFNGLRELEASESHADERCOMPILERPROC)load("glReleaseShaderCompiler");
+ glad_glShaderBinary = (PFNGLSHADERBINARYPROC)load("glShaderBinary");
+ glad_glGetShaderPrecisionFormat = (PFNGLGETSHADERPRECISIONFORMATPROC)load("glGetShaderPrecisionFormat");
+ glad_glDepthRangef = (PFNGLDEPTHRANGEFPROC)load("glDepthRangef");
+ glad_glClearDepthf = (PFNGLCLEARDEPTHFPROC)load("glClearDepthf");
+ glad_glGetProgramBinary = (PFNGLGETPROGRAMBINARYPROC)load("glGetProgramBinary");
+ glad_glProgramBinary = (PFNGLPROGRAMBINARYPROC)load("glProgramBinary");
+ glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)load("glProgramParameteri");
+ glad_glUseProgramStages = (PFNGLUSEPROGRAMSTAGESPROC)load("glUseProgramStages");
+ glad_glActiveShaderProgram = (PFNGLACTIVESHADERPROGRAMPROC)load("glActiveShaderProgram");
+ glad_glCreateShaderProgramv = (PFNGLCREATESHADERPROGRAMVPROC)load("glCreateShaderProgramv");
+ glad_glBindProgramPipeline = (PFNGLBINDPROGRAMPIPELINEPROC)load("glBindProgramPipeline");
+ glad_glDeleteProgramPipelines = (PFNGLDELETEPROGRAMPIPELINESPROC)load("glDeleteProgramPipelines");
+ glad_glGenProgramPipelines = (PFNGLGENPROGRAMPIPELINESPROC)load("glGenProgramPipelines");
+ glad_glIsProgramPipeline = (PFNGLISPROGRAMPIPELINEPROC)load("glIsProgramPipeline");
+ glad_glGetProgramPipelineiv = (PFNGLGETPROGRAMPIPELINEIVPROC)load("glGetProgramPipelineiv");
+ glad_glProgramParameteri = (PFNGLPROGRAMPARAMETERIPROC)load("glProgramParameteri");
+ glad_glProgramUniform1i = (PFNGLPROGRAMUNIFORM1IPROC)load("glProgramUniform1i");
+ glad_glProgramUniform1iv = (PFNGLPROGRAMUNIFORM1IVPROC)load("glProgramUniform1iv");
+ glad_glProgramUniform1f = (PFNGLPROGRAMUNIFORM1FPROC)load("glProgramUniform1f");
+ glad_glProgramUniform1fv = (PFNGLPROGRAMUNIFORM1FVPROC)load("glProgramUniform1fv");
+ glad_glProgramUniform1d = (PFNGLPROGRAMUNIFORM1DPROC)load("glProgramUniform1d");
+ glad_glProgramUniform1dv = (PFNGLPROGRAMUNIFORM1DVPROC)load("glProgramUniform1dv");
+ glad_glProgramUniform1ui = (PFNGLPROGRAMUNIFORM1UIPROC)load("glProgramUniform1ui");
+ glad_glProgramUniform1uiv = (PFNGLPROGRAMUNIFORM1UIVPROC)load("glProgramUniform1uiv");
+ glad_glProgramUniform2i = (PFNGLPROGRAMUNIFORM2IPROC)load("glProgramUniform2i");
+ glad_glProgramUniform2iv = (PFNGLPROGRAMUNIFORM2IVPROC)load("glProgramUniform2iv");
+ glad_glProgramUniform2f = (PFNGLPROGRAMUNIFORM2FPROC)load("glProgramUniform2f");
+ glad_glProgramUniform2fv = (PFNGLPROGRAMUNIFORM2FVPROC)load("glProgramUniform2fv");
+ glad_glProgramUniform2d = (PFNGLPROGRAMUNIFORM2DPROC)load("glProgramUniform2d");
+ glad_glProgramUniform2dv = (PFNGLPROGRAMUNIFORM2DVPROC)load("glProgramUniform2dv");
+ glad_glProgramUniform2ui = (PFNGLPROGRAMUNIFORM2UIPROC)load("glProgramUniform2ui");
+ glad_glProgramUniform2uiv = (PFNGLPROGRAMUNIFORM2UIVPROC)load("glProgramUniform2uiv");
+ glad_glProgramUniform3i = (PFNGLPROGRAMUNIFORM3IPROC)load("glProgramUniform3i");
+ glad_glProgramUniform3iv = (PFNGLPROGRAMUNIFORM3IVPROC)load("glProgramUniform3iv");
+ glad_glProgramUniform3f = (PFNGLPROGRAMUNIFORM3FPROC)load("glProgramUniform3f");
+ glad_glProgramUniform3fv = (PFNGLPROGRAMUNIFORM3FVPROC)load("glProgramUniform3fv");
+ glad_glProgramUniform3d = (PFNGLPROGRAMUNIFORM3DPROC)load("glProgramUniform3d");
+ glad_glProgramUniform3dv = (PFNGLPROGRAMUNIFORM3DVPROC)load("glProgramUniform3dv");
+ glad_glProgramUniform3ui = (PFNGLPROGRAMUNIFORM3UIPROC)load("glProgramUniform3ui");
+ glad_glProgramUniform3uiv = (PFNGLPROGRAMUNIFORM3UIVPROC)load("glProgramUniform3uiv");
+ glad_glProgramUniform4i = (PFNGLPROGRAMUNIFORM4IPROC)load("glProgramUniform4i");
+ glad_glProgramUniform4iv = (PFNGLPROGRAMUNIFORM4IVPROC)load("glProgramUniform4iv");
+ glad_glProgramUniform4f = (PFNGLPROGRAMUNIFORM4FPROC)load("glProgramUniform4f");
+ glad_glProgramUniform4fv = (PFNGLPROGRAMUNIFORM4FVPROC)load("glProgramUniform4fv");
+ glad_glProgramUniform4d = (PFNGLPROGRAMUNIFORM4DPROC)load("glProgramUniform4d");
+ glad_glProgramUniform4dv = (PFNGLPROGRAMUNIFORM4DVPROC)load("glProgramUniform4dv");
+ glad_glProgramUniform4ui = (PFNGLPROGRAMUNIFORM4UIPROC)load("glProgramUniform4ui");
+ glad_glProgramUniform4uiv = (PFNGLPROGRAMUNIFORM4UIVPROC)load("glProgramUniform4uiv");
+ glad_glProgramUniformMatrix2fv = (PFNGLPROGRAMUNIFORMMATRIX2FVPROC)load("glProgramUniformMatrix2fv");
+ glad_glProgramUniformMatrix3fv = (PFNGLPROGRAMUNIFORMMATRIX3FVPROC)load("glProgramUniformMatrix3fv");
+ glad_glProgramUniformMatrix4fv = (PFNGLPROGRAMUNIFORMMATRIX4FVPROC)load("glProgramUniformMatrix4fv");
+ glad_glProgramUniformMatrix2dv = (PFNGLPROGRAMUNIFORMMATRIX2DVPROC)load("glProgramUniformMatrix2dv");
+ glad_glProgramUniformMatrix3dv = (PFNGLPROGRAMUNIFORMMATRIX3DVPROC)load("glProgramUniformMatrix3dv");
+ glad_glProgramUniformMatrix4dv = (PFNGLPROGRAMUNIFORMMATRIX4DVPROC)load("glProgramUniformMatrix4dv");
+ glad_glProgramUniformMatrix2x3fv = (PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC)load("glProgramUniformMatrix2x3fv");
+ glad_glProgramUniformMatrix3x2fv = (PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC)load("glProgramUniformMatrix3x2fv");
+ glad_glProgramUniformMatrix2x4fv = (PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC)load("glProgramUniformMatrix2x4fv");
+ glad_glProgramUniformMatrix4x2fv = (PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC)load("glProgramUniformMatrix4x2fv");
+ glad_glProgramUniformMatrix3x4fv = (PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC)load("glProgramUniformMatrix3x4fv");
+ glad_glProgramUniformMatrix4x3fv = (PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC)load("glProgramUniformMatrix4x3fv");
+ glad_glProgramUniformMatrix2x3dv = (PFNGLPROGRAMUNIFORMMATRIX2X3DVPROC)load("glProgramUniformMatrix2x3dv");
+ glad_glProgramUniformMatrix3x2dv = (PFNGLPROGRAMUNIFORMMATRIX3X2DVPROC)load("glProgramUniformMatrix3x2dv");
+ glad_glProgramUniformMatrix2x4dv = (PFNGLPROGRAMUNIFORMMATRIX2X4DVPROC)load("glProgramUniformMatrix2x4dv");
+ glad_glProgramUniformMatrix4x2dv = (PFNGLPROGRAMUNIFORMMATRIX4X2DVPROC)load("glProgramUniformMatrix4x2dv");
+ glad_glProgramUniformMatrix3x4dv = (PFNGLPROGRAMUNIFORMMATRIX3X4DVPROC)load("glProgramUniformMatrix3x4dv");
+ glad_glProgramUniformMatrix4x3dv = (PFNGLPROGRAMUNIFORMMATRIX4X3DVPROC)load("glProgramUniformMatrix4x3dv");
+ glad_glValidateProgramPipeline = (PFNGLVALIDATEPROGRAMPIPELINEPROC)load("glValidateProgramPipeline");
+ glad_glGetProgramPipelineInfoLog = (PFNGLGETPROGRAMPIPELINEINFOLOGPROC)load("glGetProgramPipelineInfoLog");
+ glad_glVertexAttribL1d = (PFNGLVERTEXATTRIBL1DPROC)load("glVertexAttribL1d");
+ glad_glVertexAttribL2d = (PFNGLVERTEXATTRIBL2DPROC)load("glVertexAttribL2d");
+ glad_glVertexAttribL3d = (PFNGLVERTEXATTRIBL3DPROC)load("glVertexAttribL3d");
+ glad_glVertexAttribL4d = (PFNGLVERTEXATTRIBL4DPROC)load("glVertexAttribL4d");
+ glad_glVertexAttribL1dv = (PFNGLVERTEXATTRIBL1DVPROC)load("glVertexAttribL1dv");
+ glad_glVertexAttribL2dv = (PFNGLVERTEXATTRIBL2DVPROC)load("glVertexAttribL2dv");
+ glad_glVertexAttribL3dv = (PFNGLVERTEXATTRIBL3DVPROC)load("glVertexAttribL3dv");
+ glad_glVertexAttribL4dv = (PFNGLVERTEXATTRIBL4DVPROC)load("glVertexAttribL4dv");
+ glad_glVertexAttribLPointer = (PFNGLVERTEXATTRIBLPOINTERPROC)load("glVertexAttribLPointer");
+ glad_glGetVertexAttribLdv = (PFNGLGETVERTEXATTRIBLDVPROC)load("glGetVertexAttribLdv");
+ glad_glViewportArrayv = (PFNGLVIEWPORTARRAYVPROC)load("glViewportArrayv");
+ glad_glViewportIndexedf = (PFNGLVIEWPORTINDEXEDFPROC)load("glViewportIndexedf");
+ glad_glViewportIndexedfv = (PFNGLVIEWPORTINDEXEDFVPROC)load("glViewportIndexedfv");
+ glad_glScissorArrayv = (PFNGLSCISSORARRAYVPROC)load("glScissorArrayv");
+ glad_glScissorIndexed = (PFNGLSCISSORINDEXEDPROC)load("glScissorIndexed");
+ glad_glScissorIndexedv = (PFNGLSCISSORINDEXEDVPROC)load("glScissorIndexedv");
+ glad_glDepthRangeArrayv = (PFNGLDEPTHRANGEARRAYVPROC)load("glDepthRangeArrayv");
+ glad_glDepthRangeIndexed = (PFNGLDEPTHRANGEINDEXEDPROC)load("glDepthRangeIndexed");
+ glad_glGetFloati_v = (PFNGLGETFLOATI_VPROC)load("glGetFloati_v");
+ glad_glGetDoublei_v = (PFNGLGETDOUBLEI_VPROC)load("glGetDoublei_v");
+}
+static void load_GL_VERSION_4_2(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_4_2) return;
+ glad_glDrawArraysInstancedBaseInstance = (PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC)load("glDrawArraysInstancedBaseInstance");
+ glad_glDrawElementsInstancedBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC)load("glDrawElementsInstancedBaseInstance");
+ glad_glDrawElementsInstancedBaseVertexBaseInstance = (PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC)load("glDrawElementsInstancedBaseVertexBaseInstance");
+ glad_glGetInternalformativ = (PFNGLGETINTERNALFORMATIVPROC)load("glGetInternalformativ");
+ glad_glGetActiveAtomicCounterBufferiv = (PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC)load("glGetActiveAtomicCounterBufferiv");
+ glad_glBindImageTexture = (PFNGLBINDIMAGETEXTUREPROC)load("glBindImageTexture");
+ glad_glMemoryBarrier = (PFNGLMEMORYBARRIERPROC)load("glMemoryBarrier");
+ glad_glTexStorage1D = (PFNGLTEXSTORAGE1DPROC)load("glTexStorage1D");
+ glad_glTexStorage2D = (PFNGLTEXSTORAGE2DPROC)load("glTexStorage2D");
+ glad_glTexStorage3D = (PFNGLTEXSTORAGE3DPROC)load("glTexStorage3D");
+ glad_glDrawTransformFeedbackInstanced = (PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC)load("glDrawTransformFeedbackInstanced");
+ glad_glDrawTransformFeedbackStreamInstanced = (PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC)load("glDrawTransformFeedbackStreamInstanced");
+}
+static void load_GL_VERSION_4_3(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_4_3) return;
+ glad_glClearBufferData = (PFNGLCLEARBUFFERDATAPROC)load("glClearBufferData");
+ glad_glClearBufferSubData = (PFNGLCLEARBUFFERSUBDATAPROC)load("glClearBufferSubData");
+ glad_glDispatchCompute = (PFNGLDISPATCHCOMPUTEPROC)load("glDispatchCompute");
+ glad_glDispatchComputeIndirect = (PFNGLDISPATCHCOMPUTEINDIRECTPROC)load("glDispatchComputeIndirect");
+ glad_glCopyImageSubData = (PFNGLCOPYIMAGESUBDATAPROC)load("glCopyImageSubData");
+ glad_glFramebufferParameteri = (PFNGLFRAMEBUFFERPARAMETERIPROC)load("glFramebufferParameteri");
+ glad_glGetFramebufferParameteriv = (PFNGLGETFRAMEBUFFERPARAMETERIVPROC)load("glGetFramebufferParameteriv");
+ glad_glGetInternalformati64v = (PFNGLGETINTERNALFORMATI64VPROC)load("glGetInternalformati64v");
+ glad_glInvalidateTexSubImage = (PFNGLINVALIDATETEXSUBIMAGEPROC)load("glInvalidateTexSubImage");
+ glad_glInvalidateTexImage = (PFNGLINVALIDATETEXIMAGEPROC)load("glInvalidateTexImage");
+ glad_glInvalidateBufferSubData = (PFNGLINVALIDATEBUFFERSUBDATAPROC)load("glInvalidateBufferSubData");
+ glad_glInvalidateBufferData = (PFNGLINVALIDATEBUFFERDATAPROC)load("glInvalidateBufferData");
+ glad_glInvalidateFramebuffer = (PFNGLINVALIDATEFRAMEBUFFERPROC)load("glInvalidateFramebuffer");
+ glad_glInvalidateSubFramebuffer = (PFNGLINVALIDATESUBFRAMEBUFFERPROC)load("glInvalidateSubFramebuffer");
+ glad_glMultiDrawArraysIndirect = (PFNGLMULTIDRAWARRAYSINDIRECTPROC)load("glMultiDrawArraysIndirect");
+ glad_glMultiDrawElementsIndirect = (PFNGLMULTIDRAWELEMENTSINDIRECTPROC)load("glMultiDrawElementsIndirect");
+ glad_glGetProgramInterfaceiv = (PFNGLGETPROGRAMINTERFACEIVPROC)load("glGetProgramInterfaceiv");
+ glad_glGetProgramResourceIndex = (PFNGLGETPROGRAMRESOURCEINDEXPROC)load("glGetProgramResourceIndex");
+ glad_glGetProgramResourceName = (PFNGLGETPROGRAMRESOURCENAMEPROC)load("glGetProgramResourceName");
+ glad_glGetProgramResourceiv = (PFNGLGETPROGRAMRESOURCEIVPROC)load("glGetProgramResourceiv");
+ glad_glGetProgramResourceLocation = (PFNGLGETPROGRAMRESOURCELOCATIONPROC)load("glGetProgramResourceLocation");
+ glad_glGetProgramResourceLocationIndex = (PFNGLGETPROGRAMRESOURCELOCATIONINDEXPROC)load("glGetProgramResourceLocationIndex");
+ glad_glShaderStorageBlockBinding = (PFNGLSHADERSTORAGEBLOCKBINDINGPROC)load("glShaderStorageBlockBinding");
+ glad_glTexBufferRange = (PFNGLTEXBUFFERRANGEPROC)load("glTexBufferRange");
+ glad_glTexStorage2DMultisample = (PFNGLTEXSTORAGE2DMULTISAMPLEPROC)load("glTexStorage2DMultisample");
+ glad_glTexStorage3DMultisample = (PFNGLTEXSTORAGE3DMULTISAMPLEPROC)load("glTexStorage3DMultisample");
+ glad_glTextureView = (PFNGLTEXTUREVIEWPROC)load("glTextureView");
+ glad_glBindVertexBuffer = (PFNGLBINDVERTEXBUFFERPROC)load("glBindVertexBuffer");
+ glad_glVertexAttribFormat = (PFNGLVERTEXATTRIBFORMATPROC)load("glVertexAttribFormat");
+ glad_glVertexAttribIFormat = (PFNGLVERTEXATTRIBIFORMATPROC)load("glVertexAttribIFormat");
+ glad_glVertexAttribLFormat = (PFNGLVERTEXATTRIBLFORMATPROC)load("glVertexAttribLFormat");
+ glad_glVertexAttribBinding = (PFNGLVERTEXATTRIBBINDINGPROC)load("glVertexAttribBinding");
+ glad_glVertexBindingDivisor = (PFNGLVERTEXBINDINGDIVISORPROC)load("glVertexBindingDivisor");
+ glad_glDebugMessageControl = (PFNGLDEBUGMESSAGECONTROLPROC)load("glDebugMessageControl");
+ glad_glDebugMessageInsert = (PFNGLDEBUGMESSAGEINSERTPROC)load("glDebugMessageInsert");
+ glad_glDebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKPROC)load("glDebugMessageCallback");
+ glad_glGetDebugMessageLog = (PFNGLGETDEBUGMESSAGELOGPROC)load("glGetDebugMessageLog");
+ glad_glPushDebugGroup = (PFNGLPUSHDEBUGGROUPPROC)load("glPushDebugGroup");
+ glad_glPopDebugGroup = (PFNGLPOPDEBUGGROUPPROC)load("glPopDebugGroup");
+ glad_glObjectLabel = (PFNGLOBJECTLABELPROC)load("glObjectLabel");
+ glad_glGetObjectLabel = (PFNGLGETOBJECTLABELPROC)load("glGetObjectLabel");
+ glad_glObjectPtrLabel = (PFNGLOBJECTPTRLABELPROC)load("glObjectPtrLabel");
+ glad_glGetObjectPtrLabel = (PFNGLGETOBJECTPTRLABELPROC)load("glGetObjectPtrLabel");
+ glad_glGetPointerv = (PFNGLGETPOINTERVPROC)load("glGetPointerv");
+}
+static void load_GL_VERSION_4_4(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_4_4) return;
+ glad_glBufferStorage = (PFNGLBUFFERSTORAGEPROC)load("glBufferStorage");
+ glad_glClearTexImage = (PFNGLCLEARTEXIMAGEPROC)load("glClearTexImage");
+ glad_glClearTexSubImage = (PFNGLCLEARTEXSUBIMAGEPROC)load("glClearTexSubImage");
+ glad_glBindBuffersBase = (PFNGLBINDBUFFERSBASEPROC)load("glBindBuffersBase");
+ glad_glBindBuffersRange = (PFNGLBINDBUFFERSRANGEPROC)load("glBindBuffersRange");
+ glad_glBindTextures = (PFNGLBINDTEXTURESPROC)load("glBindTextures");
+ glad_glBindSamplers = (PFNGLBINDSAMPLERSPROC)load("glBindSamplers");
+ glad_glBindImageTextures = (PFNGLBINDIMAGETEXTURESPROC)load("glBindImageTextures");
+ glad_glBindVertexBuffers = (PFNGLBINDVERTEXBUFFERSPROC)load("glBindVertexBuffers");
+}
+static void load_GL_VERSION_4_5(GLADloadproc load) {
+ if(!GLAD_GL_VERSION_4_5) return;
+ glad_glClipControl = (PFNGLCLIPCONTROLPROC)load("glClipControl");
+ glad_glCreateTransformFeedbacks = (PFNGLCREATETRANSFORMFEEDBACKSPROC)load("glCreateTransformFeedbacks");
+ glad_glTransformFeedbackBufferBase = (PFNGLTRANSFORMFEEDBACKBUFFERBASEPROC)load("glTransformFeedbackBufferBase");
+ glad_glTransformFeedbackBufferRange = (PFNGLTRANSFORMFEEDBACKBUFFERRANGEPROC)load("glTransformFeedbackBufferRange");
+ glad_glGetTransformFeedbackiv = (PFNGLGETTRANSFORMFEEDBACKIVPROC)load("glGetTransformFeedbackiv");
+ glad_glGetTransformFeedbacki_v = (PFNGLGETTRANSFORMFEEDBACKI_VPROC)load("glGetTransformFeedbacki_v");
+ glad_glGetTransformFeedbacki64_v = (PFNGLGETTRANSFORMFEEDBACKI64_VPROC)load("glGetTransformFeedbacki64_v");
+ glad_glCreateBuffers = (PFNGLCREATEBUFFERSPROC)load("glCreateBuffers");
+ glad_glNamedBufferStorage = (PFNGLNAMEDBUFFERSTORAGEPROC)load("glNamedBufferStorage");
+ glad_glNamedBufferData = (PFNGLNAMEDBUFFERDATAPROC)load("glNamedBufferData");
+ glad_glNamedBufferSubData = (PFNGLNAMEDBUFFERSUBDATAPROC)load("glNamedBufferSubData");
+ glad_glCopyNamedBufferSubData = (PFNGLCOPYNAMEDBUFFERSUBDATAPROC)load("glCopyNamedBufferSubData");
+ glad_glClearNamedBufferData = (PFNGLCLEARNAMEDBUFFERDATAPROC)load("glClearNamedBufferData");
+ glad_glClearNamedBufferSubData = (PFNGLCLEARNAMEDBUFFERSUBDATAPROC)load("glClearNamedBufferSubData");
+ glad_glMapNamedBuffer = (PFNGLMAPNAMEDBUFFERPROC)load("glMapNamedBuffer");
+ glad_glMapNamedBufferRange = (PFNGLMAPNAMEDBUFFERRANGEPROC)load("glMapNamedBufferRange");
+ glad_glUnmapNamedBuffer = (PFNGLUNMAPNAMEDBUFFERPROC)load("glUnmapNamedBuffer");
+ glad_glFlushMappedNamedBufferRange = (PFNGLFLUSHMAPPEDNAMEDBUFFERRANGEPROC)load("glFlushMappedNamedBufferRange");
+ glad_glGetNamedBufferParameteriv = (PFNGLGETNAMEDBUFFERPARAMETERIVPROC)load("glGetNamedBufferParameteriv");
+ glad_glGetNamedBufferParameteri64v = (PFNGLGETNAMEDBUFFERPARAMETERI64VPROC)load("glGetNamedBufferParameteri64v");
+ glad_glGetNamedBufferPointerv = (PFNGLGETNAMEDBUFFERPOINTERVPROC)load("glGetNamedBufferPointerv");
+ glad_glGetNamedBufferSubData = (PFNGLGETNAMEDBUFFERSUBDATAPROC)load("glGetNamedBufferSubData");
+ glad_glCreateFramebuffers = (PFNGLCREATEFRAMEBUFFERSPROC)load("glCreateFramebuffers");
+ glad_glNamedFramebufferRenderbuffer = (PFNGLNAMEDFRAMEBUFFERRENDERBUFFERPROC)load("glNamedFramebufferRenderbuffer");
+ glad_glNamedFramebufferParameteri = (PFNGLNAMEDFRAMEBUFFERPARAMETERIPROC)load("glNamedFramebufferParameteri");
+ glad_glNamedFramebufferTexture = (PFNGLNAMEDFRAMEBUFFERTEXTUREPROC)load("glNamedFramebufferTexture");
+ glad_glNamedFramebufferTextureLayer = (PFNGLNAMEDFRAMEBUFFERTEXTURELAYERPROC)load("glNamedFramebufferTextureLayer");
+ glad_glNamedFramebufferDrawBuffer = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERPROC)load("glNamedFramebufferDrawBuffer");
+ glad_glNamedFramebufferDrawBuffers = (PFNGLNAMEDFRAMEBUFFERDRAWBUFFERSPROC)load("glNamedFramebufferDrawBuffers");
+ glad_glNamedFramebufferReadBuffer = (PFNGLNAMEDFRAMEBUFFERREADBUFFERPROC)load("glNamedFramebufferReadBuffer");
+ glad_glInvalidateNamedFramebufferData = (PFNGLINVALIDATENAMEDFRAMEBUFFERDATAPROC)load("glInvalidateNamedFramebufferData");
+ glad_glInvalidateNamedFramebufferSubData = (PFNGLINVALIDATENAMEDFRAMEBUFFERSUBDATAPROC)load("glInvalidateNamedFramebufferSubData");
+ glad_glClearNamedFramebufferiv = (PFNGLCLEARNAMEDFRAMEBUFFERIVPROC)load("glClearNamedFramebufferiv");
+ glad_glClearNamedFramebufferuiv = (PFNGLCLEARNAMEDFRAMEBUFFERUIVPROC)load("glClearNamedFramebufferuiv");
+ glad_glClearNamedFramebufferfv = (PFNGLCLEARNAMEDFRAMEBUFFERFVPROC)load("glClearNamedFramebufferfv");
+ glad_glClearNamedFramebufferfi = (PFNGLCLEARNAMEDFRAMEBUFFERFIPROC)load("glClearNamedFramebufferfi");
+ glad_glBlitNamedFramebuffer = (PFNGLBLITNAMEDFRAMEBUFFERPROC)load("glBlitNamedFramebuffer");
+ glad_glCheckNamedFramebufferStatus = (PFNGLCHECKNAMEDFRAMEBUFFERSTATUSPROC)load("glCheckNamedFramebufferStatus");
+ glad_glGetNamedFramebufferParameteriv = (PFNGLGETNAMEDFRAMEBUFFERPARAMETERIVPROC)load("glGetNamedFramebufferParameteriv");
+ glad_glGetNamedFramebufferAttachmentParameteriv = (PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVPROC)load("glGetNamedFramebufferAttachmentParameteriv");
+ glad_glCreateRenderbuffers = (PFNGLCREATERENDERBUFFERSPROC)load("glCreateRenderbuffers");
+ glad_glNamedRenderbufferStorage = (PFNGLNAMEDRENDERBUFFERSTORAGEPROC)load("glNamedRenderbufferStorage");
+ glad_glNamedRenderbufferStorageMultisample = (PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEPROC)load("glNamedRenderbufferStorageMultisample");
+ glad_glGetNamedRenderbufferParameteriv = (PFNGLGETNAMEDRENDERBUFFERPARAMETERIVPROC)load("glGetNamedRenderbufferParameteriv");
+ glad_glCreateTextures = (PFNGLCREATETEXTURESPROC)load("glCreateTextures");
+ glad_glTextureBuffer = (PFNGLTEXTUREBUFFERPROC)load("glTextureBuffer");
+ glad_glTextureBufferRange = (PFNGLTEXTUREBUFFERRANGEPROC)load("glTextureBufferRange");
+ glad_glTextureStorage1D = (PFNGLTEXTURESTORAGE1DPROC)load("glTextureStorage1D");
+ glad_glTextureStorage2D = (PFNGLTEXTURESTORAGE2DPROC)load("glTextureStorage2D");
+ glad_glTextureStorage3D = (PFNGLTEXTURESTORAGE3DPROC)load("glTextureStorage3D");
+ glad_glTextureStorage2DMultisample = (PFNGLTEXTURESTORAGE2DMULTISAMPLEPROC)load("glTextureStorage2DMultisample");
+ glad_glTextureStorage3DMultisample = (PFNGLTEXTURESTORAGE3DMULTISAMPLEPROC)load("glTextureStorage3DMultisample");
+ glad_glTextureSubImage1D = (PFNGLTEXTURESUBIMAGE1DPROC)load("glTextureSubImage1D");
+ glad_glTextureSubImage2D = (PFNGLTEXTURESUBIMAGE2DPROC)load("glTextureSubImage2D");
+ glad_glTextureSubImage3D = (PFNGLTEXTURESUBIMAGE3DPROC)load("glTextureSubImage3D");
+ glad_glCompressedTextureSubImage1D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE1DPROC)load("glCompressedTextureSubImage1D");
+ glad_glCompressedTextureSubImage2D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE2DPROC)load("glCompressedTextureSubImage2D");
+ glad_glCompressedTextureSubImage3D = (PFNGLCOMPRESSEDTEXTURESUBIMAGE3DPROC)load("glCompressedTextureSubImage3D");
+ glad_glCopyTextureSubImage1D = (PFNGLCOPYTEXTURESUBIMAGE1DPROC)load("glCopyTextureSubImage1D");
+ glad_glCopyTextureSubImage2D = (PFNGLCOPYTEXTURESUBIMAGE2DPROC)load("glCopyTextureSubImage2D");
+ glad_glCopyTextureSubImage3D = (PFNGLCOPYTEXTURESUBIMAGE3DPROC)load("glCopyTextureSubImage3D");
+ glad_glTextureParameterf = (PFNGLTEXTUREPARAMETERFPROC)load("glTextureParameterf");
+ glad_glTextureParameterfv = (PFNGLTEXTUREPARAMETERFVPROC)load("glTextureParameterfv");
+ glad_glTextureParameteri = (PFNGLTEXTUREPARAMETERIPROC)load("glTextureParameteri");
+ glad_glTextureParameterIiv = (PFNGLTEXTUREPARAMETERIIVPROC)load("glTextureParameterIiv");
+ glad_glTextureParameterIuiv = (PFNGLTEXTUREPARAMETERIUIVPROC)load("glTextureParameterIuiv");
+ glad_glTextureParameteriv = (PFNGLTEXTUREPARAMETERIVPROC)load("glTextureParameteriv");
+ glad_glGenerateTextureMipmap = (PFNGLGENERATETEXTUREMIPMAPPROC)load("glGenerateTextureMipmap");
+ glad_glBindTextureUnit = (PFNGLBINDTEXTUREUNITPROC)load("glBindTextureUnit");
+ glad_glGetTextureImage = (PFNGLGETTEXTUREIMAGEPROC)load("glGetTextureImage");
+ glad_glGetCompressedTextureImage = (PFNGLGETCOMPRESSEDTEXTUREIMAGEPROC)load("glGetCompressedTextureImage");
+ glad_glGetTextureLevelParameterfv = (PFNGLGETTEXTURELEVELPARAMETERFVPROC)load("glGetTextureLevelParameterfv");
+ glad_glGetTextureLevelParameteriv = (PFNGLGETTEXTURELEVELPARAMETERIVPROC)load("glGetTextureLevelParameteriv");
+ glad_glGetTextureParameterfv = (PFNGLGETTEXTUREPARAMETERFVPROC)load("glGetTextureParameterfv");
+ glad_glGetTextureParameterIiv = (PFNGLGETTEXTUREPARAMETERIIVPROC)load("glGetTextureParameterIiv");
+ glad_glGetTextureParameterIuiv = (PFNGLGETTEXTUREPARAMETERIUIVPROC)load("glGetTextureParameterIuiv");
+ glad_glGetTextureParameteriv = (PFNGLGETTEXTUREPARAMETERIVPROC)load("glGetTextureParameteriv");
+ glad_glCreateVertexArrays = (PFNGLCREATEVERTEXARRAYSPROC)load("glCreateVertexArrays");
+ glad_glDisableVertexArrayAttrib = (PFNGLDISABLEVERTEXARRAYATTRIBPROC)load("glDisableVertexArrayAttrib");
+ glad_glEnableVertexArrayAttrib = (PFNGLENABLEVERTEXARRAYATTRIBPROC)load("glEnableVertexArrayAttrib");
+ glad_glVertexArrayElementBuffer = (PFNGLVERTEXARRAYELEMENTBUFFERPROC)load("glVertexArrayElementBuffer");
+ glad_glVertexArrayVertexBuffer = (PFNGLVERTEXARRAYVERTEXBUFFERPROC)load("glVertexArrayVertexBuffer");
+ glad_glVertexArrayVertexBuffers = (PFNGLVERTEXARRAYVERTEXBUFFERSPROC)load("glVertexArrayVertexBuffers");
+ glad_glVertexArrayAttribBinding = (PFNGLVERTEXARRAYATTRIBBINDINGPROC)load("glVertexArrayAttribBinding");
+ glad_glVertexArrayAttribFormat = (PFNGLVERTEXARRAYATTRIBFORMATPROC)load("glVertexArrayAttribFormat");
+ glad_glVertexArrayAttribIFormat = (PFNGLVERTEXARRAYATTRIBIFORMATPROC)load("glVertexArrayAttribIFormat");
+ glad_glVertexArrayAttribLFormat = (PFNGLVERTEXARRAYATTRIBLFORMATPROC)load("glVertexArrayAttribLFormat");
+ glad_glVertexArrayBindingDivisor = (PFNGLVERTEXARRAYBINDINGDIVISORPROC)load("glVertexArrayBindingDivisor");
+ glad_glGetVertexArrayiv = (PFNGLGETVERTEXARRAYIVPROC)load("glGetVertexArrayiv");
+ glad_glGetVertexArrayIndexediv = (PFNGLGETVERTEXARRAYINDEXEDIVPROC)load("glGetVertexArrayIndexediv");
+ glad_glGetVertexArrayIndexed64iv = (PFNGLGETVERTEXARRAYINDEXED64IVPROC)load("glGetVertexArrayIndexed64iv");
+ glad_glCreateSamplers = (PFNGLCREATESAMPLERSPROC)load("glCreateSamplers");
+ glad_glCreateProgramPipelines = (PFNGLCREATEPROGRAMPIPELINESPROC)load("glCreateProgramPipelines");
+ glad_glCreateQueries = (PFNGLCREATEQUERIESPROC)load("glCreateQueries");
+ glad_glGetQueryBufferObjecti64v = (PFNGLGETQUERYBUFFEROBJECTI64VPROC)load("glGetQueryBufferObjecti64v");
+ glad_glGetQueryBufferObjectiv = (PFNGLGETQUERYBUFFEROBJECTIVPROC)load("glGetQueryBufferObjectiv");
+ glad_glGetQueryBufferObjectui64v = (PFNGLGETQUERYBUFFEROBJECTUI64VPROC)load("glGetQueryBufferObjectui64v");
+ glad_glGetQueryBufferObjectuiv = (PFNGLGETQUERYBUFFEROBJECTUIVPROC)load("glGetQueryBufferObjectuiv");
+ glad_glMemoryBarrierByRegion = (PFNGLMEMORYBARRIERBYREGIONPROC)load("glMemoryBarrierByRegion");
+ glad_glGetTextureSubImage = (PFNGLGETTEXTURESUBIMAGEPROC)load("glGetTextureSubImage");
+ glad_glGetCompressedTextureSubImage = (PFNGLGETCOMPRESSEDTEXTURESUBIMAGEPROC)load("glGetCompressedTextureSubImage");
+ glad_glGetGraphicsResetStatus = (PFNGLGETGRAPHICSRESETSTATUSPROC)load("glGetGraphicsResetStatus");
+ glad_glGetnCompressedTexImage = (PFNGLGETNCOMPRESSEDTEXIMAGEPROC)load("glGetnCompressedTexImage");
+ glad_glGetnTexImage = (PFNGLGETNTEXIMAGEPROC)load("glGetnTexImage");
+ glad_glGetnUniformdv = (PFNGLGETNUNIFORMDVPROC)load("glGetnUniformdv");
+ glad_glGetnUniformfv = (PFNGLGETNUNIFORMFVPROC)load("glGetnUniformfv");
+ glad_glGetnUniformiv = (PFNGLGETNUNIFORMIVPROC)load("glGetnUniformiv");
+ glad_glGetnUniformuiv = (PFNGLGETNUNIFORMUIVPROC)load("glGetnUniformuiv");
+ glad_glReadnPixels = (PFNGLREADNPIXELSPROC)load("glReadnPixels");
+ glad_glGetnMapdv = (PFNGLGETNMAPDVPROC)load("glGetnMapdv");
+ glad_glGetnMapfv = (PFNGLGETNMAPFVPROC)load("glGetnMapfv");
+ glad_glGetnMapiv = (PFNGLGETNMAPIVPROC)load("glGetnMapiv");
+ glad_glGetnPixelMapfv = (PFNGLGETNPIXELMAPFVPROC)load("glGetnPixelMapfv");
+ glad_glGetnPixelMapuiv = (PFNGLGETNPIXELMAPUIVPROC)load("glGetnPixelMapuiv");
+ glad_glGetnPixelMapusv = (PFNGLGETNPIXELMAPUSVPROC)load("glGetnPixelMapusv");
+ glad_glGetnPolygonStipple = (PFNGLGETNPOLYGONSTIPPLEPROC)load("glGetnPolygonStipple");
+ glad_glGetnColorTable = (PFNGLGETNCOLORTABLEPROC)load("glGetnColorTable");
+ glad_glGetnConvolutionFilter = (PFNGLGETNCONVOLUTIONFILTERPROC)load("glGetnConvolutionFilter");
+ glad_glGetnSeparableFilter = (PFNGLGETNSEPARABLEFILTERPROC)load("glGetnSeparableFilter");
+ glad_glGetnHistogram = (PFNGLGETNHISTOGRAMPROC)load("glGetnHistogram");
+ glad_glGetnMinmax = (PFNGLGETNMINMAXPROC)load("glGetnMinmax");
+ glad_glTextureBarrier = (PFNGLTEXTUREBARRIERPROC)load("glTextureBarrier");
+}
+static int find_extensionsGL(void) {
+ if (!get_exts()) return 0;
+ (void)&has_ext;
+ free_exts();
+ return 1;
+}
+
+static void find_coreGL(void) {
+
+ /* Thank you @elmindreda
+ * https://github.com/elmindreda/greg/blob/master/templates/greg.c.in#L176
+ * https://github.com/glfw/glfw/blob/master/src/context.c#L36
+ */
+ int i, major, minor;
+
+ const char* version;
+ const char* prefixes[] = {
+ "OpenGL ES-CM ",
+ "OpenGL ES-CL ",
+ "OpenGL ES ",
+ NULL
+ };
+
+ version = (const char*) glGetString(GL_VERSION);
+ if (!version) return;
+
+ for (i = 0; prefixes[i]; i++) {
+ const size_t length = strlen(prefixes[i]);
+ if (strncmp(version, prefixes[i], length) == 0) {
+ version += length;
+ break;
+ }
+ }
+
+/* PR #18 */
+#ifdef _MSC_VER
+ sscanf_s(version, "%d.%d", &major, &minor);
+#else
+ sscanf(version, "%d.%d", &major, &minor);
+#endif
+
+ GLVersion.major = major; GLVersion.minor = minor;
+ max_loaded_major = major; max_loaded_minor = minor;
+ GLAD_GL_VERSION_1_0 = (major == 1 && minor >= 0) || major > 1;
+ GLAD_GL_VERSION_1_1 = (major == 1 && minor >= 1) || major > 1;
+ GLAD_GL_VERSION_1_2 = (major == 1 && minor >= 2) || major > 1;
+ GLAD_GL_VERSION_1_3 = (major == 1 && minor >= 3) || major > 1;
+ GLAD_GL_VERSION_1_4 = (major == 1 && minor >= 4) || major > 1;
+ GLAD_GL_VERSION_1_5 = (major == 1 && minor >= 5) || major > 1;
+ GLAD_GL_VERSION_2_0 = (major == 2 && minor >= 0) || major > 2;
+ GLAD_GL_VERSION_2_1 = (major == 2 && minor >= 1) || major > 2;
+ GLAD_GL_VERSION_3_0 = (major == 3 && minor >= 0) || major > 3;
+ GLAD_GL_VERSION_3_1 = (major == 3 && minor >= 1) || major > 3;
+ GLAD_GL_VERSION_3_2 = (major == 3 && minor >= 2) || major > 3;
+ GLAD_GL_VERSION_3_3 = (major == 3 && minor >= 3) || major > 3;
+ GLAD_GL_VERSION_4_0 = (major == 4 && minor >= 0) || major > 4;
+ GLAD_GL_VERSION_4_1 = (major == 4 && minor >= 1) || major > 4;
+ GLAD_GL_VERSION_4_2 = (major == 4 && minor >= 2) || major > 4;
+ GLAD_GL_VERSION_4_3 = (major == 4 && minor >= 3) || major > 4;
+ GLAD_GL_VERSION_4_4 = (major == 4 && minor >= 4) || major > 4;
+ GLAD_GL_VERSION_4_5 = (major == 4 && minor >= 5) || major > 4;
+ if (GLVersion.major > 4 || (GLVersion.major >= 4 && GLVersion.minor >= 5)) {
+ max_loaded_major = 4;
+ max_loaded_minor = 5;
+ }
+}
+
+int gladLoadGLLoader(GLADloadproc load) {
+ GLVersion.major = 0; GLVersion.minor = 0;
+ glGetString = (PFNGLGETSTRINGPROC)load("glGetString");
+ if(glGetString == NULL) return 0;
+ if(glGetString(GL_VERSION) == NULL) return 0;
+ find_coreGL();
+ load_GL_VERSION_1_0(load);
+ load_GL_VERSION_1_1(load);
+ load_GL_VERSION_1_2(load);
+ load_GL_VERSION_1_3(load);
+ load_GL_VERSION_1_4(load);
+ load_GL_VERSION_1_5(load);
+ load_GL_VERSION_2_0(load);
+ load_GL_VERSION_2_1(load);
+ load_GL_VERSION_3_0(load);
+ load_GL_VERSION_3_1(load);
+ load_GL_VERSION_3_2(load);
+ load_GL_VERSION_3_3(load);
+ load_GL_VERSION_4_0(load);
+ load_GL_VERSION_4_1(load);
+ load_GL_VERSION_4_2(load);
+ load_GL_VERSION_4_3(load);
+ load_GL_VERSION_4_4(load);
+ load_GL_VERSION_4_5(load);
+
+ if (!find_extensionsGL()) return 0;
+ return GLVersion.major != 0 || GLVersion.minor != 0;
+}
diff --git a/chromium/third_party/dawn/third_party/picojson/picojson.h b/chromium/third_party/dawn/third_party/picojson/picojson.h
new file mode 100644
index 00000000000..218049764c4
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/picojson/picojson.h
@@ -0,0 +1,1040 @@
+/*
+ * Copyright 2009-2010 Cybozu Labs, Inc.
+ * Copyright 2011-2014 Kazuho Oku
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef picojson_h
+#define picojson_h
+
+#include <algorithm>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cstddef>
+#include <iostream>
+#include <iterator>
+#include <limits>
+#include <map>
+#include <stdexcept>
+#include <string>
+#include <vector>
+
+// for isnan/isinf
+#if __cplusplus>=201103L
+# include <cmath>
+#else
+extern "C" {
+# ifdef _MSC_VER
+# include <float.h>
+# elif defined(__INTEL_COMPILER)
+# include <mathimf.h>
+# else
+# include <math.h>
+# endif
+}
+#endif
+
+#ifndef PICOJSON_USE_RVALUE_REFERENCE
+# if (defined(__cpp_rvalue_references) && __cpp_rvalue_references >= 200610) || (defined(_MSC_VER) && _MSC_VER >= 1600)
+# define PICOJSON_USE_RVALUE_REFERENCE 1
+# else
+# define PICOJSON_USE_RVALUE_REFERENCE 0
+# endif
+#endif//PICOJSON_USE_RVALUE_REFERENCE
+
+
+// experimental support for int64_t (see README.mkdn for detail)
+#ifdef PICOJSON_USE_INT64
+# define __STDC_FORMAT_MACROS
+# include <errno.h>
+# include <inttypes.h>
+#endif
+
+// to disable the use of localeconv(3), set PICOJSON_USE_LOCALE to 0
+#ifndef PICOJSON_USE_LOCALE
+# define PICOJSON_USE_LOCALE 1
+#endif
+#if PICOJSON_USE_LOCALE
+extern "C" {
+# include <locale.h>
+}
+#endif
+
+#ifndef PICOJSON_ASSERT
+# define PICOJSON_ASSERT(e) do { if (! (e)) throw std::runtime_error(#e); } while (0)
+#endif
+
+#ifdef _MSC_VER
+ #define SNPRINTF _snprintf_s
+ #pragma warning(push)
+ #pragma warning(disable : 4244) // conversion from int to char
+ #pragma warning(disable : 4127) // conditional expression is constant
+ #pragma warning(disable : 4702) // unreachable code
+#else
+ #define SNPRINTF snprintf
+#endif
+
+namespace picojson {
+
+ enum {
+ null_type,
+ boolean_type,
+ number_type,
+ string_type,
+ array_type,
+ object_type
+#ifdef PICOJSON_USE_INT64
+ , int64_type
+#endif
+ };
+
+ enum {
+ INDENT_WIDTH = 2
+ };
+
+ struct null {};
+
+ class value {
+ public:
+ typedef std::vector<value> array;
+ typedef std::map<std::string, value> object;
+ union _storage {
+ bool boolean_;
+ double number_;
+#ifdef PICOJSON_USE_INT64
+ int64_t int64_;
+#endif
+ std::string* string_;
+ array* array_;
+ object* object_;
+ };
+ protected:
+ int type_;
+ _storage u_;
+ public:
+ value();
+ value(int type, bool);
+ explicit value(bool b);
+#ifdef PICOJSON_USE_INT64
+ explicit value(int64_t i);
+#endif
+ explicit value(double n);
+ explicit value(const std::string& s);
+ explicit value(const array& a);
+ explicit value(const object& o);
+ explicit value(const char* s);
+ value(const char* s, size_t len);
+ ~value();
+ value(const value& x);
+ value& operator=(const value& x);
+#if PICOJSON_USE_RVALUE_REFERENCE
+ value(value&& x)throw();
+ value& operator=(value&& x)throw();
+#endif
+ void swap(value& x)throw();
+ template <typename T> bool is() const;
+ template <typename T> const T& get() const;
+ template <typename T> T& get();
+ bool evaluate_as_boolean() const;
+ const value& get(size_t idx) const;
+ const value& get(const std::string& key) const;
+ value& get(size_t idx);
+ value& get(const std::string& key);
+
+ bool contains(size_t idx) const;
+ bool contains(const std::string& key) const;
+ std::string to_str() const;
+ template <typename Iter> void serialize(Iter os, bool prettify = false) const;
+ std::string serialize(bool prettify = false) const;
+ private:
+ template <typename T> value(const T*); // intentionally defined to block implicit conversion of pointer to bool
+ template <typename Iter> static void _indent(Iter os, int indent);
+ template <typename Iter> void _serialize(Iter os, int indent) const;
+ std::string _serialize(int indent) const;
+ };
+
+ typedef value::array array;
+ typedef value::object object;
+
+ inline value::value() : type_(null_type) {}
+
+ inline value::value(int type, bool) : type_(type) {
+ switch (type) {
+#define INIT(p, v) case p##type: u_.p = v; break
+ INIT(boolean_, false);
+ INIT(number_, 0.0);
+#ifdef PICOJSON_USE_INT64
+ INIT(int64_, 0);
+#endif
+ INIT(string_, new std::string());
+ INIT(array_, new array());
+ INIT(object_, new object());
+#undef INIT
+ default: break;
+ }
+ }
+
+ inline value::value(bool b) : type_(boolean_type) {
+ u_.boolean_ = b;
+ }
+
+#ifdef PICOJSON_USE_INT64
+ inline value::value(int64_t i) : type_(int64_type) {
+ u_.int64_ = i;
+ }
+#endif
+
+ inline value::value(double n) : type_(number_type) {
+ if (
+#ifdef _MSC_VER
+ ! _finite(n)
+#elif __cplusplus>=201103L || !(defined(isnan) && defined(isinf))
+ std::isnan(n) || std::isinf(n)
+#else
+ isnan(n) || isinf(n)
+#endif
+ ) {
+ // throw std::overflow_error("");
+ PICOJSON_ASSERT(false);
+ }
+ u_.number_ = n;
+ }
+
+ inline value::value(const std::string& s) : type_(string_type) {
+ u_.string_ = new std::string(s);
+ }
+
+ inline value::value(const array& a) : type_(array_type) {
+ u_.array_ = new array(a);
+ }
+
+ inline value::value(const object& o) : type_(object_type) {
+ u_.object_ = new object(o);
+ }
+
+ inline value::value(const char* s) : type_(string_type) {
+ u_.string_ = new std::string(s);
+ }
+
+ inline value::value(const char* s, size_t len) : type_(string_type) {
+ u_.string_ = new std::string(s, len);
+ }
+
+ inline value::~value() {
+ switch (type_) {
+#define DEINIT(p) case p##type: delete u_.p; break
+ DEINIT(string_);
+ DEINIT(array_);
+ DEINIT(object_);
+#undef DEINIT
+ default: break;
+ }
+ }
+
+ inline value::value(const value& x) : type_(x.type_) {
+ switch (type_) {
+#define INIT(p, v) case p##type: u_.p = v; break
+ INIT(string_, new std::string(*x.u_.string_));
+ INIT(array_, new array(*x.u_.array_));
+ INIT(object_, new object(*x.u_.object_));
+#undef INIT
+ default:
+ u_ = x.u_;
+ break;
+ }
+ }
+
+ inline value& value::operator=(const value& x) {
+ if (this != &x) {
+ value t(x);
+ swap(t);
+ }
+ return *this;
+ }
+
+#if PICOJSON_USE_RVALUE_REFERENCE
+ inline value::value(value&& x)throw() : type_(null_type) {
+ swap(x);
+ }
+ inline value& value::operator=(value&& x)throw() {
+ swap(x);
+ return *this;
+ }
+#endif
+ inline void value::swap(value& x)throw() {
+ std::swap(type_, x.type_);
+ std::swap(u_, x.u_);
+ }
+
+#define IS(ctype, jtype) \
+ template <> inline bool value::is<ctype>() const { \
+ return type_ == jtype##_type; \
+ }
+ IS(null, null)
+ IS(bool, boolean)
+#ifdef PICOJSON_USE_INT64
+ IS(int64_t, int64)
+#endif
+ IS(std::string, string)
+ IS(array, array)
+ IS(object, object)
+#undef IS
+ template <> inline bool value::is<double>() const {
+ return type_ == number_type
+#ifdef PICOJSON_USE_INT64
+ || type_ == int64_type
+#endif
+ ;
+ }
+
+#define GET(ctype, var) \
+ template <> inline const ctype& value::get<ctype>() const { \
+ PICOJSON_ASSERT("type mismatch! call is<type>() before get<type>()" \
+ && is<ctype>()); \
+ return var; \
+ } \
+ template <> inline ctype& value::get<ctype>() { \
+ PICOJSON_ASSERT("type mismatch! call is<type>() before get<type>()" \
+ && is<ctype>()); \
+ return var; \
+ }
+ GET(bool, u_.boolean_)
+ GET(std::string, *u_.string_)
+ GET(array, *u_.array_)
+ GET(object, *u_.object_)
+#ifdef PICOJSON_USE_INT64
+ GET(double, (type_ == int64_type && (const_cast<value*>(this)->type_ = number_type, const_cast<value*>(this)->u_.number_ = u_.int64_), u_.number_))
+ GET(int64_t, u_.int64_)
+#else
+ GET(double, u_.number_)
+#endif
+#undef GET
+
+ inline bool value::evaluate_as_boolean() const {
+ switch (type_) {
+ case null_type:
+ return false;
+ case boolean_type:
+ return u_.boolean_;
+ case number_type:
+ return u_.number_ != 0;
+#ifdef PICOJSON_USE_INT64
+ case int64_type:
+ return u_.int64_ != 0;
+#endif
+ case string_type:
+ return ! u_.string_->empty();
+ default:
+ return true;
+ }
+ }
+
+ inline const value& value::get(size_t idx) const {
+ static value s_null;
+ PICOJSON_ASSERT(is<array>());
+ return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null;
+ }
+
+ inline value& value::get(size_t idx) {
+ static value s_null;
+ PICOJSON_ASSERT(is<array>());
+ return idx < u_.array_->size() ? (*u_.array_)[idx] : s_null;
+ }
+
+ inline const value& value::get(const std::string& key) const {
+ static value s_null;
+ PICOJSON_ASSERT(is<object>());
+ object::const_iterator i = u_.object_->find(key);
+ return i != u_.object_->end() ? i->second : s_null;
+ }
+
+ inline value& value::get(const std::string& key) {
+ static value s_null;
+ PICOJSON_ASSERT(is<object>());
+ object::iterator i = u_.object_->find(key);
+ return i != u_.object_->end() ? i->second : s_null;
+ }
+
+ inline bool value::contains(size_t idx) const {
+ PICOJSON_ASSERT(is<array>());
+ return idx < u_.array_->size();
+ }
+
+ inline bool value::contains(const std::string& key) const {
+ PICOJSON_ASSERT(is<object>());
+ object::const_iterator i = u_.object_->find(key);
+ return i != u_.object_->end();
+ }
+
+ inline std::string value::to_str() const {
+ switch (type_) {
+ case null_type: return "null";
+ case boolean_type: return u_.boolean_ ? "true" : "false";
+#ifdef PICOJSON_USE_INT64
+ case int64_type: {
+ char buf[sizeof("-9223372036854775808")];
+ SNPRINTF(buf, sizeof(buf), "%" PRId64, u_.int64_);
+ return buf;
+ }
+#endif
+ case number_type: {
+ char buf[256];
+ double tmp;
+ SNPRINTF(buf, sizeof(buf), fabs(u_.number_) < (1ULL << 53) && modf(u_.number_, &tmp) == 0 ? "%.f" : "%.17g", u_.number_);
+#if PICOJSON_USE_LOCALE
+ char *decimal_point = localeconv()->decimal_point;
+ if (strcmp(decimal_point, ".") != 0) {
+ size_t decimal_point_len = strlen(decimal_point);
+ for (char *p = buf; *p != '\0'; ++p) {
+ if (strncmp(p, decimal_point, decimal_point_len) == 0) {
+ return std::string(buf, p) + "." + (p + decimal_point_len);
+ }
+ }
+ }
+#endif
+ return buf;
+ }
+ case string_type: return *u_.string_;
+ case array_type: return "array";
+ case object_type: return "object";
+ default: PICOJSON_ASSERT(0);
+#ifdef _MSC_VER
+ __assume(0);
+#endif
+ }
+ return std::string();
+ }
+
+ template <typename Iter> void copy(const std::string& s, Iter oi) {
+ std::copy(s.begin(), s.end(), oi);
+ }
+
+ template <typename Iter> void serialize_str(const std::string& s, Iter oi) {
+ *oi++ = '"';
+ for (std::string::const_iterator i = s.begin(); i != s.end(); ++i) {
+ switch (*i) {
+#define MAP(val, sym) case val: copy(sym, oi); break
+ MAP('"', "\\\"");
+ MAP('\\', "\\\\");
+ MAP('/', "\\/");
+ MAP('\b', "\\b");
+ MAP('\f', "\\f");
+ MAP('\n', "\\n");
+ MAP('\r', "\\r");
+ MAP('\t', "\\t");
+#undef MAP
+ default:
+ if (static_cast<unsigned char>(*i) < 0x20 || *i == 0x7f) {
+ char buf[7];
+ SNPRINTF(buf, sizeof(buf), "\\u%04x", *i & 0xff);
+ copy(buf, buf + 6, oi);
+ } else {
+ *oi++ = *i;
+ }
+ break;
+ }
+ }
+ *oi++ = '"';
+ }
+
+ template <typename Iter> void value::serialize(Iter oi, bool prettify) const {
+ return _serialize(oi, prettify ? 0 : -1);
+ }
+
+ inline std::string value::serialize(bool prettify) const {
+ return _serialize(prettify ? 0 : -1);
+ }
+
+ template <typename Iter> void value::_indent(Iter oi, int indent) {
+ *oi++ = '\n';
+ for (int i = 0; i < indent * INDENT_WIDTH; ++i) {
+ *oi++ = ' ';
+ }
+ }
+
+ template <typename Iter> void value::_serialize(Iter oi, int indent) const {
+ switch (type_) {
+ case string_type:
+ serialize_str(*u_.string_, oi);
+ break;
+ case array_type: {
+ *oi++ = '[';
+ if (indent != -1) {
+ ++indent;
+ }
+ for (array::const_iterator i = u_.array_->begin();
+ i != u_.array_->end();
+ ++i) {
+ if (i != u_.array_->begin()) {
+ *oi++ = ',';
+ }
+ if (indent != -1) {
+ _indent(oi, indent);
+ }
+ i->_serialize(oi, indent);
+ }
+ if (indent != -1) {
+ --indent;
+ if (! u_.array_->empty()) {
+ _indent(oi, indent);
+ }
+ }
+ *oi++ = ']';
+ break;
+ }
+ case object_type: {
+ *oi++ = '{';
+ if (indent != -1) {
+ ++indent;
+ }
+ for (object::const_iterator i = u_.object_->begin();
+ i != u_.object_->end();
+ ++i) {
+ if (i != u_.object_->begin()) {
+ *oi++ = ',';
+ }
+ if (indent != -1) {
+ _indent(oi, indent);
+ }
+ serialize_str(i->first, oi);
+ *oi++ = ':';
+ if (indent != -1) {
+ *oi++ = ' ';
+ }
+ i->second._serialize(oi, indent);
+ }
+ if (indent != -1) {
+ --indent;
+ if (! u_.object_->empty()) {
+ _indent(oi, indent);
+ }
+ }
+ *oi++ = '}';
+ break;
+ }
+ default:
+ copy(to_str(), oi);
+ break;
+ }
+ if (indent == 0) {
+ *oi++ = '\n';
+ }
+ }
+
+ inline std::string value::_serialize(int indent) const {
+ std::string s;
+ _serialize(std::back_inserter(s), indent);
+ return s;
+ }
+
+ template <typename Iter> class input {
+ protected:
+ Iter cur_, end_;
+ int last_ch_;
+ bool ungot_;
+ int line_;
+ public:
+ input(const Iter& first, const Iter& last) : cur_(first), end_(last), last_ch_(-1), ungot_(false), line_(1) {}
+ int getc() {
+ if (ungot_) {
+ ungot_ = false;
+ return last_ch_;
+ }
+ if (cur_ == end_) {
+ last_ch_ = -1;
+ return -1;
+ }
+ if (last_ch_ == '\n') {
+ line_++;
+ }
+ last_ch_ = *cur_ & 0xff;
+ ++cur_;
+ return last_ch_;
+ }
+ void ungetc() {
+ if (last_ch_ != -1) {
+ PICOJSON_ASSERT(! ungot_);
+ ungot_ = true;
+ }
+ }
+ Iter cur() const { return cur_; }
+ int line() const { return line_; }
+ void skip_ws() {
+ while (1) {
+ int ch = getc();
+ if (! (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')) {
+ ungetc();
+ break;
+ }
+ }
+ }
+ bool expect(int expect) {
+ skip_ws();
+ if (getc() != expect) {
+ ungetc();
+ return false;
+ }
+ return true;
+ }
+ bool match(const std::string& pattern) {
+ for (std::string::const_iterator pi(pattern.begin());
+ pi != pattern.end();
+ ++pi) {
+ if (getc() != *pi) {
+ ungetc();
+ return false;
+ }
+ }
+ return true;
+ }
+ };
+
+ template<typename Iter> inline int _parse_quadhex(input<Iter> &in) {
+ int uni_ch = 0, hex;
+ for (int i = 0; i < 4; i++) {
+ if ((hex = in.getc()) == -1) {
+ return -1;
+ }
+ if ('0' <= hex && hex <= '9') {
+ hex -= '0';
+ } else if ('A' <= hex && hex <= 'F') {
+ hex -= 'A' - 0xa;
+ } else if ('a' <= hex && hex <= 'f') {
+ hex -= 'a' - 0xa;
+ } else {
+ in.ungetc();
+ return -1;
+ }
+ uni_ch = uni_ch * 16 + hex;
+ }
+ return uni_ch;
+ }
+
+ template<typename String, typename Iter> inline bool _parse_codepoint(String& out, input<Iter>& in) {
+ int uni_ch;
+ if ((uni_ch = _parse_quadhex(in)) == -1) {
+ return false;
+ }
+ if (0xd800 <= uni_ch && uni_ch <= 0xdfff) {
+ if (0xdc00 <= uni_ch) {
+ // a second 16-bit of a surrogate pair appeared
+ return false;
+ }
+ // first 16-bit of surrogate pair, get the next one
+ if (in.getc() != '\\' || in.getc() != 'u') {
+ in.ungetc();
+ return false;
+ }
+ int second = _parse_quadhex(in);
+ if (! (0xdc00 <= second && second <= 0xdfff)) {
+ return false;
+ }
+ uni_ch = ((uni_ch - 0xd800) << 10) | ((second - 0xdc00) & 0x3ff);
+ uni_ch += 0x10000;
+ }
+ if (uni_ch < 0x80) {
+ out.push_back(uni_ch);
+ } else {
+ if (uni_ch < 0x800) {
+ out.push_back(0xc0 | (uni_ch >> 6));
+ } else {
+ if (uni_ch < 0x10000) {
+ out.push_back(0xe0 | (uni_ch >> 12));
+ } else {
+ out.push_back(0xf0 | (uni_ch >> 18));
+ out.push_back(0x80 | ((uni_ch >> 12) & 0x3f));
+ }
+ out.push_back(0x80 | ((uni_ch >> 6) & 0x3f));
+ }
+ out.push_back(0x80 | (uni_ch & 0x3f));
+ }
+ return true;
+ }
+
+ template<typename String, typename Iter> inline bool _parse_string(String& out, input<Iter>& in) {
+ while (1) {
+ int ch = in.getc();
+ if (ch < ' ') {
+ in.ungetc();
+ return false;
+ } else if (ch == '"') {
+ return true;
+ } else if (ch == '\\') {
+ if ((ch = in.getc()) == -1) {
+ return false;
+ }
+ switch (ch) {
+#define MAP(sym, val) case sym: out.push_back(val); break
+ MAP('"', '\"');
+ MAP('\\', '\\');
+ MAP('/', '/');
+ MAP('b', '\b');
+ MAP('f', '\f');
+ MAP('n', '\n');
+ MAP('r', '\r');
+ MAP('t', '\t');
+#undef MAP
+ case 'u':
+ if (! _parse_codepoint(out, in)) {
+ return false;
+ }
+ break;
+ default:
+ return false;
+ }
+ } else {
+ out.push_back(ch);
+ }
+ }
+ return false;
+ }
+
+ template <typename Context, typename Iter> inline bool _parse_array(Context& ctx, input<Iter>& in) {
+ if (! ctx.parse_array_start()) {
+ return false;
+ }
+ size_t idx = 0;
+ if (in.expect(']')) {
+ return ctx.parse_array_stop(idx);
+ }
+ do {
+ if (! ctx.parse_array_item(in, idx)) {
+ return false;
+ }
+ idx++;
+ } while (in.expect(','));
+ return in.expect(']') && ctx.parse_array_stop(idx);
+ }
+
+ template <typename Context, typename Iter> inline bool _parse_object(Context& ctx, input<Iter>& in) {
+ if (! ctx.parse_object_start()) {
+ return false;
+ }
+ if (in.expect('}')) {
+ return true;
+ }
+ do {
+ std::string key;
+ if (! in.expect('"')
+ || ! _parse_string(key, in)
+ || ! in.expect(':')) {
+ return false;
+ }
+ if (! ctx.parse_object_item(in, key)) {
+ return false;
+ }
+ } while (in.expect(','));
+ return in.expect('}');
+ }
+
+ template <typename Iter> inline std::string _parse_number(input<Iter>& in) {
+ std::string num_str;
+ while (1) {
+ int ch = in.getc();
+ if (('0' <= ch && ch <= '9') || ch == '+' || ch == '-'
+ || ch == 'e' || ch == 'E') {
+ num_str.push_back(ch);
+ } else if (ch == '.') {
+#if PICOJSON_USE_LOCALE
+ num_str += localeconv()->decimal_point;
+#else
+ num_str.push_back('.');
+#endif
+ } else {
+ in.ungetc();
+ break;
+ }
+ }
+ return num_str;
+ }
+
+ template <typename Context, typename Iter> inline bool _parse(Context& ctx, input<Iter>& in) {
+ in.skip_ws();
+ int ch = in.getc();
+ switch (ch) {
+#define IS(ch, text, op) case ch: \
+ if (in.match(text) && op) { \
+ return true; \
+ } else { \
+ return false; \
+ }
+ IS('n', "ull", ctx.set_null());
+ IS('f', "alse", ctx.set_bool(false));
+ IS('t', "rue", ctx.set_bool(true));
+#undef IS
+ case '"':
+ return ctx.parse_string(in);
+ case '[':
+ return _parse_array(ctx, in);
+ case '{':
+ return _parse_object(ctx, in);
+ default:
+ if (('0' <= ch && ch <= '9') || ch == '-') {
+ double f;
+ char *endp;
+ in.ungetc();
+ std::string num_str = _parse_number(in);
+ if (num_str.empty()) {
+ return false;
+ }
+#ifdef PICOJSON_USE_INT64
+ {
+ errno = 0;
+ intmax_t ival = strtoimax(num_str.c_str(), &endp, 10);
+ if (errno == 0
+ && std::numeric_limits<int64_t>::min() <= ival
+ && ival <= std::numeric_limits<int64_t>::max()
+ && endp == num_str.c_str() + num_str.size()) {
+ ctx.set_int64(ival);
+ return true;
+ }
+ }
+#endif
+ f = strtod(num_str.c_str(), &endp);
+ if (endp == num_str.c_str() + num_str.size()) {
+ ctx.set_number(f);
+ return true;
+ }
+ return false;
+ }
+ break;
+ }
+ in.ungetc();
+ return false;
+ }
+
+ class deny_parse_context {
+ public:
+ bool set_null() { return false; }
+ bool set_bool(bool) { return false; }
+#ifdef PICOJSON_USE_INT64
+ bool set_int64(int64_t) { return false; }
+#endif
+ bool set_number(double) { return false; }
+ template <typename Iter> bool parse_string(input<Iter>&) { return false; }
+ bool parse_array_start() { return false; }
+ template <typename Iter> bool parse_array_item(input<Iter>&, size_t) {
+ return false;
+ }
+ bool parse_array_stop(size_t) { return false; }
+ bool parse_object_start() { return false; }
+ template <typename Iter> bool parse_object_item(input<Iter>&, const std::string&) {
+ return false;
+ }
+ };
+
+ class default_parse_context {
+ protected:
+ value* out_;
+ public:
+ default_parse_context(value* out) : out_(out) {}
+ bool set_null() {
+ *out_ = value();
+ return true;
+ }
+ bool set_bool(bool b) {
+ *out_ = value(b);
+ return true;
+ }
+#ifdef PICOJSON_USE_INT64
+ bool set_int64(int64_t i) {
+ *out_ = value(i);
+ return true;
+ }
+#endif
+ bool set_number(double f) {
+ *out_ = value(f);
+ return true;
+ }
+ template<typename Iter> bool parse_string(input<Iter>& in) {
+ *out_ = value(string_type, false);
+ return _parse_string(out_->get<std::string>(), in);
+ }
+ bool parse_array_start() {
+ *out_ = value(array_type, false);
+ return true;
+ }
+ template <typename Iter> bool parse_array_item(input<Iter>& in, size_t) {
+ array& a = out_->get<array>();
+ a.push_back(value());
+ default_parse_context ctx(&a.back());
+ return _parse(ctx, in);
+ }
+ bool parse_array_stop(size_t) { return true; }
+ bool parse_object_start() {
+ *out_ = value(object_type, false);
+ return true;
+ }
+ template <typename Iter> bool parse_object_item(input<Iter>& in, const std::string& key) {
+ object& o = out_->get<object>();
+ default_parse_context ctx(&o[key]);
+ return _parse(ctx, in);
+ }
+ private:
+ default_parse_context(const default_parse_context&);
+ default_parse_context& operator=(const default_parse_context&);
+ };
+
+ class null_parse_context {
+ public:
+ struct dummy_str {
+ void push_back(int) {}
+ };
+ public:
+ null_parse_context() {}
+ bool set_null() { return true; }
+ bool set_bool(bool) { return true; }
+#ifdef PICOJSON_USE_INT64
+ bool set_int64(int64_t) { return true; }
+#endif
+ bool set_number(double) { return true; }
+ template <typename Iter> bool parse_string(input<Iter>& in) {
+ dummy_str s;
+ return _parse_string(s, in);
+ }
+ bool parse_array_start() { return true; }
+ template <typename Iter> bool parse_array_item(input<Iter>& in, size_t) {
+ return _parse(*this, in);
+ }
+ bool parse_array_stop(size_t) { return true; }
+ bool parse_object_start() { return true; }
+ template <typename Iter> bool parse_object_item(input<Iter>& in, const std::string&) {
+ return _parse(*this, in);
+ }
+ private:
+ null_parse_context(const null_parse_context&);
+ null_parse_context& operator=(const null_parse_context&);
+ };
+
+ // obsolete, use the version below
+ template <typename Iter> inline std::string parse(value& out, Iter& pos, const Iter& last) {
+ std::string err;
+ pos = parse(out, pos, last, &err);
+ return err;
+ }
+
+ template <typename Context, typename Iter> inline Iter _parse(Context& ctx, const Iter& first, const Iter& last, std::string* err) {
+ input<Iter> in(first, last);
+ if (! _parse(ctx, in) && err != NULL) {
+ char buf[64];
+ SNPRINTF(buf, sizeof(buf), "syntax error at line %d near: ", in.line());
+ *err = buf;
+ while (1) {
+ int ch = in.getc();
+ if (ch == -1 || ch == '\n') {
+ break;
+ } else if (ch >= ' ') {
+ err->push_back(ch);
+ }
+ }
+ }
+ return in.cur();
+ }
+
+ template <typename Iter> inline Iter parse(value& out, const Iter& first, const Iter& last, std::string* err) {
+ default_parse_context ctx(&out);
+ return _parse(ctx, first, last, err);
+ }
+
+ inline std::string parse(value& out, const std::string& s) {
+ std::string err;
+ parse(out, s.begin(), s.end(), &err);
+ return err;
+ }
+
+ inline std::string parse(value& out, std::istream& is) {
+ std::string err;
+ parse(out, std::istreambuf_iterator<char>(is.rdbuf()),
+ std::istreambuf_iterator<char>(), &err);
+ return err;
+ }
+
+ template <typename T> struct last_error_t {
+ static std::string s;
+ };
+ template <typename T> std::string last_error_t<T>::s;
+
+ inline void set_last_error(const std::string& s) {
+ last_error_t<bool>::s = s;
+ }
+
+ inline const std::string& get_last_error() {
+ return last_error_t<bool>::s;
+ }
+
+ inline bool operator==(const value& x, const value& y) {
+ if (x.is<null>())
+ return y.is<null>();
+#define PICOJSON_CMP(type) \
+ if (x.is<type>()) \
+ return y.is<type>() && x.get<type>() == y.get<type>()
+ PICOJSON_CMP(bool);
+ PICOJSON_CMP(double);
+ PICOJSON_CMP(std::string);
+ PICOJSON_CMP(array);
+ PICOJSON_CMP(object);
+#undef PICOJSON_CMP
+ PICOJSON_ASSERT(0);
+#ifdef _MSC_VER
+ __assume(0);
+#endif
+ return false;
+ }
+
+ inline bool operator!=(const value& x, const value& y) {
+ return ! (x == y);
+ }
+}
+
+#if !PICOJSON_USE_RVALUE_REFERENCE
+namespace std {
+ template<> inline void swap(picojson::value& x, picojson::value& y)
+ {
+ x.swap(y);
+ }
+}
+#endif
+
+inline std::istream& operator>>(std::istream& is, picojson::value& x)
+{
+ picojson::set_last_error(std::string());
+ std::string err = picojson::parse(x, is);
+ if (! err.empty()) {
+ picojson::set_last_error(err);
+ is.setstate(std::ios::failbit);
+ }
+ return is;
+}
+
+inline std::ostream& operator<<(std::ostream& os, const picojson::value& x)
+{
+ x.serialize(std::ostream_iterator<char>(os));
+ return os;
+}
+#ifdef _MSC_VER
+ #pragma warning(pop)
+#endif
+
+#endif
diff --git a/chromium/third_party/dawn/third_party/tinygltfloader/tiny_gltf_loader.h b/chromium/third_party/dawn/third_party/tinygltfloader/tiny_gltf_loader.h
new file mode 100644
index 00000000000..47927211204
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/tinygltfloader/tiny_gltf_loader.h
@@ -0,0 +1,2656 @@
+//
+// Tiny glTF loader.
+//
+//
+// The MIT License (MIT)
+//
+// Copyright (c) 2015 - 2016 Syoyo Fujita and many contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+// Version:
+// - v0.9.5 Support parsing `extras` parameter.
+// - v0.9.4 Support parsing `shader`, `program` and `tecnique` thanks to
+// @lukesanantonio
+// - v0.9.3 Support binary glTF
+// - v0.9.2 Support parsing `texture`
+// - v0.9.1 Support loading glTF asset from memory
+// - v0.9.0 Initial
+//
+// Tiny glTF loader is using following third party libraries:
+//
+// - picojson: C++ JSON library.
+// - base64: base64 decode/encode library.
+// - stb_image: Image loading library.
+//
+#ifndef TINY_GLTF_LOADER_H_
+#define TINY_GLTF_LOADER_H_
+
+#include <cassert>
+#include <cstring>
+#include <map>
+#include <string>
+#include <vector>
+
+namespace tinygltf {
+
+#define TINYGLTF_MODE_POINTS (0)
+#define TINYGLTF_MODE_LINE (1)
+#define TINYGLTF_MODE_LINE_LOOP (2)
+#define TINYGLTF_MODE_TRIANGLES (4)
+#define TINYGLTF_MODE_TRIANGLE_STRIP (5)
+#define TINYGLTF_MODE_TRIANGLE_FAN (6)
+
+#define TINYGLTF_COMPONENT_TYPE_BYTE (5120)
+#define TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE (5121)
+#define TINYGLTF_COMPONENT_TYPE_SHORT (5122)
+#define TINYGLTF_COMPONENT_TYPE_UNSIGNED_SHORT (5123)
+#define TINYGLTF_COMPONENT_TYPE_INT (5124)
+#define TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT (5125)
+#define TINYGLTF_COMPONENT_TYPE_FLOAT (5126)
+#define TINYGLTF_COMPONENT_TYPE_DOUBLE (5127)
+
+#define TINYGLTF_TEXTURE_FILTER_NEAREST (9728)
+#define TINYGLTF_TEXTURE_FILTER_LINEAR (9729)
+#define TINYGLTF_TEXTURE_FILTER_NEAREST_MIPMAP_NEAREST (9984)
+#define TINYGLTF_TEXTURE_FILTER_LINEAR_MIPMAP_NEAREST (9985)
+#define TINYGLTF_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR (9986)
+#define TINYGLTF_TEXTURE_FILTER_LINEAR_MIPMAP_LINEAR (9987)
+
+#define TINYGLTF_TEXTURE_WRAP_RPEAT (10497)
+#define TINYGLTF_TEXTURE_WRAP_CLAMP_TO_EDGE (33071)
+#define TINYGLTF_TEXTURE_WRAP_MIRRORED_REPEAT (33648)
+
+// Redeclarations of the above for technique.parameters.
+#define TINYGLTF_PARAMETER_TYPE_BYTE (5120)
+#define TINYGLTF_PARAMETER_TYPE_UNSIGNED_BYTE (5121)
+#define TINYGLTF_PARAMETER_TYPE_SHORT (5122)
+#define TINYGLTF_PARAMETER_TYPE_UNSIGNED_SHORT (5123)
+#define TINYGLTF_PARAMETER_TYPE_INT (5124)
+#define TINYGLTF_PARAMETER_TYPE_UNSIGNED_INT (5125)
+#define TINYGLTF_PARAMETER_TYPE_FLOAT (5126)
+
+#define TINYGLTF_PARAMETER_TYPE_FLOAT_VEC2 (35664)
+#define TINYGLTF_PARAMETER_TYPE_FLOAT_VEC3 (35665)
+#define TINYGLTF_PARAMETER_TYPE_FLOAT_VEC4 (35666)
+
+#define TINYGLTF_PARAMETER_TYPE_INT_VEC2 (35667)
+#define TINYGLTF_PARAMETER_TYPE_INT_VEC3 (35668)
+#define TINYGLTF_PARAMETER_TYPE_INT_VEC4 (35669)
+
+#define TINYGLTF_PARAMETER_TYPE_BOOL (35670)
+#define TINYGLTF_PARAMETER_TYPE_BOOL_VEC2 (35671)
+#define TINYGLTF_PARAMETER_TYPE_BOOL_VEC3 (35672)
+#define TINYGLTF_PARAMETER_TYPE_BOOL_VEC4 (35673)
+
+#define TINYGLTF_PARAMETER_TYPE_FLOAT_MAT2 (35674)
+#define TINYGLTF_PARAMETER_TYPE_FLOAT_MAT3 (35675)
+#define TINYGLTF_PARAMETER_TYPE_FLOAT_MAT4 (35676)
+
+#define TINYGLTF_PARAMETER_TYPE_SAMPLER_2D (35678)
+
+// End parameter types
+
+#define TINYGLTF_TYPE_VEC2 (2)
+#define TINYGLTF_TYPE_VEC3 (3)
+#define TINYGLTF_TYPE_VEC4 (4)
+#define TINYGLTF_TYPE_MAT2 (32 + 2)
+#define TINYGLTF_TYPE_MAT3 (32 + 3)
+#define TINYGLTF_TYPE_MAT4 (32 + 4)
+#define TINYGLTF_TYPE_SCALAR (64 + 1)
+#define TINYGLTF_TYPE_VECTOR (64 + 4)
+#define TINYGLTF_TYPE_MATRIX (64 + 16)
+
+#define TINYGLTF_IMAGE_FORMAT_JPEG (0)
+#define TINYGLTF_IMAGE_FORMAT_PNG (1)
+#define TINYGLTF_IMAGE_FORMAT_BMP (2)
+#define TINYGLTF_IMAGE_FORMAT_GIF (3)
+
+#define TINYGLTF_TEXTURE_FORMAT_ALPHA (6406)
+#define TINYGLTF_TEXTURE_FORMAT_RGB (6407)
+#define TINYGLTF_TEXTURE_FORMAT_RGBA (6408)
+#define TINYGLTF_TEXTURE_FORMAT_LUMINANCE (6409)
+#define TINYGLTF_TEXTURE_FORMAT_LUMINANCE_ALPHA (6410)
+
+#define TINYGLTF_TEXTURE_TARGET_TEXTURE2D (3553)
+#define TINYGLTF_TEXTURE_TYPE_UNSIGNED_BYTE (5121)
+
+#define TINYGLTF_TARGET_ARRAY_BUFFER (34962)
+#define TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER (34963)
+
+#define TINYGLTF_SHADER_TYPE_VERTEX_SHADER (35633)
+#define TINYGLTF_SHADER_TYPE_FRAGMENT_SHADER (35632)
+
+typedef enum {
+ NULL_TYPE = 0,
+ NUMBER_TYPE = 1,
+ INT_TYPE = 2,
+ BOOL_TYPE = 3,
+ STRING_TYPE = 4,
+ ARRAY_TYPE = 5,
+ BINARY_TYPE = 6,
+ OBJECT_TYPE = 7
+} Type;
+
+// Simple class to represent JSON object
+class Value {
+ public:
+ typedef std::vector<Value> Array;
+ typedef std::map<std::string, Value> Object;
+
+ Value() : type_(NULL_TYPE) {}
+
+ explicit Value(bool b) : type_(BOOL_TYPE) { boolean_value_ = b; }
+ explicit Value(int i) : type_(INT_TYPE) { int_value_ = i; }
+ explicit Value(double n) : type_(NUMBER_TYPE) { number_value_ = n; }
+ explicit Value(const std::string &s) : type_(STRING_TYPE) {
+ string_value_ = s;
+ }
+ explicit Value(const unsigned char *p, size_t n) : type_(BINARY_TYPE) {
+ binary_value_.resize(n);
+ memcpy(binary_value_.data(), p, n);
+ }
+ explicit Value(const Array &a) : type_(ARRAY_TYPE) {
+ array_value_ = Array(a);
+ }
+ explicit Value(const Object &o) : type_(OBJECT_TYPE) {
+ object_value_ = Object(o);
+ }
+
+ char Type() const { return static_cast<const char>(type_); }
+
+ bool IsBool() const { return (type_ == BOOL_TYPE); }
+
+ bool IsInt() const { return (type_ == INT_TYPE); }
+
+ bool IsNumber() const { return (type_ == NUMBER_TYPE); }
+
+ bool IsString() const { return (type_ == STRING_TYPE); }
+
+ bool IsBinary() const { return (type_ == BINARY_TYPE); }
+
+ bool IsArray() const { return (type_ == ARRAY_TYPE); }
+
+ bool IsObject() const { return (type_ == OBJECT_TYPE); }
+
+ // Accessor
+ template <typename T>
+ const T &Get() const;
+ template <typename T>
+ T &Get();
+
+ // Lookup value from an array
+ const Value &Get(int idx) const {
+ static Value &null_value = *(new Value());
+ assert(IsArray());
+ assert(idx >= 0);
+ return (static_cast<size_t>(idx) < array_value_.size())
+ ? array_value_[static_cast<size_t>(idx)]
+ : null_value;
+ }
+
+ // Lookup value from a key-value pair
+ const Value &Get(const std::string &key) const {
+ static Value &null_value = *(new Value());
+ assert(IsObject());
+ Object::const_iterator it = object_value_.find(key);
+ return (it != object_value_.end()) ? it->second : null_value;
+ }
+
+ size_t ArrayLen() const {
+ if (!IsArray()) return 0;
+ return array_value_.size();
+ }
+
+ // Valid only for object type.
+ bool Has(const std::string &key) const {
+ if (!IsObject()) return false;
+ Object::const_iterator it = object_value_.find(key);
+ return (it != object_value_.end()) ? true : false;
+ }
+
+ // List keys
+ std::vector<std::string> Keys() const {
+ std::vector<std::string> keys;
+ if (!IsObject()) return keys; // empty
+
+ for (Object::const_iterator it = object_value_.begin();
+ it != object_value_.end(); ++it) {
+ keys.push_back(it->first);
+ }
+
+ return keys;
+ }
+
+ protected:
+ int type_;
+
+ int int_value_;
+ double number_value_;
+ std::string string_value_;
+ std::vector<unsigned char> binary_value_;
+ Array array_value_;
+ Object object_value_;
+ bool boolean_value_;
+ char pad[3];
+
+ int pad0;
+};
+
+#define TINYGLTF_VALUE_GET(ctype, var) \
+ template <> \
+ inline const ctype &Value::Get<ctype>() const { \
+ return var; \
+ } \
+ template <> \
+ inline ctype &Value::Get<ctype>() { \
+ return var; \
+ }
+TINYGLTF_VALUE_GET(bool, boolean_value_)
+TINYGLTF_VALUE_GET(double, number_value_)
+TINYGLTF_VALUE_GET(int, int_value_)
+TINYGLTF_VALUE_GET(std::string, string_value_)
+TINYGLTF_VALUE_GET(std::vector<unsigned char>, binary_value_)
+TINYGLTF_VALUE_GET(Value::Array, array_value_)
+TINYGLTF_VALUE_GET(Value::Object, object_value_)
+#undef TINYGLTF_VALUE_GET
+
+typedef struct {
+ std::string string_value;
+ std::vector<double> number_array;
+} Parameter;
+
+typedef std::map<std::string, Parameter> ParameterMap;
+
+typedef struct {
+ std::string sampler;
+ std::string target_id;
+ std::string target_path;
+ Value extras;
+} AnimationChannel;
+
+typedef struct {
+ std::string input;
+ std::string interpolation;
+ std::string output;
+ Value extras;
+} AnimationSampler;
+
+typedef struct {
+ std::string name;
+ std::vector<AnimationChannel> channels;
+ std::map<std::string, AnimationSampler> samplers;
+ ParameterMap parameters;
+ Value extras;
+} Animation;
+
+typedef struct {
+ std::string name;
+ int minFilter;
+ int magFilter;
+ int wrapS;
+ int wrapT;
+ int wrapR; // TinyGLTF extension
+ int pad0;
+ Value extras;
+} Sampler;
+
+typedef struct {
+ std::string name;
+ int width;
+ int height;
+ int component;
+ int pad0;
+ std::vector<unsigned char> image;
+
+ std::string bufferView; // KHR_binary_glTF extenstion.
+ std::string mimeType; // KHR_binary_glTF extenstion.
+
+ Value extras;
+} Image;
+
+typedef struct {
+ int format;
+ int internalFormat;
+ std::string sampler; // Required
+ std::string source; // Required
+ int target;
+ int type;
+ std::string name;
+ Value extras;
+} Texture;
+
+typedef struct {
+ std::string name;
+ std::string technique;
+ ParameterMap values;
+
+ Value extras;
+} Material;
+
+typedef struct {
+ std::string name;
+ std::string buffer; // Required
+ size_t byteOffset; // Required
+ size_t byteLength; // default: 0
+ int target;
+ int pad0;
+ Value extras;
+} BufferView;
+
+typedef struct {
+ std::string bufferView;
+ std::string name;
+ size_t byteOffset;
+ size_t byteStride;
+ int componentType; // One of TINYGLTF_COMPONENT_TYPE_***
+ int pad0;
+ size_t count;
+ int type; // One of TINYGLTF_TYPE_***
+ int pad1;
+ std::vector<double> minValues; // Optional
+ std::vector<double> maxValues; // Optional
+ Value extras;
+} Accessor;
+
+class Camera {
+ public:
+ Camera() {}
+ ~Camera() {}
+
+ std::string name;
+ bool isOrthographic; // false = perspective.
+
+ // Some common properties.
+ float aspectRatio;
+ float yFov;
+ float zFar;
+ float zNear;
+};
+
+typedef struct {
+ std::map<std::string, std::string> attributes; // A dictionary object of
+ // strings, where each string
+ // is the ID of the accessor
+ // containing an attribute.
+ std::string material; // The ID of the material to apply to this primitive
+ // when rendering.
+ std::string indices; // The ID of the accessor that contains the indices.
+ int mode; // one of TINYGLTF_MODE_***
+ int pad0;
+
+ Value extras; // "extra" property
+} Primitive;
+
+typedef struct {
+ std::string name;
+ std::vector<Primitive> primitives;
+ Value extras;
+} Mesh;
+
+class Node {
+ public:
+ Node() {}
+ ~Node() {}
+
+ std::string camera; // camera object referenced by this node.
+
+ std::string name;
+ std::vector<std::string> children;
+ std::vector<double> rotation; // length must be 0 or 4
+ std::vector<double> scale; // length must be 0 or 3
+ std::vector<double> translation; // length must be 0 or 3
+ std::vector<double> matrix; // length must be 0 or 16
+ std::vector<std::string> meshes;
+
+ Value extras;
+};
+
+typedef struct {
+ std::string name;
+ std::vector<unsigned char> data;
+ Value extras;
+} Buffer;
+
+typedef struct {
+ std::string name;
+ int type;
+ int pad0;
+ std::vector<unsigned char> source;
+
+ Value extras;
+} Shader;
+
+typedef struct {
+ std::string name;
+ std::string vertexShader;
+ std::string fragmentShader;
+ std::vector<std::string> attributes;
+
+ Value extras;
+} Program;
+
+typedef struct {
+ int count;
+ int pad0;
+ std::string node;
+ std::string semantic;
+ int type;
+ int pad1;
+ Parameter value;
+} TechniqueParameter;
+
+typedef struct {
+ std::string name;
+ std::string program;
+ std::map<std::string, TechniqueParameter> parameters;
+ std::map<std::string, std::string> attributes;
+ std::map<std::string, std::string> uniforms;
+
+ Value extras;
+} Technique;
+
+typedef struct {
+ std::string generator;
+ std::string version;
+ std::string profile_api;
+ std::string profile_version;
+ bool premultipliedAlpha;
+ char pad[7];
+ Value extras;
+} Asset;
+
+class Scene {
+ public:
+ Scene() {}
+ ~Scene() {}
+
+ std::map<std::string, Accessor> accessors;
+ std::map<std::string, Animation> animations;
+ std::map<std::string, Buffer> buffers;
+ std::map<std::string, BufferView> bufferViews;
+ std::map<std::string, Material> materials;
+ std::map<std::string, Mesh> meshes;
+ std::map<std::string, Node> nodes;
+ std::map<std::string, Texture> textures;
+ std::map<std::string, Image> images;
+ std::map<std::string, Shader> shaders;
+ std::map<std::string, Program> programs;
+ std::map<std::string, Technique> techniques;
+ std::map<std::string, Sampler> samplers;
+ std::map<std::string, std::vector<std::string> > scenes; // list of nodes
+
+ std::string defaultScene;
+
+ Asset asset;
+
+ Value extras;
+};
+
+enum SectionCheck {
+ NO_REQUIRE = 0x00,
+ REQUIRE_SCENE = 0x01,
+ REQUIRE_SCENES = 0x02,
+ REQUIRE_NODES = 0x04,
+ REQUIRE_ACCESSORS = 0x08,
+ REQUIRE_BUFFERS = 0x10,
+ REQUIRE_BUFFER_VIEWS = 0x20,
+ REQUIRE_ALL = 0x3f
+};
+
+class TinyGLTFLoader {
+ public:
+ TinyGLTFLoader() : bin_data_(NULL), bin_size_(0), is_binary_(false) {
+ pad[0] = pad[1] = pad[2] = pad[3] = pad[4] = pad[5] = pad[6] = 0;
+ }
+ ~TinyGLTFLoader() {}
+
+ /// Loads glTF ASCII asset from a file.
+ /// Returns false and set error string to `err` if there's an error.
+ bool LoadASCIIFromFile(Scene *scene, std::string *err,
+ const std::string &filename,
+ unsigned int check_sections = REQUIRE_ALL);
+
+ /// Loads glTF ASCII asset from string(memory).
+ /// `length` = strlen(str);
+ /// Returns false and set error string to `err` if there's an error.
+ bool LoadASCIIFromString(Scene *scene, std::string *err, const char *str,
+ const unsigned int length,
+ const std::string &base_dir,
+ unsigned int check_sections = REQUIRE_ALL);
+
+ /// Loads glTF binary asset from a file.
+ /// Returns false and set error string to `err` if there's an error.
+ bool LoadBinaryFromFile(Scene *scene, std::string *err,
+ const std::string &filename,
+ unsigned int check_sections = REQUIRE_ALL);
+
+ /// Loads glTF binary asset from memory.
+ /// `length` = strlen(str);
+ /// Returns false and set error string to `err` if there's an error.
+ bool LoadBinaryFromMemory(Scene *scene, std::string *err,
+ const unsigned char *bytes,
+ const unsigned int length,
+ const std::string &base_dir = "",
+ unsigned int check_sections = REQUIRE_ALL);
+
+ private:
+ /// Loads glTF asset from string(memory).
+ /// `length` = strlen(str);
+ /// Returns false and set error string to `err` if there's an error.
+ bool LoadFromString(Scene *scene, std::string *err, const char *str,
+ const unsigned int length, const std::string &base_dir,
+ unsigned int check_sections);
+
+ const unsigned char *bin_data_;
+ size_t bin_size_;
+ bool is_binary_;
+ char pad[7];
+};
+
+} // namespace tinygltf
+
+#ifdef TINYGLTF_LOADER_IMPLEMENTATION
+#include <algorithm>
+//#include <cassert>
+#include <fstream>
+#include <sstream>
+
+#ifdef __clang__
+// Disable some warnings for external files.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wfloat-equal"
+#pragma clang diagnostic ignored "-Wexit-time-destructors"
+#pragma clang diagnostic ignored "-Wconversion"
+#pragma clang diagnostic ignored "-Wold-style-cast"
+#pragma clang diagnostic ignored "-Wdouble-promotion"
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+#pragma clang diagnostic ignored "-Wreserved-id-macro"
+#pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
+#pragma clang diagnostic ignored "-Wpadded"
+#endif
+
+#define PICOJSON_USE_INT64
+#include "picojson/picojson.h"
+#include "stb/stb_image.h"
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+#ifdef _WIN32
+#include <Windows.h>
+#else
+#include <wordexp.h>
+#endif
+
+#if defined(__sparcv9)
+// Big endian
+#else
+#if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU
+#define TINYGLTF_LITTLE_ENDIAN 1
+#endif
+#endif
+
+namespace tinygltf {
+
+static void swap4(unsigned int *val) {
+#ifdef TINYGLTF_LITTLE_ENDIAN
+ (void)val;
+#else
+ unsigned int tmp = *val;
+ unsigned char *dst = reinterpret_cast<unsigned char *>(val);
+ unsigned char *src = reinterpret_cast<unsigned char *>(&tmp);
+
+ dst[0] = src[3];
+ dst[1] = src[2];
+ dst[2] = src[1];
+ dst[3] = src[0];
+#endif
+}
+
+static bool FileExists(const std::string &abs_filename) {
+ bool ret;
+#ifdef _WIN32
+ FILE *fp;
+ errno_t err = fopen_s(&fp, abs_filename.c_str(), "rb");
+ if (err != 0) {
+ return false;
+ }
+#else
+ FILE *fp = fopen(abs_filename.c_str(), "rb");
+#endif
+ if (fp) {
+ ret = true;
+ fclose(fp);
+ } else {
+ ret = false;
+ }
+
+ return ret;
+}
+
+static std::string ExpandFilePath(const std::string &filepath) {
+#ifdef _WIN32
+ DWORD len = ExpandEnvironmentStringsA(filepath.c_str(), NULL, 0);
+ char *str = new char[len];
+ ExpandEnvironmentStringsA(filepath.c_str(), str, len);
+
+ std::string s(str);
+
+ delete[] str;
+
+ return s;
+#else
+
+#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
+ // no expansion
+ std::string s = filepath;
+#else
+ std::string s;
+ wordexp_t p;
+
+ if (filepath.empty()) {
+ return "";
+ }
+
+ // char** w;
+ int ret = wordexp(filepath.c_str(), &p, 0);
+ if (ret) {
+ // err
+ s = filepath;
+ return s;
+ }
+
+ // Use first element only.
+ if (p.we_wordv) {
+ s = std::string(p.we_wordv[0]);
+ wordfree(&p);
+ } else {
+ s = filepath;
+ }
+
+#endif
+
+ return s;
+#endif
+}
+
+static std::string JoinPath(const std::string &path0,
+ const std::string &path1) {
+ if (path0.empty()) {
+ return path1;
+ } else {
+ // check '/'
+ char lastChar = *path0.rbegin();
+ if (lastChar != '/') {
+ return path0 + std::string("/") + path1;
+ } else {
+ return path0 + path1;
+ }
+ }
+}
+
+static std::string FindFile(const std::vector<std::string> &paths,
+ const std::string &filepath) {
+ for (size_t i = 0; i < paths.size(); i++) {
+ std::string absPath = ExpandFilePath(JoinPath(paths[i], filepath));
+ if (FileExists(absPath)) {
+ return absPath;
+ }
+ }
+
+ return std::string();
+}
+
+// std::string GetFilePathExtension(const std::string& FileName)
+//{
+// if(FileName.find_last_of(".") != std::string::npos)
+// return FileName.substr(FileName.find_last_of(".")+1);
+// return "";
+//}
+
+static std::string GetBaseDir(const std::string &filepath) {
+ if (filepath.find_last_of("/\\") != std::string::npos)
+ return filepath.substr(0, filepath.find_last_of("/\\"));
+ return "";
+}
+
+// std::string base64_encode(unsigned char const* , unsigned int len);
+std::string base64_decode(std::string const &s);
+
+/*
+ base64.cpp and base64.h
+
+ Copyright (C) 2004-2008 René Nyffenegger
+
+ This source code is provided 'as-is', without any express or implied
+ warranty. In no event will the author be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this source code must not be misrepresented; you must not
+ claim that you wrote the original source code. If you use this source code
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original source code.
+
+ 3. This notice may not be removed or altered from any source distribution.
+
+ René Nyffenegger rene.nyffenegger@adp-gmbh.ch
+
+*/
+
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wexit-time-destructors"
+#pragma clang diagnostic ignored "-Wglobal-constructors"
+#pragma clang diagnostic ignored "-Wsign-conversion"
+#pragma clang diagnostic ignored "-Wconversion"
+#endif
+static const std::string base64_chars =
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789+/";
+
+static inline bool is_base64(unsigned char c) {
+ return (isalnum(c) || (c == '+') || (c == '/'));
+}
+
+std::string base64_decode(std::string const &encoded_string) {
+ int in_len = static_cast<int>(encoded_string.size());
+ int i = 0;
+ int j = 0;
+ int in_ = 0;
+ unsigned char char_array_4[4], char_array_3[3];
+ std::string ret;
+
+ while (in_len-- && (encoded_string[in_] != '=') &&
+ is_base64(encoded_string[in_])) {
+ char_array_4[i++] = encoded_string[in_];
+ in_++;
+ if (i == 4) {
+ for (i = 0; i < 4; i++)
+ char_array_4[i] =
+ static_cast<unsigned char>(base64_chars.find(char_array_4[i]));
+
+ char_array_3[0] =
+ (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+ char_array_3[1] =
+ ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+ char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+ for (i = 0; (i < 3); i++) ret += char_array_3[i];
+ i = 0;
+ }
+ }
+
+ if (i) {
+ for (j = i; j < 4; j++) char_array_4[j] = 0;
+
+ for (j = 0; j < 4; j++)
+ char_array_4[j] =
+ static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
+
+ char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
+ char_array_3[1] =
+ ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
+ char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
+
+ for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
+ }
+
+ return ret;
+}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
+static bool LoadExternalFile(std::vector<unsigned char> *out, std::string *err,
+ const std::string &filename,
+ const std::string &basedir, size_t reqBytes,
+ bool checkSize) {
+ out->clear();
+
+ std::vector<std::string> paths;
+ paths.push_back(basedir);
+ paths.push_back(".");
+
+ std::string filepath = FindFile(paths, filename);
+ if (filepath.empty()) {
+ if (err) {
+ (*err) += "File not found : " + filename + "\n";
+ }
+ return false;
+ }
+
+ std::ifstream f(filepath.c_str(), std::ifstream::binary);
+ if (!f) {
+ if (err) {
+ (*err) += "File open error : " + filepath + "\n";
+ }
+ return false;
+ }
+
+ f.seekg(0, f.end);
+ size_t sz = static_cast<size_t>(f.tellg());
+ std::vector<unsigned char> buf(sz);
+
+ f.seekg(0, f.beg);
+ f.read(reinterpret_cast<char *>(&buf.at(0)),
+ static_cast<std::streamsize>(sz));
+ f.close();
+
+ if (checkSize) {
+ if (reqBytes == sz) {
+ out->swap(buf);
+ return true;
+ } else {
+ std::stringstream ss;
+ ss << "File size mismatch : " << filepath << ", requestedBytes "
+ << reqBytes << ", but got " << sz << std::endl;
+ if (err) {
+ (*err) += ss.str();
+ }
+ return false;
+ }
+ }
+
+ out->swap(buf);
+ return true;
+}
+
+static bool LoadImageData(Image *image, std::string *err, int req_width,
+ int req_height, const unsigned char *bytes,
+ int size) {
+ int w, h, comp;
+ unsigned char *data = stbi_load_from_memory(bytes, size, &w, &h, &comp, 0);
+ if (!data) {
+ if (err) {
+ (*err) += "Unknown image format.\n";
+ }
+ return false;
+ }
+
+ if (w < 1 || h < 1) {
+ free(data);
+ if (err) {
+ (*err) += "Unknown image format.\n";
+ }
+ return false;
+ }
+
+ if (req_width > 0) {
+ if (req_width != w) {
+ free(data);
+ if (err) {
+ (*err) += "Image width mismatch.\n";
+ }
+ return false;
+ }
+ }
+
+ if (req_height > 0) {
+ if (req_height != h) {
+ free(data);
+ if (err) {
+ (*err) += "Image height mismatch.\n";
+ }
+ return false;
+ }
+ }
+
+ image->width = w;
+ image->height = h;
+ image->component = comp;
+ image->image.resize(static_cast<size_t>(w * h * comp));
+ std::copy(data, data + w * h * comp, image->image.begin());
+
+ free(data);
+
+ return true;
+}
+
+static bool IsDataURI(const std::string &in) {
+ std::string header = "data:application/octet-stream;base64,";
+ if (in.find(header) == 0) {
+ return true;
+ }
+
+ header = "data:image/png;base64,";
+ if (in.find(header) == 0) {
+ return true;
+ }
+
+ header = "data:image/jpeg;base64,";
+ if (in.find(header) == 0) {
+ return true;
+ }
+
+ header = "data:text/plain;base64,";
+ if (in.find(header) == 0) {
+ return true;
+ }
+
+ return false;
+}
+
+static bool DecodeDataURI(std::vector<unsigned char> *out,
+ const std::string &in, size_t reqBytes,
+ bool checkSize) {
+ std::string header = "data:application/octet-stream;base64,";
+ std::string data;
+ if (in.find(header) == 0) {
+ data = base64_decode(in.substr(header.size())); // cut mime string.
+ }
+
+ if (data.empty()) {
+ header = "data:image/jpeg;base64,";
+ if (in.find(header) == 0) {
+ data = base64_decode(in.substr(header.size())); // cut mime string.
+ }
+ }
+
+ if (data.empty()) {
+ header = "data:image/png;base64,";
+ if (in.find(header) == 0) {
+ data = base64_decode(in.substr(header.size())); // cut mime string.
+ }
+ }
+
+ if (data.empty()) {
+ header = "data:text/plain;base64,";
+ if (in.find(header) == 0) {
+ data = base64_decode(in.substr(header.size()));
+ }
+ }
+
+ if (data.empty()) {
+ return false;
+ }
+
+ if (checkSize) {
+ if (data.size() != reqBytes) {
+ return false;
+ }
+ out->resize(reqBytes);
+ } else {
+ out->resize(data.size());
+ }
+ std::copy(data.begin(), data.end(), out->begin());
+ return true;
+}
+
+static void ParseObjectProperty(Value *ret, const picojson::object &o) {
+ tinygltf::Value::Object vo;
+ picojson::object::const_iterator it(o.begin());
+ picojson::object::const_iterator itEnd(o.end());
+
+ for (; it != itEnd; it++) {
+ picojson::value v = it->second;
+
+ if (v.is<bool>()) {
+ vo[it->first] = tinygltf::Value(v.get<bool>());
+ } else if (v.is<double>()) {
+ vo[it->first] = tinygltf::Value(v.get<double>());
+ } else if (v.is<int64_t>()) {
+ vo[it->first] =
+ tinygltf::Value(static_cast<int>(v.get<int64_t>())); // truncate
+ } else if (v.is<std::string>()) {
+ vo[it->first] = tinygltf::Value(v.get<std::string>());
+ } else if (v.is<picojson::object>()) {
+ tinygltf::Value child_value;
+ ParseObjectProperty(&child_value, v.get<picojson::object>());
+ }
+ // TODO(syoyo) binary, array
+ }
+
+ (*ret) = tinygltf::Value(vo);
+}
+
+static bool ParseExtrasProperty(Value *ret, const picojson::object &o) {
+ picojson::object::const_iterator it = o.find("extras");
+ if (it == o.end()) {
+ return false;
+ }
+
+ // FIXME(syoyo) Currently we only support `object` type for extras property.
+ if (!it->second.is<picojson::object>()) {
+ return false;
+ }
+
+ ParseObjectProperty(ret, it->second.get<picojson::object>());
+
+ return true;
+}
+
+static bool ParseBooleanProperty(bool *ret, std::string *err,
+ const picojson::object &o,
+ const std::string &property, bool required) {
+ picojson::object::const_iterator it = o.find(property);
+ if (it == o.end()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is missing.\n";
+ }
+ }
+ return false;
+ }
+
+ if (!it->second.is<bool>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is not a bool type.\n";
+ }
+ }
+ return false;
+ }
+
+ if (ret) {
+ (*ret) = it->second.get<bool>();
+ }
+
+ return true;
+}
+
+static bool ParseNumberProperty(double *ret, std::string *err,
+ const picojson::object &o,
+ const std::string &property, bool required) {
+ picojson::object::const_iterator it = o.find(property);
+ if (it == o.end()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is missing.\n";
+ }
+ }
+ return false;
+ }
+
+ if (!it->second.is<double>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is not a number type.\n";
+ }
+ }
+ return false;
+ }
+
+ if (ret) {
+ (*ret) = it->second.get<double>();
+ }
+
+ return true;
+}
+
+static bool ParseNumberArrayProperty(std::vector<double> *ret, std::string *err,
+ const picojson::object &o,
+ const std::string &property,
+ bool required) {
+ picojson::object::const_iterator it = o.find(property);
+ if (it == o.end()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is missing.\n";
+ }
+ }
+ return false;
+ }
+
+ if (!it->second.is<picojson::array>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is not an array.\n";
+ }
+ }
+ return false;
+ }
+
+ ret->clear();
+ const picojson::array &arr = it->second.get<picojson::array>();
+ for (size_t i = 0; i < arr.size(); i++) {
+ if (!arr[i].is<double>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is not a number.\n";
+ }
+ }
+ return false;
+ }
+ ret->push_back(arr[i].get<double>());
+ }
+
+ return true;
+}
+
+static bool ParseStringProperty(
+ std::string *ret, std::string *err, const picojson::object &o,
+ const std::string &property, bool required,
+ const std::string &parent_node = std::string()) {
+ picojson::object::const_iterator it = o.find(property);
+ if (it == o.end()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is missing";
+ if (parent_node.empty()) {
+ (*err) += ".\n";
+ } else {
+ (*err) += " in `" + parent_node + "'.\n";
+ }
+ }
+ }
+ return false;
+ }
+
+ if (!it->second.is<std::string>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is not a string type.\n";
+ }
+ }
+ return false;
+ }
+
+ if (ret) {
+ (*ret) = it->second.get<std::string>();
+ }
+
+ return true;
+}
+
+static bool ParseStringArrayProperty(std::vector<std::string> *ret,
+ std::string *err,
+ const picojson::object &o,
+ const std::string &property,
+ bool required) {
+ picojson::object::const_iterator it = o.find(property);
+ if (it == o.end()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is missing.\n";
+ }
+ }
+ return false;
+ }
+
+ if (!it->second.is<picojson::array>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is not an array.\n";
+ }
+ }
+ return false;
+ }
+
+ ret->clear();
+ const picojson::array &arr = it->second.get<picojson::array>();
+ for (size_t i = 0; i < arr.size(); i++) {
+ if (!arr[i].is<std::string>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is not a string.\n";
+ }
+ }
+ return false;
+ }
+ ret->push_back(arr[i].get<std::string>());
+ }
+
+ return true;
+}
+
+static bool ParseStringMapProperty(std::map<std::string, std::string> *ret,
+ std::string *err, const picojson::object &o,
+ const std::string &property, bool required) {
+ picojson::object::const_iterator it = o.find(property);
+ if (it == o.end()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is missing.\n";
+ }
+ }
+ return false;
+ }
+
+ // Make sure we are dealing with an object / dictionary.
+ if (!it->second.is<picojson::object>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' property is not an object.\n";
+ }
+ }
+ return false;
+ }
+
+ ret->clear();
+ const picojson::object &dict = it->second.get<picojson::object>();
+
+ picojson::object::const_iterator dictIt(dict.begin());
+ picojson::object::const_iterator dictItEnd(dict.end());
+
+ for (; dictIt != dictItEnd; ++dictIt) {
+ // Check that the value is a string.
+ if (!dictIt->second.is<std::string>()) {
+ if (required) {
+ if (err) {
+ (*err) += "'" + property + "' value is not a string.\n";
+ }
+ }
+ return false;
+ }
+
+ // Insert into the list.
+ (*ret)[dictIt->first] = dictIt->second.get<std::string>();
+ }
+ return true;
+}
+
+static bool ParseKHRBinaryExtension(const picojson::object &o, std::string *err,
+ std::string *buffer_view,
+ std::string *mime_type, int *image_width,
+ int *image_height) {
+ picojson::object j = o;
+
+ if (j.find("extensions") == j.end()) {
+ if (err) {
+ (*err) += "`extensions' property is missing.\n";
+ }
+ return false;
+ }
+
+ if (!(j["extensions"].is<picojson::object>())) {
+ if (err) {
+ (*err) += "Invalid `extensions' property.\n";
+ }
+ return false;
+ }
+
+ picojson::object ext = j["extensions"].get<picojson::object>();
+
+ if (ext.find("KHR_binary_glTF") == ext.end()) {
+ if (err) {
+ (*err) +=
+ "`KHR_binary_glTF' property is missing in extension property.\n";
+ }
+ return false;
+ }
+
+ if (!(ext["KHR_binary_glTF"].is<picojson::object>())) {
+ if (err) {
+ (*err) += "Invalid `KHR_binary_glTF' property.\n";
+ }
+ return false;
+ }
+
+ picojson::object k = ext["KHR_binary_glTF"].get<picojson::object>();
+
+ if (!ParseStringProperty(buffer_view, err, k, "bufferView", true)) {
+ return false;
+ }
+
+ if (mime_type) {
+ ParseStringProperty(mime_type, err, k, "mimeType", false);
+ }
+
+ if (image_width) {
+ double width = 0.0;
+ if (ParseNumberProperty(&width, err, k, "width", false)) {
+ (*image_width) = static_cast<int>(width);
+ }
+ }
+
+ if (image_height) {
+ double height = 0.0;
+ if (ParseNumberProperty(&height, err, k, "height", false)) {
+ (*image_height) = static_cast<int>(height);
+ }
+ }
+
+ return true;
+}
+
+static bool ParseAsset(Asset *asset, std::string *err,
+ const picojson::object &o) {
+ ParseStringProperty(&asset->generator, err, o, "generator", false);
+ ParseBooleanProperty(&asset->premultipliedAlpha, err, o, "premultipliedAlpha",
+ false);
+
+ ParseStringProperty(&asset->version, err, o, "version", false);
+
+ picojson::object::const_iterator profile = o.find("profile");
+ if (profile != o.end()) {
+ const picojson::value &v = profile->second;
+ if (v.contains("api") & v.get("api").is<std::string>()) {
+ asset->profile_api = v.get("api").get<std::string>();
+ }
+ if (v.contains("version") & v.get("version").is<std::string>()) {
+ asset->profile_version = v.get("version").get<std::string>();
+ }
+ }
+
+ return true;
+}
+
+static bool ParseImage(Image *image, std::string *err,
+ const picojson::object &o, const std::string &basedir,
+ bool is_binary, const unsigned char *bin_data,
+ size_t bin_size) {
+ std::string uri;
+ if (!ParseStringProperty(&uri, err, o, "uri", true)) {
+ return false;
+ }
+
+ ParseStringProperty(&image->name, err, o, "name", false);
+
+ std::vector<unsigned char> img;
+
+ if (is_binary) {
+ // Still binary glTF accepts external dataURI. First try external resources.
+ bool loaded = false;
+ if (IsDataURI(uri)) {
+ loaded = DecodeDataURI(&img, uri, 0, false);
+ } else {
+ // Assume external .bin file.
+ loaded = LoadExternalFile(&img, err, uri, basedir, 0, false);
+ }
+
+ if (!loaded) {
+ // load data from (embedded) binary data
+
+ if ((bin_size == 0) || (bin_data == NULL)) {
+ if (err) {
+ (*err) += "Invalid binary data.\n";
+ }
+ return false;
+ }
+
+ // There should be "extensions" property.
+ // "extensions":{"KHR_binary_glTF":{"bufferView": "id", ...
+
+ std::string buffer_view;
+ std::string mime_type;
+ int image_width;
+ int image_height;
+ bool ret = ParseKHRBinaryExtension(o, err, &buffer_view, &mime_type,
+ &image_width, &image_height);
+ if (!ret) {
+ return false;
+ }
+
+ if (uri.compare("data:,") == 0) {
+ // ok
+ } else {
+ if (err) {
+ (*err) += "Invalid URI for binary data.\n";
+ }
+ return false;
+ }
+
+ // Just only save some information here. Loading actual image data from
+ // bufferView is done in other place.
+ image->bufferView = buffer_view;
+ image->mimeType = mime_type;
+ image->width = image_width;
+ image->height = image_height;
+
+ return true;
+ }
+ } else {
+ if (IsDataURI(uri)) {
+ if (!DecodeDataURI(&img, uri, 0, false)) {
+ if (err) {
+ (*err) += "Failed to decode 'uri' for image parameter.\n";
+ }
+ return false;
+ }
+ } else {
+ // Assume external file
+ if (!LoadExternalFile(&img, err, uri, basedir, 0, false)) {
+ if (err) {
+ (*err) += "Failed to load external 'uri'. for image parameter\n";
+ }
+ return false;
+ }
+ if (img.empty()) {
+ if (err) {
+ (*err) += "Image is empty.\n";
+ }
+ return false;
+ }
+ }
+ }
+
+ return LoadImageData(image, err, 0, 0, &img.at(0),
+ static_cast<int>(img.size()));
+}
+
+static bool ParseTexture(Texture *texture, std::string *err,
+ const picojson::object &o,
+ const std::string &basedir) {
+ (void)basedir;
+
+ if (!ParseStringProperty(&texture->sampler, err, o, "sampler", true)) {
+ return false;
+ }
+
+ if (!ParseStringProperty(&texture->source, err, o, "source", true)) {
+ return false;
+ }
+
+ ParseStringProperty(&texture->name, err, o, "name", false);
+
+ double format = TINYGLTF_TEXTURE_FORMAT_RGBA;
+ ParseNumberProperty(&format, err, o, "format", false);
+
+ double internalFormat = TINYGLTF_TEXTURE_FORMAT_RGBA;
+ ParseNumberProperty(&internalFormat, err, o, "internalFormat", false);
+
+ double target = TINYGLTF_TEXTURE_TARGET_TEXTURE2D;
+ ParseNumberProperty(&target, err, o, "target", false);
+
+ double type = TINYGLTF_TEXTURE_TYPE_UNSIGNED_BYTE;
+ ParseNumberProperty(&type, err, o, "type", false);
+
+ texture->format = static_cast<int>(format);
+ texture->internalFormat = static_cast<int>(internalFormat);
+ texture->target = static_cast<int>(target);
+ texture->type = static_cast<int>(type);
+
+ return true;
+}
+
+static bool ParseBuffer(Buffer *buffer, std::string *err,
+ const picojson::object &o, const std::string &basedir,
+ bool is_binary = false,
+ const unsigned char *bin_data = NULL,
+ size_t bin_size = 0) {
+ double byteLength;
+ if (!ParseNumberProperty(&byteLength, err, o, "byteLength", true)) {
+ return false;
+ }
+
+ std::string uri;
+ if (!ParseStringProperty(&uri, err, o, "uri", true)) {
+ return false;
+ }
+
+ picojson::object::const_iterator type = o.find("type");
+ if (type != o.end()) {
+ if (type->second.is<std::string>()) {
+ const std::string &ty = (type->second).get<std::string>();
+ if (ty.compare("arraybuffer") == 0) {
+ // buffer.type = "arraybuffer";
+ }
+ }
+ }
+
+ size_t bytes = static_cast<size_t>(byteLength);
+ if (is_binary) {
+ // Still binary glTF accepts external dataURI. First try external resources.
+ bool loaded = false;
+ if (IsDataURI(uri)) {
+ loaded = DecodeDataURI(&buffer->data, uri, bytes, true);
+ } else {
+ // Assume external .bin file.
+ loaded = LoadExternalFile(&buffer->data, err, uri, basedir, bytes, true);
+ }
+
+ if (!loaded) {
+ // load data from (embedded) binary data
+
+ if ((bin_size == 0) || (bin_data == NULL)) {
+ if (err) {
+ (*err) += "Invalid binary data.\n";
+ }
+ return false;
+ }
+
+ if (byteLength > bin_size) {
+ if (err) {
+ std::stringstream ss;
+ ss << "Invalid `byteLength'. Must be equal or less than binary size: "
+ "`byteLength' = "
+ << byteLength << ", binary size = " << bin_size << std::endl;
+ (*err) += ss.str();
+ }
+ return false;
+ }
+
+ if (uri.compare("data:,") == 0) {
+ // @todo { check uri }
+ buffer->data.resize(static_cast<size_t>(byteLength));
+ memcpy(&(buffer->data.at(0)), bin_data,
+ static_cast<size_t>(byteLength));
+
+ } else {
+ if (err) {
+ (*err) += "Invalid URI for binary data.\n";
+ }
+ return false;
+ }
+ }
+
+ } else {
+ if (IsDataURI(uri)) {
+ if (!DecodeDataURI(&buffer->data, uri, bytes, true)) {
+ if (err) {
+ (*err) += "Failed to decode 'uri'.\n";
+ }
+ return false;
+ }
+ } else {
+ // Assume external .bin file.
+ if (!LoadExternalFile(&buffer->data, err, uri, basedir, bytes, true)) {
+ return false;
+ }
+ }
+ }
+
+ ParseStringProperty(&buffer->name, err, o, "name", false);
+
+ return true;
+}
+
+static bool ParseBufferView(BufferView *bufferView, std::string *err,
+ const picojson::object &o) {
+ std::string buffer;
+ if (!ParseStringProperty(&buffer, err, o, "buffer", true)) {
+ return false;
+ }
+
+ double byteOffset;
+ if (!ParseNumberProperty(&byteOffset, err, o, "byteOffset", true)) {
+ return false;
+ }
+
+ double byteLength = 0.0;
+ ParseNumberProperty(&byteLength, err, o, "byteLength", false);
+
+ double target = 0.0;
+ ParseNumberProperty(&target, err, o, "target", false);
+ int targetValue = static_cast<int>(target);
+ if ((targetValue == TINYGLTF_TARGET_ARRAY_BUFFER) ||
+ (targetValue == TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER)) {
+ // OK
+ } else {
+ targetValue = 0;
+ }
+ bufferView->target = targetValue;
+
+ ParseStringProperty(&bufferView->name, err, o, "name", false);
+
+ bufferView->buffer = buffer;
+ bufferView->byteOffset = static_cast<size_t>(byteOffset);
+ bufferView->byteLength = static_cast<size_t>(byteLength);
+
+ return true;
+}
+
+static bool ParseAccessor(Accessor *accessor, std::string *err,
+ const picojson::object &o) {
+ std::string bufferView;
+ if (!ParseStringProperty(&bufferView, err, o, "bufferView", true)) {
+ return false;
+ }
+
+ double byteOffset;
+ if (!ParseNumberProperty(&byteOffset, err, o, "byteOffset", true)) {
+ return false;
+ }
+
+ double componentType;
+ if (!ParseNumberProperty(&componentType, err, o, "componentType", true)) {
+ return false;
+ }
+
+ double count = 0.0;
+ if (!ParseNumberProperty(&count, err, o, "count", true)) {
+ return false;
+ }
+
+ std::string type;
+ if (!ParseStringProperty(&type, err, o, "type", true)) {
+ return false;
+ }
+
+ if (type.compare("SCALAR") == 0) {
+ accessor->type = TINYGLTF_TYPE_SCALAR;
+ } else if (type.compare("VEC2") == 0) {
+ accessor->type = TINYGLTF_TYPE_VEC2;
+ } else if (type.compare("VEC3") == 0) {
+ accessor->type = TINYGLTF_TYPE_VEC3;
+ } else if (type.compare("VEC4") == 0) {
+ accessor->type = TINYGLTF_TYPE_VEC4;
+ } else if (type.compare("MAT2") == 0) {
+ accessor->type = TINYGLTF_TYPE_MAT2;
+ } else if (type.compare("MAT3") == 0) {
+ accessor->type = TINYGLTF_TYPE_MAT3;
+ } else if (type.compare("MAT4") == 0) {
+ accessor->type = TINYGLTF_TYPE_MAT4;
+ } else {
+ std::stringstream ss;
+ ss << "Unsupported `type` for accessor object. Got \"" << type << "\"\n";
+ if (err) {
+ (*err) += ss.str();
+ }
+ return false;
+ }
+
+ double byteStride = 0.0;
+ ParseNumberProperty(&byteStride, err, o, "byteStride", false);
+
+ ParseStringProperty(&accessor->name, err, o, "name", false);
+
+ accessor->minValues.clear();
+ accessor->maxValues.clear();
+ ParseNumberArrayProperty(&accessor->minValues, err, o, "min", false);
+ ParseNumberArrayProperty(&accessor->maxValues, err, o, "max", false);
+
+ accessor->count = static_cast<size_t>(count);
+ accessor->bufferView = bufferView;
+ accessor->byteOffset = static_cast<size_t>(byteOffset);
+ accessor->byteStride = static_cast<size_t>(byteStride);
+
+ {
+ int comp = static_cast<int>(componentType);
+ if (comp >= TINYGLTF_COMPONENT_TYPE_BYTE &&
+ comp <= TINYGLTF_COMPONENT_TYPE_DOUBLE) {
+ // OK
+ accessor->componentType = comp;
+ } else {
+ std::stringstream ss;
+ ss << "Invalid `componentType` in accessor. Got " << comp << "\n";
+ if (err) {
+ (*err) += ss.str();
+ }
+ return false;
+ }
+ }
+
+ ParseExtrasProperty(&(accessor->extras), o);
+
+ return true;
+}
+
+static bool ParsePrimitive(Primitive *primitive, std::string *err,
+ const picojson::object &o) {
+ if (!ParseStringProperty(&primitive->material, err, o, "material", true,
+ "mesh.primitive")) {
+ return false;
+ }
+
+ double mode = static_cast<double>(TINYGLTF_MODE_TRIANGLES);
+ ParseNumberProperty(&mode, err, o, "mode", false);
+
+ int primMode = static_cast<int>(mode);
+ primitive->mode = primMode;
+
+ primitive->indices = "";
+ ParseStringProperty(&primitive->indices, err, o, "indices", false);
+
+ ParseStringMapProperty(&primitive->attributes, err, o, "attributes", false);
+
+ ParseExtrasProperty(&(primitive->extras), o);
+
+ return true;
+}
+
+static bool ParseMesh(Mesh *mesh, std::string *err, const picojson::object &o) {
+ ParseStringProperty(&mesh->name, err, o, "name", false);
+
+ mesh->primitives.clear();
+ picojson::object::const_iterator primObject = o.find("primitives");
+ if ((primObject != o.end()) && (primObject->second).is<picojson::array>()) {
+ const picojson::array &primArray =
+ (primObject->second).get<picojson::array>();
+ for (size_t i = 0; i < primArray.size(); i++) {
+ Primitive primitive;
+ if (ParsePrimitive(&primitive, err,
+ primArray[i].get<picojson::object>())) {
+ // Only add the primitive if the parsing succeeds.
+ mesh->primitives.push_back(primitive);
+ }
+ }
+ }
+
+ ParseExtrasProperty(&(mesh->extras), o);
+
+ return true;
+}
+
+static bool ParseNode(Node *node, std::string *err, const picojson::object &o) {
+ ParseStringProperty(&node->name, err, o, "name", false);
+
+ ParseNumberArrayProperty(&node->rotation, err, o, "rotation", false);
+ ParseNumberArrayProperty(&node->scale, err, o, "scale", false);
+ ParseNumberArrayProperty(&node->translation, err, o, "translation", false);
+ ParseNumberArrayProperty(&node->matrix, err, o, "matrix", false);
+ ParseStringArrayProperty(&node->meshes, err, o, "meshes", false);
+
+ node->children.clear();
+ picojson::object::const_iterator childrenObject = o.find("children");
+ if ((childrenObject != o.end()) &&
+ (childrenObject->second).is<picojson::array>()) {
+ const picojson::array &childrenArray =
+ (childrenObject->second).get<picojson::array>();
+ for (size_t i = 0; i < childrenArray.size(); i++) {
+ if (!childrenArray[i].is<std::string>()) {
+ if (err) {
+ (*err) += "Invalid `children` array.\n";
+ }
+ return false;
+ }
+ const std::string &childrenNode = childrenArray[i].get<std::string>();
+ node->children.push_back(childrenNode);
+ }
+ }
+
+ ParseExtrasProperty(&(node->extras), o);
+
+ return true;
+}
+
+static bool ParseParameterProperty(Parameter *param, std::string *err,
+ const picojson::object &o,
+ const std::string &prop, bool required) {
+ double num_val;
+
+ // A parameter value can either be a string or an array of either a boolean or
+ // a number. Booleans of any kind aren't supported here. Granted, it
+ // complicates the Parameter structure and breaks it semantically in the sense
+ // that the client probably works off the assumption that if the string is
+ // empty the vector is used, etc. Would a tagged union work?
+ if (ParseStringProperty(&param->string_value, err, o, prop, false)) {
+ // Found string property.
+ return true;
+ } else if (ParseNumberArrayProperty(&param->number_array, err, o, prop,
+ false)) {
+ // Found a number array.
+ return true;
+ } else if (ParseNumberProperty(&num_val, err, o, prop, false)) {
+ param->number_array.push_back(num_val);
+ return true;
+ } else {
+ if (required) {
+ if (err) {
+ (*err) += "parameter must be a string or number / number array.\n";
+ }
+ }
+ return false;
+ }
+}
+
+static bool ParseMaterial(Material *material, std::string *err,
+ const picojson::object &o) {
+ ParseStringProperty(&material->name, err, o, "name", false);
+ ParseStringProperty(&material->technique, err, o, "technique", false);
+
+ material->values.clear();
+ picojson::object::const_iterator valuesIt = o.find("values");
+
+ if ((valuesIt != o.end()) && (valuesIt->second).is<picojson::object>()) {
+ const picojson::object &values_object =
+ (valuesIt->second).get<picojson::object>();
+
+ picojson::object::const_iterator it(values_object.begin());
+ picojson::object::const_iterator itEnd(values_object.end());
+
+ for (; it != itEnd; it++) {
+ Parameter param;
+ if (ParseParameterProperty(&param, err, values_object, it->first,
+ false)) {
+ material->values[it->first] = param;
+ }
+ }
+ }
+
+ ParseExtrasProperty(&(material->extras), o);
+
+ return true;
+}
+
+static bool ParseShader(Shader *shader, std::string *err,
+ const picojson::object &o, const std::string &basedir,
+ bool is_binary = false,
+ const unsigned char *bin_data = NULL,
+ size_t bin_size = 0) {
+ std::string uri;
+ if (!ParseStringProperty(&uri, err, o, "uri", true)) {
+ return false;
+ }
+
+ if (is_binary) {
+ // Still binary glTF accepts external dataURI. First try external resources.
+ bool loaded = false;
+ if (IsDataURI(uri)) {
+ loaded = DecodeDataURI(&shader->source, uri, 0, false);
+ } else {
+ // Assume external .bin file.
+ loaded = LoadExternalFile(&shader->source, err, uri, basedir, 0, false);
+ }
+
+ if (!loaded) {
+ // load data from (embedded) binary data
+
+ if ((bin_size == 0) || (bin_data == NULL)) {
+ if (err) {
+ (*err) += "Invalid binary data.\n";
+ }
+ return false;
+ }
+
+ // There should be "extensions" property.
+ // "extensions":{"KHR_binary_glTF":{"bufferView": "id", ...
+
+ std::string buffer_view;
+ std::string mime_type;
+ int image_width;
+ int image_height;
+ bool ret = ParseKHRBinaryExtension(o, err, &buffer_view, &mime_type,
+ &image_width, &image_height);
+ if (!ret) {
+ return false;
+ }
+
+ if (uri.compare("data:,") == 0) {
+ // ok
+ } else {
+ if (err) {
+ (*err) += "Invalid URI for binary data.\n";
+ }
+ return false;
+ }
+ }
+ } else {
+ // Load shader source from data uri
+ // TODO(syoyo): Support ascii or utf-8 data uris.
+ if (IsDataURI(uri)) {
+ if (!DecodeDataURI(&shader->source, uri, 0, false)) {
+ if (err) {
+ (*err) += "Failed to decode 'uri' for shader parameter.\n";
+ }
+ return false;
+ }
+ } else {
+ // Assume external file
+ if (!LoadExternalFile(&shader->source, err, uri, basedir, 0, false)) {
+ if (err) {
+ (*err) += "Failed to load external 'uri' for shader parameter.\n";
+ }
+ return false;
+ }
+ if (shader->source.empty()) {
+ if (err) {
+ (*err) += "shader is empty.\n"; // This may be OK?
+ }
+ return false;
+ }
+ }
+ }
+
+ double type;
+ if (!ParseNumberProperty(&type, err, o, "type", true)) {
+ return false;
+ }
+
+ shader->type = static_cast<int>(type);
+
+ ParseExtrasProperty(&(shader->extras), o);
+
+ return true;
+}
+
+static bool ParseProgram(Program *program, std::string *err,
+ const picojson::object &o) {
+ ParseStringProperty(&program->name, err, o, "name", false);
+
+ if (!ParseStringProperty(&program->vertexShader, err, o, "vertexShader",
+ true)) {
+ return false;
+ }
+ if (!ParseStringProperty(&program->fragmentShader, err, o, "fragmentShader",
+ true)) {
+ return false;
+ }
+
+ // I suppose the list of attributes isn't needed, but a technique doesn't
+ // really make sense without it.
+ ParseStringArrayProperty(&program->attributes, err, o, "attributes", false);
+
+ ParseExtrasProperty(&(program->extras), o);
+
+ return true;
+}
+
+static bool ParseTechniqueParameter(TechniqueParameter *param, std::string *err,
+ const picojson::object &o) {
+ double count = 1;
+ ParseNumberProperty(&count, err, o, "count", false);
+
+ double type;
+ if (!ParseNumberProperty(&type, err, o, "type", true)) {
+ return false;
+ }
+
+ ParseStringProperty(&param->node, err, o, "node", false);
+ ParseStringProperty(&param->semantic, err, o, "semantic", false);
+
+ ParseParameterProperty(&param->value, err, o, "value", false);
+
+ param->count = static_cast<int>(count);
+ param->type = static_cast<int>(type);
+
+ return true;
+}
+
+static bool ParseTechnique(Technique *technique, std::string *err,
+ const picojson::object &o) {
+ ParseStringProperty(&technique->name, err, o, "name", false);
+
+ if (!ParseStringProperty(&technique->program, err, o, "program", true)) {
+ return false;
+ }
+
+ ParseStringMapProperty(&technique->attributes, err, o, "attributes", false);
+ ParseStringMapProperty(&technique->uniforms, err, o, "uniforms", false);
+
+ technique->parameters.clear();
+ picojson::object::const_iterator paramsIt = o.find("parameters");
+
+ // Verify parameters is an object
+ if ((paramsIt != o.end()) && (paramsIt->second).is<picojson::object>()) {
+ // For each parameter in params_object.
+ const picojson::object &params_object =
+ (paramsIt->second).get<picojson::object>();
+
+ picojson::object::const_iterator it(params_object.begin());
+ picojson::object::const_iterator itEnd(params_object.end());
+
+ for (; it != itEnd; it++) {
+ TechniqueParameter param;
+
+ // Skip non-objects
+ if (!it->second.is<picojson::object>()) continue;
+
+ // Parse the technique parameter
+ const picojson::object &param_obj = it->second.get<picojson::object>();
+ if (ParseTechniqueParameter(&param, err, param_obj)) {
+ // Add if successful
+ technique->parameters[it->first] = param;
+ }
+ }
+ }
+
+ ParseExtrasProperty(&(technique->extras), o);
+
+ return true;
+}
+
+static bool ParseAnimationChannel(AnimationChannel *channel, std::string *err,
+ const picojson::object &o) {
+ if (!ParseStringProperty(&channel->sampler, err, o, "sampler", true)) {
+ if (err) {
+ (*err) += "`sampler` field is missing in animation channels\n";
+ }
+ return false;
+ }
+
+ picojson::object::const_iterator targetIt = o.find("target");
+ if ((targetIt != o.end()) && (targetIt->second).is<picojson::object>()) {
+ const picojson::object &target_object =
+ (targetIt->second).get<picojson::object>();
+
+ if (!ParseStringProperty(&channel->target_id, err, target_object, "id",
+ true)) {
+ if (err) {
+ (*err) += "`id` field is missing in animation.channels.target\n";
+ }
+ return false;
+ }
+
+ if (!ParseStringProperty(&channel->target_path, err, target_object, "path",
+ true)) {
+ if (err) {
+ (*err) += "`path` field is missing in animation.channels.target\n";
+ }
+ return false;
+ }
+ }
+
+ ParseExtrasProperty(&(channel->extras), o);
+
+ return true;
+}
+
+static bool ParseAnimation(Animation *animation, std::string *err,
+ const picojson::object &o) {
+ {
+ picojson::object::const_iterator channelsIt = o.find("channels");
+ if ((channelsIt != o.end()) && (channelsIt->second).is<picojson::array>()) {
+ const picojson::array &channelArray =
+ (channelsIt->second).get<picojson::array>();
+ for (size_t i = 0; i < channelArray.size(); i++) {
+ AnimationChannel channel;
+ if (ParseAnimationChannel(&channel, err,
+ channelArray[i].get<picojson::object>())) {
+ // Only add the channel if the parsing succeeds.
+ animation->channels.push_back(channel);
+ }
+ }
+ }
+ }
+
+ {
+ picojson::object::const_iterator samplerIt = o.find("samplers");
+ if ((samplerIt != o.end()) && (samplerIt->second).is<picojson::object>()) {
+ const picojson::object &sampler_object =
+ (samplerIt->second).get<picojson::object>();
+
+ picojson::object::const_iterator it = sampler_object.begin();
+ picojson::object::const_iterator itEnd = sampler_object.end();
+
+ for (; it != itEnd; it++) {
+ // Skip non-objects
+ if (!it->second.is<picojson::object>()) continue;
+
+ const picojson::object &s = it->second.get<picojson::object>();
+
+ AnimationSampler sampler;
+ if (!ParseStringProperty(&sampler.input, err, s, "input", true)) {
+ if (err) {
+ (*err) += "`input` field is missing in animation.sampler\n";
+ }
+ return false;
+ }
+ if (!ParseStringProperty(&sampler.interpolation, err, s,
+ "interpolation", true)) {
+ if (err) {
+ (*err) += "`interpolation` field is missing in animation.sampler\n";
+ }
+ return false;
+ }
+ if (!ParseStringProperty(&sampler.output, err, s, "output", true)) {
+ if (err) {
+ (*err) += "`output` field is missing in animation.sampler\n";
+ }
+ return false;
+ }
+
+ animation->samplers[it->first] = sampler;
+ }
+ }
+ }
+
+ picojson::object::const_iterator parametersIt = o.find("parameters");
+ if ((parametersIt != o.end()) &&
+ (parametersIt->second).is<picojson::object>()) {
+ const picojson::object &parameters_object =
+ (parametersIt->second).get<picojson::object>();
+
+ picojson::object::const_iterator it(parameters_object.begin());
+ picojson::object::const_iterator itEnd(parameters_object.end());
+
+ for (; it != itEnd; it++) {
+ Parameter param;
+ if (ParseParameterProperty(&param, err, parameters_object, it->first,
+ false)) {
+ animation->parameters[it->first] = param;
+ }
+ }
+ }
+ ParseStringProperty(&animation->name, err, o, "name", false);
+
+ ParseExtrasProperty(&(animation->extras), o);
+
+ return true;
+}
+
+static bool ParseSampler(Sampler *sampler, std::string *err,
+ const picojson::object &o) {
+ ParseStringProperty(&sampler->name, err, o, "name", false);
+
+ double minFilter =
+ static_cast<double>(TINYGLTF_TEXTURE_FILTER_NEAREST_MIPMAP_LINEAR);
+ double magFilter = static_cast<double>(TINYGLTF_TEXTURE_FILTER_LINEAR);
+ double wrapS = static_cast<double>(TINYGLTF_TEXTURE_WRAP_RPEAT);
+ double wrapT = static_cast<double>(TINYGLTF_TEXTURE_WRAP_RPEAT);
+ ParseNumberProperty(&minFilter, err, o, "minFilter", false);
+ ParseNumberProperty(&magFilter, err, o, "magFilter", false);
+ ParseNumberProperty(&wrapS, err, o, "wrapS", false);
+ ParseNumberProperty(&wrapT, err, o, "wrapT", false);
+
+ sampler->minFilter = static_cast<int>(minFilter);
+ sampler->magFilter = static_cast<int>(magFilter);
+ sampler->wrapS = static_cast<int>(wrapS);
+ sampler->wrapT = static_cast<int>(wrapT);
+
+ ParseExtrasProperty(&(sampler->extras), o);
+
+ return true;
+}
+
+bool TinyGLTFLoader::LoadFromString(Scene *scene, std::string *err,
+ const char *str, unsigned int length,
+ const std::string &base_dir,
+ unsigned int check_sections) {
+ picojson::value v;
+ std::string perr = picojson::parse(v, str, str + length);
+
+ if (!perr.empty()) {
+ if (err) {
+ (*err) = perr;
+ }
+ return false;
+ }
+
+ if (v.contains("scene") && v.get("scene").is<std::string>()) {
+ // OK
+ } else if (check_sections & REQUIRE_SCENE) {
+ if (err) {
+ (*err) += "\"scene\" object not found in .gltf\n";
+ }
+ return false;
+ }
+
+ if (v.contains("scenes") && v.get("scenes").is<picojson::object>()) {
+ // OK
+ } else if (check_sections & REQUIRE_SCENES) {
+ if (err) {
+ (*err) += "\"scenes\" object not found in .gltf\n";
+ }
+ return false;
+ }
+
+ if (v.contains("nodes") && v.get("nodes").is<picojson::object>()) {
+ // OK
+ } else if (check_sections & REQUIRE_NODES) {
+ if (err) {
+ (*err) += "\"nodes\" object not found in .gltf\n";
+ }
+ return false;
+ }
+
+ if (v.contains("accessors") && v.get("accessors").is<picojson::object>()) {
+ // OK
+ } else if (check_sections & REQUIRE_ACCESSORS) {
+ if (err) {
+ (*err) += "\"accessors\" object not found in .gltf\n";
+ }
+ return false;
+ }
+
+ if (v.contains("buffers") && v.get("buffers").is<picojson::object>()) {
+ // OK
+ } else if (check_sections & REQUIRE_BUFFERS) {
+ if (err) {
+ (*err) += "\"buffers\" object not found in .gltf\n";
+ }
+ return false;
+ }
+
+ if (v.contains("bufferViews") &&
+ v.get("bufferViews").is<picojson::object>()) {
+ // OK
+ } else if (check_sections & REQUIRE_BUFFER_VIEWS) {
+ if (err) {
+ (*err) += "\"bufferViews\" object not found in .gltf\n";
+ }
+ return false;
+ }
+
+ scene->buffers.clear();
+ scene->bufferViews.clear();
+ scene->accessors.clear();
+ scene->meshes.clear();
+ scene->nodes.clear();
+ scene->defaultScene = "";
+
+ // 0. Parse Asset
+ if (v.contains("asset") && v.get("asset").is<picojson::object>()) {
+ const picojson::object &root = v.get("asset").get<picojson::object>();
+
+ ParseAsset(&scene->asset, err, root);
+ }
+
+ // 1. Parse Buffer
+ if (v.contains("buffers") && v.get("buffers").is<picojson::object>()) {
+ const picojson::object &root = v.get("buffers").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ Buffer buffer;
+ if (!ParseBuffer(&buffer, err, (it->second).get<picojson::object>(),
+ base_dir, is_binary_, bin_data_, bin_size_)) {
+ return false;
+ }
+
+ scene->buffers[it->first] = buffer;
+ }
+ }
+
+ // 2. Parse BufferView
+ if (v.contains("bufferViews") &&
+ v.get("bufferViews").is<picojson::object>()) {
+ const picojson::object &root = v.get("bufferViews").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ BufferView bufferView;
+ if (!ParseBufferView(&bufferView, err,
+ (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->bufferViews[it->first] = bufferView;
+ }
+ }
+
+ // 3. Parse Accessor
+ if (v.contains("accessors") && v.get("accessors").is<picojson::object>()) {
+ const picojson::object &root = v.get("accessors").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ Accessor accessor;
+ if (!ParseAccessor(&accessor, err,
+ (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->accessors[it->first] = accessor;
+ }
+ }
+
+ // 4. Parse Mesh
+ if (v.contains("meshes") && v.get("meshes").is<picojson::object>()) {
+ const picojson::object &root = v.get("meshes").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ Mesh mesh;
+ if (!ParseMesh(&mesh, err, (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->meshes[it->first] = mesh;
+ }
+ }
+
+ // 5. Parse Node
+ if (v.contains("nodes") && v.get("nodes").is<picojson::object>()) {
+ const picojson::object &root = v.get("nodes").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ Node node;
+ if (!ParseNode(&node, err, (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->nodes[it->first] = node;
+ }
+ }
+
+ // 6. Parse scenes.
+ if (v.contains("scenes") && v.get("scenes").is<picojson::object>()) {
+ const picojson::object &root = v.get("scenes").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ if (!((it->second).is<picojson::object>())) {
+ if (err) {
+ (*err) += "`scenes' does not contain an object.";
+ }
+ return false;
+ }
+ const picojson::object &o = (it->second).get<picojson::object>();
+ std::vector<std::string> nodes;
+ if (!ParseStringArrayProperty(&nodes, err, o, "nodes", false)) {
+ return false;
+ }
+
+ scene->scenes[it->first] = nodes;
+ }
+ }
+
+ // 7. Parse default scenes.
+ if (v.contains("scene") && v.get("scene").is<std::string>()) {
+ const std::string defaultScene = v.get("scene").get<std::string>();
+
+ scene->defaultScene = defaultScene;
+ }
+
+ // 8. Parse Material
+ if (v.contains("materials") && v.get("materials").is<picojson::object>()) {
+ const picojson::object &root = v.get("materials").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ Material material;
+ if (!ParseMaterial(&material, err,
+ (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->materials[it->first] = material;
+ }
+ }
+
+ // 9. Parse Image
+ if (v.contains("images") && v.get("images").is<picojson::object>()) {
+ const picojson::object &root = v.get("images").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ Image image;
+ if (!ParseImage(&image, err, (it->second).get<picojson::object>(),
+ base_dir, is_binary_, bin_data_, bin_size_)) {
+ return false;
+ }
+
+ if (!image.bufferView.empty()) {
+ // Load image from the buffer view.
+ if (scene->bufferViews.find(image.bufferView) ==
+ scene->bufferViews.end()) {
+ if (err) {
+ std::stringstream ss;
+ ss << "bufferView \"" << image.bufferView
+ << "\" not found in the scene." << std::endl;
+ (*err) += ss.str();
+ }
+ return false;
+ }
+
+ const BufferView &bufferView = scene->bufferViews[image.bufferView];
+ const Buffer &buffer = scene->buffers[bufferView.buffer];
+
+ bool ret = LoadImageData(&image, err, image.width, image.height,
+ &buffer.data[bufferView.byteOffset],
+ static_cast<int>(bufferView.byteLength));
+ if (!ret) {
+ return false;
+ }
+ }
+
+ scene->images[it->first] = image;
+ }
+ }
+
+ // 10. Parse Texture
+ if (v.contains("textures") && v.get("textures").is<picojson::object>()) {
+ const picojson::object &root = v.get("textures").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; it++) {
+ Texture texture;
+ if (!ParseTexture(&texture, err, (it->second).get<picojson::object>(),
+ base_dir)) {
+ return false;
+ }
+
+ scene->textures[it->first] = texture;
+ }
+ }
+
+ // 11. Parse Shader
+ if (v.contains("shaders") && v.get("shaders").is<picojson::object>()) {
+ const picojson::object &root = v.get("shaders").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; ++it) {
+ Shader shader;
+ if (!ParseShader(&shader, err, (it->second).get<picojson::object>(),
+ base_dir, is_binary_, bin_data_, bin_size_)) {
+ return false;
+ }
+
+ scene->shaders[it->first] = shader;
+ }
+ }
+
+ // 12. Parse Program
+ if (v.contains("programs") && v.get("programs").is<picojson::object>()) {
+ const picojson::object &root = v.get("programs").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; ++it) {
+ Program program;
+ if (!ParseProgram(&program, err, (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->programs[it->first] = program;
+ }
+ }
+
+ // 13. Parse Technique
+ if (v.contains("techniques") && v.get("techniques").is<picojson::object>()) {
+ const picojson::object &root = v.get("techniques").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; ++it) {
+ Technique technique;
+ if (!ParseTechnique(&technique, err,
+ (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->techniques[it->first] = technique;
+ }
+ }
+
+ // 14. Parse Animation
+ if (v.contains("animations") && v.get("animations").is<picojson::object>()) {
+ const picojson::object &root = v.get("animations").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; ++it) {
+ Animation animation;
+ if (!ParseAnimation(&animation, err,
+ (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->animations[it->first] = animation;
+ }
+ }
+
+ // 15. Parse Sampler
+ if (v.contains("samplers") && v.get("samplers").is<picojson::object>()) {
+ const picojson::object &root = v.get("samplers").get<picojson::object>();
+
+ picojson::object::const_iterator it(root.begin());
+ picojson::object::const_iterator itEnd(root.end());
+ for (; it != itEnd; ++it) {
+ Sampler sampler;
+ if (!ParseSampler(&sampler, err, (it->second).get<picojson::object>())) {
+ return false;
+ }
+
+ scene->samplers[it->first] = sampler;
+ }
+ }
+ return true;
+}
+
+bool TinyGLTFLoader::LoadASCIIFromString(Scene *scene, std::string *err,
+ const char *str, unsigned int length,
+ const std::string &base_dir,
+ unsigned int check_sections) {
+ is_binary_ = false;
+ bin_data_ = NULL;
+ bin_size_ = 0;
+
+ return LoadFromString(scene, err, str, length, base_dir, check_sections);
+}
+
+bool TinyGLTFLoader::LoadASCIIFromFile(Scene *scene, std::string *err,
+ const std::string &filename,
+ unsigned int check_sections) {
+ std::stringstream ss;
+
+ std::ifstream f(filename.c_str());
+ if (!f) {
+ ss << "Failed to open file: " << filename << std::endl;
+ if (err) {
+ (*err) = ss.str();
+ }
+ return false;
+ }
+
+ f.seekg(0, f.end);
+ size_t sz = static_cast<size_t>(f.tellg());
+ std::vector<char> buf(sz);
+
+ if (sz == 0) {
+ if (err) {
+ (*err) = "Empty file.";
+ }
+ return false;
+ }
+
+ f.seekg(0, f.beg);
+ f.read(&buf.at(0), static_cast<std::streamsize>(sz));
+ f.close();
+
+ std::string basedir = GetBaseDir(filename);
+
+ bool ret = LoadASCIIFromString(scene, err, &buf.at(0),
+ static_cast<unsigned int>(buf.size()), basedir,
+ check_sections);
+
+ return ret;
+}
+
+bool TinyGLTFLoader::LoadBinaryFromMemory(Scene *scene, std::string *err,
+ const unsigned char *bytes,
+ unsigned int size,
+ const std::string &base_dir,
+ unsigned int check_sections) {
+ if (size < 20) {
+ if (err) {
+ (*err) = "Too short data size for glTF Binary.";
+ }
+ return false;
+ }
+
+ if (bytes[0] == 'g' && bytes[1] == 'l' && bytes[2] == 'T' &&
+ bytes[3] == 'F') {
+ // ok
+ } else {
+ if (err) {
+ (*err) = "Invalid magic.";
+ }
+ return false;
+ }
+
+ unsigned int version; // 4 bytes
+ unsigned int length; // 4 bytes
+ unsigned int scene_length; // 4 bytes
+ unsigned int scene_format; // 4 bytes;
+
+ // @todo { Endian swap for big endian machine. }
+ memcpy(&version, bytes + 4, 4);
+ swap4(&version);
+ memcpy(&length, bytes + 8, 4);
+ swap4(&length);
+ memcpy(&scene_length, bytes + 12, 4);
+ swap4(&scene_length);
+ memcpy(&scene_format, bytes + 16, 4);
+ swap4(&scene_format);
+
+ if ((20 + scene_length >= size) || (scene_length < 1) ||
+ (scene_format != 0)) { // 0 = JSON format.
+ if (err) {
+ (*err) = "Invalid glTF binary.";
+ }
+ return false;
+ }
+
+ // Extract JSON string.
+ std::string jsonString(reinterpret_cast<const char *>(&bytes[20]),
+ scene_length);
+
+ is_binary_ = true;
+ bin_data_ = bytes + 20 + scene_length;
+ bin_size_ =
+ length - (20 + scene_length); // extract header + JSON scene data.
+
+ bool ret =
+ LoadFromString(scene, err, reinterpret_cast<const char *>(&bytes[20]),
+ scene_length, base_dir, check_sections);
+ if (!ret) {
+ return ret;
+ }
+
+ return true;
+}
+
+bool TinyGLTFLoader::LoadBinaryFromFile(Scene *scene, std::string *err,
+ const std::string &filename,
+ unsigned int check_sections) {
+ std::stringstream ss;
+
+ std::ifstream f(filename.c_str(), std::ios::binary);
+ if (!f) {
+ ss << "Failed to open file: " << filename << std::endl;
+ if (err) {
+ (*err) = ss.str();
+ }
+ return false;
+ }
+
+ f.seekg(0, f.end);
+ size_t sz = static_cast<size_t>(f.tellg());
+ std::vector<char> buf(sz);
+
+ f.seekg(0, f.beg);
+ f.read(&buf.at(0), static_cast<std::streamsize>(sz));
+ f.close();
+
+ std::string basedir = GetBaseDir(filename);
+
+ bool ret = LoadBinaryFromMemory(
+ scene, err, reinterpret_cast<unsigned char *>(&buf.at(0)),
+ static_cast<unsigned int>(buf.size()), basedir, check_sections);
+
+ return ret;
+}
+
+} // namespace tinygltf
+
+#endif // TINYGLTF_LOADER_IMPLEMENTATION
+
+#endif // TINY_GLTF_LOADER_H_
diff --git a/chromium/third_party/dawn/third_party/vulkan/vk_platform.h b/chromium/third_party/dawn/third_party/vulkan/vk_platform.h
new file mode 100644
index 00000000000..72f80493caf
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/vulkan/vk_platform.h
@@ -0,0 +1,120 @@
+//
+// File: vk_platform.h
+//
+/*
+** Copyright (c) 2014-2017 The Khronos Group Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+
+#ifndef VK_PLATFORM_H_
+#define VK_PLATFORM_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif // __cplusplus
+
+/*
+***************************************************************************************************
+* Platform-specific directives and type declarations
+***************************************************************************************************
+*/
+
+/* Platform-specific calling convention macros.
+ *
+ * Platforms should define these so that Vulkan clients call Vulkan commands
+ * with the same calling conventions that the Vulkan implementation expects.
+ *
+ * VKAPI_ATTR - Placed before the return type in function declarations.
+ * Useful for C++11 and GCC/Clang-style function attribute syntax.
+ * VKAPI_CALL - Placed after the return type in function declarations.
+ * Useful for MSVC-style calling convention syntax.
+ * VKAPI_PTR - Placed between the '(' and '*' in function pointer types.
+ *
+ * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void);
+ * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void);
+ */
+#if defined(_WIN32)
+ // On Windows, Vulkan commands use the stdcall convention
+ #define VKAPI_ATTR
+ #define VKAPI_CALL __stdcall
+ #define VKAPI_PTR VKAPI_CALL
+#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
+ #error "Vulkan isn't supported for the 'armeabi' NDK ABI"
+#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
+ // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat"
+ // calling convention, i.e. float parameters are passed in registers. This
+ // is true even if the rest of the application passes floats on the stack,
+ // as it does by default when compiling for the armeabi-v7a NDK ABI.
+ #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp")))
+ #define VKAPI_CALL
+ #define VKAPI_PTR VKAPI_ATTR
+#else
+ // On other platforms, use the default calling convention
+ #define VKAPI_ATTR
+ #define VKAPI_CALL
+ #define VKAPI_PTR
+#endif
+
+#include <stddef.h>
+
+#if !defined(VK_NO_STDINT_H)
+ #if defined(_MSC_VER) && (_MSC_VER < 1600)
+ typedef signed __int8 int8_t;
+ typedef unsigned __int8 uint8_t;
+ typedef signed __int16 int16_t;
+ typedef unsigned __int16 uint16_t;
+ typedef signed __int32 int32_t;
+ typedef unsigned __int32 uint32_t;
+ typedef signed __int64 int64_t;
+ typedef unsigned __int64 uint64_t;
+ #else
+ #include <stdint.h>
+ #endif
+#endif // !defined(VK_NO_STDINT_H)
+
+#ifdef __cplusplus
+} // extern "C"
+#endif // __cplusplus
+
+// Platform-specific headers required by platform window system extensions.
+// These are enabled prior to #including "vulkan.h". The same enable then
+// controls inclusion of the extension interfaces in vulkan.h.
+
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+#include <android/native_window.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_MIR_KHR
+#include <mir_toolkit/client_types.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+#include <wayland-client.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+#include <windows.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+#include <X11/Xlib.h>
+#endif
+
+#ifdef VK_USE_PLATFORM_XCB_KHR
+#include <xcb/xcb.h>
+#endif
+
+#endif
diff --git a/chromium/third_party/dawn/third_party/vulkan/vulkan.h b/chromium/third_party/dawn/third_party/vulkan/vulkan.h
new file mode 100644
index 00000000000..8e21042ac13
--- /dev/null
+++ b/chromium/third_party/dawn/third_party/vulkan/vulkan.h
@@ -0,0 +1,6937 @@
+#ifndef VULKAN_H_
+#define VULKAN_H_ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2015-2017 The Khronos Group Inc.
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+/*
+** This header is generated from the Khronos Vulkan XML API Registry.
+**
+*/
+
+
+#define VK_VERSION_1_0 1
+#include "vk_platform.h"
+
+#define VK_MAKE_VERSION(major, minor, patch) \
+ (((major) << 22) | ((minor) << 12) | (patch))
+
+// DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead.
+//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0) // Patch version should always be set to 0
+
+// Vulkan 1.0 version number
+#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)// Patch version should always be set to 0
+
+#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
+#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
+#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff)
+// Version of this file
+#define VK_HEADER_VERSION 65
+
+
+#define VK_NULL_HANDLE 0
+
+
+
+#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
+
+
+#if !defined(VK_DEFINE_NON_DISPATCHABLE_HANDLE)
+#if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
+ #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
+#else
+ #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
+#endif
+#endif
+
+
+
+typedef uint32_t VkFlags;
+typedef uint32_t VkBool32;
+typedef uint64_t VkDeviceSize;
+typedef uint32_t VkSampleMask;
+
+VK_DEFINE_HANDLE(VkInstance)
+VK_DEFINE_HANDLE(VkPhysicalDevice)
+VK_DEFINE_HANDLE(VkDevice)
+VK_DEFINE_HANDLE(VkQueue)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore)
+VK_DEFINE_HANDLE(VkCommandBuffer)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool)
+
+#define VK_LOD_CLAMP_NONE 1000.0f
+#define VK_REMAINING_MIP_LEVELS (~0U)
+#define VK_REMAINING_ARRAY_LAYERS (~0U)
+#define VK_WHOLE_SIZE (~0ULL)
+#define VK_ATTACHMENT_UNUSED (~0U)
+#define VK_TRUE 1
+#define VK_FALSE 0
+#define VK_QUEUE_FAMILY_IGNORED (~0U)
+#define VK_SUBPASS_EXTERNAL (~0U)
+#define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256
+#define VK_UUID_SIZE 16
+#define VK_MAX_MEMORY_TYPES 32
+#define VK_MAX_MEMORY_HEAPS 16
+#define VK_MAX_EXTENSION_NAME_SIZE 256
+#define VK_MAX_DESCRIPTION_SIZE 256
+
+
+typedef enum VkPipelineCacheHeaderVersion {
+ VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1,
+ VK_PIPELINE_CACHE_HEADER_VERSION_BEGIN_RANGE = VK_PIPELINE_CACHE_HEADER_VERSION_ONE,
+ VK_PIPELINE_CACHE_HEADER_VERSION_END_RANGE = VK_PIPELINE_CACHE_HEADER_VERSION_ONE,
+ VK_PIPELINE_CACHE_HEADER_VERSION_RANGE_SIZE = (VK_PIPELINE_CACHE_HEADER_VERSION_ONE - VK_PIPELINE_CACHE_HEADER_VERSION_ONE + 1),
+ VK_PIPELINE_CACHE_HEADER_VERSION_MAX_ENUM = 0x7FFFFFFF
+} VkPipelineCacheHeaderVersion;
+
+typedef enum VkResult {
+ VK_SUCCESS = 0,
+ VK_NOT_READY = 1,
+ VK_TIMEOUT = 2,
+ VK_EVENT_SET = 3,
+ VK_EVENT_RESET = 4,
+ VK_INCOMPLETE = 5,
+ VK_ERROR_OUT_OF_HOST_MEMORY = -1,
+ VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
+ VK_ERROR_INITIALIZATION_FAILED = -3,
+ VK_ERROR_DEVICE_LOST = -4,
+ VK_ERROR_MEMORY_MAP_FAILED = -5,
+ VK_ERROR_LAYER_NOT_PRESENT = -6,
+ VK_ERROR_EXTENSION_NOT_PRESENT = -7,
+ VK_ERROR_FEATURE_NOT_PRESENT = -8,
+ VK_ERROR_INCOMPATIBLE_DRIVER = -9,
+ VK_ERROR_TOO_MANY_OBJECTS = -10,
+ VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
+ VK_ERROR_FRAGMENTED_POOL = -12,
+ VK_ERROR_SURFACE_LOST_KHR = -1000000000,
+ VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
+ VK_SUBOPTIMAL_KHR = 1000001003,
+ VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
+ VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
+ VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
+ VK_ERROR_INVALID_SHADER_NV = -1000012000,
+ VK_ERROR_OUT_OF_POOL_MEMORY_KHR = -1000069000,
+ VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR = -1000072003,
+ VK_ERROR_NOT_PERMITTED_EXT = -1000174001,
+ VK_RESULT_BEGIN_RANGE = VK_ERROR_FRAGMENTED_POOL,
+ VK_RESULT_END_RANGE = VK_INCOMPLETE,
+ VK_RESULT_RANGE_SIZE = (VK_INCOMPLETE - VK_ERROR_FRAGMENTED_POOL + 1),
+ VK_RESULT_MAX_ENUM = 0x7FFFFFFF
+} VkResult;
+
+typedef enum VkStructureType {
+ VK_STRUCTURE_TYPE_APPLICATION_INFO = 0,
+ VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1,
+ VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2,
+ VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 3,
+ VK_STRUCTURE_TYPE_SUBMIT_INFO = 4,
+ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 5,
+ VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 6,
+ VK_STRUCTURE_TYPE_BIND_SPARSE_INFO = 7,
+ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 8,
+ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 9,
+ VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10,
+ VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 11,
+ VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 12,
+ VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 13,
+ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 14,
+ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 15,
+ VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 16,
+ VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 17,
+ VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 18,
+ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19,
+ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20,
+ VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21,
+ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22,
+ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23,
+ VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24,
+ VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25,
+ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26,
+ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27,
+ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 28,
+ VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 29,
+ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 30,
+ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 31,
+ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32,
+ VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33,
+ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 34,
+ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 35,
+ VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 36,
+ VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 37,
+ VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 38,
+ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 39,
+ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO = 40,
+ VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO = 41,
+ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO = 42,
+ VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43,
+ VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 44,
+ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 45,
+ VK_STRUCTURE_TYPE_MEMORY_BARRIER = 46,
+ VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO = 47,
+ VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO = 48,
+ VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR = 1000001000,
+ VK_STRUCTURE_TYPE_PRESENT_INFO_KHR = 1000001001,
+ VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR = 1000002000,
+ VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR = 1000002001,
+ VK_STRUCTURE_TYPE_DISPLAY_PRESENT_INFO_KHR = 1000003000,
+ VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
+ VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
+ VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
+ VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR = 1000007000,
+ VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000,
+ VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
+ VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000,
+ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000,
+ VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000,
+ VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001,
+ VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002,
+ VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000,
+ VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001,
+ VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002,
+ VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000,
+ VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHX = 1000053000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHX = 1000053001,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHX = 1000053002,
+ VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV = 1000056000,
+ VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_NV = 1000056001,
+ VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000,
+ VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001,
+ VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV = 1000058000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR = 1000059000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR = 1000059001,
+ VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR = 1000059002,
+ VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR = 1000059003,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR = 1000059004,
+ VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR = 1000059005,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR = 1000059006,
+ VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR = 1000059007,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR = 1000059008,
+ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO_KHX = 1000060000,
+ VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO_KHX = 1000060003,
+ VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO_KHX = 1000060004,
+ VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO_KHX = 1000060005,
+ VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO_KHX = 1000060006,
+ VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHX = 1000060010,
+ VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO_KHX = 1000060013,
+ VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO_KHX = 1000060014,
+ VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHX = 1000060007,
+ VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHX = 1000060008,
+ VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHX = 1000060009,
+ VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHX = 1000060011,
+ VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHX = 1000060012,
+ VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT = 1000061000,
+ VK_STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN = 1000062000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES_KHX = 1000070000,
+ VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHX = 1000070001,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHR = 1000071000,
+ VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR = 1000071001,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO_KHR = 1000071002,
+ VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES_KHR = 1000071003,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR = 1000071004,
+ VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR = 1000072000,
+ VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR = 1000072001,
+ VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR = 1000072002,
+ VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073000,
+ VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073001,
+ VK_STRUCTURE_TYPE_MEMORY_WIN32_HANDLE_PROPERTIES_KHR = 1000073002,
+ VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR = 1000073003,
+ VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR = 1000074000,
+ VK_STRUCTURE_TYPE_MEMORY_FD_PROPERTIES_KHR = 1000074001,
+ VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR = 1000074002,
+ VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHR = 1000075000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO_KHR = 1000076000,
+ VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES_KHR = 1000076001,
+ VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHR = 1000077000,
+ VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078000,
+ VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078001,
+ VK_STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHR = 1000078002,
+ VK_STRUCTURE_TYPE_SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR = 1000078003,
+ VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR = 1000079000,
+ VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR = 1000079001,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR = 1000080000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR = 1000083000,
+ VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR = 1000084000,
+ VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR = 1000085000,
+ VK_STRUCTURE_TYPE_OBJECT_TABLE_CREATE_INFO_NVX = 1000086000,
+ VK_STRUCTURE_TYPE_INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NVX = 1000086001,
+ VK_STRUCTURE_TYPE_CMD_PROCESS_COMMANDS_INFO_NVX = 1000086002,
+ VK_STRUCTURE_TYPE_CMD_RESERVE_SPACE_FOR_COMMANDS_INFO_NVX = 1000086003,
+ VK_STRUCTURE_TYPE_DEVICE_GENERATED_COMMANDS_LIMITS_NVX = 1000086004,
+ VK_STRUCTURE_TYPE_DEVICE_GENERATED_COMMANDS_FEATURES_NVX = 1000086005,
+ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV = 1000087000,
+ VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT = 1000090000,
+ VK_STRUCTURE_TYPE_DISPLAY_POWER_INFO_EXT = 1000091000,
+ VK_STRUCTURE_TYPE_DEVICE_EVENT_INFO_EXT = 1000091001,
+ VK_STRUCTURE_TYPE_DISPLAY_EVENT_INFO_EXT = 1000091002,
+ VK_STRUCTURE_TYPE_SWAPCHAIN_COUNTER_CREATE_INFO_EXT = 1000091003,
+ VK_STRUCTURE_TYPE_PRESENT_TIMES_INFO_GOOGLE = 1000092000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX = 1000097000,
+ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV = 1000098000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = 1000099000,
+ VK_STRUCTURE_TYPE_PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = 1000099001,
+ VK_STRUCTURE_TYPE_HDR_METADATA_EXT = 1000105000,
+ VK_STRUCTURE_TYPE_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR = 1000111000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO_KHR = 1000112000,
+ VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES_KHR = 1000112001,
+ VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO_KHR = 1000113000,
+ VK_STRUCTURE_TYPE_IMPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114000,
+ VK_STRUCTURE_TYPE_EXPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114001,
+ VK_STRUCTURE_TYPE_FENCE_GET_WIN32_HANDLE_INFO_KHR = 1000114002,
+ VK_STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR = 1000115000,
+ VK_STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR = 1000115001,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR = 1000117000,
+ VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO_KHR = 1000117001,
+ VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR = 1000117002,
+ VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO_KHR = 1000117003,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR = 1000119000,
+ VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR = 1000119001,
+ VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR = 1000119002,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR = 1000120000,
+ VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK = 1000122000,
+ VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
+ VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR = 1000127000,
+ VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR = 1000127001,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT = 1000130000,
+ VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT = 1000130001,
+ VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT = 1000143000,
+ VK_STRUCTURE_TYPE_RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT = 1000143001,
+ VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT = 1000143002,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT = 1000143003,
+ VK_STRUCTURE_TYPE_MULTISAMPLE_PROPERTIES_EXT = 1000143004,
+ VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR = 1000146000,
+ VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR = 1000146001,
+ VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2_KHR = 1000146002,
+ VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR = 1000146003,
+ VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2_KHR = 1000146004,
+ VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR = 1000147000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT = 1000148000,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT = 1000148001,
+ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT = 1000148002,
+ VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV = 1000149000,
+ VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV = 1000152000,
+ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR = 1000156000,
+ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR = 1000156001,
+ VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO_KHR = 1000156002,
+ VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO_KHR = 1000156003,
+ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR = 1000156004,
+ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES_KHR = 1000156005,
+ VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR = 1000157000,
+ VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR = 1000157001,
+ VK_STRUCTURE_TYPE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160000,
+ VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160001,
+ VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT = 1000174000,
+ VK_STRUCTURE_TYPE_BEGIN_RANGE = VK_STRUCTURE_TYPE_APPLICATION_INFO,
+ VK_STRUCTURE_TYPE_END_RANGE = VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO,
+ VK_STRUCTURE_TYPE_RANGE_SIZE = (VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO - VK_STRUCTURE_TYPE_APPLICATION_INFO + 1),
+ VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkStructureType;
+
+typedef enum VkSystemAllocationScope {
+ VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0,
+ VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1,
+ VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2,
+ VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3,
+ VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4,
+ VK_SYSTEM_ALLOCATION_SCOPE_BEGIN_RANGE = VK_SYSTEM_ALLOCATION_SCOPE_COMMAND,
+ VK_SYSTEM_ALLOCATION_SCOPE_END_RANGE = VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE,
+ VK_SYSTEM_ALLOCATION_SCOPE_RANGE_SIZE = (VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE - VK_SYSTEM_ALLOCATION_SCOPE_COMMAND + 1),
+ VK_SYSTEM_ALLOCATION_SCOPE_MAX_ENUM = 0x7FFFFFFF
+} VkSystemAllocationScope;
+
+typedef enum VkInternalAllocationType {
+ VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0,
+ VK_INTERNAL_ALLOCATION_TYPE_BEGIN_RANGE = VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE,
+ VK_INTERNAL_ALLOCATION_TYPE_END_RANGE = VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE,
+ VK_INTERNAL_ALLOCATION_TYPE_RANGE_SIZE = (VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE - VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE + 1),
+ VK_INTERNAL_ALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkInternalAllocationType;
+
+typedef enum VkFormat {
+ VK_FORMAT_UNDEFINED = 0,
+ VK_FORMAT_R4G4_UNORM_PACK8 = 1,
+ VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2,
+ VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3,
+ VK_FORMAT_R5G6B5_UNORM_PACK16 = 4,
+ VK_FORMAT_B5G6R5_UNORM_PACK16 = 5,
+ VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6,
+ VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7,
+ VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8,
+ VK_FORMAT_R8_UNORM = 9,
+ VK_FORMAT_R8_SNORM = 10,
+ VK_FORMAT_R8_USCALED = 11,
+ VK_FORMAT_R8_SSCALED = 12,
+ VK_FORMAT_R8_UINT = 13,
+ VK_FORMAT_R8_SINT = 14,
+ VK_FORMAT_R8_SRGB = 15,
+ VK_FORMAT_R8G8_UNORM = 16,
+ VK_FORMAT_R8G8_SNORM = 17,
+ VK_FORMAT_R8G8_USCALED = 18,
+ VK_FORMAT_R8G8_SSCALED = 19,
+ VK_FORMAT_R8G8_UINT = 20,
+ VK_FORMAT_R8G8_SINT = 21,
+ VK_FORMAT_R8G8_SRGB = 22,
+ VK_FORMAT_R8G8B8_UNORM = 23,
+ VK_FORMAT_R8G8B8_SNORM = 24,
+ VK_FORMAT_R8G8B8_USCALED = 25,
+ VK_FORMAT_R8G8B8_SSCALED = 26,
+ VK_FORMAT_R8G8B8_UINT = 27,
+ VK_FORMAT_R8G8B8_SINT = 28,
+ VK_FORMAT_R8G8B8_SRGB = 29,
+ VK_FORMAT_B8G8R8_UNORM = 30,
+ VK_FORMAT_B8G8R8_SNORM = 31,
+ VK_FORMAT_B8G8R8_USCALED = 32,
+ VK_FORMAT_B8G8R8_SSCALED = 33,
+ VK_FORMAT_B8G8R8_UINT = 34,
+ VK_FORMAT_B8G8R8_SINT = 35,
+ VK_FORMAT_B8G8R8_SRGB = 36,
+ VK_FORMAT_R8G8B8A8_UNORM = 37,
+ VK_FORMAT_R8G8B8A8_SNORM = 38,
+ VK_FORMAT_R8G8B8A8_USCALED = 39,
+ VK_FORMAT_R8G8B8A8_SSCALED = 40,
+ VK_FORMAT_R8G8B8A8_UINT = 41,
+ VK_FORMAT_R8G8B8A8_SINT = 42,
+ VK_FORMAT_R8G8B8A8_SRGB = 43,
+ VK_FORMAT_B8G8R8A8_UNORM = 44,
+ VK_FORMAT_B8G8R8A8_SNORM = 45,
+ VK_FORMAT_B8G8R8A8_USCALED = 46,
+ VK_FORMAT_B8G8R8A8_SSCALED = 47,
+ VK_FORMAT_B8G8R8A8_UINT = 48,
+ VK_FORMAT_B8G8R8A8_SINT = 49,
+ VK_FORMAT_B8G8R8A8_SRGB = 50,
+ VK_FORMAT_A8B8G8R8_UNORM_PACK32 = 51,
+ VK_FORMAT_A8B8G8R8_SNORM_PACK32 = 52,
+ VK_FORMAT_A8B8G8R8_USCALED_PACK32 = 53,
+ VK_FORMAT_A8B8G8R8_SSCALED_PACK32 = 54,
+ VK_FORMAT_A8B8G8R8_UINT_PACK32 = 55,
+ VK_FORMAT_A8B8G8R8_SINT_PACK32 = 56,
+ VK_FORMAT_A8B8G8R8_SRGB_PACK32 = 57,
+ VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58,
+ VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59,
+ VK_FORMAT_A2R10G10B10_USCALED_PACK32 = 60,
+ VK_FORMAT_A2R10G10B10_SSCALED_PACK32 = 61,
+ VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62,
+ VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63,
+ VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64,
+ VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65,
+ VK_FORMAT_A2B10G10R10_USCALED_PACK32 = 66,
+ VK_FORMAT_A2B10G10R10_SSCALED_PACK32 = 67,
+ VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68,
+ VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69,
+ VK_FORMAT_R16_UNORM = 70,
+ VK_FORMAT_R16_SNORM = 71,
+ VK_FORMAT_R16_USCALED = 72,
+ VK_FORMAT_R16_SSCALED = 73,
+ VK_FORMAT_R16_UINT = 74,
+ VK_FORMAT_R16_SINT = 75,
+ VK_FORMAT_R16_SFLOAT = 76,
+ VK_FORMAT_R16G16_UNORM = 77,
+ VK_FORMAT_R16G16_SNORM = 78,
+ VK_FORMAT_R16G16_USCALED = 79,
+ VK_FORMAT_R16G16_SSCALED = 80,
+ VK_FORMAT_R16G16_UINT = 81,
+ VK_FORMAT_R16G16_SINT = 82,
+ VK_FORMAT_R16G16_SFLOAT = 83,
+ VK_FORMAT_R16G16B16_UNORM = 84,
+ VK_FORMAT_R16G16B16_SNORM = 85,
+ VK_FORMAT_R16G16B16_USCALED = 86,
+ VK_FORMAT_R16G16B16_SSCALED = 87,
+ VK_FORMAT_R16G16B16_UINT = 88,
+ VK_FORMAT_R16G16B16_SINT = 89,
+ VK_FORMAT_R16G16B16_SFLOAT = 90,
+ VK_FORMAT_R16G16B16A16_UNORM = 91,
+ VK_FORMAT_R16G16B16A16_SNORM = 92,
+ VK_FORMAT_R16G16B16A16_USCALED = 93,
+ VK_FORMAT_R16G16B16A16_SSCALED = 94,
+ VK_FORMAT_R16G16B16A16_UINT = 95,
+ VK_FORMAT_R16G16B16A16_SINT = 96,
+ VK_FORMAT_R16G16B16A16_SFLOAT = 97,
+ VK_FORMAT_R32_UINT = 98,
+ VK_FORMAT_R32_SINT = 99,
+ VK_FORMAT_R32_SFLOAT = 100,
+ VK_FORMAT_R32G32_UINT = 101,
+ VK_FORMAT_R32G32_SINT = 102,
+ VK_FORMAT_R32G32_SFLOAT = 103,
+ VK_FORMAT_R32G32B32_UINT = 104,
+ VK_FORMAT_R32G32B32_SINT = 105,
+ VK_FORMAT_R32G32B32_SFLOAT = 106,
+ VK_FORMAT_R32G32B32A32_UINT = 107,
+ VK_FORMAT_R32G32B32A32_SINT = 108,
+ VK_FORMAT_R32G32B32A32_SFLOAT = 109,
+ VK_FORMAT_R64_UINT = 110,
+ VK_FORMAT_R64_SINT = 111,
+ VK_FORMAT_R64_SFLOAT = 112,
+ VK_FORMAT_R64G64_UINT = 113,
+ VK_FORMAT_R64G64_SINT = 114,
+ VK_FORMAT_R64G64_SFLOAT = 115,
+ VK_FORMAT_R64G64B64_UINT = 116,
+ VK_FORMAT_R64G64B64_SINT = 117,
+ VK_FORMAT_R64G64B64_SFLOAT = 118,
+ VK_FORMAT_R64G64B64A64_UINT = 119,
+ VK_FORMAT_R64G64B64A64_SINT = 120,
+ VK_FORMAT_R64G64B64A64_SFLOAT = 121,
+ VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122,
+ VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123,
+ VK_FORMAT_D16_UNORM = 124,
+ VK_FORMAT_X8_D24_UNORM_PACK32 = 125,
+ VK_FORMAT_D32_SFLOAT = 126,
+ VK_FORMAT_S8_UINT = 127,
+ VK_FORMAT_D16_UNORM_S8_UINT = 128,
+ VK_FORMAT_D24_UNORM_S8_UINT = 129,
+ VK_FORMAT_D32_SFLOAT_S8_UINT = 130,
+ VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131,
+ VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132,
+ VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133,
+ VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134,
+ VK_FORMAT_BC2_UNORM_BLOCK = 135,
+ VK_FORMAT_BC2_SRGB_BLOCK = 136,
+ VK_FORMAT_BC3_UNORM_BLOCK = 137,
+ VK_FORMAT_BC3_SRGB_BLOCK = 138,
+ VK_FORMAT_BC4_UNORM_BLOCK = 139,
+ VK_FORMAT_BC4_SNORM_BLOCK = 140,
+ VK_FORMAT_BC5_UNORM_BLOCK = 141,
+ VK_FORMAT_BC5_SNORM_BLOCK = 142,
+ VK_FORMAT_BC6H_UFLOAT_BLOCK = 143,
+ VK_FORMAT_BC6H_SFLOAT_BLOCK = 144,
+ VK_FORMAT_BC7_UNORM_BLOCK = 145,
+ VK_FORMAT_BC7_SRGB_BLOCK = 146,
+ VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147,
+ VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148,
+ VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149,
+ VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150,
+ VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151,
+ VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152,
+ VK_FORMAT_EAC_R11_UNORM_BLOCK = 153,
+ VK_FORMAT_EAC_R11_SNORM_BLOCK = 154,
+ VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155,
+ VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156,
+ VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157,
+ VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158,
+ VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159,
+ VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160,
+ VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161,
+ VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162,
+ VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163,
+ VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164,
+ VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165,
+ VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166,
+ VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167,
+ VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168,
+ VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169,
+ VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170,
+ VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171,
+ VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172,
+ VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173,
+ VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174,
+ VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175,
+ VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176,
+ VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177,
+ VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178,
+ VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179,
+ VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180,
+ VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181,
+ VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182,
+ VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183,
+ VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184,
+ VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000,
+ VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001,
+ VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002,
+ VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003,
+ VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004,
+ VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005,
+ VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006,
+ VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007,
+ VK_FORMAT_G8B8G8R8_422_UNORM_KHR = 1000156000,
+ VK_FORMAT_B8G8R8G8_422_UNORM_KHR = 1000156001,
+ VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR = 1000156002,
+ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR = 1000156003,
+ VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM_KHR = 1000156004,
+ VK_FORMAT_G8_B8R8_2PLANE_422_UNORM_KHR = 1000156005,
+ VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM_KHR = 1000156006,
+ VK_FORMAT_R10X6_UNORM_PACK16_KHR = 1000156007,
+ VK_FORMAT_R10X6G10X6_UNORM_2PACK16_KHR = 1000156008,
+ VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR = 1000156009,
+ VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR = 1000156010,
+ VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR = 1000156011,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR = 1000156012,
+ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR = 1000156013,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR = 1000156014,
+ VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR = 1000156015,
+ VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR = 1000156016,
+ VK_FORMAT_R12X4_UNORM_PACK16_KHR = 1000156017,
+ VK_FORMAT_R12X4G12X4_UNORM_2PACK16_KHR = 1000156018,
+ VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR = 1000156019,
+ VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR = 1000156020,
+ VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR = 1000156021,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR = 1000156022,
+ VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR = 1000156023,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR = 1000156024,
+ VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR = 1000156025,
+ VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR = 1000156026,
+ VK_FORMAT_G16B16G16R16_422_UNORM_KHR = 1000156027,
+ VK_FORMAT_B16G16R16G16_422_UNORM_KHR = 1000156028,
+ VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM_KHR = 1000156029,
+ VK_FORMAT_G16_B16R16_2PLANE_420_UNORM_KHR = 1000156030,
+ VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM_KHR = 1000156031,
+ VK_FORMAT_G16_B16R16_2PLANE_422_UNORM_KHR = 1000156032,
+ VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR = 1000156033,
+ VK_FORMAT_BEGIN_RANGE = VK_FORMAT_UNDEFINED,
+ VK_FORMAT_END_RANGE = VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
+ VK_FORMAT_RANGE_SIZE = (VK_FORMAT_ASTC_12x12_SRGB_BLOCK - VK_FORMAT_UNDEFINED + 1),
+ VK_FORMAT_MAX_ENUM = 0x7FFFFFFF
+} VkFormat;
+
+typedef enum VkImageType {
+ VK_IMAGE_TYPE_1D = 0,
+ VK_IMAGE_TYPE_2D = 1,
+ VK_IMAGE_TYPE_3D = 2,
+ VK_IMAGE_TYPE_BEGIN_RANGE = VK_IMAGE_TYPE_1D,
+ VK_IMAGE_TYPE_END_RANGE = VK_IMAGE_TYPE_3D,
+ VK_IMAGE_TYPE_RANGE_SIZE = (VK_IMAGE_TYPE_3D - VK_IMAGE_TYPE_1D + 1),
+ VK_IMAGE_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkImageType;
+
+typedef enum VkImageTiling {
+ VK_IMAGE_TILING_OPTIMAL = 0,
+ VK_IMAGE_TILING_LINEAR = 1,
+ VK_IMAGE_TILING_BEGIN_RANGE = VK_IMAGE_TILING_OPTIMAL,
+ VK_IMAGE_TILING_END_RANGE = VK_IMAGE_TILING_LINEAR,
+ VK_IMAGE_TILING_RANGE_SIZE = (VK_IMAGE_TILING_LINEAR - VK_IMAGE_TILING_OPTIMAL + 1),
+ VK_IMAGE_TILING_MAX_ENUM = 0x7FFFFFFF
+} VkImageTiling;
+
+typedef enum VkPhysicalDeviceType {
+ VK_PHYSICAL_DEVICE_TYPE_OTHER = 0,
+ VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1,
+ VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2,
+ VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3,
+ VK_PHYSICAL_DEVICE_TYPE_CPU = 4,
+ VK_PHYSICAL_DEVICE_TYPE_BEGIN_RANGE = VK_PHYSICAL_DEVICE_TYPE_OTHER,
+ VK_PHYSICAL_DEVICE_TYPE_END_RANGE = VK_PHYSICAL_DEVICE_TYPE_CPU,
+ VK_PHYSICAL_DEVICE_TYPE_RANGE_SIZE = (VK_PHYSICAL_DEVICE_TYPE_CPU - VK_PHYSICAL_DEVICE_TYPE_OTHER + 1),
+ VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkPhysicalDeviceType;
+
+typedef enum VkQueryType {
+ VK_QUERY_TYPE_OCCLUSION = 0,
+ VK_QUERY_TYPE_PIPELINE_STATISTICS = 1,
+ VK_QUERY_TYPE_TIMESTAMP = 2,
+ VK_QUERY_TYPE_BEGIN_RANGE = VK_QUERY_TYPE_OCCLUSION,
+ VK_QUERY_TYPE_END_RANGE = VK_QUERY_TYPE_TIMESTAMP,
+ VK_QUERY_TYPE_RANGE_SIZE = (VK_QUERY_TYPE_TIMESTAMP - VK_QUERY_TYPE_OCCLUSION + 1),
+ VK_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkQueryType;
+
+typedef enum VkSharingMode {
+ VK_SHARING_MODE_EXCLUSIVE = 0,
+ VK_SHARING_MODE_CONCURRENT = 1,
+ VK_SHARING_MODE_BEGIN_RANGE = VK_SHARING_MODE_EXCLUSIVE,
+ VK_SHARING_MODE_END_RANGE = VK_SHARING_MODE_CONCURRENT,
+ VK_SHARING_MODE_RANGE_SIZE = (VK_SHARING_MODE_CONCURRENT - VK_SHARING_MODE_EXCLUSIVE + 1),
+ VK_SHARING_MODE_MAX_ENUM = 0x7FFFFFFF
+} VkSharingMode;
+
+typedef enum VkImageLayout {
+ VK_IMAGE_LAYOUT_UNDEFINED = 0,
+ VK_IMAGE_LAYOUT_GENERAL = 1,
+ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2,
+ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3,
+ VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4,
+ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5,
+ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL = 6,
+ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL = 7,
+ VK_IMAGE_LAYOUT_PREINITIALIZED = 8,
+ VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002,
+ VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR = 1000111000,
+ VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = 1000117000,
+ VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = 1000117001,
+ VK_IMAGE_LAYOUT_BEGIN_RANGE = VK_IMAGE_LAYOUT_UNDEFINED,
+ VK_IMAGE_LAYOUT_END_RANGE = VK_IMAGE_LAYOUT_PREINITIALIZED,
+ VK_IMAGE_LAYOUT_RANGE_SIZE = (VK_IMAGE_LAYOUT_PREINITIALIZED - VK_IMAGE_LAYOUT_UNDEFINED + 1),
+ VK_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF
+} VkImageLayout;
+
+typedef enum VkImageViewType {
+ VK_IMAGE_VIEW_TYPE_1D = 0,
+ VK_IMAGE_VIEW_TYPE_2D = 1,
+ VK_IMAGE_VIEW_TYPE_3D = 2,
+ VK_IMAGE_VIEW_TYPE_CUBE = 3,
+ VK_IMAGE_VIEW_TYPE_1D_ARRAY = 4,
+ VK_IMAGE_VIEW_TYPE_2D_ARRAY = 5,
+ VK_IMAGE_VIEW_TYPE_CUBE_ARRAY = 6,
+ VK_IMAGE_VIEW_TYPE_BEGIN_RANGE = VK_IMAGE_VIEW_TYPE_1D,
+ VK_IMAGE_VIEW_TYPE_END_RANGE = VK_IMAGE_VIEW_TYPE_CUBE_ARRAY,
+ VK_IMAGE_VIEW_TYPE_RANGE_SIZE = (VK_IMAGE_VIEW_TYPE_CUBE_ARRAY - VK_IMAGE_VIEW_TYPE_1D + 1),
+ VK_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkImageViewType;
+
+typedef enum VkComponentSwizzle {
+ VK_COMPONENT_SWIZZLE_IDENTITY = 0,
+ VK_COMPONENT_SWIZZLE_ZERO = 1,
+ VK_COMPONENT_SWIZZLE_ONE = 2,
+ VK_COMPONENT_SWIZZLE_R = 3,
+ VK_COMPONENT_SWIZZLE_G = 4,
+ VK_COMPONENT_SWIZZLE_B = 5,
+ VK_COMPONENT_SWIZZLE_A = 6,
+ VK_COMPONENT_SWIZZLE_BEGIN_RANGE = VK_COMPONENT_SWIZZLE_IDENTITY,
+ VK_COMPONENT_SWIZZLE_END_RANGE = VK_COMPONENT_SWIZZLE_A,
+ VK_COMPONENT_SWIZZLE_RANGE_SIZE = (VK_COMPONENT_SWIZZLE_A - VK_COMPONENT_SWIZZLE_IDENTITY + 1),
+ VK_COMPONENT_SWIZZLE_MAX_ENUM = 0x7FFFFFFF
+} VkComponentSwizzle;
+
+typedef enum VkVertexInputRate {
+ VK_VERTEX_INPUT_RATE_VERTEX = 0,
+ VK_VERTEX_INPUT_RATE_INSTANCE = 1,
+ VK_VERTEX_INPUT_RATE_BEGIN_RANGE = VK_VERTEX_INPUT_RATE_VERTEX,
+ VK_VERTEX_INPUT_RATE_END_RANGE = VK_VERTEX_INPUT_RATE_INSTANCE,
+ VK_VERTEX_INPUT_RATE_RANGE_SIZE = (VK_VERTEX_INPUT_RATE_INSTANCE - VK_VERTEX_INPUT_RATE_VERTEX + 1),
+ VK_VERTEX_INPUT_RATE_MAX_ENUM = 0x7FFFFFFF
+} VkVertexInputRate;
+
+typedef enum VkPrimitiveTopology {
+ VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0,
+ VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1,
+ VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2,
+ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3,
+ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP = 4,
+ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN = 5,
+ VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY = 6,
+ VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY = 7,
+ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY = 8,
+ VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9,
+ VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10,
+ VK_PRIMITIVE_TOPOLOGY_BEGIN_RANGE = VK_PRIMITIVE_TOPOLOGY_POINT_LIST,
+ VK_PRIMITIVE_TOPOLOGY_END_RANGE = VK_PRIMITIVE_TOPOLOGY_PATCH_LIST,
+ VK_PRIMITIVE_TOPOLOGY_RANGE_SIZE = (VK_PRIMITIVE_TOPOLOGY_PATCH_LIST - VK_PRIMITIVE_TOPOLOGY_POINT_LIST + 1),
+ VK_PRIMITIVE_TOPOLOGY_MAX_ENUM = 0x7FFFFFFF
+} VkPrimitiveTopology;
+
+typedef enum VkPolygonMode {
+ VK_POLYGON_MODE_FILL = 0,
+ VK_POLYGON_MODE_LINE = 1,
+ VK_POLYGON_MODE_POINT = 2,
+ VK_POLYGON_MODE_FILL_RECTANGLE_NV = 1000153000,
+ VK_POLYGON_MODE_BEGIN_RANGE = VK_POLYGON_MODE_FILL,
+ VK_POLYGON_MODE_END_RANGE = VK_POLYGON_MODE_POINT,
+ VK_POLYGON_MODE_RANGE_SIZE = (VK_POLYGON_MODE_POINT - VK_POLYGON_MODE_FILL + 1),
+ VK_POLYGON_MODE_MAX_ENUM = 0x7FFFFFFF
+} VkPolygonMode;
+
+typedef enum VkFrontFace {
+ VK_FRONT_FACE_COUNTER_CLOCKWISE = 0,
+ VK_FRONT_FACE_CLOCKWISE = 1,
+ VK_FRONT_FACE_BEGIN_RANGE = VK_FRONT_FACE_COUNTER_CLOCKWISE,
+ VK_FRONT_FACE_END_RANGE = VK_FRONT_FACE_CLOCKWISE,
+ VK_FRONT_FACE_RANGE_SIZE = (VK_FRONT_FACE_CLOCKWISE - VK_FRONT_FACE_COUNTER_CLOCKWISE + 1),
+ VK_FRONT_FACE_MAX_ENUM = 0x7FFFFFFF
+} VkFrontFace;
+
+typedef enum VkCompareOp {
+ VK_COMPARE_OP_NEVER = 0,
+ VK_COMPARE_OP_LESS = 1,
+ VK_COMPARE_OP_EQUAL = 2,
+ VK_COMPARE_OP_LESS_OR_EQUAL = 3,
+ VK_COMPARE_OP_GREATER = 4,
+ VK_COMPARE_OP_NOT_EQUAL = 5,
+ VK_COMPARE_OP_GREATER_OR_EQUAL = 6,
+ VK_COMPARE_OP_ALWAYS = 7,
+ VK_COMPARE_OP_BEGIN_RANGE = VK_COMPARE_OP_NEVER,
+ VK_COMPARE_OP_END_RANGE = VK_COMPARE_OP_ALWAYS,
+ VK_COMPARE_OP_RANGE_SIZE = (VK_COMPARE_OP_ALWAYS - VK_COMPARE_OP_NEVER + 1),
+ VK_COMPARE_OP_MAX_ENUM = 0x7FFFFFFF
+} VkCompareOp;
+
+typedef enum VkStencilOp {
+ VK_STENCIL_OP_KEEP = 0,
+ VK_STENCIL_OP_ZERO = 1,
+ VK_STENCIL_OP_REPLACE = 2,
+ VK_STENCIL_OP_INCREMENT_AND_CLAMP = 3,
+ VK_STENCIL_OP_DECREMENT_AND_CLAMP = 4,
+ VK_STENCIL_OP_INVERT = 5,
+ VK_STENCIL_OP_INCREMENT_AND_WRAP = 6,
+ VK_STENCIL_OP_DECREMENT_AND_WRAP = 7,
+ VK_STENCIL_OP_BEGIN_RANGE = VK_STENCIL_OP_KEEP,
+ VK_STENCIL_OP_END_RANGE = VK_STENCIL_OP_DECREMENT_AND_WRAP,
+ VK_STENCIL_OP_RANGE_SIZE = (VK_STENCIL_OP_DECREMENT_AND_WRAP - VK_STENCIL_OP_KEEP + 1),
+ VK_STENCIL_OP_MAX_ENUM = 0x7FFFFFFF
+} VkStencilOp;
+
+typedef enum VkLogicOp {
+ VK_LOGIC_OP_CLEAR = 0,
+ VK_LOGIC_OP_AND = 1,
+ VK_LOGIC_OP_AND_REVERSE = 2,
+ VK_LOGIC_OP_COPY = 3,
+ VK_LOGIC_OP_AND_INVERTED = 4,
+ VK_LOGIC_OP_NO_OP = 5,
+ VK_LOGIC_OP_XOR = 6,
+ VK_LOGIC_OP_OR = 7,
+ VK_LOGIC_OP_NOR = 8,
+ VK_LOGIC_OP_EQUIVALENT = 9,
+ VK_LOGIC_OP_INVERT = 10,
+ VK_LOGIC_OP_OR_REVERSE = 11,
+ VK_LOGIC_OP_COPY_INVERTED = 12,
+ VK_LOGIC_OP_OR_INVERTED = 13,
+ VK_LOGIC_OP_NAND = 14,
+ VK_LOGIC_OP_SET = 15,
+ VK_LOGIC_OP_BEGIN_RANGE = VK_LOGIC_OP_CLEAR,
+ VK_LOGIC_OP_END_RANGE = VK_LOGIC_OP_SET,
+ VK_LOGIC_OP_RANGE_SIZE = (VK_LOGIC_OP_SET - VK_LOGIC_OP_CLEAR + 1),
+ VK_LOGIC_OP_MAX_ENUM = 0x7FFFFFFF
+} VkLogicOp;
+
+typedef enum VkBlendFactor {
+ VK_BLEND_FACTOR_ZERO = 0,
+ VK_BLEND_FACTOR_ONE = 1,
+ VK_BLEND_FACTOR_SRC_COLOR = 2,
+ VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 3,
+ VK_BLEND_FACTOR_DST_COLOR = 4,
+ VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR = 5,
+ VK_BLEND_FACTOR_SRC_ALPHA = 6,
+ VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 7,
+ VK_BLEND_FACTOR_DST_ALPHA = 8,
+ VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 9,
+ VK_BLEND_FACTOR_CONSTANT_COLOR = 10,
+ VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR = 11,
+ VK_BLEND_FACTOR_CONSTANT_ALPHA = 12,
+ VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA = 13,
+ VK_BLEND_FACTOR_SRC_ALPHA_SATURATE = 14,
+ VK_BLEND_FACTOR_SRC1_COLOR = 15,
+ VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR = 16,
+ VK_BLEND_FACTOR_SRC1_ALPHA = 17,
+ VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA = 18,
+ VK_BLEND_FACTOR_BEGIN_RANGE = VK_BLEND_FACTOR_ZERO,
+ VK_BLEND_FACTOR_END_RANGE = VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA,
+ VK_BLEND_FACTOR_RANGE_SIZE = (VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA - VK_BLEND_FACTOR_ZERO + 1),
+ VK_BLEND_FACTOR_MAX_ENUM = 0x7FFFFFFF
+} VkBlendFactor;
+
+typedef enum VkBlendOp {
+ VK_BLEND_OP_ADD = 0,
+ VK_BLEND_OP_SUBTRACT = 1,
+ VK_BLEND_OP_REVERSE_SUBTRACT = 2,
+ VK_BLEND_OP_MIN = 3,
+ VK_BLEND_OP_MAX = 4,
+ VK_BLEND_OP_ZERO_EXT = 1000148000,
+ VK_BLEND_OP_SRC_EXT = 1000148001,
+ VK_BLEND_OP_DST_EXT = 1000148002,
+ VK_BLEND_OP_SRC_OVER_EXT = 1000148003,
+ VK_BLEND_OP_DST_OVER_EXT = 1000148004,
+ VK_BLEND_OP_SRC_IN_EXT = 1000148005,
+ VK_BLEND_OP_DST_IN_EXT = 1000148006,
+ VK_BLEND_OP_SRC_OUT_EXT = 1000148007,
+ VK_BLEND_OP_DST_OUT_EXT = 1000148008,
+ VK_BLEND_OP_SRC_ATOP_EXT = 1000148009,
+ VK_BLEND_OP_DST_ATOP_EXT = 1000148010,
+ VK_BLEND_OP_XOR_EXT = 1000148011,
+ VK_BLEND_OP_MULTIPLY_EXT = 1000148012,
+ VK_BLEND_OP_SCREEN_EXT = 1000148013,
+ VK_BLEND_OP_OVERLAY_EXT = 1000148014,
+ VK_BLEND_OP_DARKEN_EXT = 1000148015,
+ VK_BLEND_OP_LIGHTEN_EXT = 1000148016,
+ VK_BLEND_OP_COLORDODGE_EXT = 1000148017,
+ VK_BLEND_OP_COLORBURN_EXT = 1000148018,
+ VK_BLEND_OP_HARDLIGHT_EXT = 1000148019,
+ VK_BLEND_OP_SOFTLIGHT_EXT = 1000148020,
+ VK_BLEND_OP_DIFFERENCE_EXT = 1000148021,
+ VK_BLEND_OP_EXCLUSION_EXT = 1000148022,
+ VK_BLEND_OP_INVERT_EXT = 1000148023,
+ VK_BLEND_OP_INVERT_RGB_EXT = 1000148024,
+ VK_BLEND_OP_LINEARDODGE_EXT = 1000148025,
+ VK_BLEND_OP_LINEARBURN_EXT = 1000148026,
+ VK_BLEND_OP_VIVIDLIGHT_EXT = 1000148027,
+ VK_BLEND_OP_LINEARLIGHT_EXT = 1000148028,
+ VK_BLEND_OP_PINLIGHT_EXT = 1000148029,
+ VK_BLEND_OP_HARDMIX_EXT = 1000148030,
+ VK_BLEND_OP_HSL_HUE_EXT = 1000148031,
+ VK_BLEND_OP_HSL_SATURATION_EXT = 1000148032,
+ VK_BLEND_OP_HSL_COLOR_EXT = 1000148033,
+ VK_BLEND_OP_HSL_LUMINOSITY_EXT = 1000148034,
+ VK_BLEND_OP_PLUS_EXT = 1000148035,
+ VK_BLEND_OP_PLUS_CLAMPED_EXT = 1000148036,
+ VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT = 1000148037,
+ VK_BLEND_OP_PLUS_DARKER_EXT = 1000148038,
+ VK_BLEND_OP_MINUS_EXT = 1000148039,
+ VK_BLEND_OP_MINUS_CLAMPED_EXT = 1000148040,
+ VK_BLEND_OP_CONTRAST_EXT = 1000148041,
+ VK_BLEND_OP_INVERT_OVG_EXT = 1000148042,
+ VK_BLEND_OP_RED_EXT = 1000148043,
+ VK_BLEND_OP_GREEN_EXT = 1000148044,
+ VK_BLEND_OP_BLUE_EXT = 1000148045,
+ VK_BLEND_OP_BEGIN_RANGE = VK_BLEND_OP_ADD,
+ VK_BLEND_OP_END_RANGE = VK_BLEND_OP_MAX,
+ VK_BLEND_OP_RANGE_SIZE = (VK_BLEND_OP_MAX - VK_BLEND_OP_ADD + 1),
+ VK_BLEND_OP_MAX_ENUM = 0x7FFFFFFF
+} VkBlendOp;
+
+typedef enum VkDynamicState {
+ VK_DYNAMIC_STATE_VIEWPORT = 0,
+ VK_DYNAMIC_STATE_SCISSOR = 1,
+ VK_DYNAMIC_STATE_LINE_WIDTH = 2,
+ VK_DYNAMIC_STATE_DEPTH_BIAS = 3,
+ VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4,
+ VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5,
+ VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6,
+ VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7,
+ VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8,
+ VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV = 1000087000,
+ VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT = 1000099000,
+ VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT = 1000143000,
+ VK_DYNAMIC_STATE_BEGIN_RANGE = VK_DYNAMIC_STATE_VIEWPORT,
+ VK_DYNAMIC_STATE_END_RANGE = VK_DYNAMIC_STATE_STENCIL_REFERENCE,
+ VK_DYNAMIC_STATE_RANGE_SIZE = (VK_DYNAMIC_STATE_STENCIL_REFERENCE - VK_DYNAMIC_STATE_VIEWPORT + 1),
+ VK_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF
+} VkDynamicState;
+
+typedef enum VkFilter {
+ VK_FILTER_NEAREST = 0,
+ VK_FILTER_LINEAR = 1,
+ VK_FILTER_CUBIC_IMG = 1000015000,
+ VK_FILTER_BEGIN_RANGE = VK_FILTER_NEAREST,
+ VK_FILTER_END_RANGE = VK_FILTER_LINEAR,
+ VK_FILTER_RANGE_SIZE = (VK_FILTER_LINEAR - VK_FILTER_NEAREST + 1),
+ VK_FILTER_MAX_ENUM = 0x7FFFFFFF
+} VkFilter;
+
+typedef enum VkSamplerMipmapMode {
+ VK_SAMPLER_MIPMAP_MODE_NEAREST = 0,
+ VK_SAMPLER_MIPMAP_MODE_LINEAR = 1,
+ VK_SAMPLER_MIPMAP_MODE_BEGIN_RANGE = VK_SAMPLER_MIPMAP_MODE_NEAREST,
+ VK_SAMPLER_MIPMAP_MODE_END_RANGE = VK_SAMPLER_MIPMAP_MODE_LINEAR,
+ VK_SAMPLER_MIPMAP_MODE_RANGE_SIZE = (VK_SAMPLER_MIPMAP_MODE_LINEAR - VK_SAMPLER_MIPMAP_MODE_NEAREST + 1),
+ VK_SAMPLER_MIPMAP_MODE_MAX_ENUM = 0x7FFFFFFF
+} VkSamplerMipmapMode;
+
+typedef enum VkSamplerAddressMode {
+ VK_SAMPLER_ADDRESS_MODE_REPEAT = 0,
+ VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1,
+ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2,
+ VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER = 3,
+ VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE = 4,
+ VK_SAMPLER_ADDRESS_MODE_BEGIN_RANGE = VK_SAMPLER_ADDRESS_MODE_REPEAT,
+ VK_SAMPLER_ADDRESS_MODE_END_RANGE = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER,
+ VK_SAMPLER_ADDRESS_MODE_RANGE_SIZE = (VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER - VK_SAMPLER_ADDRESS_MODE_REPEAT + 1),
+ VK_SAMPLER_ADDRESS_MODE_MAX_ENUM = 0x7FFFFFFF
+} VkSamplerAddressMode;
+
+typedef enum VkBorderColor {
+ VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0,
+ VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1,
+ VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2,
+ VK_BORDER_COLOR_INT_OPAQUE_BLACK = 3,
+ VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE = 4,
+ VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5,
+ VK_BORDER_COLOR_BEGIN_RANGE = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
+ VK_BORDER_COLOR_END_RANGE = VK_BORDER_COLOR_INT_OPAQUE_WHITE,
+ VK_BORDER_COLOR_RANGE_SIZE = (VK_BORDER_COLOR_INT_OPAQUE_WHITE - VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK + 1),
+ VK_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF
+} VkBorderColor;
+
+typedef enum VkDescriptorType {
+ VK_DESCRIPTOR_TYPE_SAMPLER = 0,
+ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1,
+ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2,
+ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE = 3,
+ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER = 4,
+ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER = 5,
+ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 6,
+ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7,
+ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8,
+ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9,
+ VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10,
+ VK_DESCRIPTOR_TYPE_BEGIN_RANGE = VK_DESCRIPTOR_TYPE_SAMPLER,
+ VK_DESCRIPTOR_TYPE_END_RANGE = VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
+ VK_DESCRIPTOR_TYPE_RANGE_SIZE = (VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT - VK_DESCRIPTOR_TYPE_SAMPLER + 1),
+ VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkDescriptorType;
+
+typedef enum VkAttachmentLoadOp {
+ VK_ATTACHMENT_LOAD_OP_LOAD = 0,
+ VK_ATTACHMENT_LOAD_OP_CLEAR = 1,
+ VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2,
+ VK_ATTACHMENT_LOAD_OP_BEGIN_RANGE = VK_ATTACHMENT_LOAD_OP_LOAD,
+ VK_ATTACHMENT_LOAD_OP_END_RANGE = VK_ATTACHMENT_LOAD_OP_DONT_CARE,
+ VK_ATTACHMENT_LOAD_OP_RANGE_SIZE = (VK_ATTACHMENT_LOAD_OP_DONT_CARE - VK_ATTACHMENT_LOAD_OP_LOAD + 1),
+ VK_ATTACHMENT_LOAD_OP_MAX_ENUM = 0x7FFFFFFF
+} VkAttachmentLoadOp;
+
+typedef enum VkAttachmentStoreOp {
+ VK_ATTACHMENT_STORE_OP_STORE = 0,
+ VK_ATTACHMENT_STORE_OP_DONT_CARE = 1,
+ VK_ATTACHMENT_STORE_OP_BEGIN_RANGE = VK_ATTACHMENT_STORE_OP_STORE,
+ VK_ATTACHMENT_STORE_OP_END_RANGE = VK_ATTACHMENT_STORE_OP_DONT_CARE,
+ VK_ATTACHMENT_STORE_OP_RANGE_SIZE = (VK_ATTACHMENT_STORE_OP_DONT_CARE - VK_ATTACHMENT_STORE_OP_STORE + 1),
+ VK_ATTACHMENT_STORE_OP_MAX_ENUM = 0x7FFFFFFF
+} VkAttachmentStoreOp;
+
+typedef enum VkPipelineBindPoint {
+ VK_PIPELINE_BIND_POINT_GRAPHICS = 0,
+ VK_PIPELINE_BIND_POINT_COMPUTE = 1,
+ VK_PIPELINE_BIND_POINT_BEGIN_RANGE = VK_PIPELINE_BIND_POINT_GRAPHICS,
+ VK_PIPELINE_BIND_POINT_END_RANGE = VK_PIPELINE_BIND_POINT_COMPUTE,
+ VK_PIPELINE_BIND_POINT_RANGE_SIZE = (VK_PIPELINE_BIND_POINT_COMPUTE - VK_PIPELINE_BIND_POINT_GRAPHICS + 1),
+ VK_PIPELINE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF
+} VkPipelineBindPoint;
+
+typedef enum VkCommandBufferLevel {
+ VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0,
+ VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1,
+ VK_COMMAND_BUFFER_LEVEL_BEGIN_RANGE = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
+ VK_COMMAND_BUFFER_LEVEL_END_RANGE = VK_COMMAND_BUFFER_LEVEL_SECONDARY,
+ VK_COMMAND_BUFFER_LEVEL_RANGE_SIZE = (VK_COMMAND_BUFFER_LEVEL_SECONDARY - VK_COMMAND_BUFFER_LEVEL_PRIMARY + 1),
+ VK_COMMAND_BUFFER_LEVEL_MAX_ENUM = 0x7FFFFFFF
+} VkCommandBufferLevel;
+
+typedef enum VkIndexType {
+ VK_INDEX_TYPE_UINT16 = 0,
+ VK_INDEX_TYPE_UINT32 = 1,
+ VK_INDEX_TYPE_BEGIN_RANGE = VK_INDEX_TYPE_UINT16,
+ VK_INDEX_TYPE_END_RANGE = VK_INDEX_TYPE_UINT32,
+ VK_INDEX_TYPE_RANGE_SIZE = (VK_INDEX_TYPE_UINT32 - VK_INDEX_TYPE_UINT16 + 1),
+ VK_INDEX_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkIndexType;
+
+typedef enum VkSubpassContents {
+ VK_SUBPASS_CONTENTS_INLINE = 0,
+ VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1,
+ VK_SUBPASS_CONTENTS_BEGIN_RANGE = VK_SUBPASS_CONTENTS_INLINE,
+ VK_SUBPASS_CONTENTS_END_RANGE = VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS,
+ VK_SUBPASS_CONTENTS_RANGE_SIZE = (VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS - VK_SUBPASS_CONTENTS_INLINE + 1),
+ VK_SUBPASS_CONTENTS_MAX_ENUM = 0x7FFFFFFF
+} VkSubpassContents;
+
+typedef enum VkObjectType {
+ VK_OBJECT_TYPE_UNKNOWN = 0,
+ VK_OBJECT_TYPE_INSTANCE = 1,
+ VK_OBJECT_TYPE_PHYSICAL_DEVICE = 2,
+ VK_OBJECT_TYPE_DEVICE = 3,
+ VK_OBJECT_TYPE_QUEUE = 4,
+ VK_OBJECT_TYPE_SEMAPHORE = 5,
+ VK_OBJECT_TYPE_COMMAND_BUFFER = 6,
+ VK_OBJECT_TYPE_FENCE = 7,
+ VK_OBJECT_TYPE_DEVICE_MEMORY = 8,
+ VK_OBJECT_TYPE_BUFFER = 9,
+ VK_OBJECT_TYPE_IMAGE = 10,
+ VK_OBJECT_TYPE_EVENT = 11,
+ VK_OBJECT_TYPE_QUERY_POOL = 12,
+ VK_OBJECT_TYPE_BUFFER_VIEW = 13,
+ VK_OBJECT_TYPE_IMAGE_VIEW = 14,
+ VK_OBJECT_TYPE_SHADER_MODULE = 15,
+ VK_OBJECT_TYPE_PIPELINE_CACHE = 16,
+ VK_OBJECT_TYPE_PIPELINE_LAYOUT = 17,
+ VK_OBJECT_TYPE_RENDER_PASS = 18,
+ VK_OBJECT_TYPE_PIPELINE = 19,
+ VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 20,
+ VK_OBJECT_TYPE_SAMPLER = 21,
+ VK_OBJECT_TYPE_DESCRIPTOR_POOL = 22,
+ VK_OBJECT_TYPE_DESCRIPTOR_SET = 23,
+ VK_OBJECT_TYPE_FRAMEBUFFER = 24,
+ VK_OBJECT_TYPE_COMMAND_POOL = 25,
+ VK_OBJECT_TYPE_SURFACE_KHR = 1000000000,
+ VK_OBJECT_TYPE_SWAPCHAIN_KHR = 1000001000,
+ VK_OBJECT_TYPE_DISPLAY_KHR = 1000002000,
+ VK_OBJECT_TYPE_DISPLAY_MODE_KHR = 1000002001,
+ VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000,
+ VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR = 1000085000,
+ VK_OBJECT_TYPE_OBJECT_TABLE_NVX = 1000086000,
+ VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX = 1000086001,
+ VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_KHR = 1000156000,
+ VK_OBJECT_TYPE_VALIDATION_CACHE_EXT = 1000160000,
+ VK_OBJECT_TYPE_BEGIN_RANGE = VK_OBJECT_TYPE_UNKNOWN,
+ VK_OBJECT_TYPE_END_RANGE = VK_OBJECT_TYPE_COMMAND_POOL,
+ VK_OBJECT_TYPE_RANGE_SIZE = (VK_OBJECT_TYPE_COMMAND_POOL - VK_OBJECT_TYPE_UNKNOWN + 1),
+ VK_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF
+} VkObjectType;
+
+typedef VkFlags VkInstanceCreateFlags;
+
+typedef enum VkFormatFeatureFlagBits {
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x00000001,
+ VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x00000002,
+ VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 0x00000004,
+ VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000008,
+ VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT = 0x00000010,
+ VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 0x00000020,
+ VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT = 0x00000040,
+ VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 0x00000080,
+ VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 0x00000100,
+ VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000200,
+ VK_FORMAT_FEATURE_BLIT_SRC_BIT = 0x00000400,
+ VK_FORMAT_FEATURE_BLIT_DST_BIT = 0x00000800,
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 0x00001000,
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = 0x00002000,
+ VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR = 0x00004000,
+ VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR = 0x00008000,
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT = 0x00010000,
+ VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR = 0x00020000,
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR = 0x00040000,
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT_KHR = 0x00080000,
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT_KHR = 0x00100000,
+ VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR = 0x00200000,
+ VK_FORMAT_FEATURE_DISJOINT_BIT_KHR = 0x00400000,
+ VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR = 0x00800000,
+ VK_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkFormatFeatureFlagBits;
+typedef VkFlags VkFormatFeatureFlags;
+
+typedef enum VkImageUsageFlagBits {
+ VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 0x00000001,
+ VK_IMAGE_USAGE_TRANSFER_DST_BIT = 0x00000002,
+ VK_IMAGE_USAGE_SAMPLED_BIT = 0x00000004,
+ VK_IMAGE_USAGE_STORAGE_BIT = 0x00000008,
+ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000010,
+ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020,
+ VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040,
+ VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080,
+ VK_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkImageUsageFlagBits;
+typedef VkFlags VkImageUsageFlags;
+
+typedef enum VkImageCreateFlagBits {
+ VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001,
+ VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002,
+ VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004,
+ VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000008,
+ VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000010,
+ VK_IMAGE_CREATE_BIND_SFR_BIT_KHX = 0x00000040,
+ VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR = 0x00000020,
+ VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR = 0x00000080,
+ VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR = 0x00000100,
+ VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT = 0x00001000,
+ VK_IMAGE_CREATE_DISJOINT_BIT_KHR = 0x00000200,
+ VK_IMAGE_CREATE_ALIAS_BIT_KHR = 0x00000400,
+ VK_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkImageCreateFlagBits;
+typedef VkFlags VkImageCreateFlags;
+
+typedef enum VkSampleCountFlagBits {
+ VK_SAMPLE_COUNT_1_BIT = 0x00000001,
+ VK_SAMPLE_COUNT_2_BIT = 0x00000002,
+ VK_SAMPLE_COUNT_4_BIT = 0x00000004,
+ VK_SAMPLE_COUNT_8_BIT = 0x00000008,
+ VK_SAMPLE_COUNT_16_BIT = 0x00000010,
+ VK_SAMPLE_COUNT_32_BIT = 0x00000020,
+ VK_SAMPLE_COUNT_64_BIT = 0x00000040,
+ VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkSampleCountFlagBits;
+typedef VkFlags VkSampleCountFlags;
+
+typedef enum VkQueueFlagBits {
+ VK_QUEUE_GRAPHICS_BIT = 0x00000001,
+ VK_QUEUE_COMPUTE_BIT = 0x00000002,
+ VK_QUEUE_TRANSFER_BIT = 0x00000004,
+ VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008,
+ VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkQueueFlagBits;
+typedef VkFlags VkQueueFlags;
+
+typedef enum VkMemoryPropertyFlagBits {
+ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001,
+ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002,
+ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004,
+ VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 0x00000008,
+ VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010,
+ VK_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkMemoryPropertyFlagBits;
+typedef VkFlags VkMemoryPropertyFlags;
+
+typedef enum VkMemoryHeapFlagBits {
+ VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001,
+ VK_MEMORY_HEAP_MULTI_INSTANCE_BIT_KHX = 0x00000002,
+ VK_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkMemoryHeapFlagBits;
+typedef VkFlags VkMemoryHeapFlags;
+typedef VkFlags VkDeviceCreateFlags;
+typedef VkFlags VkDeviceQueueCreateFlags;
+
+typedef enum VkPipelineStageFlagBits {
+ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001,
+ VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002,
+ VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004,
+ VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 0x00000008,
+ VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT = 0x00000010,
+ VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT = 0x00000020,
+ VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 0x00000040,
+ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 0x00000080,
+ VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 0x00000100,
+ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 0x00000200,
+ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400,
+ VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 0x00000800,
+ VK_PIPELINE_STAGE_TRANSFER_BIT = 0x00001000,
+ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT = 0x00002000,
+ VK_PIPELINE_STAGE_HOST_BIT = 0x00004000,
+ VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 0x00008000,
+ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 0x00010000,
+ VK_PIPELINE_STAGE_COMMAND_PROCESS_BIT_NVX = 0x00020000,
+ VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkPipelineStageFlagBits;
+typedef VkFlags VkPipelineStageFlags;
+typedef VkFlags VkMemoryMapFlags;
+
+typedef enum VkImageAspectFlagBits {
+ VK_IMAGE_ASPECT_COLOR_BIT = 0x00000001,
+ VK_IMAGE_ASPECT_DEPTH_BIT = 0x00000002,
+ VK_IMAGE_ASPECT_STENCIL_BIT = 0x00000004,
+ VK_IMAGE_ASPECT_METADATA_BIT = 0x00000008,
+ VK_IMAGE_ASPECT_PLANE_0_BIT_KHR = 0x00000010,
+ VK_IMAGE_ASPECT_PLANE_1_BIT_KHR = 0x00000020,
+ VK_IMAGE_ASPECT_PLANE_2_BIT_KHR = 0x00000040,
+ VK_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkImageAspectFlagBits;
+typedef VkFlags VkImageAspectFlags;
+
+typedef enum VkSparseImageFormatFlagBits {
+ VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 0x00000001,
+ VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 0x00000002,
+ VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 0x00000004,
+ VK_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkSparseImageFormatFlagBits;
+typedef VkFlags VkSparseImageFormatFlags;
+
+typedef enum VkSparseMemoryBindFlagBits {
+ VK_SPARSE_MEMORY_BIND_METADATA_BIT = 0x00000001,
+ VK_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkSparseMemoryBindFlagBits;
+typedef VkFlags VkSparseMemoryBindFlags;
+
+typedef enum VkFenceCreateFlagBits {
+ VK_FENCE_CREATE_SIGNALED_BIT = 0x00000001,
+ VK_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkFenceCreateFlagBits;
+typedef VkFlags VkFenceCreateFlags;
+typedef VkFlags VkSemaphoreCreateFlags;
+typedef VkFlags VkEventCreateFlags;
+typedef VkFlags VkQueryPoolCreateFlags;
+
+typedef enum VkQueryPipelineStatisticFlagBits {
+ VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 0x00000001,
+ VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 0x00000002,
+ VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 0x00000004,
+ VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT = 0x00000008,
+ VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT = 0x00000010,
+ VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT = 0x00000020,
+ VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT = 0x00000040,
+ VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT = 0x00000080,
+ VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 0x00000100,
+ VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200,
+ VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400,
+ VK_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkQueryPipelineStatisticFlagBits;
+typedef VkFlags VkQueryPipelineStatisticFlags;
+
+typedef enum VkQueryResultFlagBits {
+ VK_QUERY_RESULT_64_BIT = 0x00000001,
+ VK_QUERY_RESULT_WAIT_BIT = 0x00000002,
+ VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004,
+ VK_QUERY_RESULT_PARTIAL_BIT = 0x00000008,
+ VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkQueryResultFlagBits;
+typedef VkFlags VkQueryResultFlags;
+
+typedef enum VkBufferCreateFlagBits {
+ VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001,
+ VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002,
+ VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004,
+ VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkBufferCreateFlagBits;
+typedef VkFlags VkBufferCreateFlags;
+
+typedef enum VkBufferUsageFlagBits {
+ VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x00000001,
+ VK_BUFFER_USAGE_TRANSFER_DST_BIT = 0x00000002,
+ VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000004,
+ VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 0x00000008,
+ VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 0x00000010,
+ VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 0x00000020,
+ VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 0x00000040,
+ VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x00000080,
+ VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x00000100,
+ VK_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkBufferUsageFlagBits;
+typedef VkFlags VkBufferUsageFlags;
+typedef VkFlags VkBufferViewCreateFlags;
+typedef VkFlags VkImageViewCreateFlags;
+typedef VkFlags VkShaderModuleCreateFlags;
+typedef VkFlags VkPipelineCacheCreateFlags;
+
+typedef enum VkPipelineCreateFlagBits {
+ VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001,
+ VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002,
+ VK_PIPELINE_CREATE_DERIVATIVE_BIT = 0x00000004,
+ VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHX = 0x00000008,
+ VK_PIPELINE_CREATE_DISPATCH_BASE_KHX = 0x00000010,
+ VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkPipelineCreateFlagBits;
+typedef VkFlags VkPipelineCreateFlags;
+typedef VkFlags VkPipelineShaderStageCreateFlags;
+
+typedef enum VkShaderStageFlagBits {
+ VK_SHADER_STAGE_VERTEX_BIT = 0x00000001,
+ VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002,
+ VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004,
+ VK_SHADER_STAGE_GEOMETRY_BIT = 0x00000008,
+ VK_SHADER_STAGE_FRAGMENT_BIT = 0x00000010,
+ VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020,
+ VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F,
+ VK_SHADER_STAGE_ALL = 0x7FFFFFFF,
+ VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkShaderStageFlagBits;
+typedef VkFlags VkPipelineVertexInputStateCreateFlags;
+typedef VkFlags VkPipelineInputAssemblyStateCreateFlags;
+typedef VkFlags VkPipelineTessellationStateCreateFlags;
+typedef VkFlags VkPipelineViewportStateCreateFlags;
+typedef VkFlags VkPipelineRasterizationStateCreateFlags;
+
+typedef enum VkCullModeFlagBits {
+ VK_CULL_MODE_NONE = 0,
+ VK_CULL_MODE_FRONT_BIT = 0x00000001,
+ VK_CULL_MODE_BACK_BIT = 0x00000002,
+ VK_CULL_MODE_FRONT_AND_BACK = 0x00000003,
+ VK_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkCullModeFlagBits;
+typedef VkFlags VkCullModeFlags;
+typedef VkFlags VkPipelineMultisampleStateCreateFlags;
+typedef VkFlags VkPipelineDepthStencilStateCreateFlags;
+typedef VkFlags VkPipelineColorBlendStateCreateFlags;
+
+typedef enum VkColorComponentFlagBits {
+ VK_COLOR_COMPONENT_R_BIT = 0x00000001,
+ VK_COLOR_COMPONENT_G_BIT = 0x00000002,
+ VK_COLOR_COMPONENT_B_BIT = 0x00000004,
+ VK_COLOR_COMPONENT_A_BIT = 0x00000008,
+ VK_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkColorComponentFlagBits;
+typedef VkFlags VkColorComponentFlags;
+typedef VkFlags VkPipelineDynamicStateCreateFlags;
+typedef VkFlags VkPipelineLayoutCreateFlags;
+typedef VkFlags VkShaderStageFlags;
+typedef VkFlags VkSamplerCreateFlags;
+
+typedef enum VkDescriptorSetLayoutCreateFlagBits {
+ VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR = 0x00000001,
+ VK_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkDescriptorSetLayoutCreateFlagBits;
+typedef VkFlags VkDescriptorSetLayoutCreateFlags;
+
+typedef enum VkDescriptorPoolCreateFlagBits {
+ VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001,
+ VK_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkDescriptorPoolCreateFlagBits;
+typedef VkFlags VkDescriptorPoolCreateFlags;
+typedef VkFlags VkDescriptorPoolResetFlags;
+typedef VkFlags VkFramebufferCreateFlags;
+typedef VkFlags VkRenderPassCreateFlags;
+
+typedef enum VkAttachmentDescriptionFlagBits {
+ VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001,
+ VK_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkAttachmentDescriptionFlagBits;
+typedef VkFlags VkAttachmentDescriptionFlags;
+
+typedef enum VkSubpassDescriptionFlagBits {
+ VK_SUBPASS_DESCRIPTION_PER_VIEW_ATTRIBUTES_BIT_NVX = 0x00000001,
+ VK_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX = 0x00000002,
+ VK_SUBPASS_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkSubpassDescriptionFlagBits;
+typedef VkFlags VkSubpassDescriptionFlags;
+
+typedef enum VkAccessFlagBits {
+ VK_ACCESS_INDIRECT_COMMAND_READ_BIT = 0x00000001,
+ VK_ACCESS_INDEX_READ_BIT = 0x00000002,
+ VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 0x00000004,
+ VK_ACCESS_UNIFORM_READ_BIT = 0x00000008,
+ VK_ACCESS_INPUT_ATTACHMENT_READ_BIT = 0x00000010,
+ VK_ACCESS_SHADER_READ_BIT = 0x00000020,
+ VK_ACCESS_SHADER_WRITE_BIT = 0x00000040,
+ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT = 0x00000080,
+ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT = 0x00000100,
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 0x00000200,
+ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 0x00000400,
+ VK_ACCESS_TRANSFER_READ_BIT = 0x00000800,
+ VK_ACCESS_TRANSFER_WRITE_BIT = 0x00001000,
+ VK_ACCESS_HOST_READ_BIT = 0x00002000,
+ VK_ACCESS_HOST_WRITE_BIT = 0x00004000,
+ VK_ACCESS_MEMORY_READ_BIT = 0x00008000,
+ VK_ACCESS_MEMORY_WRITE_BIT = 0x00010000,
+ VK_ACCESS_COMMAND_PROCESS_READ_BIT_NVX = 0x00020000,
+ VK_ACCESS_COMMAND_PROCESS_WRITE_BIT_NVX = 0x00040000,
+ VK_ACCESS_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT = 0x00080000,
+ VK_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkAccessFlagBits;
+typedef VkFlags VkAccessFlags;
+
+typedef enum VkDependencyFlagBits {
+ VK_DEPENDENCY_BY_REGION_BIT = 0x00000001,
+ VK_DEPENDENCY_VIEW_LOCAL_BIT_KHX = 0x00000002,
+ VK_DEPENDENCY_DEVICE_GROUP_BIT_KHX = 0x00000004,
+ VK_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkDependencyFlagBits;
+typedef VkFlags VkDependencyFlags;
+
+typedef enum VkCommandPoolCreateFlagBits {
+ VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001,
+ VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002,
+ VK_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkCommandPoolCreateFlagBits;
+typedef VkFlags VkCommandPoolCreateFlags;
+
+typedef enum VkCommandPoolResetFlagBits {
+ VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
+ VK_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkCommandPoolResetFlagBits;
+typedef VkFlags VkCommandPoolResetFlags;
+
+typedef enum VkCommandBufferUsageFlagBits {
+ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001,
+ VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 0x00000002,
+ VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 0x00000004,
+ VK_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkCommandBufferUsageFlagBits;
+typedef VkFlags VkCommandBufferUsageFlags;
+
+typedef enum VkQueryControlFlagBits {
+ VK_QUERY_CONTROL_PRECISE_BIT = 0x00000001,
+ VK_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkQueryControlFlagBits;
+typedef VkFlags VkQueryControlFlags;
+
+typedef enum VkCommandBufferResetFlagBits {
+ VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
+ VK_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkCommandBufferResetFlagBits;
+typedef VkFlags VkCommandBufferResetFlags;
+
+typedef enum VkStencilFaceFlagBits {
+ VK_STENCIL_FACE_FRONT_BIT = 0x00000001,
+ VK_STENCIL_FACE_BACK_BIT = 0x00000002,
+ VK_STENCIL_FRONT_AND_BACK = 0x00000003,
+ VK_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
+} VkStencilFaceFlagBits;
+typedef VkFlags VkStencilFaceFlags;
+
+typedef struct VkApplicationInfo {
+ VkStructureType sType;
+ const void* pNext;
+ const char* pApplicationName;
+ uint32_t applicationVersion;
+ const char* pEngineName;
+ uint32_t engineVersion;
+ uint32_t apiVersion;
+} VkApplicationInfo;
+
+typedef struct VkInstanceCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkInstanceCreateFlags flags;
+ const VkApplicationInfo* pApplicationInfo;
+ uint32_t enabledLayerCount;
+ const char* const* ppEnabledLayerNames;
+ uint32_t enabledExtensionCount;
+ const char* const* ppEnabledExtensionNames;
+} VkInstanceCreateInfo;
+
+typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)(
+ void* pUserData,
+ size_t size,
+ size_t alignment,
+ VkSystemAllocationScope allocationScope);
+
+typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)(
+ void* pUserData,
+ void* pOriginal,
+ size_t size,
+ size_t alignment,
+ VkSystemAllocationScope allocationScope);
+
+typedef void (VKAPI_PTR *PFN_vkFreeFunction)(
+ void* pUserData,
+ void* pMemory);
+
+typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)(
+ void* pUserData,
+ size_t size,
+ VkInternalAllocationType allocationType,
+ VkSystemAllocationScope allocationScope);
+
+typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)(
+ void* pUserData,
+ size_t size,
+ VkInternalAllocationType allocationType,
+ VkSystemAllocationScope allocationScope);
+
+typedef struct VkAllocationCallbacks {
+ void* pUserData;
+ PFN_vkAllocationFunction pfnAllocation;
+ PFN_vkReallocationFunction pfnReallocation;
+ PFN_vkFreeFunction pfnFree;
+ PFN_vkInternalAllocationNotification pfnInternalAllocation;
+ PFN_vkInternalFreeNotification pfnInternalFree;
+} VkAllocationCallbacks;
+
+typedef struct VkPhysicalDeviceFeatures {
+ VkBool32 robustBufferAccess;
+ VkBool32 fullDrawIndexUint32;
+ VkBool32 imageCubeArray;
+ VkBool32 independentBlend;
+ VkBool32 geometryShader;
+ VkBool32 tessellationShader;
+ VkBool32 sampleRateShading;
+ VkBool32 dualSrcBlend;
+ VkBool32 logicOp;
+ VkBool32 multiDrawIndirect;
+ VkBool32 drawIndirectFirstInstance;
+ VkBool32 depthClamp;
+ VkBool32 depthBiasClamp;
+ VkBool32 fillModeNonSolid;
+ VkBool32 depthBounds;
+ VkBool32 wideLines;
+ VkBool32 largePoints;
+ VkBool32 alphaToOne;
+ VkBool32 multiViewport;
+ VkBool32 samplerAnisotropy;
+ VkBool32 textureCompressionETC2;
+ VkBool32 textureCompressionASTC_LDR;
+ VkBool32 textureCompressionBC;
+ VkBool32 occlusionQueryPrecise;
+ VkBool32 pipelineStatisticsQuery;
+ VkBool32 vertexPipelineStoresAndAtomics;
+ VkBool32 fragmentStoresAndAtomics;
+ VkBool32 shaderTessellationAndGeometryPointSize;
+ VkBool32 shaderImageGatherExtended;
+ VkBool32 shaderStorageImageExtendedFormats;
+ VkBool32 shaderStorageImageMultisample;
+ VkBool32 shaderStorageImageReadWithoutFormat;
+ VkBool32 shaderStorageImageWriteWithoutFormat;
+ VkBool32 shaderUniformBufferArrayDynamicIndexing;
+ VkBool32 shaderSampledImageArrayDynamicIndexing;
+ VkBool32 shaderStorageBufferArrayDynamicIndexing;
+ VkBool32 shaderStorageImageArrayDynamicIndexing;
+ VkBool32 shaderClipDistance;
+ VkBool32 shaderCullDistance;
+ VkBool32 shaderFloat64;
+ VkBool32 shaderInt64;
+ VkBool32 shaderInt16;
+ VkBool32 shaderResourceResidency;
+ VkBool32 shaderResourceMinLod;
+ VkBool32 sparseBinding;
+ VkBool32 sparseResidencyBuffer;
+ VkBool32 sparseResidencyImage2D;
+ VkBool32 sparseResidencyImage3D;
+ VkBool32 sparseResidency2Samples;
+ VkBool32 sparseResidency4Samples;
+ VkBool32 sparseResidency8Samples;
+ VkBool32 sparseResidency16Samples;
+ VkBool32 sparseResidencyAliased;
+ VkBool32 variableMultisampleRate;
+ VkBool32 inheritedQueries;
+} VkPhysicalDeviceFeatures;
+
+typedef struct VkFormatProperties {
+ VkFormatFeatureFlags linearTilingFeatures;
+ VkFormatFeatureFlags optimalTilingFeatures;
+ VkFormatFeatureFlags bufferFeatures;
+} VkFormatProperties;
+
+typedef struct VkExtent3D {
+ uint32_t width;
+ uint32_t height;
+ uint32_t depth;
+} VkExtent3D;
+
+typedef struct VkImageFormatProperties {
+ VkExtent3D maxExtent;
+ uint32_t maxMipLevels;
+ uint32_t maxArrayLayers;
+ VkSampleCountFlags sampleCounts;
+ VkDeviceSize maxResourceSize;
+} VkImageFormatProperties;
+
+typedef struct VkPhysicalDeviceLimits {
+ uint32_t maxImageDimension1D;
+ uint32_t maxImageDimension2D;
+ uint32_t maxImageDimension3D;
+ uint32_t maxImageDimensionCube;
+ uint32_t maxImageArrayLayers;
+ uint32_t maxTexelBufferElements;
+ uint32_t maxUniformBufferRange;
+ uint32_t maxStorageBufferRange;
+ uint32_t maxPushConstantsSize;
+ uint32_t maxMemoryAllocationCount;
+ uint32_t maxSamplerAllocationCount;
+ VkDeviceSize bufferImageGranularity;
+ VkDeviceSize sparseAddressSpaceSize;
+ uint32_t maxBoundDescriptorSets;
+ uint32_t maxPerStageDescriptorSamplers;
+ uint32_t maxPerStageDescriptorUniformBuffers;
+ uint32_t maxPerStageDescriptorStorageBuffers;
+ uint32_t maxPerStageDescriptorSampledImages;
+ uint32_t maxPerStageDescriptorStorageImages;
+ uint32_t maxPerStageDescriptorInputAttachments;
+ uint32_t maxPerStageResources;
+ uint32_t maxDescriptorSetSamplers;
+ uint32_t maxDescriptorSetUniformBuffers;
+ uint32_t maxDescriptorSetUniformBuffersDynamic;
+ uint32_t maxDescriptorSetStorageBuffers;
+ uint32_t maxDescriptorSetStorageBuffersDynamic;
+ uint32_t maxDescriptorSetSampledImages;
+ uint32_t maxDescriptorSetStorageImages;
+ uint32_t maxDescriptorSetInputAttachments;
+ uint32_t maxVertexInputAttributes;
+ uint32_t maxVertexInputBindings;
+ uint32_t maxVertexInputAttributeOffset;
+ uint32_t maxVertexInputBindingStride;
+ uint32_t maxVertexOutputComponents;
+ uint32_t maxTessellationGenerationLevel;
+ uint32_t maxTessellationPatchSize;
+ uint32_t maxTessellationControlPerVertexInputComponents;
+ uint32_t maxTessellationControlPerVertexOutputComponents;
+ uint32_t maxTessellationControlPerPatchOutputComponents;
+ uint32_t maxTessellationControlTotalOutputComponents;
+ uint32_t maxTessellationEvaluationInputComponents;
+ uint32_t maxTessellationEvaluationOutputComponents;
+ uint32_t maxGeometryShaderInvocations;
+ uint32_t maxGeometryInputComponents;
+ uint32_t maxGeometryOutputComponents;
+ uint32_t maxGeometryOutputVertices;
+ uint32_t maxGeometryTotalOutputComponents;
+ uint32_t maxFragmentInputComponents;
+ uint32_t maxFragmentOutputAttachments;
+ uint32_t maxFragmentDualSrcAttachments;
+ uint32_t maxFragmentCombinedOutputResources;
+ uint32_t maxComputeSharedMemorySize;
+ uint32_t maxComputeWorkGroupCount[3];
+ uint32_t maxComputeWorkGroupInvocations;
+ uint32_t maxComputeWorkGroupSize[3];
+ uint32_t subPixelPrecisionBits;
+ uint32_t subTexelPrecisionBits;
+ uint32_t mipmapPrecisionBits;
+ uint32_t maxDrawIndexedIndexValue;
+ uint32_t maxDrawIndirectCount;
+ float maxSamplerLodBias;
+ float maxSamplerAnisotropy;
+ uint32_t maxViewports;
+ uint32_t maxViewportDimensions[2];
+ float viewportBoundsRange[2];
+ uint32_t viewportSubPixelBits;
+ size_t minMemoryMapAlignment;
+ VkDeviceSize minTexelBufferOffsetAlignment;
+ VkDeviceSize minUniformBufferOffsetAlignment;
+ VkDeviceSize minStorageBufferOffsetAlignment;
+ int32_t minTexelOffset;
+ uint32_t maxTexelOffset;
+ int32_t minTexelGatherOffset;
+ uint32_t maxTexelGatherOffset;
+ float minInterpolationOffset;
+ float maxInterpolationOffset;
+ uint32_t subPixelInterpolationOffsetBits;
+ uint32_t maxFramebufferWidth;
+ uint32_t maxFramebufferHeight;
+ uint32_t maxFramebufferLayers;
+ VkSampleCountFlags framebufferColorSampleCounts;
+ VkSampleCountFlags framebufferDepthSampleCounts;
+ VkSampleCountFlags framebufferStencilSampleCounts;
+ VkSampleCountFlags framebufferNoAttachmentsSampleCounts;
+ uint32_t maxColorAttachments;
+ VkSampleCountFlags sampledImageColorSampleCounts;
+ VkSampleCountFlags sampledImageIntegerSampleCounts;
+ VkSampleCountFlags sampledImageDepthSampleCounts;
+ VkSampleCountFlags sampledImageStencilSampleCounts;
+ VkSampleCountFlags storageImageSampleCounts;
+ uint32_t maxSampleMaskWords;
+ VkBool32 timestampComputeAndGraphics;
+ float timestampPeriod;
+ uint32_t maxClipDistances;
+ uint32_t maxCullDistances;
+ uint32_t maxCombinedClipAndCullDistances;
+ uint32_t discreteQueuePriorities;
+ float pointSizeRange[2];
+ float lineWidthRange[2];
+ float pointSizeGranularity;
+ float lineWidthGranularity;
+ VkBool32 strictLines;
+ VkBool32 standardSampleLocations;
+ VkDeviceSize optimalBufferCopyOffsetAlignment;
+ VkDeviceSize optimalBufferCopyRowPitchAlignment;
+ VkDeviceSize nonCoherentAtomSize;
+} VkPhysicalDeviceLimits;
+
+typedef struct VkPhysicalDeviceSparseProperties {
+ VkBool32 residencyStandard2DBlockShape;
+ VkBool32 residencyStandard2DMultisampleBlockShape;
+ VkBool32 residencyStandard3DBlockShape;
+ VkBool32 residencyAlignedMipSize;
+ VkBool32 residencyNonResidentStrict;
+} VkPhysicalDeviceSparseProperties;
+
+typedef struct VkPhysicalDeviceProperties {
+ uint32_t apiVersion;
+ uint32_t driverVersion;
+ uint32_t vendorID;
+ uint32_t deviceID;
+ VkPhysicalDeviceType deviceType;
+ char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE];
+ uint8_t pipelineCacheUUID[VK_UUID_SIZE];
+ VkPhysicalDeviceLimits limits;
+ VkPhysicalDeviceSparseProperties sparseProperties;
+} VkPhysicalDeviceProperties;
+
+typedef struct VkQueueFamilyProperties {
+ VkQueueFlags queueFlags;
+ uint32_t queueCount;
+ uint32_t timestampValidBits;
+ VkExtent3D minImageTransferGranularity;
+} VkQueueFamilyProperties;
+
+typedef struct VkMemoryType {
+ VkMemoryPropertyFlags propertyFlags;
+ uint32_t heapIndex;
+} VkMemoryType;
+
+typedef struct VkMemoryHeap {
+ VkDeviceSize size;
+ VkMemoryHeapFlags flags;
+} VkMemoryHeap;
+
+typedef struct VkPhysicalDeviceMemoryProperties {
+ uint32_t memoryTypeCount;
+ VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES];
+ uint32_t memoryHeapCount;
+ VkMemoryHeap memoryHeaps[VK_MAX_MEMORY_HEAPS];
+} VkPhysicalDeviceMemoryProperties;
+
+typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void);
+typedef struct VkDeviceQueueCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceQueueCreateFlags flags;
+ uint32_t queueFamilyIndex;
+ uint32_t queueCount;
+ const float* pQueuePriorities;
+} VkDeviceQueueCreateInfo;
+
+typedef struct VkDeviceCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceCreateFlags flags;
+ uint32_t queueCreateInfoCount;
+ const VkDeviceQueueCreateInfo* pQueueCreateInfos;
+ uint32_t enabledLayerCount;
+ const char* const* ppEnabledLayerNames;
+ uint32_t enabledExtensionCount;
+ const char* const* ppEnabledExtensionNames;
+ const VkPhysicalDeviceFeatures* pEnabledFeatures;
+} VkDeviceCreateInfo;
+
+typedef struct VkExtensionProperties {
+ char extensionName[VK_MAX_EXTENSION_NAME_SIZE];
+ uint32_t specVersion;
+} VkExtensionProperties;
+
+typedef struct VkLayerProperties {
+ char layerName[VK_MAX_EXTENSION_NAME_SIZE];
+ uint32_t specVersion;
+ uint32_t implementationVersion;
+ char description[VK_MAX_DESCRIPTION_SIZE];
+} VkLayerProperties;
+
+typedef struct VkSubmitInfo {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t waitSemaphoreCount;
+ const VkSemaphore* pWaitSemaphores;
+ const VkPipelineStageFlags* pWaitDstStageMask;
+ uint32_t commandBufferCount;
+ const VkCommandBuffer* pCommandBuffers;
+ uint32_t signalSemaphoreCount;
+ const VkSemaphore* pSignalSemaphores;
+} VkSubmitInfo;
+
+typedef struct VkMemoryAllocateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceSize allocationSize;
+ uint32_t memoryTypeIndex;
+} VkMemoryAllocateInfo;
+
+typedef struct VkMappedMemoryRange {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceMemory memory;
+ VkDeviceSize offset;
+ VkDeviceSize size;
+} VkMappedMemoryRange;
+
+typedef struct VkMemoryRequirements {
+ VkDeviceSize size;
+ VkDeviceSize alignment;
+ uint32_t memoryTypeBits;
+} VkMemoryRequirements;
+
+typedef struct VkSparseImageFormatProperties {
+ VkImageAspectFlags aspectMask;
+ VkExtent3D imageGranularity;
+ VkSparseImageFormatFlags flags;
+} VkSparseImageFormatProperties;
+
+typedef struct VkSparseImageMemoryRequirements {
+ VkSparseImageFormatProperties formatProperties;
+ uint32_t imageMipTailFirstLod;
+ VkDeviceSize imageMipTailSize;
+ VkDeviceSize imageMipTailOffset;
+ VkDeviceSize imageMipTailStride;
+} VkSparseImageMemoryRequirements;
+
+typedef struct VkSparseMemoryBind {
+ VkDeviceSize resourceOffset;
+ VkDeviceSize size;
+ VkDeviceMemory memory;
+ VkDeviceSize memoryOffset;
+ VkSparseMemoryBindFlags flags;
+} VkSparseMemoryBind;
+
+typedef struct VkSparseBufferMemoryBindInfo {
+ VkBuffer buffer;
+ uint32_t bindCount;
+ const VkSparseMemoryBind* pBinds;
+} VkSparseBufferMemoryBindInfo;
+
+typedef struct VkSparseImageOpaqueMemoryBindInfo {
+ VkImage image;
+ uint32_t bindCount;
+ const VkSparseMemoryBind* pBinds;
+} VkSparseImageOpaqueMemoryBindInfo;
+
+typedef struct VkImageSubresource {
+ VkImageAspectFlags aspectMask;
+ uint32_t mipLevel;
+ uint32_t arrayLayer;
+} VkImageSubresource;
+
+typedef struct VkOffset3D {
+ int32_t x;
+ int32_t y;
+ int32_t z;
+} VkOffset3D;
+
+typedef struct VkSparseImageMemoryBind {
+ VkImageSubresource subresource;
+ VkOffset3D offset;
+ VkExtent3D extent;
+ VkDeviceMemory memory;
+ VkDeviceSize memoryOffset;
+ VkSparseMemoryBindFlags flags;
+} VkSparseImageMemoryBind;
+
+typedef struct VkSparseImageMemoryBindInfo {
+ VkImage image;
+ uint32_t bindCount;
+ const VkSparseImageMemoryBind* pBinds;
+} VkSparseImageMemoryBindInfo;
+
+typedef struct VkBindSparseInfo {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t waitSemaphoreCount;
+ const VkSemaphore* pWaitSemaphores;
+ uint32_t bufferBindCount;
+ const VkSparseBufferMemoryBindInfo* pBufferBinds;
+ uint32_t imageOpaqueBindCount;
+ const VkSparseImageOpaqueMemoryBindInfo* pImageOpaqueBinds;
+ uint32_t imageBindCount;
+ const VkSparseImageMemoryBindInfo* pImageBinds;
+ uint32_t signalSemaphoreCount;
+ const VkSemaphore* pSignalSemaphores;
+} VkBindSparseInfo;
+
+typedef struct VkFenceCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkFenceCreateFlags flags;
+} VkFenceCreateInfo;
+
+typedef struct VkSemaphoreCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkSemaphoreCreateFlags flags;
+} VkSemaphoreCreateInfo;
+
+typedef struct VkEventCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkEventCreateFlags flags;
+} VkEventCreateInfo;
+
+typedef struct VkQueryPoolCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkQueryPoolCreateFlags flags;
+ VkQueryType queryType;
+ uint32_t queryCount;
+ VkQueryPipelineStatisticFlags pipelineStatistics;
+} VkQueryPoolCreateInfo;
+
+typedef struct VkBufferCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkBufferCreateFlags flags;
+ VkDeviceSize size;
+ VkBufferUsageFlags usage;
+ VkSharingMode sharingMode;
+ uint32_t queueFamilyIndexCount;
+ const uint32_t* pQueueFamilyIndices;
+} VkBufferCreateInfo;
+
+typedef struct VkBufferViewCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkBufferViewCreateFlags flags;
+ VkBuffer buffer;
+ VkFormat format;
+ VkDeviceSize offset;
+ VkDeviceSize range;
+} VkBufferViewCreateInfo;
+
+typedef struct VkImageCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkImageCreateFlags flags;
+ VkImageType imageType;
+ VkFormat format;
+ VkExtent3D extent;
+ uint32_t mipLevels;
+ uint32_t arrayLayers;
+ VkSampleCountFlagBits samples;
+ VkImageTiling tiling;
+ VkImageUsageFlags usage;
+ VkSharingMode sharingMode;
+ uint32_t queueFamilyIndexCount;
+ const uint32_t* pQueueFamilyIndices;
+ VkImageLayout initialLayout;
+} VkImageCreateInfo;
+
+typedef struct VkSubresourceLayout {
+ VkDeviceSize offset;
+ VkDeviceSize size;
+ VkDeviceSize rowPitch;
+ VkDeviceSize arrayPitch;
+ VkDeviceSize depthPitch;
+} VkSubresourceLayout;
+
+typedef struct VkComponentMapping {
+ VkComponentSwizzle r;
+ VkComponentSwizzle g;
+ VkComponentSwizzle b;
+ VkComponentSwizzle a;
+} VkComponentMapping;
+
+typedef struct VkImageSubresourceRange {
+ VkImageAspectFlags aspectMask;
+ uint32_t baseMipLevel;
+ uint32_t levelCount;
+ uint32_t baseArrayLayer;
+ uint32_t layerCount;
+} VkImageSubresourceRange;
+
+typedef struct VkImageViewCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkImageViewCreateFlags flags;
+ VkImage image;
+ VkImageViewType viewType;
+ VkFormat format;
+ VkComponentMapping components;
+ VkImageSubresourceRange subresourceRange;
+} VkImageViewCreateInfo;
+
+typedef struct VkShaderModuleCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkShaderModuleCreateFlags flags;
+ size_t codeSize;
+ const uint32_t* pCode;
+} VkShaderModuleCreateInfo;
+
+typedef struct VkPipelineCacheCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineCacheCreateFlags flags;
+ size_t initialDataSize;
+ const void* pInitialData;
+} VkPipelineCacheCreateInfo;
+
+typedef struct VkSpecializationMapEntry {
+ uint32_t constantID;
+ uint32_t offset;
+ size_t size;
+} VkSpecializationMapEntry;
+
+typedef struct VkSpecializationInfo {
+ uint32_t mapEntryCount;
+ const VkSpecializationMapEntry* pMapEntries;
+ size_t dataSize;
+ const void* pData;
+} VkSpecializationInfo;
+
+typedef struct VkPipelineShaderStageCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineShaderStageCreateFlags flags;
+ VkShaderStageFlagBits stage;
+ VkShaderModule module;
+ const char* pName;
+ const VkSpecializationInfo* pSpecializationInfo;
+} VkPipelineShaderStageCreateInfo;
+
+typedef struct VkVertexInputBindingDescription {
+ uint32_t binding;
+ uint32_t stride;
+ VkVertexInputRate inputRate;
+} VkVertexInputBindingDescription;
+
+typedef struct VkVertexInputAttributeDescription {
+ uint32_t location;
+ uint32_t binding;
+ VkFormat format;
+ uint32_t offset;
+} VkVertexInputAttributeDescription;
+
+typedef struct VkPipelineVertexInputStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineVertexInputStateCreateFlags flags;
+ uint32_t vertexBindingDescriptionCount;
+ const VkVertexInputBindingDescription* pVertexBindingDescriptions;
+ uint32_t vertexAttributeDescriptionCount;
+ const VkVertexInputAttributeDescription* pVertexAttributeDescriptions;
+} VkPipelineVertexInputStateCreateInfo;
+
+typedef struct VkPipelineInputAssemblyStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineInputAssemblyStateCreateFlags flags;
+ VkPrimitiveTopology topology;
+ VkBool32 primitiveRestartEnable;
+} VkPipelineInputAssemblyStateCreateInfo;
+
+typedef struct VkPipelineTessellationStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineTessellationStateCreateFlags flags;
+ uint32_t patchControlPoints;
+} VkPipelineTessellationStateCreateInfo;
+
+typedef struct VkViewport {
+ float x;
+ float y;
+ float width;
+ float height;
+ float minDepth;
+ float maxDepth;
+} VkViewport;
+
+typedef struct VkOffset2D {
+ int32_t x;
+ int32_t y;
+} VkOffset2D;
+
+typedef struct VkExtent2D {
+ uint32_t width;
+ uint32_t height;
+} VkExtent2D;
+
+typedef struct VkRect2D {
+ VkOffset2D offset;
+ VkExtent2D extent;
+} VkRect2D;
+
+typedef struct VkPipelineViewportStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineViewportStateCreateFlags flags;
+ uint32_t viewportCount;
+ const VkViewport* pViewports;
+ uint32_t scissorCount;
+ const VkRect2D* pScissors;
+} VkPipelineViewportStateCreateInfo;
+
+typedef struct VkPipelineRasterizationStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineRasterizationStateCreateFlags flags;
+ VkBool32 depthClampEnable;
+ VkBool32 rasterizerDiscardEnable;
+ VkPolygonMode polygonMode;
+ VkCullModeFlags cullMode;
+ VkFrontFace frontFace;
+ VkBool32 depthBiasEnable;
+ float depthBiasConstantFactor;
+ float depthBiasClamp;
+ float depthBiasSlopeFactor;
+ float lineWidth;
+} VkPipelineRasterizationStateCreateInfo;
+
+typedef struct VkPipelineMultisampleStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineMultisampleStateCreateFlags flags;
+ VkSampleCountFlagBits rasterizationSamples;
+ VkBool32 sampleShadingEnable;
+ float minSampleShading;
+ const VkSampleMask* pSampleMask;
+ VkBool32 alphaToCoverageEnable;
+ VkBool32 alphaToOneEnable;
+} VkPipelineMultisampleStateCreateInfo;
+
+typedef struct VkStencilOpState {
+ VkStencilOp failOp;
+ VkStencilOp passOp;
+ VkStencilOp depthFailOp;
+ VkCompareOp compareOp;
+ uint32_t compareMask;
+ uint32_t writeMask;
+ uint32_t reference;
+} VkStencilOpState;
+
+typedef struct VkPipelineDepthStencilStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineDepthStencilStateCreateFlags flags;
+ VkBool32 depthTestEnable;
+ VkBool32 depthWriteEnable;
+ VkCompareOp depthCompareOp;
+ VkBool32 depthBoundsTestEnable;
+ VkBool32 stencilTestEnable;
+ VkStencilOpState front;
+ VkStencilOpState back;
+ float minDepthBounds;
+ float maxDepthBounds;
+} VkPipelineDepthStencilStateCreateInfo;
+
+typedef struct VkPipelineColorBlendAttachmentState {
+ VkBool32 blendEnable;
+ VkBlendFactor srcColorBlendFactor;
+ VkBlendFactor dstColorBlendFactor;
+ VkBlendOp colorBlendOp;
+ VkBlendFactor srcAlphaBlendFactor;
+ VkBlendFactor dstAlphaBlendFactor;
+ VkBlendOp alphaBlendOp;
+ VkColorComponentFlags colorWriteMask;
+} VkPipelineColorBlendAttachmentState;
+
+typedef struct VkPipelineColorBlendStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineColorBlendStateCreateFlags flags;
+ VkBool32 logicOpEnable;
+ VkLogicOp logicOp;
+ uint32_t attachmentCount;
+ const VkPipelineColorBlendAttachmentState* pAttachments;
+ float blendConstants[4];
+} VkPipelineColorBlendStateCreateInfo;
+
+typedef struct VkPipelineDynamicStateCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineDynamicStateCreateFlags flags;
+ uint32_t dynamicStateCount;
+ const VkDynamicState* pDynamicStates;
+} VkPipelineDynamicStateCreateInfo;
+
+typedef struct VkGraphicsPipelineCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineCreateFlags flags;
+ uint32_t stageCount;
+ const VkPipelineShaderStageCreateInfo* pStages;
+ const VkPipelineVertexInputStateCreateInfo* pVertexInputState;
+ const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState;
+ const VkPipelineTessellationStateCreateInfo* pTessellationState;
+ const VkPipelineViewportStateCreateInfo* pViewportState;
+ const VkPipelineRasterizationStateCreateInfo* pRasterizationState;
+ const VkPipelineMultisampleStateCreateInfo* pMultisampleState;
+ const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState;
+ const VkPipelineColorBlendStateCreateInfo* pColorBlendState;
+ const VkPipelineDynamicStateCreateInfo* pDynamicState;
+ VkPipelineLayout layout;
+ VkRenderPass renderPass;
+ uint32_t subpass;
+ VkPipeline basePipelineHandle;
+ int32_t basePipelineIndex;
+} VkGraphicsPipelineCreateInfo;
+
+typedef struct VkComputePipelineCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineCreateFlags flags;
+ VkPipelineShaderStageCreateInfo stage;
+ VkPipelineLayout layout;
+ VkPipeline basePipelineHandle;
+ int32_t basePipelineIndex;
+} VkComputePipelineCreateInfo;
+
+typedef struct VkPushConstantRange {
+ VkShaderStageFlags stageFlags;
+ uint32_t offset;
+ uint32_t size;
+} VkPushConstantRange;
+
+typedef struct VkPipelineLayoutCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineLayoutCreateFlags flags;
+ uint32_t setLayoutCount;
+ const VkDescriptorSetLayout* pSetLayouts;
+ uint32_t pushConstantRangeCount;
+ const VkPushConstantRange* pPushConstantRanges;
+} VkPipelineLayoutCreateInfo;
+
+typedef struct VkSamplerCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkSamplerCreateFlags flags;
+ VkFilter magFilter;
+ VkFilter minFilter;
+ VkSamplerMipmapMode mipmapMode;
+ VkSamplerAddressMode addressModeU;
+ VkSamplerAddressMode addressModeV;
+ VkSamplerAddressMode addressModeW;
+ float mipLodBias;
+ VkBool32 anisotropyEnable;
+ float maxAnisotropy;
+ VkBool32 compareEnable;
+ VkCompareOp compareOp;
+ float minLod;
+ float maxLod;
+ VkBorderColor borderColor;
+ VkBool32 unnormalizedCoordinates;
+} VkSamplerCreateInfo;
+
+typedef struct VkDescriptorSetLayoutBinding {
+ uint32_t binding;
+ VkDescriptorType descriptorType;
+ uint32_t descriptorCount;
+ VkShaderStageFlags stageFlags;
+ const VkSampler* pImmutableSamplers;
+} VkDescriptorSetLayoutBinding;
+
+typedef struct VkDescriptorSetLayoutCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkDescriptorSetLayoutCreateFlags flags;
+ uint32_t bindingCount;
+ const VkDescriptorSetLayoutBinding* pBindings;
+} VkDescriptorSetLayoutCreateInfo;
+
+typedef struct VkDescriptorPoolSize {
+ VkDescriptorType type;
+ uint32_t descriptorCount;
+} VkDescriptorPoolSize;
+
+typedef struct VkDescriptorPoolCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkDescriptorPoolCreateFlags flags;
+ uint32_t maxSets;
+ uint32_t poolSizeCount;
+ const VkDescriptorPoolSize* pPoolSizes;
+} VkDescriptorPoolCreateInfo;
+
+typedef struct VkDescriptorSetAllocateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkDescriptorPool descriptorPool;
+ uint32_t descriptorSetCount;
+ const VkDescriptorSetLayout* pSetLayouts;
+} VkDescriptorSetAllocateInfo;
+
+typedef struct VkDescriptorImageInfo {
+ VkSampler sampler;
+ VkImageView imageView;
+ VkImageLayout imageLayout;
+} VkDescriptorImageInfo;
+
+typedef struct VkDescriptorBufferInfo {
+ VkBuffer buffer;
+ VkDeviceSize offset;
+ VkDeviceSize range;
+} VkDescriptorBufferInfo;
+
+typedef struct VkWriteDescriptorSet {
+ VkStructureType sType;
+ const void* pNext;
+ VkDescriptorSet dstSet;
+ uint32_t dstBinding;
+ uint32_t dstArrayElement;
+ uint32_t descriptorCount;
+ VkDescriptorType descriptorType;
+ const VkDescriptorImageInfo* pImageInfo;
+ const VkDescriptorBufferInfo* pBufferInfo;
+ const VkBufferView* pTexelBufferView;
+} VkWriteDescriptorSet;
+
+typedef struct VkCopyDescriptorSet {
+ VkStructureType sType;
+ const void* pNext;
+ VkDescriptorSet srcSet;
+ uint32_t srcBinding;
+ uint32_t srcArrayElement;
+ VkDescriptorSet dstSet;
+ uint32_t dstBinding;
+ uint32_t dstArrayElement;
+ uint32_t descriptorCount;
+} VkCopyDescriptorSet;
+
+typedef struct VkFramebufferCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkFramebufferCreateFlags flags;
+ VkRenderPass renderPass;
+ uint32_t attachmentCount;
+ const VkImageView* pAttachments;
+ uint32_t width;
+ uint32_t height;
+ uint32_t layers;
+} VkFramebufferCreateInfo;
+
+typedef struct VkAttachmentDescription {
+ VkAttachmentDescriptionFlags flags;
+ VkFormat format;
+ VkSampleCountFlagBits samples;
+ VkAttachmentLoadOp loadOp;
+ VkAttachmentStoreOp storeOp;
+ VkAttachmentLoadOp stencilLoadOp;
+ VkAttachmentStoreOp stencilStoreOp;
+ VkImageLayout initialLayout;
+ VkImageLayout finalLayout;
+} VkAttachmentDescription;
+
+typedef struct VkAttachmentReference {
+ uint32_t attachment;
+ VkImageLayout layout;
+} VkAttachmentReference;
+
+typedef struct VkSubpassDescription {
+ VkSubpassDescriptionFlags flags;
+ VkPipelineBindPoint pipelineBindPoint;
+ uint32_t inputAttachmentCount;
+ const VkAttachmentReference* pInputAttachments;
+ uint32_t colorAttachmentCount;
+ const VkAttachmentReference* pColorAttachments;
+ const VkAttachmentReference* pResolveAttachments;
+ const VkAttachmentReference* pDepthStencilAttachment;
+ uint32_t preserveAttachmentCount;
+ const uint32_t* pPreserveAttachments;
+} VkSubpassDescription;
+
+typedef struct VkSubpassDependency {
+ uint32_t srcSubpass;
+ uint32_t dstSubpass;
+ VkPipelineStageFlags srcStageMask;
+ VkPipelineStageFlags dstStageMask;
+ VkAccessFlags srcAccessMask;
+ VkAccessFlags dstAccessMask;
+ VkDependencyFlags dependencyFlags;
+} VkSubpassDependency;
+
+typedef struct VkRenderPassCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkRenderPassCreateFlags flags;
+ uint32_t attachmentCount;
+ const VkAttachmentDescription* pAttachments;
+ uint32_t subpassCount;
+ const VkSubpassDescription* pSubpasses;
+ uint32_t dependencyCount;
+ const VkSubpassDependency* pDependencies;
+} VkRenderPassCreateInfo;
+
+typedef struct VkCommandPoolCreateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkCommandPoolCreateFlags flags;
+ uint32_t queueFamilyIndex;
+} VkCommandPoolCreateInfo;
+
+typedef struct VkCommandBufferAllocateInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkCommandPool commandPool;
+ VkCommandBufferLevel level;
+ uint32_t commandBufferCount;
+} VkCommandBufferAllocateInfo;
+
+typedef struct VkCommandBufferInheritanceInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkRenderPass renderPass;
+ uint32_t subpass;
+ VkFramebuffer framebuffer;
+ VkBool32 occlusionQueryEnable;
+ VkQueryControlFlags queryFlags;
+ VkQueryPipelineStatisticFlags pipelineStatistics;
+} VkCommandBufferInheritanceInfo;
+
+typedef struct VkCommandBufferBeginInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkCommandBufferUsageFlags flags;
+ const VkCommandBufferInheritanceInfo* pInheritanceInfo;
+} VkCommandBufferBeginInfo;
+
+typedef struct VkBufferCopy {
+ VkDeviceSize srcOffset;
+ VkDeviceSize dstOffset;
+ VkDeviceSize size;
+} VkBufferCopy;
+
+typedef struct VkImageSubresourceLayers {
+ VkImageAspectFlags aspectMask;
+ uint32_t mipLevel;
+ uint32_t baseArrayLayer;
+ uint32_t layerCount;
+} VkImageSubresourceLayers;
+
+typedef struct VkImageCopy {
+ VkImageSubresourceLayers srcSubresource;
+ VkOffset3D srcOffset;
+ VkImageSubresourceLayers dstSubresource;
+ VkOffset3D dstOffset;
+ VkExtent3D extent;
+} VkImageCopy;
+
+typedef struct VkImageBlit {
+ VkImageSubresourceLayers srcSubresource;
+ VkOffset3D srcOffsets[2];
+ VkImageSubresourceLayers dstSubresource;
+ VkOffset3D dstOffsets[2];
+} VkImageBlit;
+
+typedef struct VkBufferImageCopy {
+ VkDeviceSize bufferOffset;
+ uint32_t bufferRowLength;
+ uint32_t bufferImageHeight;
+ VkImageSubresourceLayers imageSubresource;
+ VkOffset3D imageOffset;
+ VkExtent3D imageExtent;
+} VkBufferImageCopy;
+
+typedef union VkClearColorValue {
+ float float32[4];
+ int32_t int32[4];
+ uint32_t uint32[4];
+} VkClearColorValue;
+
+typedef struct VkClearDepthStencilValue {
+ float depth;
+ uint32_t stencil;
+} VkClearDepthStencilValue;
+
+typedef union VkClearValue {
+ VkClearColorValue color;
+ VkClearDepthStencilValue depthStencil;
+} VkClearValue;
+
+typedef struct VkClearAttachment {
+ VkImageAspectFlags aspectMask;
+ uint32_t colorAttachment;
+ VkClearValue clearValue;
+} VkClearAttachment;
+
+typedef struct VkClearRect {
+ VkRect2D rect;
+ uint32_t baseArrayLayer;
+ uint32_t layerCount;
+} VkClearRect;
+
+typedef struct VkImageResolve {
+ VkImageSubresourceLayers srcSubresource;
+ VkOffset3D srcOffset;
+ VkImageSubresourceLayers dstSubresource;
+ VkOffset3D dstOffset;
+ VkExtent3D extent;
+} VkImageResolve;
+
+typedef struct VkMemoryBarrier {
+ VkStructureType sType;
+ const void* pNext;
+ VkAccessFlags srcAccessMask;
+ VkAccessFlags dstAccessMask;
+} VkMemoryBarrier;
+
+typedef struct VkBufferMemoryBarrier {
+ VkStructureType sType;
+ const void* pNext;
+ VkAccessFlags srcAccessMask;
+ VkAccessFlags dstAccessMask;
+ uint32_t srcQueueFamilyIndex;
+ uint32_t dstQueueFamilyIndex;
+ VkBuffer buffer;
+ VkDeviceSize offset;
+ VkDeviceSize size;
+} VkBufferMemoryBarrier;
+
+typedef struct VkImageMemoryBarrier {
+ VkStructureType sType;
+ const void* pNext;
+ VkAccessFlags srcAccessMask;
+ VkAccessFlags dstAccessMask;
+ VkImageLayout oldLayout;
+ VkImageLayout newLayout;
+ uint32_t srcQueueFamilyIndex;
+ uint32_t dstQueueFamilyIndex;
+ VkImage image;
+ VkImageSubresourceRange subresourceRange;
+} VkImageMemoryBarrier;
+
+typedef struct VkRenderPassBeginInfo {
+ VkStructureType sType;
+ const void* pNext;
+ VkRenderPass renderPass;
+ VkFramebuffer framebuffer;
+ VkRect2D renderArea;
+ uint32_t clearValueCount;
+ const VkClearValue* pClearValues;
+} VkRenderPassBeginInfo;
+
+typedef struct VkDispatchIndirectCommand {
+ uint32_t x;
+ uint32_t y;
+ uint32_t z;
+} VkDispatchIndirectCommand;
+
+typedef struct VkDrawIndexedIndirectCommand {
+ uint32_t indexCount;
+ uint32_t instanceCount;
+ uint32_t firstIndex;
+ int32_t vertexOffset;
+ uint32_t firstInstance;
+} VkDrawIndexedIndirectCommand;
+
+typedef struct VkDrawIndirectCommand {
+ uint32_t vertexCount;
+ uint32_t instanceCount;
+ uint32_t firstVertex;
+ uint32_t firstInstance;
+} VkDrawIndirectCommand;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance);
+typedef void (VKAPI_PTR *PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties);
+typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char* pName);
+typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetDeviceProcAddr)(VkDevice device, const char* pName);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice);
+typedef void (VKAPI_PTR *PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t* pPropertyCount, VkLayerProperties* pProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties);
+typedef void (VKAPI_PTR *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue);
+typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence);
+typedef VkResult (VKAPI_PTR *PFN_vkQueueWaitIdle)(VkQueue queue);
+typedef VkResult (VKAPI_PTR *PFN_vkDeviceWaitIdle)(VkDevice device);
+typedef VkResult (VKAPI_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory);
+typedef void (VKAPI_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData);
+typedef void (VKAPI_PTR *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory memory);
+typedef VkResult (VKAPI_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges);
+typedef VkResult (VKAPI_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges);
+typedef void (VKAPI_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes);
+typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset);
+typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory)(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset);
+typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements);
+typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements);
+typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements* pSparseMemoryRequirements);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkQueueBindSparse)(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence);
+typedef void (VKAPI_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences);
+typedef VkResult (VKAPI_PTR *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence);
+typedef VkResult (VKAPI_PTR *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore);
+typedef void (VKAPI_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent);
+typedef void (VKAPI_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkGetEventStatus)(VkDevice device, VkEvent event);
+typedef VkResult (VKAPI_PTR *PFN_vkSetEvent)(VkDevice device, VkEvent event);
+typedef VkResult (VKAPI_PTR *PFN_vkResetEvent)(VkDevice device, VkEvent event);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool);
+typedef void (VKAPI_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer);
+typedef void (VKAPI_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView);
+typedef void (VKAPI_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage);
+typedef void (VKAPI_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator);
+typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView);
+typedef void (VKAPI_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule);
+typedef void (VKAPI_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache);
+typedef void (VKAPI_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData);
+typedef VkResult (VKAPI_PTR *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines);
+typedef void (VKAPI_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout);
+typedef void (VKAPI_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler);
+typedef void (VKAPI_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout);
+typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool);
+typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags);
+typedef VkResult (VKAPI_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets);
+typedef VkResult (VKAPI_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets);
+typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer);
+typedef void (VKAPI_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass);
+typedef void (VKAPI_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator);
+typedef void (VKAPI_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool);
+typedef void (VKAPI_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkResetCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags);
+typedef VkResult (VKAPI_PTR *PFN_vkAllocateCommandBuffers)(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers);
+typedef void (VKAPI_PTR *PFN_vkFreeCommandBuffers)(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers);
+typedef VkResult (VKAPI_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo);
+typedef VkResult (VKAPI_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer commandBuffer);
+typedef VkResult (VKAPI_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags);
+typedef void (VKAPI_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline);
+typedef void (VKAPI_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports);
+typedef void (VKAPI_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors);
+typedef void (VKAPI_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer commandBuffer, float lineWidth);
+typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor);
+typedef void (VKAPI_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConstants[4]);
+typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds);
+typedef void (VKAPI_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask);
+typedef void (VKAPI_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask);
+typedef void (VKAPI_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference);
+typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets);
+typedef void (VKAPI_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType);
+typedef void (VKAPI_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets);
+typedef void (VKAPI_PTR *PFN_vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance);
+typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance);
+typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride);
+typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride);
+typedef void (VKAPI_PTR *PFN_vkCmdDispatch)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
+typedef void (VKAPI_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset);
+typedef void (VKAPI_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions);
+typedef void (VKAPI_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions);
+typedef void (VKAPI_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter);
+typedef void (VKAPI_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions);
+typedef void (VKAPI_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions);
+typedef void (VKAPI_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData);
+typedef void (VKAPI_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data);
+typedef void (VKAPI_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges);
+typedef void (VKAPI_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges);
+typedef void (VKAPI_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects);
+typedef void (VKAPI_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions);
+typedef void (VKAPI_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask);
+typedef void (VKAPI_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask);
+typedef void (VKAPI_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers);
+typedef void (VKAPI_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers);
+typedef void (VKAPI_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags);
+typedef void (VKAPI_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query);
+typedef void (VKAPI_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount);
+typedef void (VKAPI_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query);
+typedef void (VKAPI_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags);
+typedef void (VKAPI_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues);
+typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents);
+typedef void (VKAPI_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer commandBuffer, VkSubpassContents contents);
+typedef void (VKAPI_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer commandBuffer);
+typedef void (VKAPI_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance(
+ const VkInstanceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkInstance* pInstance);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyInstance(
+ VkInstance instance,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices(
+ VkInstance instance,
+ uint32_t* pPhysicalDeviceCount,
+ VkPhysicalDevice* pPhysicalDevices);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures(
+ VkPhysicalDevice physicalDevice,
+ VkPhysicalDeviceFeatures* pFeatures);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(
+ VkPhysicalDevice physicalDevice,
+ VkFormat format,
+ VkFormatProperties* pFormatProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(
+ VkPhysicalDevice physicalDevice,
+ VkFormat format,
+ VkImageType type,
+ VkImageTiling tiling,
+ VkImageUsageFlags usage,
+ VkImageCreateFlags flags,
+ VkImageFormatProperties* pImageFormatProperties);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties(
+ VkPhysicalDevice physicalDevice,
+ VkPhysicalDeviceProperties* pProperties);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pQueueFamilyPropertyCount,
+ VkQueueFamilyProperties* pQueueFamilyProperties);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(
+ VkPhysicalDevice physicalDevice,
+ VkPhysicalDeviceMemoryProperties* pMemoryProperties);
+
+VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(
+ VkInstance instance,
+ const char* pName);
+
+VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(
+ VkDevice device,
+ const char* pName);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice(
+ VkPhysicalDevice physicalDevice,
+ const VkDeviceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDevice* pDevice);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyDevice(
+ VkDevice device,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(
+ const char* pLayerName,
+ uint32_t* pPropertyCount,
+ VkExtensionProperties* pProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(
+ VkPhysicalDevice physicalDevice,
+ const char* pLayerName,
+ uint32_t* pPropertyCount,
+ VkExtensionProperties* pProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties(
+ uint32_t* pPropertyCount,
+ VkLayerProperties* pProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pPropertyCount,
+ VkLayerProperties* pProperties);
+
+VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue(
+ VkDevice device,
+ uint32_t queueFamilyIndex,
+ uint32_t queueIndex,
+ VkQueue* pQueue);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit(
+ VkQueue queue,
+ uint32_t submitCount,
+ const VkSubmitInfo* pSubmits,
+ VkFence fence);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle(
+ VkQueue queue);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle(
+ VkDevice device);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory(
+ VkDevice device,
+ const VkMemoryAllocateInfo* pAllocateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDeviceMemory* pMemory);
+
+VKAPI_ATTR void VKAPI_CALL vkFreeMemory(
+ VkDevice device,
+ VkDeviceMemory memory,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory(
+ VkDevice device,
+ VkDeviceMemory memory,
+ VkDeviceSize offset,
+ VkDeviceSize size,
+ VkMemoryMapFlags flags,
+ void** ppData);
+
+VKAPI_ATTR void VKAPI_CALL vkUnmapMemory(
+ VkDevice device,
+ VkDeviceMemory memory);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges(
+ VkDevice device,
+ uint32_t memoryRangeCount,
+ const VkMappedMemoryRange* pMemoryRanges);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges(
+ VkDevice device,
+ uint32_t memoryRangeCount,
+ const VkMappedMemoryRange* pMemoryRanges);
+
+VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment(
+ VkDevice device,
+ VkDeviceMemory memory,
+ VkDeviceSize* pCommittedMemoryInBytes);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory(
+ VkDevice device,
+ VkBuffer buffer,
+ VkDeviceMemory memory,
+ VkDeviceSize memoryOffset);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory(
+ VkDevice device,
+ VkImage image,
+ VkDeviceMemory memory,
+ VkDeviceSize memoryOffset);
+
+VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements(
+ VkDevice device,
+ VkBuffer buffer,
+ VkMemoryRequirements* pMemoryRequirements);
+
+VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements(
+ VkDevice device,
+ VkImage image,
+ VkMemoryRequirements* pMemoryRequirements);
+
+VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements(
+ VkDevice device,
+ VkImage image,
+ uint32_t* pSparseMemoryRequirementCount,
+ VkSparseImageMemoryRequirements* pSparseMemoryRequirements);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(
+ VkPhysicalDevice physicalDevice,
+ VkFormat format,
+ VkImageType type,
+ VkSampleCountFlagBits samples,
+ VkImageUsageFlags usage,
+ VkImageTiling tiling,
+ uint32_t* pPropertyCount,
+ VkSparseImageFormatProperties* pProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse(
+ VkQueue queue,
+ uint32_t bindInfoCount,
+ const VkBindSparseInfo* pBindInfo,
+ VkFence fence);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence(
+ VkDevice device,
+ const VkFenceCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkFence* pFence);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyFence(
+ VkDevice device,
+ VkFence fence,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkResetFences(
+ VkDevice device,
+ uint32_t fenceCount,
+ const VkFence* pFences);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus(
+ VkDevice device,
+ VkFence fence);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences(
+ VkDevice device,
+ uint32_t fenceCount,
+ const VkFence* pFences,
+ VkBool32 waitAll,
+ uint64_t timeout);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore(
+ VkDevice device,
+ const VkSemaphoreCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSemaphore* pSemaphore);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore(
+ VkDevice device,
+ VkSemaphore semaphore,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent(
+ VkDevice device,
+ const VkEventCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkEvent* pEvent);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyEvent(
+ VkDevice device,
+ VkEvent event,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus(
+ VkDevice device,
+ VkEvent event);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent(
+ VkDevice device,
+ VkEvent event);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent(
+ VkDevice device,
+ VkEvent event);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool(
+ VkDevice device,
+ const VkQueryPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkQueryPool* pQueryPool);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool(
+ VkDevice device,
+ VkQueryPool queryPool,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults(
+ VkDevice device,
+ VkQueryPool queryPool,
+ uint32_t firstQuery,
+ uint32_t queryCount,
+ size_t dataSize,
+ void* pData,
+ VkDeviceSize stride,
+ VkQueryResultFlags flags);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer(
+ VkDevice device,
+ const VkBufferCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkBuffer* pBuffer);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer(
+ VkDevice device,
+ VkBuffer buffer,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView(
+ VkDevice device,
+ const VkBufferViewCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkBufferView* pView);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView(
+ VkDevice device,
+ VkBufferView bufferView,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage(
+ VkDevice device,
+ const VkImageCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkImage* pImage);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyImage(
+ VkDevice device,
+ VkImage image,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout(
+ VkDevice device,
+ VkImage image,
+ const VkImageSubresource* pSubresource,
+ VkSubresourceLayout* pLayout);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(
+ VkDevice device,
+ const VkImageViewCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkImageView* pView);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyImageView(
+ VkDevice device,
+ VkImageView imageView,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule(
+ VkDevice device,
+ const VkShaderModuleCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkShaderModule* pShaderModule);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule(
+ VkDevice device,
+ VkShaderModule shaderModule,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache(
+ VkDevice device,
+ const VkPipelineCacheCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkPipelineCache* pPipelineCache);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache(
+ VkDevice device,
+ VkPipelineCache pipelineCache,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData(
+ VkDevice device,
+ VkPipelineCache pipelineCache,
+ size_t* pDataSize,
+ void* pData);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches(
+ VkDevice device,
+ VkPipelineCache dstCache,
+ uint32_t srcCacheCount,
+ const VkPipelineCache* pSrcCaches);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines(
+ VkDevice device,
+ VkPipelineCache pipelineCache,
+ uint32_t createInfoCount,
+ const VkGraphicsPipelineCreateInfo* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
+ VkPipeline* pPipelines);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines(
+ VkDevice device,
+ VkPipelineCache pipelineCache,
+ uint32_t createInfoCount,
+ const VkComputePipelineCreateInfo* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
+ VkPipeline* pPipelines);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline(
+ VkDevice device,
+ VkPipeline pipeline,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout(
+ VkDevice device,
+ const VkPipelineLayoutCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkPipelineLayout* pPipelineLayout);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout(
+ VkDevice device,
+ VkPipelineLayout pipelineLayout,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler(
+ VkDevice device,
+ const VkSamplerCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSampler* pSampler);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroySampler(
+ VkDevice device,
+ VkSampler sampler,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout(
+ VkDevice device,
+ const VkDescriptorSetLayoutCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDescriptorSetLayout* pSetLayout);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout(
+ VkDevice device,
+ VkDescriptorSetLayout descriptorSetLayout,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool(
+ VkDevice device,
+ const VkDescriptorPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDescriptorPool* pDescriptorPool);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool(
+ VkDevice device,
+ VkDescriptorPool descriptorPool,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool(
+ VkDevice device,
+ VkDescriptorPool descriptorPool,
+ VkDescriptorPoolResetFlags flags);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets(
+ VkDevice device,
+ const VkDescriptorSetAllocateInfo* pAllocateInfo,
+ VkDescriptorSet* pDescriptorSets);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets(
+ VkDevice device,
+ VkDescriptorPool descriptorPool,
+ uint32_t descriptorSetCount,
+ const VkDescriptorSet* pDescriptorSets);
+
+VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets(
+ VkDevice device,
+ uint32_t descriptorWriteCount,
+ const VkWriteDescriptorSet* pDescriptorWrites,
+ uint32_t descriptorCopyCount,
+ const VkCopyDescriptorSet* pDescriptorCopies);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer(
+ VkDevice device,
+ const VkFramebufferCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkFramebuffer* pFramebuffer);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer(
+ VkDevice device,
+ VkFramebuffer framebuffer,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass(
+ VkDevice device,
+ const VkRenderPassCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkRenderPass* pRenderPass);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass(
+ VkDevice device,
+ VkRenderPass renderPass,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity(
+ VkDevice device,
+ VkRenderPass renderPass,
+ VkExtent2D* pGranularity);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool(
+ VkDevice device,
+ const VkCommandPoolCreateInfo* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkCommandPool* pCommandPool);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool(
+ VkDevice device,
+ VkCommandPool commandPool,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool(
+ VkDevice device,
+ VkCommandPool commandPool,
+ VkCommandPoolResetFlags flags);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers(
+ VkDevice device,
+ const VkCommandBufferAllocateInfo* pAllocateInfo,
+ VkCommandBuffer* pCommandBuffers);
+
+VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers(
+ VkDevice device,
+ VkCommandPool commandPool,
+ uint32_t commandBufferCount,
+ const VkCommandBuffer* pCommandBuffers);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer(
+ VkCommandBuffer commandBuffer,
+ const VkCommandBufferBeginInfo* pBeginInfo);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer(
+ VkCommandBuffer commandBuffer);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer(
+ VkCommandBuffer commandBuffer,
+ VkCommandBufferResetFlags flags);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline(
+ VkCommandBuffer commandBuffer,
+ VkPipelineBindPoint pipelineBindPoint,
+ VkPipeline pipeline);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport(
+ VkCommandBuffer commandBuffer,
+ uint32_t firstViewport,
+ uint32_t viewportCount,
+ const VkViewport* pViewports);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor(
+ VkCommandBuffer commandBuffer,
+ uint32_t firstScissor,
+ uint32_t scissorCount,
+ const VkRect2D* pScissors);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth(
+ VkCommandBuffer commandBuffer,
+ float lineWidth);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias(
+ VkCommandBuffer commandBuffer,
+ float depthBiasConstantFactor,
+ float depthBiasClamp,
+ float depthBiasSlopeFactor);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants(
+ VkCommandBuffer commandBuffer,
+ const float blendConstants[4]);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds(
+ VkCommandBuffer commandBuffer,
+ float minDepthBounds,
+ float maxDepthBounds);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask(
+ VkCommandBuffer commandBuffer,
+ VkStencilFaceFlags faceMask,
+ uint32_t compareMask);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask(
+ VkCommandBuffer commandBuffer,
+ VkStencilFaceFlags faceMask,
+ uint32_t writeMask);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference(
+ VkCommandBuffer commandBuffer,
+ VkStencilFaceFlags faceMask,
+ uint32_t reference);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets(
+ VkCommandBuffer commandBuffer,
+ VkPipelineBindPoint pipelineBindPoint,
+ VkPipelineLayout layout,
+ uint32_t firstSet,
+ uint32_t descriptorSetCount,
+ const VkDescriptorSet* pDescriptorSets,
+ uint32_t dynamicOffsetCount,
+ const uint32_t* pDynamicOffsets);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer(
+ VkCommandBuffer commandBuffer,
+ VkBuffer buffer,
+ VkDeviceSize offset,
+ VkIndexType indexType);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers(
+ VkCommandBuffer commandBuffer,
+ uint32_t firstBinding,
+ uint32_t bindingCount,
+ const VkBuffer* pBuffers,
+ const VkDeviceSize* pOffsets);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDraw(
+ VkCommandBuffer commandBuffer,
+ uint32_t vertexCount,
+ uint32_t instanceCount,
+ uint32_t firstVertex,
+ uint32_t firstInstance);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed(
+ VkCommandBuffer commandBuffer,
+ uint32_t indexCount,
+ uint32_t instanceCount,
+ uint32_t firstIndex,
+ int32_t vertexOffset,
+ uint32_t firstInstance);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect(
+ VkCommandBuffer commandBuffer,
+ VkBuffer buffer,
+ VkDeviceSize offset,
+ uint32_t drawCount,
+ uint32_t stride);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect(
+ VkCommandBuffer commandBuffer,
+ VkBuffer buffer,
+ VkDeviceSize offset,
+ uint32_t drawCount,
+ uint32_t stride);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDispatch(
+ VkCommandBuffer commandBuffer,
+ uint32_t groupCountX,
+ uint32_t groupCountY,
+ uint32_t groupCountZ);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect(
+ VkCommandBuffer commandBuffer,
+ VkBuffer buffer,
+ VkDeviceSize offset);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer(
+ VkCommandBuffer commandBuffer,
+ VkBuffer srcBuffer,
+ VkBuffer dstBuffer,
+ uint32_t regionCount,
+ const VkBufferCopy* pRegions);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage(
+ VkCommandBuffer commandBuffer,
+ VkImage srcImage,
+ VkImageLayout srcImageLayout,
+ VkImage dstImage,
+ VkImageLayout dstImageLayout,
+ uint32_t regionCount,
+ const VkImageCopy* pRegions);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage(
+ VkCommandBuffer commandBuffer,
+ VkImage srcImage,
+ VkImageLayout srcImageLayout,
+ VkImage dstImage,
+ VkImageLayout dstImageLayout,
+ uint32_t regionCount,
+ const VkImageBlit* pRegions,
+ VkFilter filter);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage(
+ VkCommandBuffer commandBuffer,
+ VkBuffer srcBuffer,
+ VkImage dstImage,
+ VkImageLayout dstImageLayout,
+ uint32_t regionCount,
+ const VkBufferImageCopy* pRegions);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer(
+ VkCommandBuffer commandBuffer,
+ VkImage srcImage,
+ VkImageLayout srcImageLayout,
+ VkBuffer dstBuffer,
+ uint32_t regionCount,
+ const VkBufferImageCopy* pRegions);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer(
+ VkCommandBuffer commandBuffer,
+ VkBuffer dstBuffer,
+ VkDeviceSize dstOffset,
+ VkDeviceSize dataSize,
+ const void* pData);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer(
+ VkCommandBuffer commandBuffer,
+ VkBuffer dstBuffer,
+ VkDeviceSize dstOffset,
+ VkDeviceSize size,
+ uint32_t data);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage(
+ VkCommandBuffer commandBuffer,
+ VkImage image,
+ VkImageLayout imageLayout,
+ const VkClearColorValue* pColor,
+ uint32_t rangeCount,
+ const VkImageSubresourceRange* pRanges);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage(
+ VkCommandBuffer commandBuffer,
+ VkImage image,
+ VkImageLayout imageLayout,
+ const VkClearDepthStencilValue* pDepthStencil,
+ uint32_t rangeCount,
+ const VkImageSubresourceRange* pRanges);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments(
+ VkCommandBuffer commandBuffer,
+ uint32_t attachmentCount,
+ const VkClearAttachment* pAttachments,
+ uint32_t rectCount,
+ const VkClearRect* pRects);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage(
+ VkCommandBuffer commandBuffer,
+ VkImage srcImage,
+ VkImageLayout srcImageLayout,
+ VkImage dstImage,
+ VkImageLayout dstImageLayout,
+ uint32_t regionCount,
+ const VkImageResolve* pRegions);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent(
+ VkCommandBuffer commandBuffer,
+ VkEvent event,
+ VkPipelineStageFlags stageMask);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent(
+ VkCommandBuffer commandBuffer,
+ VkEvent event,
+ VkPipelineStageFlags stageMask);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents(
+ VkCommandBuffer commandBuffer,
+ uint32_t eventCount,
+ const VkEvent* pEvents,
+ VkPipelineStageFlags srcStageMask,
+ VkPipelineStageFlags dstStageMask,
+ uint32_t memoryBarrierCount,
+ const VkMemoryBarrier* pMemoryBarriers,
+ uint32_t bufferMemoryBarrierCount,
+ const VkBufferMemoryBarrier* pBufferMemoryBarriers,
+ uint32_t imageMemoryBarrierCount,
+ const VkImageMemoryBarrier* pImageMemoryBarriers);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier(
+ VkCommandBuffer commandBuffer,
+ VkPipelineStageFlags srcStageMask,
+ VkPipelineStageFlags dstStageMask,
+ VkDependencyFlags dependencyFlags,
+ uint32_t memoryBarrierCount,
+ const VkMemoryBarrier* pMemoryBarriers,
+ uint32_t bufferMemoryBarrierCount,
+ const VkBufferMemoryBarrier* pBufferMemoryBarriers,
+ uint32_t imageMemoryBarrierCount,
+ const VkImageMemoryBarrier* pImageMemoryBarriers);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery(
+ VkCommandBuffer commandBuffer,
+ VkQueryPool queryPool,
+ uint32_t query,
+ VkQueryControlFlags flags);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery(
+ VkCommandBuffer commandBuffer,
+ VkQueryPool queryPool,
+ uint32_t query);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool(
+ VkCommandBuffer commandBuffer,
+ VkQueryPool queryPool,
+ uint32_t firstQuery,
+ uint32_t queryCount);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp(
+ VkCommandBuffer commandBuffer,
+ VkPipelineStageFlagBits pipelineStage,
+ VkQueryPool queryPool,
+ uint32_t query);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults(
+ VkCommandBuffer commandBuffer,
+ VkQueryPool queryPool,
+ uint32_t firstQuery,
+ uint32_t queryCount,
+ VkBuffer dstBuffer,
+ VkDeviceSize dstOffset,
+ VkDeviceSize stride,
+ VkQueryResultFlags flags);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants(
+ VkCommandBuffer commandBuffer,
+ VkPipelineLayout layout,
+ VkShaderStageFlags stageFlags,
+ uint32_t offset,
+ uint32_t size,
+ const void* pValues);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass(
+ VkCommandBuffer commandBuffer,
+ const VkRenderPassBeginInfo* pRenderPassBegin,
+ VkSubpassContents contents);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass(
+ VkCommandBuffer commandBuffer,
+ VkSubpassContents contents);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass(
+ VkCommandBuffer commandBuffer);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands(
+ VkCommandBuffer commandBuffer,
+ uint32_t commandBufferCount,
+ const VkCommandBuffer* pCommandBuffers);
+#endif
+
+#define VK_KHR_surface 1
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
+
+#define VK_KHR_SURFACE_SPEC_VERSION 25
+#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface"
+#define VK_COLORSPACE_SRGB_NONLINEAR_KHR VK_COLOR_SPACE_SRGB_NONLINEAR_KHR
+
+
+typedef enum VkColorSpaceKHR {
+ VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0,
+ VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT = 1000104001,
+ VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT = 1000104002,
+ VK_COLOR_SPACE_DCI_P3_LINEAR_EXT = 1000104003,
+ VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT = 1000104004,
+ VK_COLOR_SPACE_BT709_LINEAR_EXT = 1000104005,
+ VK_COLOR_SPACE_BT709_NONLINEAR_EXT = 1000104006,
+ VK_COLOR_SPACE_BT2020_LINEAR_EXT = 1000104007,
+ VK_COLOR_SPACE_HDR10_ST2084_EXT = 1000104008,
+ VK_COLOR_SPACE_DOLBYVISION_EXT = 1000104009,
+ VK_COLOR_SPACE_HDR10_HLG_EXT = 1000104010,
+ VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT = 1000104011,
+ VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT = 1000104012,
+ VK_COLOR_SPACE_PASS_THROUGH_EXT = 1000104013,
+ VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT = 1000104014,
+ VK_COLOR_SPACE_BEGIN_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
+ VK_COLOR_SPACE_END_RANGE_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
+ VK_COLOR_SPACE_RANGE_SIZE_KHR = (VK_COLOR_SPACE_SRGB_NONLINEAR_KHR - VK_COLOR_SPACE_SRGB_NONLINEAR_KHR + 1),
+ VK_COLOR_SPACE_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkColorSpaceKHR;
+
+typedef enum VkPresentModeKHR {
+ VK_PRESENT_MODE_IMMEDIATE_KHR = 0,
+ VK_PRESENT_MODE_MAILBOX_KHR = 1,
+ VK_PRESENT_MODE_FIFO_KHR = 2,
+ VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3,
+ VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR = 1000111000,
+ VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR = 1000111001,
+ VK_PRESENT_MODE_BEGIN_RANGE_KHR = VK_PRESENT_MODE_IMMEDIATE_KHR,
+ VK_PRESENT_MODE_END_RANGE_KHR = VK_PRESENT_MODE_FIFO_RELAXED_KHR,
+ VK_PRESENT_MODE_RANGE_SIZE_KHR = (VK_PRESENT_MODE_FIFO_RELAXED_KHR - VK_PRESENT_MODE_IMMEDIATE_KHR + 1),
+ VK_PRESENT_MODE_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkPresentModeKHR;
+
+
+typedef enum VkSurfaceTransformFlagBitsKHR {
+ VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 0x00000001,
+ VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 0x00000002,
+ VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 0x00000004,
+ VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR = 0x00000008,
+ VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR = 0x00000010,
+ VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR = 0x00000020,
+ VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 0x00000040,
+ VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 0x00000080,
+ VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100,
+ VK_SURFACE_TRANSFORM_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkSurfaceTransformFlagBitsKHR;
+typedef VkFlags VkSurfaceTransformFlagsKHR;
+
+typedef enum VkCompositeAlphaFlagBitsKHR {
+ VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 0x00000001,
+ VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 0x00000002,
+ VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 0x00000004,
+ VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 0x00000008,
+ VK_COMPOSITE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkCompositeAlphaFlagBitsKHR;
+typedef VkFlags VkCompositeAlphaFlagsKHR;
+
+typedef struct VkSurfaceCapabilitiesKHR {
+ uint32_t minImageCount;
+ uint32_t maxImageCount;
+ VkExtent2D currentExtent;
+ VkExtent2D minImageExtent;
+ VkExtent2D maxImageExtent;
+ uint32_t maxImageArrayLayers;
+ VkSurfaceTransformFlagsKHR supportedTransforms;
+ VkSurfaceTransformFlagBitsKHR currentTransform;
+ VkCompositeAlphaFlagsKHR supportedCompositeAlpha;
+ VkImageUsageFlags supportedUsageFlags;
+} VkSurfaceCapabilitiesKHR;
+
+typedef struct VkSurfaceFormatKHR {
+ VkFormat format;
+ VkColorSpaceKHR colorSpace;
+} VkSurfaceFormatKHR;
+
+
+typedef void (VKAPI_PTR *PFN_vkDestroySurfaceKHR)(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR(
+ VkInstance instance,
+ VkSurfaceKHR surface,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ VkSurfaceKHR surface,
+ VkBool32* pSupported);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(
+ VkPhysicalDevice physicalDevice,
+ VkSurfaceKHR surface,
+ VkSurfaceCapabilitiesKHR* pSurfaceCapabilities);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(
+ VkPhysicalDevice physicalDevice,
+ VkSurfaceKHR surface,
+ uint32_t* pSurfaceFormatCount,
+ VkSurfaceFormatKHR* pSurfaceFormats);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(
+ VkPhysicalDevice physicalDevice,
+ VkSurfaceKHR surface,
+ uint32_t* pPresentModeCount,
+ VkPresentModeKHR* pPresentModes);
+#endif
+
+#define VK_KHR_swapchain 1
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR)
+
+#define VK_KHR_SWAPCHAIN_SPEC_VERSION 68
+#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain"
+
+
+typedef enum VkSwapchainCreateFlagBitsKHR {
+ VK_SWAPCHAIN_CREATE_BIND_SFR_BIT_KHX = 0x00000001,
+ VK_SWAPCHAIN_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkSwapchainCreateFlagBitsKHR;
+typedef VkFlags VkSwapchainCreateFlagsKHR;
+
+typedef struct VkSwapchainCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkSwapchainCreateFlagsKHR flags;
+ VkSurfaceKHR surface;
+ uint32_t minImageCount;
+ VkFormat imageFormat;
+ VkColorSpaceKHR imageColorSpace;
+ VkExtent2D imageExtent;
+ uint32_t imageArrayLayers;
+ VkImageUsageFlags imageUsage;
+ VkSharingMode imageSharingMode;
+ uint32_t queueFamilyIndexCount;
+ const uint32_t* pQueueFamilyIndices;
+ VkSurfaceTransformFlagBitsKHR preTransform;
+ VkCompositeAlphaFlagBitsKHR compositeAlpha;
+ VkPresentModeKHR presentMode;
+ VkBool32 clipped;
+ VkSwapchainKHR oldSwapchain;
+} VkSwapchainCreateInfoKHR;
+
+typedef struct VkPresentInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t waitSemaphoreCount;
+ const VkSemaphore* pWaitSemaphores;
+ uint32_t swapchainCount;
+ const VkSwapchainKHR* pSwapchains;
+ const uint32_t* pImageIndices;
+ VkResult* pResults;
+} VkPresentInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain);
+typedef void (VKAPI_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages);
+typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex);
+typedef VkResult (VKAPI_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR* pPresentInfo);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR(
+ VkDevice device,
+ const VkSwapchainCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSwapchainKHR* pSwapchain);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR(
+ VkDevice device,
+ VkSwapchainKHR swapchain,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(
+ VkDevice device,
+ VkSwapchainKHR swapchain,
+ uint32_t* pSwapchainImageCount,
+ VkImage* pSwapchainImages);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR(
+ VkDevice device,
+ VkSwapchainKHR swapchain,
+ uint64_t timeout,
+ VkSemaphore semaphore,
+ VkFence fence,
+ uint32_t* pImageIndex);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR(
+ VkQueue queue,
+ const VkPresentInfoKHR* pPresentInfo);
+#endif
+
+#define VK_KHR_display 1
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayModeKHR)
+
+#define VK_KHR_DISPLAY_SPEC_VERSION 21
+#define VK_KHR_DISPLAY_EXTENSION_NAME "VK_KHR_display"
+
+
+typedef enum VkDisplayPlaneAlphaFlagBitsKHR {
+ VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR = 0x00000001,
+ VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR = 0x00000002,
+ VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR = 0x00000004,
+ VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR = 0x00000008,
+ VK_DISPLAY_PLANE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkDisplayPlaneAlphaFlagBitsKHR;
+typedef VkFlags VkDisplayPlaneAlphaFlagsKHR;
+typedef VkFlags VkDisplayModeCreateFlagsKHR;
+typedef VkFlags VkDisplaySurfaceCreateFlagsKHR;
+
+typedef struct VkDisplayPropertiesKHR {
+ VkDisplayKHR display;
+ const char* displayName;
+ VkExtent2D physicalDimensions;
+ VkExtent2D physicalResolution;
+ VkSurfaceTransformFlagsKHR supportedTransforms;
+ VkBool32 planeReorderPossible;
+ VkBool32 persistentContent;
+} VkDisplayPropertiesKHR;
+
+typedef struct VkDisplayModeParametersKHR {
+ VkExtent2D visibleRegion;
+ uint32_t refreshRate;
+} VkDisplayModeParametersKHR;
+
+typedef struct VkDisplayModePropertiesKHR {
+ VkDisplayModeKHR displayMode;
+ VkDisplayModeParametersKHR parameters;
+} VkDisplayModePropertiesKHR;
+
+typedef struct VkDisplayModeCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkDisplayModeCreateFlagsKHR flags;
+ VkDisplayModeParametersKHR parameters;
+} VkDisplayModeCreateInfoKHR;
+
+typedef struct VkDisplayPlaneCapabilitiesKHR {
+ VkDisplayPlaneAlphaFlagsKHR supportedAlpha;
+ VkOffset2D minSrcPosition;
+ VkOffset2D maxSrcPosition;
+ VkExtent2D minSrcExtent;
+ VkExtent2D maxSrcExtent;
+ VkOffset2D minDstPosition;
+ VkOffset2D maxDstPosition;
+ VkExtent2D minDstExtent;
+ VkExtent2D maxDstExtent;
+} VkDisplayPlaneCapabilitiesKHR;
+
+typedef struct VkDisplayPlanePropertiesKHR {
+ VkDisplayKHR currentDisplay;
+ uint32_t currentStackIndex;
+} VkDisplayPlanePropertiesKHR;
+
+typedef struct VkDisplaySurfaceCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkDisplaySurfaceCreateFlagsKHR flags;
+ VkDisplayModeKHR displayMode;
+ uint32_t planeIndex;
+ uint32_t planeStackIndex;
+ VkSurfaceTransformFlagBitsKHR transform;
+ float globalAlpha;
+ VkDisplayPlaneAlphaFlagBitsKHR alphaMode;
+ VkExtent2D imageExtent;
+} VkDisplaySurfaceCreateInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPropertiesKHR* pProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlanePropertiesKHR* pProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneSupportedDisplaysKHR)(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t* pDisplayCount, VkDisplayKHR* pDisplays);
+typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayModePropertiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t* pPropertyCount, VkDisplayModePropertiesKHR* pProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayModeKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode);
+typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR* pCapabilities);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayPlaneSurfaceKHR)(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pPropertyCount,
+ VkDisplayPropertiesKHR* pProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pPropertyCount,
+ VkDisplayPlanePropertiesKHR* pProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t planeIndex,
+ uint32_t* pDisplayCount,
+ VkDisplayKHR* pDisplays);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR(
+ VkPhysicalDevice physicalDevice,
+ VkDisplayKHR display,
+ uint32_t* pPropertyCount,
+ VkDisplayModePropertiesKHR* pProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR(
+ VkPhysicalDevice physicalDevice,
+ VkDisplayKHR display,
+ const VkDisplayModeCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDisplayModeKHR* pMode);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR(
+ VkPhysicalDevice physicalDevice,
+ VkDisplayModeKHR mode,
+ uint32_t planeIndex,
+ VkDisplayPlaneCapabilitiesKHR* pCapabilities);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR(
+ VkInstance instance,
+ const VkDisplaySurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+#endif
+
+#define VK_KHR_display_swapchain 1
+#define VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION 9
+#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME "VK_KHR_display_swapchain"
+
+typedef struct VkDisplayPresentInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkRect2D srcRect;
+ VkRect2D dstRect;
+ VkBool32 persistent;
+} VkDisplayPresentInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateSharedSwapchainsKHR)(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR(
+ VkDevice device,
+ uint32_t swapchainCount,
+ const VkSwapchainCreateInfoKHR* pCreateInfos,
+ const VkAllocationCallbacks* pAllocator,
+ VkSwapchainKHR* pSwapchains);
+#endif
+
+#ifdef VK_USE_PLATFORM_XLIB_KHR
+#define VK_KHR_xlib_surface 1
+#include <X11/Xlib.h>
+
+#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6
+#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface"
+
+typedef VkFlags VkXlibSurfaceCreateFlagsKHR;
+
+typedef struct VkXlibSurfaceCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkXlibSurfaceCreateFlagsKHR flags;
+ Display* dpy;
+ Window window;
+} VkXlibSurfaceCreateInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR(
+ VkInstance instance,
+ const VkXlibSurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+
+VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ Display* dpy,
+ VisualID visualID);
+#endif
+#endif /* VK_USE_PLATFORM_XLIB_KHR */
+
+#ifdef VK_USE_PLATFORM_XCB_KHR
+#define VK_KHR_xcb_surface 1
+#include <xcb/xcb.h>
+
+#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6
+#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface"
+
+typedef VkFlags VkXcbSurfaceCreateFlagsKHR;
+
+typedef struct VkXcbSurfaceCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkXcbSurfaceCreateFlagsKHR flags;
+ xcb_connection_t* connection;
+ xcb_window_t window;
+} VkXcbSurfaceCreateInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR(
+ VkInstance instance,
+ const VkXcbSurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+
+VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ xcb_connection_t* connection,
+ xcb_visualid_t visual_id);
+#endif
+#endif /* VK_USE_PLATFORM_XCB_KHR */
+
+#ifdef VK_USE_PLATFORM_WAYLAND_KHR
+#define VK_KHR_wayland_surface 1
+#include <wayland-client.h>
+
+#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6
+#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface"
+
+typedef VkFlags VkWaylandSurfaceCreateFlagsKHR;
+
+typedef struct VkWaylandSurfaceCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkWaylandSurfaceCreateFlagsKHR flags;
+ struct wl_display* display;
+ struct wl_surface* surface;
+} VkWaylandSurfaceCreateInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR(
+ VkInstance instance,
+ const VkWaylandSurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+
+VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ struct wl_display* display);
+#endif
+#endif /* VK_USE_PLATFORM_WAYLAND_KHR */
+
+#ifdef VK_USE_PLATFORM_MIR_KHR
+#define VK_KHR_mir_surface 1
+#include <mir_toolkit/client_types.h>
+
+#define VK_KHR_MIR_SURFACE_SPEC_VERSION 4
+#define VK_KHR_MIR_SURFACE_EXTENSION_NAME "VK_KHR_mir_surface"
+
+typedef VkFlags VkMirSurfaceCreateFlagsKHR;
+
+typedef struct VkMirSurfaceCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkMirSurfaceCreateFlagsKHR flags;
+ MirConnection* connection;
+ MirSurface* mirSurface;
+} VkMirSurfaceCreateInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateMirSurfaceKHR)(VkInstance instance, const VkMirSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceMirPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, MirConnection* connection);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateMirSurfaceKHR(
+ VkInstance instance,
+ const VkMirSurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+
+VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceMirPresentationSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex,
+ MirConnection* connection);
+#endif
+#endif /* VK_USE_PLATFORM_MIR_KHR */
+
+#ifdef VK_USE_PLATFORM_ANDROID_KHR
+#define VK_KHR_android_surface 1
+#include <android/native_window.h>
+
+#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6
+#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface"
+
+typedef VkFlags VkAndroidSurfaceCreateFlagsKHR;
+
+typedef struct VkAndroidSurfaceCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkAndroidSurfaceCreateFlagsKHR flags;
+ ANativeWindow* window;
+} VkAndroidSurfaceCreateInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR(
+ VkInstance instance,
+ const VkAndroidSurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+#endif
+#endif /* VK_USE_PLATFORM_ANDROID_KHR */
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+#define VK_KHR_win32_surface 1
+#include <windows.h>
+
+#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6
+#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface"
+
+typedef VkFlags VkWin32SurfaceCreateFlagsKHR;
+
+typedef struct VkWin32SurfaceCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkWin32SurfaceCreateFlagsKHR flags;
+ HINSTANCE hinstance;
+ HWND hwnd;
+} VkWin32SurfaceCreateInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(
+ VkInstance instance,
+ const VkWin32SurfaceCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+
+VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t queueFamilyIndex);
+#endif
+#endif /* VK_USE_PLATFORM_WIN32_KHR */
+
+#define VK_KHR_sampler_mirror_clamp_to_edge 1
+#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION 1
+#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME "VK_KHR_sampler_mirror_clamp_to_edge"
+
+
+#define VK_KHR_get_physical_device_properties2 1
+#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION 1
+#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_physical_device_properties2"
+
+typedef struct VkPhysicalDeviceFeatures2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkPhysicalDeviceFeatures features;
+} VkPhysicalDeviceFeatures2KHR;
+
+typedef struct VkPhysicalDeviceProperties2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkPhysicalDeviceProperties properties;
+} VkPhysicalDeviceProperties2KHR;
+
+typedef struct VkFormatProperties2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkFormatProperties formatProperties;
+} VkFormatProperties2KHR;
+
+typedef struct VkImageFormatProperties2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkImageFormatProperties imageFormatProperties;
+} VkImageFormatProperties2KHR;
+
+typedef struct VkPhysicalDeviceImageFormatInfo2KHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkFormat format;
+ VkImageType type;
+ VkImageTiling tiling;
+ VkImageUsageFlags usage;
+ VkImageCreateFlags flags;
+} VkPhysicalDeviceImageFormatInfo2KHR;
+
+typedef struct VkQueueFamilyProperties2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkQueueFamilyProperties queueFamilyProperties;
+} VkQueueFamilyProperties2KHR;
+
+typedef struct VkPhysicalDeviceMemoryProperties2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkPhysicalDeviceMemoryProperties memoryProperties;
+} VkPhysicalDeviceMemoryProperties2KHR;
+
+typedef struct VkSparseImageFormatProperties2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkSparseImageFormatProperties properties;
+} VkSparseImageFormatProperties2KHR;
+
+typedef struct VkPhysicalDeviceSparseImageFormatInfo2KHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkFormat format;
+ VkImageType type;
+ VkSampleCountFlagBits samples;
+ VkImageUsageFlags usage;
+ VkImageTiling tiling;
+} VkPhysicalDeviceSparseImageFormatInfo2KHR;
+
+
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2KHR* pFeatures);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2KHR* pProperties);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties2KHR)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2KHR* pFormatProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo, VkImageFormatProperties2KHR* pImageFormatProperties);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2KHR* pQueueFamilyProperties);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2KHR* pProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2KHR(
+ VkPhysicalDevice physicalDevice,
+ VkPhysicalDeviceFeatures2KHR* pFeatures);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ VkPhysicalDeviceProperties2KHR* pProperties);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ VkFormat format,
+ VkFormatProperties2KHR* pFormatProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceImageFormatInfo2KHR* pImageFormatInfo,
+ VkImageFormatProperties2KHR* pImageFormatProperties);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ uint32_t* pQueueFamilyPropertyCount,
+ VkQueueFamilyProperties2KHR* pQueueFamilyProperties);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ VkPhysicalDeviceMemoryProperties2KHR* pMemoryProperties);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2KHR(
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceSparseImageFormatInfo2KHR* pFormatInfo,
+ uint32_t* pPropertyCount,
+ VkSparseImageFormatProperties2KHR* pProperties);
+#endif
+
+#define VK_KHR_shader_draw_parameters 1
+#define VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION 1
+#define VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME "VK_KHR_shader_draw_parameters"
+
+
+#define VK_KHR_maintenance1 1
+#define VK_KHR_MAINTENANCE1_SPEC_VERSION 1
+#define VK_KHR_MAINTENANCE1_EXTENSION_NAME "VK_KHR_maintenance1"
+
+typedef VkFlags VkCommandPoolTrimFlagsKHR;
+
+typedef void (VKAPI_PTR *PFN_vkTrimCommandPoolKHR)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlagsKHR flags);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkTrimCommandPoolKHR(
+ VkDevice device,
+ VkCommandPool commandPool,
+ VkCommandPoolTrimFlagsKHR flags);
+#endif
+
+#define VK_KHR_external_memory_capabilities 1
+#define VK_LUID_SIZE_KHR 8
+#define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_memory_capabilities"
+
+
+typedef enum VkExternalMemoryHandleTypeFlagBitsKHR {
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = 0x00000001,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = 0x00000002,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = 0x00000004,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT_KHR = 0x00000008,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT_KHR = 0x00000010,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT_KHR = 0x00000020,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT_KHR = 0x00000040,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkExternalMemoryHandleTypeFlagBitsKHR;
+typedef VkFlags VkExternalMemoryHandleTypeFlagsKHR;
+
+typedef enum VkExternalMemoryFeatureFlagBitsKHR {
+ VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_KHR = 0x00000001,
+ VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHR = 0x00000002,
+ VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHR = 0x00000004,
+ VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkExternalMemoryFeatureFlagBitsKHR;
+typedef VkFlags VkExternalMemoryFeatureFlagsKHR;
+
+typedef struct VkExternalMemoryPropertiesKHR {
+ VkExternalMemoryFeatureFlagsKHR externalMemoryFeatures;
+ VkExternalMemoryHandleTypeFlagsKHR exportFromImportedHandleTypes;
+ VkExternalMemoryHandleTypeFlagsKHR compatibleHandleTypes;
+} VkExternalMemoryPropertiesKHR;
+
+typedef struct VkPhysicalDeviceExternalImageFormatInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagBitsKHR handleType;
+} VkPhysicalDeviceExternalImageFormatInfoKHR;
+
+typedef struct VkExternalImageFormatPropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkExternalMemoryPropertiesKHR externalMemoryProperties;
+} VkExternalImageFormatPropertiesKHR;
+
+typedef struct VkPhysicalDeviceExternalBufferInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkBufferCreateFlags flags;
+ VkBufferUsageFlags usage;
+ VkExternalMemoryHandleTypeFlagBitsKHR handleType;
+} VkPhysicalDeviceExternalBufferInfoKHR;
+
+typedef struct VkExternalBufferPropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkExternalMemoryPropertiesKHR externalMemoryProperties;
+} VkExternalBufferPropertiesKHR;
+
+typedef struct VkPhysicalDeviceIDPropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ uint8_t deviceUUID[VK_UUID_SIZE];
+ uint8_t driverUUID[VK_UUID_SIZE];
+ uint8_t deviceLUID[VK_LUID_SIZE_KHR];
+ uint32_t deviceNodeMask;
+ VkBool32 deviceLUIDValid;
+} VkPhysicalDeviceIDPropertiesKHR;
+
+
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfoKHR* pExternalBufferInfo, VkExternalBufferPropertiesKHR* pExternalBufferProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferPropertiesKHR(
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceExternalBufferInfoKHR* pExternalBufferInfo,
+ VkExternalBufferPropertiesKHR* pExternalBufferProperties);
+#endif
+
+#define VK_KHR_external_memory 1
+#define VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME "VK_KHR_external_memory"
+#define VK_QUEUE_FAMILY_EXTERNAL_KHR (~0U-1)
+
+typedef struct VkExternalMemoryImageCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagsKHR handleTypes;
+} VkExternalMemoryImageCreateInfoKHR;
+
+typedef struct VkExternalMemoryBufferCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagsKHR handleTypes;
+} VkExternalMemoryBufferCreateInfoKHR;
+
+typedef struct VkExportMemoryAllocateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagsKHR handleTypes;
+} VkExportMemoryAllocateInfoKHR;
+
+
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+#define VK_KHR_external_memory_win32 1
+#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32"
+
+typedef struct VkImportMemoryWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagBitsKHR handleType;
+ HANDLE handle;
+ LPCWSTR name;
+} VkImportMemoryWin32HandleInfoKHR;
+
+typedef struct VkExportMemoryWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ const SECURITY_ATTRIBUTES* pAttributes;
+ DWORD dwAccess;
+ LPCWSTR name;
+} VkExportMemoryWin32HandleInfoKHR;
+
+typedef struct VkMemoryWin32HandlePropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t memoryTypeBits;
+} VkMemoryWin32HandlePropertiesKHR;
+
+typedef struct VkMemoryGetWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceMemory memory;
+ VkExternalMemoryHandleTypeFlagBitsKHR handleType;
+} VkMemoryGetWin32HandleInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
+typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBitsKHR handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR(
+ VkDevice device,
+ const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo,
+ HANDLE* pHandle);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR(
+ VkDevice device,
+ VkExternalMemoryHandleTypeFlagBitsKHR handleType,
+ HANDLE handle,
+ VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties);
+#endif
+#endif /* VK_USE_PLATFORM_WIN32_KHR */
+
+#define VK_KHR_external_memory_fd 1
+#define VK_KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME "VK_KHR_external_memory_fd"
+
+typedef struct VkImportMemoryFdInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagBitsKHR handleType;
+ int fd;
+} VkImportMemoryFdInfoKHR;
+
+typedef struct VkMemoryFdPropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t memoryTypeBits;
+} VkMemoryFdPropertiesKHR;
+
+typedef struct VkMemoryGetFdInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceMemory memory;
+ VkExternalMemoryHandleTypeFlagBitsKHR handleType;
+} VkMemoryGetFdInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryFdKHR)(VkDevice device, const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd);
+typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryFdPropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBitsKHR handleType, int fd, VkMemoryFdPropertiesKHR* pMemoryFdProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdKHR(
+ VkDevice device,
+ const VkMemoryGetFdInfoKHR* pGetFdInfo,
+ int* pFd);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR(
+ VkDevice device,
+ VkExternalMemoryHandleTypeFlagBitsKHR handleType,
+ int fd,
+ VkMemoryFdPropertiesKHR* pMemoryFdProperties);
+#endif
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+#define VK_KHR_win32_keyed_mutex 1
+#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1
+#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex"
+
+typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t acquireCount;
+ const VkDeviceMemory* pAcquireSyncs;
+ const uint64_t* pAcquireKeys;
+ const uint32_t* pAcquireTimeouts;
+ uint32_t releaseCount;
+ const VkDeviceMemory* pReleaseSyncs;
+ const uint64_t* pReleaseKeys;
+} VkWin32KeyedMutexAcquireReleaseInfoKHR;
+
+
+#endif /* VK_USE_PLATFORM_WIN32_KHR */
+
+#define VK_KHR_external_semaphore_capabilities 1
+#define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_semaphore_capabilities"
+
+
+typedef enum VkExternalSemaphoreHandleTypeFlagBitsKHR {
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = 0x00000001,
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = 0x00000002,
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = 0x00000004,
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT_KHR = 0x00000008,
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR = 0x00000010,
+ VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkExternalSemaphoreHandleTypeFlagBitsKHR;
+typedef VkFlags VkExternalSemaphoreHandleTypeFlagsKHR;
+
+typedef enum VkExternalSemaphoreFeatureFlagBitsKHR {
+ VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT_KHR = 0x00000001,
+ VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT_KHR = 0x00000002,
+ VK_EXTERNAL_SEMAPHORE_FEATURE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkExternalSemaphoreFeatureFlagBitsKHR;
+typedef VkFlags VkExternalSemaphoreFeatureFlagsKHR;
+
+typedef struct VkPhysicalDeviceExternalSemaphoreInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalSemaphoreHandleTypeFlagBitsKHR handleType;
+} VkPhysicalDeviceExternalSemaphoreInfoKHR;
+
+typedef struct VkExternalSemaphorePropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkExternalSemaphoreHandleTypeFlagsKHR exportFromImportedHandleTypes;
+ VkExternalSemaphoreHandleTypeFlagsKHR compatibleHandleTypes;
+ VkExternalSemaphoreFeatureFlagsKHR externalSemaphoreFeatures;
+} VkExternalSemaphorePropertiesKHR;
+
+
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfoKHR* pExternalSemaphoreInfo, VkExternalSemaphorePropertiesKHR* pExternalSemaphoreProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphorePropertiesKHR(
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceExternalSemaphoreInfoKHR* pExternalSemaphoreInfo,
+ VkExternalSemaphorePropertiesKHR* pExternalSemaphoreProperties);
+#endif
+
+#define VK_KHR_external_semaphore 1
+#define VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_KHR_external_semaphore"
+
+
+typedef enum VkSemaphoreImportFlagBitsKHR {
+ VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR = 0x00000001,
+ VK_SEMAPHORE_IMPORT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkSemaphoreImportFlagBitsKHR;
+typedef VkFlags VkSemaphoreImportFlagsKHR;
+
+typedef struct VkExportSemaphoreCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalSemaphoreHandleTypeFlagsKHR handleTypes;
+} VkExportSemaphoreCreateInfoKHR;
+
+
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+#define VK_KHR_external_semaphore_win32 1
+#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32"
+
+typedef struct VkImportSemaphoreWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkSemaphore semaphore;
+ VkSemaphoreImportFlagsKHR flags;
+ VkExternalSemaphoreHandleTypeFlagBitsKHR handleType;
+ HANDLE handle;
+ LPCWSTR name;
+} VkImportSemaphoreWin32HandleInfoKHR;
+
+typedef struct VkExportSemaphoreWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ const SECURITY_ATTRIBUTES* pAttributes;
+ DWORD dwAccess;
+ LPCWSTR name;
+} VkExportSemaphoreWin32HandleInfoKHR;
+
+typedef struct VkD3D12FenceSubmitInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t waitSemaphoreValuesCount;
+ const uint64_t* pWaitSemaphoreValues;
+ uint32_t signalSemaphoreValuesCount;
+ const uint64_t* pSignalSemaphoreValues;
+} VkD3D12FenceSubmitInfoKHR;
+
+typedef struct VkSemaphoreGetWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkSemaphore semaphore;
+ VkExternalSemaphoreHandleTypeFlagBitsKHR handleType;
+} VkSemaphoreGetWin32HandleInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
+typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR(
+ VkDevice device,
+ const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR(
+ VkDevice device,
+ const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo,
+ HANDLE* pHandle);
+#endif
+#endif /* VK_USE_PLATFORM_WIN32_KHR */
+
+#define VK_KHR_external_semaphore_fd 1
+#define VK_KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME "VK_KHR_external_semaphore_fd"
+
+typedef struct VkImportSemaphoreFdInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkSemaphore semaphore;
+ VkSemaphoreImportFlagsKHR flags;
+ VkExternalSemaphoreHandleTypeFlagBitsKHR handleType;
+ int fd;
+} VkImportSemaphoreFdInfoKHR;
+
+typedef struct VkSemaphoreGetFdInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkSemaphore semaphore;
+ VkExternalSemaphoreHandleTypeFlagBitsKHR handleType;
+} VkSemaphoreGetFdInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreFdKHR)(VkDevice device, const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo);
+typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreFdKHR)(VkDevice device, const VkSemaphoreGetFdInfoKHR* pGetFdInfo, int* pFd);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreFdKHR(
+ VkDevice device,
+ const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHR(
+ VkDevice device,
+ const VkSemaphoreGetFdInfoKHR* pGetFdInfo,
+ int* pFd);
+#endif
+
+#define VK_KHR_push_descriptor 1
+#define VK_KHR_PUSH_DESCRIPTOR_SPEC_VERSION 1
+#define VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME "VK_KHR_push_descriptor"
+
+typedef struct VkPhysicalDevicePushDescriptorPropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t maxPushDescriptors;
+} VkPhysicalDevicePushDescriptorPropertiesKHR;
+
+
+typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetKHR)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetKHR(
+ VkCommandBuffer commandBuffer,
+ VkPipelineBindPoint pipelineBindPoint,
+ VkPipelineLayout layout,
+ uint32_t set,
+ uint32_t descriptorWriteCount,
+ const VkWriteDescriptorSet* pDescriptorWrites);
+#endif
+
+#define VK_KHR_16bit_storage 1
+#define VK_KHR_16BIT_STORAGE_SPEC_VERSION 1
+#define VK_KHR_16BIT_STORAGE_EXTENSION_NAME "VK_KHR_16bit_storage"
+
+typedef struct VkPhysicalDevice16BitStorageFeaturesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 storageBuffer16BitAccess;
+ VkBool32 uniformAndStorageBuffer16BitAccess;
+ VkBool32 storagePushConstant16;
+ VkBool32 storageInputOutput16;
+} VkPhysicalDevice16BitStorageFeaturesKHR;
+
+
+
+#define VK_KHR_incremental_present 1
+#define VK_KHR_INCREMENTAL_PRESENT_SPEC_VERSION 1
+#define VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME "VK_KHR_incremental_present"
+
+typedef struct VkRectLayerKHR {
+ VkOffset2D offset;
+ VkExtent2D extent;
+ uint32_t layer;
+} VkRectLayerKHR;
+
+typedef struct VkPresentRegionKHR {
+ uint32_t rectangleCount;
+ const VkRectLayerKHR* pRectangles;
+} VkPresentRegionKHR;
+
+typedef struct VkPresentRegionsKHR {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t swapchainCount;
+ const VkPresentRegionKHR* pRegions;
+} VkPresentRegionsKHR;
+
+
+
+#define VK_KHR_descriptor_update_template 1
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplateKHR)
+
+#define VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION 1
+#define VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME "VK_KHR_descriptor_update_template"
+
+
+typedef enum VkDescriptorUpdateTemplateTypeKHR {
+ VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR = 0,
+ VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR = 1,
+ VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_BEGIN_RANGE_KHR = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR,
+ VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_END_RANGE_KHR = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR,
+ VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_RANGE_SIZE_KHR = (VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR - VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR + 1),
+ VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkDescriptorUpdateTemplateTypeKHR;
+
+typedef VkFlags VkDescriptorUpdateTemplateCreateFlagsKHR;
+
+typedef struct VkDescriptorUpdateTemplateEntryKHR {
+ uint32_t dstBinding;
+ uint32_t dstArrayElement;
+ uint32_t descriptorCount;
+ VkDescriptorType descriptorType;
+ size_t offset;
+ size_t stride;
+} VkDescriptorUpdateTemplateEntryKHR;
+
+typedef struct VkDescriptorUpdateTemplateCreateInfoKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkDescriptorUpdateTemplateCreateFlagsKHR flags;
+ uint32_t descriptorUpdateEntryCount;
+ const VkDescriptorUpdateTemplateEntryKHR* pDescriptorUpdateEntries;
+ VkDescriptorUpdateTemplateTypeKHR templateType;
+ VkDescriptorSetLayout descriptorSetLayout;
+ VkPipelineBindPoint pipelineBindPoint;
+ VkPipelineLayout pipelineLayout;
+ uint32_t set;
+} VkDescriptorUpdateTemplateCreateInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorUpdateTemplateKHR)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplateKHR* pDescriptorUpdateTemplate);
+typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorUpdateTemplateKHR)(VkDevice device, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator);
+typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSetWithTemplateKHR)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, const void* pData);
+typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetWithTemplateKHR)(VkCommandBuffer commandBuffer, VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate, VkPipelineLayout layout, uint32_t set, const void* pData);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplateKHR(
+ VkDevice device,
+ const VkDescriptorUpdateTemplateCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDescriptorUpdateTemplateKHR* pDescriptorUpdateTemplate);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplateKHR(
+ VkDevice device,
+ VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplateKHR(
+ VkDevice device,
+ VkDescriptorSet descriptorSet,
+ VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
+ const void* pData);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplateKHR(
+ VkCommandBuffer commandBuffer,
+ VkDescriptorUpdateTemplateKHR descriptorUpdateTemplate,
+ VkPipelineLayout layout,
+ uint32_t set,
+ const void* pData);
+#endif
+
+#define VK_KHR_shared_presentable_image 1
+#define VK_KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION 1
+#define VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME "VK_KHR_shared_presentable_image"
+
+typedef struct VkSharedPresentSurfaceCapabilitiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkImageUsageFlags sharedPresentSupportedUsageFlags;
+} VkSharedPresentSurfaceCapabilitiesKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainStatusKHR)(VkDevice device, VkSwapchainKHR swapchain);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainStatusKHR(
+ VkDevice device,
+ VkSwapchainKHR swapchain);
+#endif
+
+#define VK_KHR_external_fence_capabilities 1
+#define VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_fence_capabilities"
+
+
+typedef enum VkExternalFenceHandleTypeFlagBitsKHR {
+ VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = 0x00000001,
+ VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = 0x00000002,
+ VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = 0x00000004,
+ VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR = 0x00000008,
+ VK_EXTERNAL_FENCE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkExternalFenceHandleTypeFlagBitsKHR;
+typedef VkFlags VkExternalFenceHandleTypeFlagsKHR;
+
+typedef enum VkExternalFenceFeatureFlagBitsKHR {
+ VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT_KHR = 0x00000001,
+ VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT_KHR = 0x00000002,
+ VK_EXTERNAL_FENCE_FEATURE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkExternalFenceFeatureFlagBitsKHR;
+typedef VkFlags VkExternalFenceFeatureFlagsKHR;
+
+typedef struct VkPhysicalDeviceExternalFenceInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalFenceHandleTypeFlagBitsKHR handleType;
+} VkPhysicalDeviceExternalFenceInfoKHR;
+
+typedef struct VkExternalFencePropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkExternalFenceHandleTypeFlagsKHR exportFromImportedHandleTypes;
+ VkExternalFenceHandleTypeFlagsKHR compatibleHandleTypes;
+ VkExternalFenceFeatureFlagsKHR externalFenceFeatures;
+} VkExternalFencePropertiesKHR;
+
+
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfoKHR* pExternalFenceInfo, VkExternalFencePropertiesKHR* pExternalFenceProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFencePropertiesKHR(
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceExternalFenceInfoKHR* pExternalFenceInfo,
+ VkExternalFencePropertiesKHR* pExternalFenceProperties);
+#endif
+
+#define VK_KHR_external_fence 1
+#define VK_KHR_EXTERNAL_FENCE_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME "VK_KHR_external_fence"
+
+
+typedef enum VkFenceImportFlagBitsKHR {
+ VK_FENCE_IMPORT_TEMPORARY_BIT_KHR = 0x00000001,
+ VK_FENCE_IMPORT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkFenceImportFlagBitsKHR;
+typedef VkFlags VkFenceImportFlagsKHR;
+
+typedef struct VkExportFenceCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalFenceHandleTypeFlagsKHR handleTypes;
+} VkExportFenceCreateInfoKHR;
+
+
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+#define VK_KHR_external_fence_win32 1
+#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32"
+
+typedef struct VkImportFenceWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkFence fence;
+ VkFenceImportFlagsKHR flags;
+ VkExternalFenceHandleTypeFlagBitsKHR handleType;
+ HANDLE handle;
+ LPCWSTR name;
+} VkImportFenceWin32HandleInfoKHR;
+
+typedef struct VkExportFenceWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ const SECURITY_ATTRIBUTES* pAttributes;
+ DWORD dwAccess;
+ LPCWSTR name;
+} VkExportFenceWin32HandleInfoKHR;
+
+typedef struct VkFenceGetWin32HandleInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkFence fence;
+ VkExternalFenceHandleTypeFlagBitsKHR handleType;
+} VkFenceGetWin32HandleInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
+typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR(
+ VkDevice device,
+ const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR(
+ VkDevice device,
+ const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo,
+ HANDLE* pHandle);
+#endif
+#endif /* VK_USE_PLATFORM_WIN32_KHR */
+
+#define VK_KHR_external_fence_fd 1
+#define VK_KHR_EXTERNAL_FENCE_FD_SPEC_VERSION 1
+#define VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME "VK_KHR_external_fence_fd"
+
+typedef struct VkImportFenceFdInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkFence fence;
+ VkFenceImportFlagsKHR flags;
+ VkExternalFenceHandleTypeFlagBitsKHR handleType;
+ int fd;
+} VkImportFenceFdInfoKHR;
+
+typedef struct VkFenceGetFdInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkFence fence;
+ VkExternalFenceHandleTypeFlagBitsKHR handleType;
+} VkFenceGetFdInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkImportFenceFdKHR)(VkDevice device, const VkImportFenceFdInfoKHR* pImportFenceFdInfo);
+typedef VkResult (VKAPI_PTR *PFN_vkGetFenceFdKHR)(VkDevice device, const VkFenceGetFdInfoKHR* pGetFdInfo, int* pFd);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceFdKHR(
+ VkDevice device,
+ const VkImportFenceFdInfoKHR* pImportFenceFdInfo);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceFdKHR(
+ VkDevice device,
+ const VkFenceGetFdInfoKHR* pGetFdInfo,
+ int* pFd);
+#endif
+
+#define VK_KHR_maintenance2 1
+#define VK_KHR_MAINTENANCE2_SPEC_VERSION 1
+#define VK_KHR_MAINTENANCE2_EXTENSION_NAME "VK_KHR_maintenance2"
+
+
+typedef enum VkPointClippingBehaviorKHR {
+ VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES_KHR = 0,
+ VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY_KHR = 1,
+ VK_POINT_CLIPPING_BEHAVIOR_BEGIN_RANGE_KHR = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES_KHR,
+ VK_POINT_CLIPPING_BEHAVIOR_END_RANGE_KHR = VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY_KHR,
+ VK_POINT_CLIPPING_BEHAVIOR_RANGE_SIZE_KHR = (VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY_KHR - VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES_KHR + 1),
+ VK_POINT_CLIPPING_BEHAVIOR_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkPointClippingBehaviorKHR;
+
+typedef enum VkTessellationDomainOriginKHR {
+ VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT_KHR = 0,
+ VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT_KHR = 1,
+ VK_TESSELLATION_DOMAIN_ORIGIN_BEGIN_RANGE_KHR = VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT_KHR,
+ VK_TESSELLATION_DOMAIN_ORIGIN_END_RANGE_KHR = VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT_KHR,
+ VK_TESSELLATION_DOMAIN_ORIGIN_RANGE_SIZE_KHR = (VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT_KHR - VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT_KHR + 1),
+ VK_TESSELLATION_DOMAIN_ORIGIN_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkTessellationDomainOriginKHR;
+
+typedef struct VkPhysicalDevicePointClippingPropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkPointClippingBehaviorKHR pointClippingBehavior;
+} VkPhysicalDevicePointClippingPropertiesKHR;
+
+typedef struct VkInputAttachmentAspectReferenceKHR {
+ uint32_t subpass;
+ uint32_t inputAttachmentIndex;
+ VkImageAspectFlags aspectMask;
+} VkInputAttachmentAspectReferenceKHR;
+
+typedef struct VkRenderPassInputAttachmentAspectCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t aspectReferenceCount;
+ const VkInputAttachmentAspectReferenceKHR* pAspectReferences;
+} VkRenderPassInputAttachmentAspectCreateInfoKHR;
+
+typedef struct VkImageViewUsageCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkImageUsageFlags usage;
+} VkImageViewUsageCreateInfoKHR;
+
+typedef struct VkPipelineTessellationDomainOriginStateCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkTessellationDomainOriginKHR domainOrigin;
+} VkPipelineTessellationDomainOriginStateCreateInfoKHR;
+
+
+
+#define VK_KHR_get_surface_capabilities2 1
+#define VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION 1
+#define VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME "VK_KHR_get_surface_capabilities2"
+
+typedef struct VkPhysicalDeviceSurfaceInfo2KHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkSurfaceKHR surface;
+} VkPhysicalDeviceSurfaceInfo2KHR;
+
+typedef struct VkSurfaceCapabilities2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkSurfaceCapabilitiesKHR surfaceCapabilities;
+} VkSurfaceCapabilities2KHR;
+
+typedef struct VkSurfaceFormat2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkSurfaceFormatKHR surfaceFormat;
+} VkSurfaceFormat2KHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkSurfaceCapabilities2KHR* pSurfaceCapabilities);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormats2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pSurfaceFormatCount, VkSurfaceFormat2KHR* pSurfaceFormats);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2KHR(
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
+ VkSurfaceCapabilities2KHR* pSurfaceCapabilities);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats2KHR(
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo,
+ uint32_t* pSurfaceFormatCount,
+ VkSurfaceFormat2KHR* pSurfaceFormats);
+#endif
+
+#define VK_KHR_variable_pointers 1
+#define VK_KHR_VARIABLE_POINTERS_SPEC_VERSION 1
+#define VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME "VK_KHR_variable_pointers"
+
+typedef struct VkPhysicalDeviceVariablePointerFeaturesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 variablePointersStorageBuffer;
+ VkBool32 variablePointers;
+} VkPhysicalDeviceVariablePointerFeaturesKHR;
+
+
+
+#define VK_KHR_dedicated_allocation 1
+#define VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION 3
+#define VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_KHR_dedicated_allocation"
+
+typedef struct VkMemoryDedicatedRequirementsKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 prefersDedicatedAllocation;
+ VkBool32 requiresDedicatedAllocation;
+} VkMemoryDedicatedRequirementsKHR;
+
+typedef struct VkMemoryDedicatedAllocateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkImage image;
+ VkBuffer buffer;
+} VkMemoryDedicatedAllocateInfoKHR;
+
+
+
+#define VK_KHR_storage_buffer_storage_class 1
+#define VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION 1
+#define VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME "VK_KHR_storage_buffer_storage_class"
+
+
+#define VK_KHR_relaxed_block_layout 1
+#define VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION 1
+#define VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME "VK_KHR_relaxed_block_layout"
+
+
+#define VK_KHR_get_memory_requirements2 1
+#define VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION 1
+#define VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME "VK_KHR_get_memory_requirements2"
+
+typedef struct VkBufferMemoryRequirementsInfo2KHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkBuffer buffer;
+} VkBufferMemoryRequirementsInfo2KHR;
+
+typedef struct VkImageMemoryRequirementsInfo2KHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkImage image;
+} VkImageMemoryRequirementsInfo2KHR;
+
+typedef struct VkImageSparseMemoryRequirementsInfo2KHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkImage image;
+} VkImageSparseMemoryRequirementsInfo2KHR;
+
+typedef struct VkMemoryRequirements2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkMemoryRequirements memoryRequirements;
+} VkMemoryRequirements2KHR;
+
+typedef struct VkSparseImageMemoryRequirements2KHR {
+ VkStructureType sType;
+ void* pNext;
+ VkSparseImageMemoryRequirements memoryRequirements;
+} VkSparseImageMemoryRequirements2KHR;
+
+
+typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements2KHR)(VkDevice device, const VkImageMemoryRequirementsInfo2KHR* pInfo, VkMemoryRequirements2KHR* pMemoryRequirements);
+typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements2KHR)(VkDevice device, const VkBufferMemoryRequirementsInfo2KHR* pInfo, VkMemoryRequirements2KHR* pMemoryRequirements);
+typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements2KHR)(VkDevice device, const VkImageSparseMemoryRequirementsInfo2KHR* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2KHR* pSparseMemoryRequirements);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2KHR(
+ VkDevice device,
+ const VkImageMemoryRequirementsInfo2KHR* pInfo,
+ VkMemoryRequirements2KHR* pMemoryRequirements);
+
+VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2KHR(
+ VkDevice device,
+ const VkBufferMemoryRequirementsInfo2KHR* pInfo,
+ VkMemoryRequirements2KHR* pMemoryRequirements);
+
+VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2KHR(
+ VkDevice device,
+ const VkImageSparseMemoryRequirementsInfo2KHR* pInfo,
+ uint32_t* pSparseMemoryRequirementCount,
+ VkSparseImageMemoryRequirements2KHR* pSparseMemoryRequirements);
+#endif
+
+#define VK_KHR_image_format_list 1
+#define VK_KHR_IMAGE_FORMAT_LIST_SPEC_VERSION 1
+#define VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME "VK_KHR_image_format_list"
+
+typedef struct VkImageFormatListCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t viewFormatCount;
+ const VkFormat* pViewFormats;
+} VkImageFormatListCreateInfoKHR;
+
+
+
+#define VK_KHR_sampler_ycbcr_conversion 1
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSamplerYcbcrConversionKHR)
+
+#define VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION 1
+#define VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME "VK_KHR_sampler_ycbcr_conversion"
+
+
+typedef enum VkSamplerYcbcrModelConversionKHR {
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY_KHR = 0,
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY_KHR = 1,
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR = 2,
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR = 3,
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR = 4,
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_BEGIN_RANGE_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY_KHR,
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_END_RANGE_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR,
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_RANGE_SIZE_KHR = (VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR - VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY_KHR + 1),
+ VK_SAMPLER_YCBCR_MODEL_CONVERSION_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkSamplerYcbcrModelConversionKHR;
+
+typedef enum VkSamplerYcbcrRangeKHR {
+ VK_SAMPLER_YCBCR_RANGE_ITU_FULL_KHR = 0,
+ VK_SAMPLER_YCBCR_RANGE_ITU_NARROW_KHR = 1,
+ VK_SAMPLER_YCBCR_RANGE_BEGIN_RANGE_KHR = VK_SAMPLER_YCBCR_RANGE_ITU_FULL_KHR,
+ VK_SAMPLER_YCBCR_RANGE_END_RANGE_KHR = VK_SAMPLER_YCBCR_RANGE_ITU_NARROW_KHR,
+ VK_SAMPLER_YCBCR_RANGE_RANGE_SIZE_KHR = (VK_SAMPLER_YCBCR_RANGE_ITU_NARROW_KHR - VK_SAMPLER_YCBCR_RANGE_ITU_FULL_KHR + 1),
+ VK_SAMPLER_YCBCR_RANGE_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkSamplerYcbcrRangeKHR;
+
+typedef enum VkChromaLocationKHR {
+ VK_CHROMA_LOCATION_COSITED_EVEN_KHR = 0,
+ VK_CHROMA_LOCATION_MIDPOINT_KHR = 1,
+ VK_CHROMA_LOCATION_BEGIN_RANGE_KHR = VK_CHROMA_LOCATION_COSITED_EVEN_KHR,
+ VK_CHROMA_LOCATION_END_RANGE_KHR = VK_CHROMA_LOCATION_MIDPOINT_KHR,
+ VK_CHROMA_LOCATION_RANGE_SIZE_KHR = (VK_CHROMA_LOCATION_MIDPOINT_KHR - VK_CHROMA_LOCATION_COSITED_EVEN_KHR + 1),
+ VK_CHROMA_LOCATION_MAX_ENUM_KHR = 0x7FFFFFFF
+} VkChromaLocationKHR;
+
+typedef struct VkSamplerYcbcrConversionCreateInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkFormat format;
+ VkSamplerYcbcrModelConversionKHR ycbcrModel;
+ VkSamplerYcbcrRangeKHR ycbcrRange;
+ VkComponentMapping components;
+ VkChromaLocationKHR xChromaOffset;
+ VkChromaLocationKHR yChromaOffset;
+ VkFilter chromaFilter;
+ VkBool32 forceExplicitReconstruction;
+} VkSamplerYcbcrConversionCreateInfoKHR;
+
+typedef struct VkSamplerYcbcrConversionInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkSamplerYcbcrConversionKHR conversion;
+} VkSamplerYcbcrConversionInfoKHR;
+
+typedef struct VkBindImagePlaneMemoryInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkImageAspectFlagBits planeAspect;
+} VkBindImagePlaneMemoryInfoKHR;
+
+typedef struct VkImagePlaneMemoryRequirementsInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkImageAspectFlagBits planeAspect;
+} VkImagePlaneMemoryRequirementsInfoKHR;
+
+typedef struct VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 samplerYcbcrConversion;
+} VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR;
+
+typedef struct VkSamplerYcbcrConversionImageFormatPropertiesKHR {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t combinedImageSamplerDescriptorCount;
+} VkSamplerYcbcrConversionImageFormatPropertiesKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateSamplerYcbcrConversionKHR)(VkDevice device, const VkSamplerYcbcrConversionCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversionKHR* pYcbcrConversion);
+typedef void (VKAPI_PTR *PFN_vkDestroySamplerYcbcrConversionKHR)(VkDevice device, VkSamplerYcbcrConversionKHR ycbcrConversion, const VkAllocationCallbacks* pAllocator);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversionKHR(
+ VkDevice device,
+ const VkSamplerYcbcrConversionCreateInfoKHR* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSamplerYcbcrConversionKHR* pYcbcrConversion);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversionKHR(
+ VkDevice device,
+ VkSamplerYcbcrConversionKHR ycbcrConversion,
+ const VkAllocationCallbacks* pAllocator);
+#endif
+
+#define VK_KHR_bind_memory2 1
+#define VK_KHR_BIND_MEMORY_2_SPEC_VERSION 1
+#define VK_KHR_BIND_MEMORY_2_EXTENSION_NAME "VK_KHR_bind_memory2"
+
+typedef struct VkBindBufferMemoryInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkBuffer buffer;
+ VkDeviceMemory memory;
+ VkDeviceSize memoryOffset;
+} VkBindBufferMemoryInfoKHR;
+
+typedef struct VkBindImageMemoryInfoKHR {
+ VkStructureType sType;
+ const void* pNext;
+ VkImage image;
+ VkDeviceMemory memory;
+ VkDeviceSize memoryOffset;
+} VkBindImageMemoryInfoKHR;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory2KHR)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfoKHR* pBindInfos);
+typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory2KHR)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfoKHR* pBindInfos);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2KHR(
+ VkDevice device,
+ uint32_t bindInfoCount,
+ const VkBindBufferMemoryInfoKHR* pBindInfos);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2KHR(
+ VkDevice device,
+ uint32_t bindInfoCount,
+ const VkBindImageMemoryInfoKHR* pBindInfos);
+#endif
+
+#define VK_EXT_debug_report 1
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT)
+
+#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 9
+#define VK_EXT_DEBUG_REPORT_EXTENSION_NAME "VK_EXT_debug_report"
+#define VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT
+#define VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT
+
+
+typedef enum VkDebugReportObjectTypeEXT {
+ VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0,
+ VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1,
+ VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT = 2,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT = 3,
+ VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT = 4,
+ VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT = 5,
+ VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT = 6,
+ VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT = 7,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT = 8,
+ VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT = 9,
+ VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT = 10,
+ VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT = 11,
+ VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT = 12,
+ VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT = 13,
+ VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT = 14,
+ VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT = 15,
+ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT = 16,
+ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT = 17,
+ VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT = 18,
+ VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT = 19,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT = 20,
+ VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT = 21,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT = 22,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT = 23,
+ VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT = 24,
+ VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT = 25,
+ VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT = 26,
+ VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT = 27,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT = 28,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT = 29,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT = 30,
+ VK_DEBUG_REPORT_OBJECT_TYPE_OBJECT_TABLE_NVX_EXT = 31,
+ VK_DEBUG_REPORT_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NVX_EXT = 32,
+ VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT = 33,
+ VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR_EXT = 1000085000,
+ VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_KHR_EXT = 1000156000,
+ VK_DEBUG_REPORT_OBJECT_TYPE_BEGIN_RANGE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_END_RANGE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT,
+ VK_DEBUG_REPORT_OBJECT_TYPE_RANGE_SIZE_EXT = (VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT - VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT + 1),
+ VK_DEBUG_REPORT_OBJECT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkDebugReportObjectTypeEXT;
+
+
+typedef enum VkDebugReportFlagBitsEXT {
+ VK_DEBUG_REPORT_INFORMATION_BIT_EXT = 0x00000001,
+ VK_DEBUG_REPORT_WARNING_BIT_EXT = 0x00000002,
+ VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT = 0x00000004,
+ VK_DEBUG_REPORT_ERROR_BIT_EXT = 0x00000008,
+ VK_DEBUG_REPORT_DEBUG_BIT_EXT = 0x00000010,
+ VK_DEBUG_REPORT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkDebugReportFlagBitsEXT;
+typedef VkFlags VkDebugReportFlagsEXT;
+
+typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)(
+ VkDebugReportFlagsEXT flags,
+ VkDebugReportObjectTypeEXT objectType,
+ uint64_t object,
+ size_t location,
+ int32_t messageCode,
+ const char* pLayerPrefix,
+ const char* pMessage,
+ void* pUserData);
+
+typedef struct VkDebugReportCallbackCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkDebugReportFlagsEXT flags;
+ PFN_vkDebugReportCallbackEXT pfnCallback;
+ void* pUserData;
+} VkDebugReportCallbackCreateInfoEXT;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback);
+typedef void (VKAPI_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator);
+typedef void (VKAPI_PTR *PFN_vkDebugReportMessageEXT)(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT(
+ VkInstance instance,
+ const VkDebugReportCallbackCreateInfoEXT* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkDebugReportCallbackEXT* pCallback);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT(
+ VkInstance instance,
+ VkDebugReportCallbackEXT callback,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(
+ VkInstance instance,
+ VkDebugReportFlagsEXT flags,
+ VkDebugReportObjectTypeEXT objectType,
+ uint64_t object,
+ size_t location,
+ int32_t messageCode,
+ const char* pLayerPrefix,
+ const char* pMessage);
+#endif
+
+#define VK_NV_glsl_shader 1
+#define VK_NV_GLSL_SHADER_SPEC_VERSION 1
+#define VK_NV_GLSL_SHADER_EXTENSION_NAME "VK_NV_glsl_shader"
+
+
+#define VK_EXT_depth_range_unrestricted 1
+#define VK_EXT_DEPTH_RANGE_UNRESTRICTED_SPEC_VERSION 1
+#define VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME "VK_EXT_depth_range_unrestricted"
+
+
+#define VK_IMG_filter_cubic 1
+#define VK_IMG_FILTER_CUBIC_SPEC_VERSION 1
+#define VK_IMG_FILTER_CUBIC_EXTENSION_NAME "VK_IMG_filter_cubic"
+
+
+#define VK_AMD_rasterization_order 1
+#define VK_AMD_RASTERIZATION_ORDER_SPEC_VERSION 1
+#define VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME "VK_AMD_rasterization_order"
+
+
+typedef enum VkRasterizationOrderAMD {
+ VK_RASTERIZATION_ORDER_STRICT_AMD = 0,
+ VK_RASTERIZATION_ORDER_RELAXED_AMD = 1,
+ VK_RASTERIZATION_ORDER_BEGIN_RANGE_AMD = VK_RASTERIZATION_ORDER_STRICT_AMD,
+ VK_RASTERIZATION_ORDER_END_RANGE_AMD = VK_RASTERIZATION_ORDER_RELAXED_AMD,
+ VK_RASTERIZATION_ORDER_RANGE_SIZE_AMD = (VK_RASTERIZATION_ORDER_RELAXED_AMD - VK_RASTERIZATION_ORDER_STRICT_AMD + 1),
+ VK_RASTERIZATION_ORDER_MAX_ENUM_AMD = 0x7FFFFFFF
+} VkRasterizationOrderAMD;
+
+typedef struct VkPipelineRasterizationStateRasterizationOrderAMD {
+ VkStructureType sType;
+ const void* pNext;
+ VkRasterizationOrderAMD rasterizationOrder;
+} VkPipelineRasterizationStateRasterizationOrderAMD;
+
+
+
+#define VK_AMD_shader_trinary_minmax 1
+#define VK_AMD_SHADER_TRINARY_MINMAX_SPEC_VERSION 1
+#define VK_AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME "VK_AMD_shader_trinary_minmax"
+
+
+#define VK_AMD_shader_explicit_vertex_parameter 1
+#define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_SPEC_VERSION 1
+#define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME "VK_AMD_shader_explicit_vertex_parameter"
+
+
+#define VK_EXT_debug_marker 1
+#define VK_EXT_DEBUG_MARKER_SPEC_VERSION 4
+#define VK_EXT_DEBUG_MARKER_EXTENSION_NAME "VK_EXT_debug_marker"
+
+typedef struct VkDebugMarkerObjectNameInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkDebugReportObjectTypeEXT objectType;
+ uint64_t object;
+ const char* pObjectName;
+} VkDebugMarkerObjectNameInfoEXT;
+
+typedef struct VkDebugMarkerObjectTagInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkDebugReportObjectTypeEXT objectType;
+ uint64_t object;
+ uint64_t tagName;
+ size_t tagSize;
+ const void* pTag;
+} VkDebugMarkerObjectTagInfoEXT;
+
+typedef struct VkDebugMarkerMarkerInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ const char* pMarkerName;
+ float color[4];
+} VkDebugMarkerMarkerInfoEXT;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectTagEXT)(VkDevice device, const VkDebugMarkerObjectTagInfoEXT* pTagInfo);
+typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectNameEXT)(VkDevice device, const VkDebugMarkerObjectNameInfoEXT* pNameInfo);
+typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerBeginEXT)(VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
+typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerEndEXT)(VkCommandBuffer commandBuffer);
+typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerInsertEXT)(VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT(
+ VkDevice device,
+ const VkDebugMarkerObjectTagInfoEXT* pTagInfo);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT(
+ VkDevice device,
+ const VkDebugMarkerObjectNameInfoEXT* pNameInfo);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT(
+ VkCommandBuffer commandBuffer,
+ const VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerEndEXT(
+ VkCommandBuffer commandBuffer);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT(
+ VkCommandBuffer commandBuffer,
+ const VkDebugMarkerMarkerInfoEXT* pMarkerInfo);
+#endif
+
+#define VK_AMD_gcn_shader 1
+#define VK_AMD_GCN_SHADER_SPEC_VERSION 1
+#define VK_AMD_GCN_SHADER_EXTENSION_NAME "VK_AMD_gcn_shader"
+
+
+#define VK_NV_dedicated_allocation 1
+#define VK_NV_DEDICATED_ALLOCATION_SPEC_VERSION 1
+#define VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_NV_dedicated_allocation"
+
+typedef struct VkDedicatedAllocationImageCreateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkBool32 dedicatedAllocation;
+} VkDedicatedAllocationImageCreateInfoNV;
+
+typedef struct VkDedicatedAllocationBufferCreateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkBool32 dedicatedAllocation;
+} VkDedicatedAllocationBufferCreateInfoNV;
+
+typedef struct VkDedicatedAllocationMemoryAllocateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkImage image;
+ VkBuffer buffer;
+} VkDedicatedAllocationMemoryAllocateInfoNV;
+
+
+
+#define VK_AMD_draw_indirect_count 1
+#define VK_AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION 1
+#define VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_AMD_draw_indirect_count"
+
+typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride);
+typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD(
+ VkCommandBuffer commandBuffer,
+ VkBuffer buffer,
+ VkDeviceSize offset,
+ VkBuffer countBuffer,
+ VkDeviceSize countBufferOffset,
+ uint32_t maxDrawCount,
+ uint32_t stride);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD(
+ VkCommandBuffer commandBuffer,
+ VkBuffer buffer,
+ VkDeviceSize offset,
+ VkBuffer countBuffer,
+ VkDeviceSize countBufferOffset,
+ uint32_t maxDrawCount,
+ uint32_t stride);
+#endif
+
+#define VK_AMD_negative_viewport_height 1
+#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION 1
+#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME "VK_AMD_negative_viewport_height"
+
+
+#define VK_AMD_gpu_shader_half_float 1
+#define VK_AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION 1
+#define VK_AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME "VK_AMD_gpu_shader_half_float"
+
+
+#define VK_AMD_shader_ballot 1
+#define VK_AMD_SHADER_BALLOT_SPEC_VERSION 1
+#define VK_AMD_SHADER_BALLOT_EXTENSION_NAME "VK_AMD_shader_ballot"
+
+
+#define VK_AMD_texture_gather_bias_lod 1
+#define VK_AMD_TEXTURE_GATHER_BIAS_LOD_SPEC_VERSION 1
+#define VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME "VK_AMD_texture_gather_bias_lod"
+
+typedef struct VkTextureLODGatherFormatPropertiesAMD {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 supportsTextureGatherLODBiasAMD;
+} VkTextureLODGatherFormatPropertiesAMD;
+
+
+
+#define VK_AMD_shader_info 1
+#define VK_AMD_SHADER_INFO_SPEC_VERSION 1
+#define VK_AMD_SHADER_INFO_EXTENSION_NAME "VK_AMD_shader_info"
+
+
+typedef enum VkShaderInfoTypeAMD {
+ VK_SHADER_INFO_TYPE_STATISTICS_AMD = 0,
+ VK_SHADER_INFO_TYPE_BINARY_AMD = 1,
+ VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD = 2,
+ VK_SHADER_INFO_TYPE_BEGIN_RANGE_AMD = VK_SHADER_INFO_TYPE_STATISTICS_AMD,
+ VK_SHADER_INFO_TYPE_END_RANGE_AMD = VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD,
+ VK_SHADER_INFO_TYPE_RANGE_SIZE_AMD = (VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD - VK_SHADER_INFO_TYPE_STATISTICS_AMD + 1),
+ VK_SHADER_INFO_TYPE_MAX_ENUM_AMD = 0x7FFFFFFF
+} VkShaderInfoTypeAMD;
+
+typedef struct VkShaderResourceUsageAMD {
+ uint32_t numUsedVgprs;
+ uint32_t numUsedSgprs;
+ uint32_t ldsSizePerLocalWorkGroup;
+ size_t ldsUsageSizeInBytes;
+ size_t scratchMemUsageInBytes;
+} VkShaderResourceUsageAMD;
+
+typedef struct VkShaderStatisticsInfoAMD {
+ VkShaderStageFlags shaderStageMask;
+ VkShaderResourceUsageAMD resourceUsage;
+ uint32_t numPhysicalVgprs;
+ uint32_t numPhysicalSgprs;
+ uint32_t numAvailableVgprs;
+ uint32_t numAvailableSgprs;
+ uint32_t computeWorkGroupSize[3];
+} VkShaderStatisticsInfoAMD;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetShaderInfoAMD)(VkDevice device, VkPipeline pipeline, VkShaderStageFlagBits shaderStage, VkShaderInfoTypeAMD infoType, size_t* pInfoSize, void* pInfo);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetShaderInfoAMD(
+ VkDevice device,
+ VkPipeline pipeline,
+ VkShaderStageFlagBits shaderStage,
+ VkShaderInfoTypeAMD infoType,
+ size_t* pInfoSize,
+ void* pInfo);
+#endif
+
+#define VK_AMD_shader_image_load_store_lod 1
+#define VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_SPEC_VERSION 1
+#define VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME "VK_AMD_shader_image_load_store_lod"
+
+
+#define VK_KHX_multiview 1
+#define VK_KHX_MULTIVIEW_SPEC_VERSION 1
+#define VK_KHX_MULTIVIEW_EXTENSION_NAME "VK_KHX_multiview"
+
+typedef struct VkRenderPassMultiviewCreateInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t subpassCount;
+ const uint32_t* pViewMasks;
+ uint32_t dependencyCount;
+ const int32_t* pViewOffsets;
+ uint32_t correlationMaskCount;
+ const uint32_t* pCorrelationMasks;
+} VkRenderPassMultiviewCreateInfoKHX;
+
+typedef struct VkPhysicalDeviceMultiviewFeaturesKHX {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 multiview;
+ VkBool32 multiviewGeometryShader;
+ VkBool32 multiviewTessellationShader;
+} VkPhysicalDeviceMultiviewFeaturesKHX;
+
+typedef struct VkPhysicalDeviceMultiviewPropertiesKHX {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t maxMultiviewViewCount;
+ uint32_t maxMultiviewInstanceIndex;
+} VkPhysicalDeviceMultiviewPropertiesKHX;
+
+
+
+#define VK_IMG_format_pvrtc 1
+#define VK_IMG_FORMAT_PVRTC_SPEC_VERSION 1
+#define VK_IMG_FORMAT_PVRTC_EXTENSION_NAME "VK_IMG_format_pvrtc"
+
+
+#define VK_NV_external_memory_capabilities 1
+#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1
+#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_NV_external_memory_capabilities"
+
+
+typedef enum VkExternalMemoryHandleTypeFlagBitsNV {
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_NV = 0x00000001,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_NV = 0x00000002,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_BIT_NV = 0x00000004,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_KMT_BIT_NV = 0x00000008,
+ VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF
+} VkExternalMemoryHandleTypeFlagBitsNV;
+typedef VkFlags VkExternalMemoryHandleTypeFlagsNV;
+
+typedef enum VkExternalMemoryFeatureFlagBitsNV {
+ VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_NV = 0x00000001,
+ VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_NV = 0x00000002,
+ VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_NV = 0x00000004,
+ VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF
+} VkExternalMemoryFeatureFlagBitsNV;
+typedef VkFlags VkExternalMemoryFeatureFlagsNV;
+
+typedef struct VkExternalImageFormatPropertiesNV {
+ VkImageFormatProperties imageFormatProperties;
+ VkExternalMemoryFeatureFlagsNV externalMemoryFeatures;
+ VkExternalMemoryHandleTypeFlagsNV exportFromImportedHandleTypes;
+ VkExternalMemoryHandleTypeFlagsNV compatibleHandleTypes;
+} VkExternalImageFormatPropertiesNV;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceExternalImageFormatPropertiesNV(
+ VkPhysicalDevice physicalDevice,
+ VkFormat format,
+ VkImageType type,
+ VkImageTiling tiling,
+ VkImageUsageFlags usage,
+ VkImageCreateFlags flags,
+ VkExternalMemoryHandleTypeFlagsNV externalHandleType,
+ VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties);
+#endif
+
+#define VK_NV_external_memory 1
+#define VK_NV_EXTERNAL_MEMORY_SPEC_VERSION 1
+#define VK_NV_EXTERNAL_MEMORY_EXTENSION_NAME "VK_NV_external_memory"
+
+typedef struct VkExternalMemoryImageCreateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagsNV handleTypes;
+} VkExternalMemoryImageCreateInfoNV;
+
+typedef struct VkExportMemoryAllocateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagsNV handleTypes;
+} VkExportMemoryAllocateInfoNV;
+
+
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+#define VK_NV_external_memory_win32 1
+#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1
+#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32"
+
+typedef struct VkImportMemoryWin32HandleInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkExternalMemoryHandleTypeFlagsNV handleType;
+ HANDLE handle;
+} VkImportMemoryWin32HandleInfoNV;
+
+typedef struct VkExportMemoryWin32HandleInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ const SECURITY_ATTRIBUTES* pAttributes;
+ DWORD dwAccess;
+} VkExportMemoryWin32HandleInfoNV;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV(
+ VkDevice device,
+ VkDeviceMemory memory,
+ VkExternalMemoryHandleTypeFlagsNV handleType,
+ HANDLE* pHandle);
+#endif
+#endif /* VK_USE_PLATFORM_WIN32_KHR */
+
+#ifdef VK_USE_PLATFORM_WIN32_KHR
+#define VK_NV_win32_keyed_mutex 1
+#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 1
+#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex"
+
+typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t acquireCount;
+ const VkDeviceMemory* pAcquireSyncs;
+ const uint64_t* pAcquireKeys;
+ const uint32_t* pAcquireTimeoutMilliseconds;
+ uint32_t releaseCount;
+ const VkDeviceMemory* pReleaseSyncs;
+ const uint64_t* pReleaseKeys;
+} VkWin32KeyedMutexAcquireReleaseInfoNV;
+
+
+#endif /* VK_USE_PLATFORM_WIN32_KHR */
+
+#define VK_KHX_device_group 1
+#define VK_KHX_DEVICE_GROUP_SPEC_VERSION 2
+#define VK_KHX_DEVICE_GROUP_EXTENSION_NAME "VK_KHX_device_group"
+#define VK_MAX_DEVICE_GROUP_SIZE_KHX 32
+
+
+typedef enum VkPeerMemoryFeatureFlagBitsKHX {
+ VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT_KHX = 0x00000001,
+ VK_PEER_MEMORY_FEATURE_COPY_DST_BIT_KHX = 0x00000002,
+ VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT_KHX = 0x00000004,
+ VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT_KHX = 0x00000008,
+ VK_PEER_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF
+} VkPeerMemoryFeatureFlagBitsKHX;
+typedef VkFlags VkPeerMemoryFeatureFlagsKHX;
+
+typedef enum VkMemoryAllocateFlagBitsKHX {
+ VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT_KHX = 0x00000001,
+ VK_MEMORY_ALLOCATE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF
+} VkMemoryAllocateFlagBitsKHX;
+typedef VkFlags VkMemoryAllocateFlagsKHX;
+
+typedef enum VkDeviceGroupPresentModeFlagBitsKHX {
+ VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHX = 0x00000001,
+ VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHX = 0x00000002,
+ VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHX = 0x00000004,
+ VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHX = 0x00000008,
+ VK_DEVICE_GROUP_PRESENT_MODE_FLAG_BITS_MAX_ENUM_KHX = 0x7FFFFFFF
+} VkDeviceGroupPresentModeFlagBitsKHX;
+typedef VkFlags VkDeviceGroupPresentModeFlagsKHX;
+
+typedef struct VkMemoryAllocateFlagsInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ VkMemoryAllocateFlagsKHX flags;
+ uint32_t deviceMask;
+} VkMemoryAllocateFlagsInfoKHX;
+
+typedef struct VkDeviceGroupRenderPassBeginInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t deviceMask;
+ uint32_t deviceRenderAreaCount;
+ const VkRect2D* pDeviceRenderAreas;
+} VkDeviceGroupRenderPassBeginInfoKHX;
+
+typedef struct VkDeviceGroupCommandBufferBeginInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t deviceMask;
+} VkDeviceGroupCommandBufferBeginInfoKHX;
+
+typedef struct VkDeviceGroupSubmitInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t waitSemaphoreCount;
+ const uint32_t* pWaitSemaphoreDeviceIndices;
+ uint32_t commandBufferCount;
+ const uint32_t* pCommandBufferDeviceMasks;
+ uint32_t signalSemaphoreCount;
+ const uint32_t* pSignalSemaphoreDeviceIndices;
+} VkDeviceGroupSubmitInfoKHX;
+
+typedef struct VkDeviceGroupBindSparseInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t resourceDeviceIndex;
+ uint32_t memoryDeviceIndex;
+} VkDeviceGroupBindSparseInfoKHX;
+
+typedef struct VkBindBufferMemoryDeviceGroupInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t deviceIndexCount;
+ const uint32_t* pDeviceIndices;
+} VkBindBufferMemoryDeviceGroupInfoKHX;
+
+typedef struct VkBindImageMemoryDeviceGroupInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t deviceIndexCount;
+ const uint32_t* pDeviceIndices;
+ uint32_t SFRRectCount;
+ const VkRect2D* pSFRRects;
+} VkBindImageMemoryDeviceGroupInfoKHX;
+
+typedef struct VkDeviceGroupPresentCapabilitiesKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t presentMask[VK_MAX_DEVICE_GROUP_SIZE_KHX];
+ VkDeviceGroupPresentModeFlagsKHX modes;
+} VkDeviceGroupPresentCapabilitiesKHX;
+
+typedef struct VkImageSwapchainCreateInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ VkSwapchainKHR swapchain;
+} VkImageSwapchainCreateInfoKHX;
+
+typedef struct VkBindImageMemorySwapchainInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ VkSwapchainKHR swapchain;
+ uint32_t imageIndex;
+} VkBindImageMemorySwapchainInfoKHX;
+
+typedef struct VkAcquireNextImageInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ VkSwapchainKHR swapchain;
+ uint64_t timeout;
+ VkSemaphore semaphore;
+ VkFence fence;
+ uint32_t deviceMask;
+} VkAcquireNextImageInfoKHX;
+
+typedef struct VkDeviceGroupPresentInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t swapchainCount;
+ const uint32_t* pDeviceMasks;
+ VkDeviceGroupPresentModeFlagBitsKHX mode;
+} VkDeviceGroupPresentInfoKHX;
+
+typedef struct VkDeviceGroupSwapchainCreateInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceGroupPresentModeFlagsKHX modes;
+} VkDeviceGroupSwapchainCreateInfoKHX;
+
+
+typedef void (VKAPI_PTR *PFN_vkGetDeviceGroupPeerMemoryFeaturesKHX)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlagsKHX* pPeerMemoryFeatures);
+typedef void (VKAPI_PTR *PFN_vkCmdSetDeviceMaskKHX)(VkCommandBuffer commandBuffer, uint32_t deviceMask);
+typedef void (VKAPI_PTR *PFN_vkCmdDispatchBaseKHX)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
+typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHX)(VkDevice device, VkDeviceGroupPresentCapabilitiesKHX* pDeviceGroupPresentCapabilities);
+typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHX)(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHX* pModes);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHX)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pRectCount, VkRect2D* pRects);
+typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImage2KHX)(VkDevice device, const VkAcquireNextImageInfoKHX* pAcquireInfo, uint32_t* pImageIndex);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeaturesKHX(
+ VkDevice device,
+ uint32_t heapIndex,
+ uint32_t localDeviceIndex,
+ uint32_t remoteDeviceIndex,
+ VkPeerMemoryFeatureFlagsKHX* pPeerMemoryFeatures);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMaskKHX(
+ VkCommandBuffer commandBuffer,
+ uint32_t deviceMask);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBaseKHX(
+ VkCommandBuffer commandBuffer,
+ uint32_t baseGroupX,
+ uint32_t baseGroupY,
+ uint32_t baseGroupZ,
+ uint32_t groupCountX,
+ uint32_t groupCountY,
+ uint32_t groupCountZ);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHX(
+ VkDevice device,
+ VkDeviceGroupPresentCapabilitiesKHX* pDeviceGroupPresentCapabilities);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHX(
+ VkDevice device,
+ VkSurfaceKHR surface,
+ VkDeviceGroupPresentModeFlagsKHX* pModes);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHX(
+ VkPhysicalDevice physicalDevice,
+ VkSurfaceKHR surface,
+ uint32_t* pRectCount,
+ VkRect2D* pRects);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHX(
+ VkDevice device,
+ const VkAcquireNextImageInfoKHX* pAcquireInfo,
+ uint32_t* pImageIndex);
+#endif
+
+#define VK_EXT_validation_flags 1
+#define VK_EXT_VALIDATION_FLAGS_SPEC_VERSION 1
+#define VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME "VK_EXT_validation_flags"
+
+
+typedef enum VkValidationCheckEXT {
+ VK_VALIDATION_CHECK_ALL_EXT = 0,
+ VK_VALIDATION_CHECK_SHADERS_EXT = 1,
+ VK_VALIDATION_CHECK_BEGIN_RANGE_EXT = VK_VALIDATION_CHECK_ALL_EXT,
+ VK_VALIDATION_CHECK_END_RANGE_EXT = VK_VALIDATION_CHECK_SHADERS_EXT,
+ VK_VALIDATION_CHECK_RANGE_SIZE_EXT = (VK_VALIDATION_CHECK_SHADERS_EXT - VK_VALIDATION_CHECK_ALL_EXT + 1),
+ VK_VALIDATION_CHECK_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkValidationCheckEXT;
+
+typedef struct VkValidationFlagsEXT {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t disabledValidationCheckCount;
+ VkValidationCheckEXT* pDisabledValidationChecks;
+} VkValidationFlagsEXT;
+
+
+
+#ifdef VK_USE_PLATFORM_VI_NN
+#define VK_NN_vi_surface 1
+#define VK_NN_VI_SURFACE_SPEC_VERSION 1
+#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface"
+
+typedef VkFlags VkViSurfaceCreateFlagsNN;
+
+typedef struct VkViSurfaceCreateInfoNN {
+ VkStructureType sType;
+ const void* pNext;
+ VkViSurfaceCreateFlagsNN flags;
+ void* window;
+} VkViSurfaceCreateInfoNN;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN(
+ VkInstance instance,
+ const VkViSurfaceCreateInfoNN* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+#endif
+#endif /* VK_USE_PLATFORM_VI_NN */
+
+#define VK_EXT_shader_subgroup_ballot 1
+#define VK_EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION 1
+#define VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME "VK_EXT_shader_subgroup_ballot"
+
+
+#define VK_EXT_shader_subgroup_vote 1
+#define VK_EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION 1
+#define VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME "VK_EXT_shader_subgroup_vote"
+
+
+#define VK_KHX_device_group_creation 1
+#define VK_KHX_DEVICE_GROUP_CREATION_SPEC_VERSION 1
+#define VK_KHX_DEVICE_GROUP_CREATION_EXTENSION_NAME "VK_KHX_device_group_creation"
+
+typedef struct VkPhysicalDeviceGroupPropertiesKHX {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t physicalDeviceCount;
+ VkPhysicalDevice physicalDevices[VK_MAX_DEVICE_GROUP_SIZE_KHX];
+ VkBool32 subsetAllocation;
+} VkPhysicalDeviceGroupPropertiesKHX;
+
+typedef struct VkDeviceGroupDeviceCreateInfoKHX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t physicalDeviceCount;
+ const VkPhysicalDevice* pPhysicalDevices;
+} VkDeviceGroupDeviceCreateInfoKHX;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceGroupsKHX)(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupPropertiesKHX* pPhysicalDeviceGroupProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroupsKHX(
+ VkInstance instance,
+ uint32_t* pPhysicalDeviceGroupCount,
+ VkPhysicalDeviceGroupPropertiesKHX* pPhysicalDeviceGroupProperties);
+#endif
+
+#define VK_NVX_device_generated_commands 1
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkObjectTableNVX)
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkIndirectCommandsLayoutNVX)
+
+#define VK_NVX_DEVICE_GENERATED_COMMANDS_SPEC_VERSION 3
+#define VK_NVX_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME "VK_NVX_device_generated_commands"
+
+
+typedef enum VkIndirectCommandsTokenTypeNVX {
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX = 0,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_DESCRIPTOR_SET_NVX = 1,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_INDEX_BUFFER_NVX = 2,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_VERTEX_BUFFER_NVX = 3,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_PUSH_CONSTANT_NVX = 4,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_INDEXED_NVX = 5,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_NVX = 6,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX = 7,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_BEGIN_RANGE_NVX = VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_END_RANGE_NVX = VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX,
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_RANGE_SIZE_NVX = (VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NVX - VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NVX + 1),
+ VK_INDIRECT_COMMANDS_TOKEN_TYPE_MAX_ENUM_NVX = 0x7FFFFFFF
+} VkIndirectCommandsTokenTypeNVX;
+
+typedef enum VkObjectEntryTypeNVX {
+ VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX = 0,
+ VK_OBJECT_ENTRY_TYPE_PIPELINE_NVX = 1,
+ VK_OBJECT_ENTRY_TYPE_INDEX_BUFFER_NVX = 2,
+ VK_OBJECT_ENTRY_TYPE_VERTEX_BUFFER_NVX = 3,
+ VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX = 4,
+ VK_OBJECT_ENTRY_TYPE_BEGIN_RANGE_NVX = VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX,
+ VK_OBJECT_ENTRY_TYPE_END_RANGE_NVX = VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX,
+ VK_OBJECT_ENTRY_TYPE_RANGE_SIZE_NVX = (VK_OBJECT_ENTRY_TYPE_PUSH_CONSTANT_NVX - VK_OBJECT_ENTRY_TYPE_DESCRIPTOR_SET_NVX + 1),
+ VK_OBJECT_ENTRY_TYPE_MAX_ENUM_NVX = 0x7FFFFFFF
+} VkObjectEntryTypeNVX;
+
+
+typedef enum VkIndirectCommandsLayoutUsageFlagBitsNVX {
+ VK_INDIRECT_COMMANDS_LAYOUT_USAGE_UNORDERED_SEQUENCES_BIT_NVX = 0x00000001,
+ VK_INDIRECT_COMMANDS_LAYOUT_USAGE_SPARSE_SEQUENCES_BIT_NVX = 0x00000002,
+ VK_INDIRECT_COMMANDS_LAYOUT_USAGE_EMPTY_EXECUTIONS_BIT_NVX = 0x00000004,
+ VK_INDIRECT_COMMANDS_LAYOUT_USAGE_INDEXED_SEQUENCES_BIT_NVX = 0x00000008,
+ VK_INDIRECT_COMMANDS_LAYOUT_USAGE_FLAG_BITS_MAX_ENUM_NVX = 0x7FFFFFFF
+} VkIndirectCommandsLayoutUsageFlagBitsNVX;
+typedef VkFlags VkIndirectCommandsLayoutUsageFlagsNVX;
+
+typedef enum VkObjectEntryUsageFlagBitsNVX {
+ VK_OBJECT_ENTRY_USAGE_GRAPHICS_BIT_NVX = 0x00000001,
+ VK_OBJECT_ENTRY_USAGE_COMPUTE_BIT_NVX = 0x00000002,
+ VK_OBJECT_ENTRY_USAGE_FLAG_BITS_MAX_ENUM_NVX = 0x7FFFFFFF
+} VkObjectEntryUsageFlagBitsNVX;
+typedef VkFlags VkObjectEntryUsageFlagsNVX;
+
+typedef struct VkDeviceGeneratedCommandsFeaturesNVX {
+ VkStructureType sType;
+ const void* pNext;
+ VkBool32 computeBindingPointSupport;
+} VkDeviceGeneratedCommandsFeaturesNVX;
+
+typedef struct VkDeviceGeneratedCommandsLimitsNVX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t maxIndirectCommandsLayoutTokenCount;
+ uint32_t maxObjectEntryCounts;
+ uint32_t minSequenceCountBufferOffsetAlignment;
+ uint32_t minSequenceIndexBufferOffsetAlignment;
+ uint32_t minCommandsTokenBufferOffsetAlignment;
+} VkDeviceGeneratedCommandsLimitsNVX;
+
+typedef struct VkIndirectCommandsTokenNVX {
+ VkIndirectCommandsTokenTypeNVX tokenType;
+ VkBuffer buffer;
+ VkDeviceSize offset;
+} VkIndirectCommandsTokenNVX;
+
+typedef struct VkIndirectCommandsLayoutTokenNVX {
+ VkIndirectCommandsTokenTypeNVX tokenType;
+ uint32_t bindingUnit;
+ uint32_t dynamicCount;
+ uint32_t divisor;
+} VkIndirectCommandsLayoutTokenNVX;
+
+typedef struct VkIndirectCommandsLayoutCreateInfoNVX {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineBindPoint pipelineBindPoint;
+ VkIndirectCommandsLayoutUsageFlagsNVX flags;
+ uint32_t tokenCount;
+ const VkIndirectCommandsLayoutTokenNVX* pTokens;
+} VkIndirectCommandsLayoutCreateInfoNVX;
+
+typedef struct VkCmdProcessCommandsInfoNVX {
+ VkStructureType sType;
+ const void* pNext;
+ VkObjectTableNVX objectTable;
+ VkIndirectCommandsLayoutNVX indirectCommandsLayout;
+ uint32_t indirectCommandsTokenCount;
+ const VkIndirectCommandsTokenNVX* pIndirectCommandsTokens;
+ uint32_t maxSequencesCount;
+ VkCommandBuffer targetCommandBuffer;
+ VkBuffer sequencesCountBuffer;
+ VkDeviceSize sequencesCountOffset;
+ VkBuffer sequencesIndexBuffer;
+ VkDeviceSize sequencesIndexOffset;
+} VkCmdProcessCommandsInfoNVX;
+
+typedef struct VkCmdReserveSpaceForCommandsInfoNVX {
+ VkStructureType sType;
+ const void* pNext;
+ VkObjectTableNVX objectTable;
+ VkIndirectCommandsLayoutNVX indirectCommandsLayout;
+ uint32_t maxSequencesCount;
+} VkCmdReserveSpaceForCommandsInfoNVX;
+
+typedef struct VkObjectTableCreateInfoNVX {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t objectCount;
+ const VkObjectEntryTypeNVX* pObjectEntryTypes;
+ const uint32_t* pObjectEntryCounts;
+ const VkObjectEntryUsageFlagsNVX* pObjectEntryUsageFlags;
+ uint32_t maxUniformBuffersPerDescriptor;
+ uint32_t maxStorageBuffersPerDescriptor;
+ uint32_t maxStorageImagesPerDescriptor;
+ uint32_t maxSampledImagesPerDescriptor;
+ uint32_t maxPipelineLayouts;
+} VkObjectTableCreateInfoNVX;
+
+typedef struct VkObjectTableEntryNVX {
+ VkObjectEntryTypeNVX type;
+ VkObjectEntryUsageFlagsNVX flags;
+} VkObjectTableEntryNVX;
+
+typedef struct VkObjectTablePipelineEntryNVX {
+ VkObjectEntryTypeNVX type;
+ VkObjectEntryUsageFlagsNVX flags;
+ VkPipeline pipeline;
+} VkObjectTablePipelineEntryNVX;
+
+typedef struct VkObjectTableDescriptorSetEntryNVX {
+ VkObjectEntryTypeNVX type;
+ VkObjectEntryUsageFlagsNVX flags;
+ VkPipelineLayout pipelineLayout;
+ VkDescriptorSet descriptorSet;
+} VkObjectTableDescriptorSetEntryNVX;
+
+typedef struct VkObjectTableVertexBufferEntryNVX {
+ VkObjectEntryTypeNVX type;
+ VkObjectEntryUsageFlagsNVX flags;
+ VkBuffer buffer;
+} VkObjectTableVertexBufferEntryNVX;
+
+typedef struct VkObjectTableIndexBufferEntryNVX {
+ VkObjectEntryTypeNVX type;
+ VkObjectEntryUsageFlagsNVX flags;
+ VkBuffer buffer;
+ VkIndexType indexType;
+} VkObjectTableIndexBufferEntryNVX;
+
+typedef struct VkObjectTablePushConstantEntryNVX {
+ VkObjectEntryTypeNVX type;
+ VkObjectEntryUsageFlagsNVX flags;
+ VkPipelineLayout pipelineLayout;
+ VkShaderStageFlags stageFlags;
+} VkObjectTablePushConstantEntryNVX;
+
+
+typedef void (VKAPI_PTR *PFN_vkCmdProcessCommandsNVX)(VkCommandBuffer commandBuffer, const VkCmdProcessCommandsInfoNVX* pProcessCommandsInfo);
+typedef void (VKAPI_PTR *PFN_vkCmdReserveSpaceForCommandsNVX)(VkCommandBuffer commandBuffer, const VkCmdReserveSpaceForCommandsInfoNVX* pReserveSpaceInfo);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateIndirectCommandsLayoutNVX)(VkDevice device, const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkIndirectCommandsLayoutNVX* pIndirectCommandsLayout);
+typedef void (VKAPI_PTR *PFN_vkDestroyIndirectCommandsLayoutNVX)(VkDevice device, VkIndirectCommandsLayoutNVX indirectCommandsLayout, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkCreateObjectTableNVX)(VkDevice device, const VkObjectTableCreateInfoNVX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkObjectTableNVX* pObjectTable);
+typedef void (VKAPI_PTR *PFN_vkDestroyObjectTableNVX)(VkDevice device, VkObjectTableNVX objectTable, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkRegisterObjectsNVX)(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, const VkObjectTableEntryNVX* const* ppObjectTableEntries, const uint32_t* pObjectIndices);
+typedef VkResult (VKAPI_PTR *PFN_vkUnregisterObjectsNVX)(VkDevice device, VkObjectTableNVX objectTable, uint32_t objectCount, const VkObjectEntryTypeNVX* pObjectEntryTypes, const uint32_t* pObjectIndices);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX)(VkPhysicalDevice physicalDevice, VkDeviceGeneratedCommandsFeaturesNVX* pFeatures, VkDeviceGeneratedCommandsLimitsNVX* pLimits);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkCmdProcessCommandsNVX(
+ VkCommandBuffer commandBuffer,
+ const VkCmdProcessCommandsInfoNVX* pProcessCommandsInfo);
+
+VKAPI_ATTR void VKAPI_CALL vkCmdReserveSpaceForCommandsNVX(
+ VkCommandBuffer commandBuffer,
+ const VkCmdReserveSpaceForCommandsInfoNVX* pReserveSpaceInfo);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateIndirectCommandsLayoutNVX(
+ VkDevice device,
+ const VkIndirectCommandsLayoutCreateInfoNVX* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkIndirectCommandsLayoutNVX* pIndirectCommandsLayout);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNVX(
+ VkDevice device,
+ VkIndirectCommandsLayoutNVX indirectCommandsLayout,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateObjectTableNVX(
+ VkDevice device,
+ const VkObjectTableCreateInfoNVX* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkObjectTableNVX* pObjectTable);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyObjectTableNVX(
+ VkDevice device,
+ VkObjectTableNVX objectTable,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkRegisterObjectsNVX(
+ VkDevice device,
+ VkObjectTableNVX objectTable,
+ uint32_t objectCount,
+ const VkObjectTableEntryNVX* const* ppObjectTableEntries,
+ const uint32_t* pObjectIndices);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkUnregisterObjectsNVX(
+ VkDevice device,
+ VkObjectTableNVX objectTable,
+ uint32_t objectCount,
+ const VkObjectEntryTypeNVX* pObjectEntryTypes,
+ const uint32_t* pObjectIndices);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceGeneratedCommandsPropertiesNVX(
+ VkPhysicalDevice physicalDevice,
+ VkDeviceGeneratedCommandsFeaturesNVX* pFeatures,
+ VkDeviceGeneratedCommandsLimitsNVX* pLimits);
+#endif
+
+#define VK_NV_clip_space_w_scaling 1
+#define VK_NV_CLIP_SPACE_W_SCALING_SPEC_VERSION 1
+#define VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME "VK_NV_clip_space_w_scaling"
+
+typedef struct VkViewportWScalingNV {
+ float xcoeff;
+ float ycoeff;
+} VkViewportWScalingNV;
+
+typedef struct VkPipelineViewportWScalingStateCreateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkBool32 viewportWScalingEnable;
+ uint32_t viewportCount;
+ const VkViewportWScalingNV* pViewportWScalings;
+} VkPipelineViewportWScalingStateCreateInfoNV;
+
+
+typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWScalingNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewportWScalingNV* pViewportWScalings);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWScalingNV(
+ VkCommandBuffer commandBuffer,
+ uint32_t firstViewport,
+ uint32_t viewportCount,
+ const VkViewportWScalingNV* pViewportWScalings);
+#endif
+
+#define VK_EXT_direct_mode_display 1
+#define VK_EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION 1
+#define VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME "VK_EXT_direct_mode_display"
+
+typedef VkResult (VKAPI_PTR *PFN_vkReleaseDisplayEXT)(VkPhysicalDevice physicalDevice, VkDisplayKHR display);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkReleaseDisplayEXT(
+ VkPhysicalDevice physicalDevice,
+ VkDisplayKHR display);
+#endif
+
+#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT
+#define VK_EXT_acquire_xlib_display 1
+#include <X11/extensions/Xrandr.h>
+
+#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1
+#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display"
+
+typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display);
+typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT(
+ VkPhysicalDevice physicalDevice,
+ Display* dpy,
+ VkDisplayKHR display);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT(
+ VkPhysicalDevice physicalDevice,
+ Display* dpy,
+ RROutput rrOutput,
+ VkDisplayKHR* pDisplay);
+#endif
+#endif /* VK_USE_PLATFORM_XLIB_XRANDR_EXT */
+
+#define VK_EXT_display_surface_counter 1
+#define VK_EXT_DISPLAY_SURFACE_COUNTER_SPEC_VERSION 1
+#define VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME "VK_EXT_display_surface_counter"
+#define VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES2_EXT VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT
+
+
+typedef enum VkSurfaceCounterFlagBitsEXT {
+ VK_SURFACE_COUNTER_VBLANK_EXT = 0x00000001,
+ VK_SURFACE_COUNTER_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkSurfaceCounterFlagBitsEXT;
+typedef VkFlags VkSurfaceCounterFlagsEXT;
+
+typedef struct VkSurfaceCapabilities2EXT {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t minImageCount;
+ uint32_t maxImageCount;
+ VkExtent2D currentExtent;
+ VkExtent2D minImageExtent;
+ VkExtent2D maxImageExtent;
+ uint32_t maxImageArrayLayers;
+ VkSurfaceTransformFlagsKHR supportedTransforms;
+ VkSurfaceTransformFlagBitsKHR currentTransform;
+ VkCompositeAlphaFlagsKHR supportedCompositeAlpha;
+ VkImageUsageFlags supportedUsageFlags;
+ VkSurfaceCounterFlagsEXT supportedSurfaceCounters;
+} VkSurfaceCapabilities2EXT;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT* pSurfaceCapabilities);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2EXT(
+ VkPhysicalDevice physicalDevice,
+ VkSurfaceKHR surface,
+ VkSurfaceCapabilities2EXT* pSurfaceCapabilities);
+#endif
+
+#define VK_EXT_display_control 1
+#define VK_EXT_DISPLAY_CONTROL_SPEC_VERSION 1
+#define VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME "VK_EXT_display_control"
+
+
+typedef enum VkDisplayPowerStateEXT {
+ VK_DISPLAY_POWER_STATE_OFF_EXT = 0,
+ VK_DISPLAY_POWER_STATE_SUSPEND_EXT = 1,
+ VK_DISPLAY_POWER_STATE_ON_EXT = 2,
+ VK_DISPLAY_POWER_STATE_BEGIN_RANGE_EXT = VK_DISPLAY_POWER_STATE_OFF_EXT,
+ VK_DISPLAY_POWER_STATE_END_RANGE_EXT = VK_DISPLAY_POWER_STATE_ON_EXT,
+ VK_DISPLAY_POWER_STATE_RANGE_SIZE_EXT = (VK_DISPLAY_POWER_STATE_ON_EXT - VK_DISPLAY_POWER_STATE_OFF_EXT + 1),
+ VK_DISPLAY_POWER_STATE_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkDisplayPowerStateEXT;
+
+typedef enum VkDeviceEventTypeEXT {
+ VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT = 0,
+ VK_DEVICE_EVENT_TYPE_BEGIN_RANGE_EXT = VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT,
+ VK_DEVICE_EVENT_TYPE_END_RANGE_EXT = VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT,
+ VK_DEVICE_EVENT_TYPE_RANGE_SIZE_EXT = (VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT - VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT + 1),
+ VK_DEVICE_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkDeviceEventTypeEXT;
+
+typedef enum VkDisplayEventTypeEXT {
+ VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT = 0,
+ VK_DISPLAY_EVENT_TYPE_BEGIN_RANGE_EXT = VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT,
+ VK_DISPLAY_EVENT_TYPE_END_RANGE_EXT = VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT,
+ VK_DISPLAY_EVENT_TYPE_RANGE_SIZE_EXT = (VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT - VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT + 1),
+ VK_DISPLAY_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkDisplayEventTypeEXT;
+
+typedef struct VkDisplayPowerInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkDisplayPowerStateEXT powerState;
+} VkDisplayPowerInfoEXT;
+
+typedef struct VkDeviceEventInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkDeviceEventTypeEXT deviceEvent;
+} VkDeviceEventInfoEXT;
+
+typedef struct VkDisplayEventInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkDisplayEventTypeEXT displayEvent;
+} VkDisplayEventInfoEXT;
+
+typedef struct VkSwapchainCounterCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkSurfaceCounterFlagsEXT surfaceCounters;
+} VkSwapchainCounterCreateInfoEXT;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkDisplayPowerControlEXT)(VkDevice device, VkDisplayKHR display, const VkDisplayPowerInfoEXT* pDisplayPowerInfo);
+typedef VkResult (VKAPI_PTR *PFN_vkRegisterDeviceEventEXT)(VkDevice device, const VkDeviceEventInfoEXT* pDeviceEventInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence);
+typedef VkResult (VKAPI_PTR *PFN_vkRegisterDisplayEventEXT)(VkDevice device, VkDisplayKHR display, const VkDisplayEventInfoEXT* pDisplayEventInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence);
+typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainCounterEXT)(VkDevice device, VkSwapchainKHR swapchain, VkSurfaceCounterFlagBitsEXT counter, uint64_t* pCounterValue);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkDisplayPowerControlEXT(
+ VkDevice device,
+ VkDisplayKHR display,
+ const VkDisplayPowerInfoEXT* pDisplayPowerInfo);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkRegisterDeviceEventEXT(
+ VkDevice device,
+ const VkDeviceEventInfoEXT* pDeviceEventInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkFence* pFence);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkRegisterDisplayEventEXT(
+ VkDevice device,
+ VkDisplayKHR display,
+ const VkDisplayEventInfoEXT* pDisplayEventInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkFence* pFence);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainCounterEXT(
+ VkDevice device,
+ VkSwapchainKHR swapchain,
+ VkSurfaceCounterFlagBitsEXT counter,
+ uint64_t* pCounterValue);
+#endif
+
+#define VK_GOOGLE_display_timing 1
+#define VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION 1
+#define VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME "VK_GOOGLE_display_timing"
+
+typedef struct VkRefreshCycleDurationGOOGLE {
+ uint64_t refreshDuration;
+} VkRefreshCycleDurationGOOGLE;
+
+typedef struct VkPastPresentationTimingGOOGLE {
+ uint32_t presentID;
+ uint64_t desiredPresentTime;
+ uint64_t actualPresentTime;
+ uint64_t earliestPresentTime;
+ uint64_t presentMargin;
+} VkPastPresentationTimingGOOGLE;
+
+typedef struct VkPresentTimeGOOGLE {
+ uint32_t presentID;
+ uint64_t desiredPresentTime;
+} VkPresentTimeGOOGLE;
+
+typedef struct VkPresentTimesInfoGOOGLE {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t swapchainCount;
+ const VkPresentTimeGOOGLE* pTimes;
+} VkPresentTimesInfoGOOGLE;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetRefreshCycleDurationGOOGLE)(VkDevice device, VkSwapchainKHR swapchain, VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties);
+typedef VkResult (VKAPI_PTR *PFN_vkGetPastPresentationTimingGOOGLE)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pPresentationTimingCount, VkPastPresentationTimingGOOGLE* pPresentationTimings);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkGetRefreshCycleDurationGOOGLE(
+ VkDevice device,
+ VkSwapchainKHR swapchain,
+ VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetPastPresentationTimingGOOGLE(
+ VkDevice device,
+ VkSwapchainKHR swapchain,
+ uint32_t* pPresentationTimingCount,
+ VkPastPresentationTimingGOOGLE* pPresentationTimings);
+#endif
+
+#define VK_NV_sample_mask_override_coverage 1
+#define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION 1
+#define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME "VK_NV_sample_mask_override_coverage"
+
+
+#define VK_NV_geometry_shader_passthrough 1
+#define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_SPEC_VERSION 1
+#define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME "VK_NV_geometry_shader_passthrough"
+
+
+#define VK_NV_viewport_array2 1
+#define VK_NV_VIEWPORT_ARRAY2_SPEC_VERSION 1
+#define VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME "VK_NV_viewport_array2"
+
+
+#define VK_NVX_multiview_per_view_attributes 1
+#define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_SPEC_VERSION 1
+#define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_EXTENSION_NAME "VK_NVX_multiview_per_view_attributes"
+
+typedef struct VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 perViewPositionAllComponents;
+} VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX;
+
+
+
+#define VK_NV_viewport_swizzle 1
+#define VK_NV_VIEWPORT_SWIZZLE_SPEC_VERSION 1
+#define VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME "VK_NV_viewport_swizzle"
+
+
+typedef enum VkViewportCoordinateSwizzleNV {
+ VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV = 0,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_X_NV = 1,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Y_NV = 2,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Y_NV = 3,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Z_NV = 4,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Z_NV = 5,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_W_NV = 6,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV = 7,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_BEGIN_RANGE_NV = VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_END_RANGE_NV = VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV,
+ VK_VIEWPORT_COORDINATE_SWIZZLE_RANGE_SIZE_NV = (VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV - VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV + 1),
+ VK_VIEWPORT_COORDINATE_SWIZZLE_MAX_ENUM_NV = 0x7FFFFFFF
+} VkViewportCoordinateSwizzleNV;
+
+typedef VkFlags VkPipelineViewportSwizzleStateCreateFlagsNV;
+
+typedef struct VkViewportSwizzleNV {
+ VkViewportCoordinateSwizzleNV x;
+ VkViewportCoordinateSwizzleNV y;
+ VkViewportCoordinateSwizzleNV z;
+ VkViewportCoordinateSwizzleNV w;
+} VkViewportSwizzleNV;
+
+typedef struct VkPipelineViewportSwizzleStateCreateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineViewportSwizzleStateCreateFlagsNV flags;
+ uint32_t viewportCount;
+ const VkViewportSwizzleNV* pViewportSwizzles;
+} VkPipelineViewportSwizzleStateCreateInfoNV;
+
+
+
+#define VK_EXT_discard_rectangles 1
+#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 1
+#define VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME "VK_EXT_discard_rectangles"
+
+
+typedef enum VkDiscardRectangleModeEXT {
+ VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT = 0,
+ VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT = 1,
+ VK_DISCARD_RECTANGLE_MODE_BEGIN_RANGE_EXT = VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT,
+ VK_DISCARD_RECTANGLE_MODE_END_RANGE_EXT = VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT,
+ VK_DISCARD_RECTANGLE_MODE_RANGE_SIZE_EXT = (VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT - VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT + 1),
+ VK_DISCARD_RECTANGLE_MODE_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkDiscardRectangleModeEXT;
+
+typedef VkFlags VkPipelineDiscardRectangleStateCreateFlagsEXT;
+
+typedef struct VkPhysicalDeviceDiscardRectanglePropertiesEXT {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t maxDiscardRectangles;
+} VkPhysicalDeviceDiscardRectanglePropertiesEXT;
+
+typedef struct VkPipelineDiscardRectangleStateCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineDiscardRectangleStateCreateFlagsEXT flags;
+ VkDiscardRectangleModeEXT discardRectangleMode;
+ uint32_t discardRectangleCount;
+ const VkRect2D* pDiscardRectangles;
+} VkPipelineDiscardRectangleStateCreateInfoEXT;
+
+
+typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEXT)(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEXT(
+ VkCommandBuffer commandBuffer,
+ uint32_t firstDiscardRectangle,
+ uint32_t discardRectangleCount,
+ const VkRect2D* pDiscardRectangles);
+#endif
+
+#define VK_EXT_swapchain_colorspace 1
+#define VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION 3
+#define VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME "VK_EXT_swapchain_colorspace"
+
+
+#define VK_EXT_hdr_metadata 1
+#define VK_EXT_HDR_METADATA_SPEC_VERSION 1
+#define VK_EXT_HDR_METADATA_EXTENSION_NAME "VK_EXT_hdr_metadata"
+
+typedef struct VkXYColorEXT {
+ float x;
+ float y;
+} VkXYColorEXT;
+
+typedef struct VkHdrMetadataEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkXYColorEXT displayPrimaryRed;
+ VkXYColorEXT displayPrimaryGreen;
+ VkXYColorEXT displayPrimaryBlue;
+ VkXYColorEXT whitePoint;
+ float maxLuminance;
+ float minLuminance;
+ float maxContentLightLevel;
+ float maxFrameAverageLightLevel;
+} VkHdrMetadataEXT;
+
+
+typedef void (VKAPI_PTR *PFN_vkSetHdrMetadataEXT)(VkDevice device, uint32_t swapchainCount, const VkSwapchainKHR* pSwapchains, const VkHdrMetadataEXT* pMetadata);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkSetHdrMetadataEXT(
+ VkDevice device,
+ uint32_t swapchainCount,
+ const VkSwapchainKHR* pSwapchains,
+ const VkHdrMetadataEXT* pMetadata);
+#endif
+
+#ifdef VK_USE_PLATFORM_IOS_MVK
+#define VK_MVK_ios_surface 1
+#define VK_MVK_IOS_SURFACE_SPEC_VERSION 2
+#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface"
+
+typedef VkFlags VkIOSSurfaceCreateFlagsMVK;
+
+typedef struct VkIOSSurfaceCreateInfoMVK {
+ VkStructureType sType;
+ const void* pNext;
+ VkIOSSurfaceCreateFlagsMVK flags;
+ const void* pView;
+} VkIOSSurfaceCreateInfoMVK;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK(
+ VkInstance instance,
+ const VkIOSSurfaceCreateInfoMVK* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+#endif
+#endif /* VK_USE_PLATFORM_IOS_MVK */
+
+#ifdef VK_USE_PLATFORM_MACOS_MVK
+#define VK_MVK_macos_surface 1
+#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 2
+#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface"
+
+typedef VkFlags VkMacOSSurfaceCreateFlagsMVK;
+
+typedef struct VkMacOSSurfaceCreateInfoMVK {
+ VkStructureType sType;
+ const void* pNext;
+ VkMacOSSurfaceCreateFlagsMVK flags;
+ const void* pView;
+} VkMacOSSurfaceCreateInfoMVK;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK(
+ VkInstance instance,
+ const VkMacOSSurfaceCreateInfoMVK* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkSurfaceKHR* pSurface);
+#endif
+#endif /* VK_USE_PLATFORM_MACOS_MVK */
+
+#define VK_EXT_sampler_filter_minmax 1
+#define VK_EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION 1
+#define VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME "VK_EXT_sampler_filter_minmax"
+
+
+typedef enum VkSamplerReductionModeEXT {
+ VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT = 0,
+ VK_SAMPLER_REDUCTION_MODE_MIN_EXT = 1,
+ VK_SAMPLER_REDUCTION_MODE_MAX_EXT = 2,
+ VK_SAMPLER_REDUCTION_MODE_BEGIN_RANGE_EXT = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT,
+ VK_SAMPLER_REDUCTION_MODE_END_RANGE_EXT = VK_SAMPLER_REDUCTION_MODE_MAX_EXT,
+ VK_SAMPLER_REDUCTION_MODE_RANGE_SIZE_EXT = (VK_SAMPLER_REDUCTION_MODE_MAX_EXT - VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT + 1),
+ VK_SAMPLER_REDUCTION_MODE_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkSamplerReductionModeEXT;
+
+typedef struct VkSamplerReductionModeCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkSamplerReductionModeEXT reductionMode;
+} VkSamplerReductionModeCreateInfoEXT;
+
+typedef struct VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 filterMinmaxSingleComponentFormats;
+ VkBool32 filterMinmaxImageComponentMapping;
+} VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT;
+
+
+
+#define VK_AMD_gpu_shader_int16 1
+#define VK_AMD_GPU_SHADER_INT16_SPEC_VERSION 1
+#define VK_AMD_GPU_SHADER_INT16_EXTENSION_NAME "VK_AMD_gpu_shader_int16"
+
+
+#define VK_AMD_mixed_attachment_samples 1
+#define VK_AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION 1
+#define VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME "VK_AMD_mixed_attachment_samples"
+
+
+#define VK_AMD_shader_fragment_mask 1
+#define VK_AMD_SHADER_FRAGMENT_MASK_SPEC_VERSION 1
+#define VK_AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME "VK_AMD_shader_fragment_mask"
+
+
+#define VK_EXT_shader_stencil_export 1
+#define VK_EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION 1
+#define VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME "VK_EXT_shader_stencil_export"
+
+
+#define VK_EXT_sample_locations 1
+#define VK_EXT_SAMPLE_LOCATIONS_SPEC_VERSION 1
+#define VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME "VK_EXT_sample_locations"
+
+typedef struct VkSampleLocationEXT {
+ float x;
+ float y;
+} VkSampleLocationEXT;
+
+typedef struct VkSampleLocationsInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkSampleCountFlagBits sampleLocationsPerPixel;
+ VkExtent2D sampleLocationGridSize;
+ uint32_t sampleLocationsCount;
+ const VkSampleLocationEXT* pSampleLocations;
+} VkSampleLocationsInfoEXT;
+
+typedef struct VkAttachmentSampleLocationsEXT {
+ uint32_t attachmentIndex;
+ VkSampleLocationsInfoEXT sampleLocationsInfo;
+} VkAttachmentSampleLocationsEXT;
+
+typedef struct VkSubpassSampleLocationsEXT {
+ uint32_t subpassIndex;
+ VkSampleLocationsInfoEXT sampleLocationsInfo;
+} VkSubpassSampleLocationsEXT;
+
+typedef struct VkRenderPassSampleLocationsBeginInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ uint32_t attachmentInitialSampleLocationsCount;
+ const VkAttachmentSampleLocationsEXT* pAttachmentInitialSampleLocations;
+ uint32_t postSubpassSampleLocationsCount;
+ const VkSubpassSampleLocationsEXT* pPostSubpassSampleLocations;
+} VkRenderPassSampleLocationsBeginInfoEXT;
+
+typedef struct VkPipelineSampleLocationsStateCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkBool32 sampleLocationsEnable;
+ VkSampleLocationsInfoEXT sampleLocationsInfo;
+} VkPipelineSampleLocationsStateCreateInfoEXT;
+
+typedef struct VkPhysicalDeviceSampleLocationsPropertiesEXT {
+ VkStructureType sType;
+ void* pNext;
+ VkSampleCountFlags sampleLocationSampleCounts;
+ VkExtent2D maxSampleLocationGridSize;
+ float sampleLocationCoordinateRange[2];
+ uint32_t sampleLocationSubPixelBits;
+ VkBool32 variableSampleLocations;
+} VkPhysicalDeviceSampleLocationsPropertiesEXT;
+
+typedef struct VkMultisamplePropertiesEXT {
+ VkStructureType sType;
+ void* pNext;
+ VkExtent2D maxSampleLocationGridSize;
+} VkMultisamplePropertiesEXT;
+
+
+typedef void (VKAPI_PTR *PFN_vkCmdSetSampleLocationsEXT)(VkCommandBuffer commandBuffer, const VkSampleLocationsInfoEXT* pSampleLocationsInfo);
+typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)(VkPhysicalDevice physicalDevice, VkSampleCountFlagBits samples, VkMultisamplePropertiesEXT* pMultisampleProperties);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleLocationsEXT(
+ VkCommandBuffer commandBuffer,
+ const VkSampleLocationsInfoEXT* pSampleLocationsInfo);
+
+VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMultisamplePropertiesEXT(
+ VkPhysicalDevice physicalDevice,
+ VkSampleCountFlagBits samples,
+ VkMultisamplePropertiesEXT* pMultisampleProperties);
+#endif
+
+#define VK_EXT_blend_operation_advanced 1
+#define VK_EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION 2
+#define VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME "VK_EXT_blend_operation_advanced"
+
+
+typedef enum VkBlendOverlapEXT {
+ VK_BLEND_OVERLAP_UNCORRELATED_EXT = 0,
+ VK_BLEND_OVERLAP_DISJOINT_EXT = 1,
+ VK_BLEND_OVERLAP_CONJOINT_EXT = 2,
+ VK_BLEND_OVERLAP_BEGIN_RANGE_EXT = VK_BLEND_OVERLAP_UNCORRELATED_EXT,
+ VK_BLEND_OVERLAP_END_RANGE_EXT = VK_BLEND_OVERLAP_CONJOINT_EXT,
+ VK_BLEND_OVERLAP_RANGE_SIZE_EXT = (VK_BLEND_OVERLAP_CONJOINT_EXT - VK_BLEND_OVERLAP_UNCORRELATED_EXT + 1),
+ VK_BLEND_OVERLAP_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkBlendOverlapEXT;
+
+typedef struct VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT {
+ VkStructureType sType;
+ void* pNext;
+ VkBool32 advancedBlendCoherentOperations;
+} VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT;
+
+typedef struct VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT {
+ VkStructureType sType;
+ void* pNext;
+ uint32_t advancedBlendMaxColorAttachments;
+ VkBool32 advancedBlendIndependentBlend;
+ VkBool32 advancedBlendNonPremultipliedSrcColor;
+ VkBool32 advancedBlendNonPremultipliedDstColor;
+ VkBool32 advancedBlendCorrelatedOverlap;
+ VkBool32 advancedBlendAllOperations;
+} VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT;
+
+typedef struct VkPipelineColorBlendAdvancedStateCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkBool32 srcPremultiplied;
+ VkBool32 dstPremultiplied;
+ VkBlendOverlapEXT blendOverlap;
+} VkPipelineColorBlendAdvancedStateCreateInfoEXT;
+
+
+
+#define VK_NV_fragment_coverage_to_color 1
+#define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_SPEC_VERSION 1
+#define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_EXTENSION_NAME "VK_NV_fragment_coverage_to_color"
+
+typedef VkFlags VkPipelineCoverageToColorStateCreateFlagsNV;
+
+typedef struct VkPipelineCoverageToColorStateCreateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineCoverageToColorStateCreateFlagsNV flags;
+ VkBool32 coverageToColorEnable;
+ uint32_t coverageToColorLocation;
+} VkPipelineCoverageToColorStateCreateInfoNV;
+
+
+
+#define VK_NV_framebuffer_mixed_samples 1
+#define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION 1
+#define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME "VK_NV_framebuffer_mixed_samples"
+
+
+typedef enum VkCoverageModulationModeNV {
+ VK_COVERAGE_MODULATION_MODE_NONE_NV = 0,
+ VK_COVERAGE_MODULATION_MODE_RGB_NV = 1,
+ VK_COVERAGE_MODULATION_MODE_ALPHA_NV = 2,
+ VK_COVERAGE_MODULATION_MODE_RGBA_NV = 3,
+ VK_COVERAGE_MODULATION_MODE_BEGIN_RANGE_NV = VK_COVERAGE_MODULATION_MODE_NONE_NV,
+ VK_COVERAGE_MODULATION_MODE_END_RANGE_NV = VK_COVERAGE_MODULATION_MODE_RGBA_NV,
+ VK_COVERAGE_MODULATION_MODE_RANGE_SIZE_NV = (VK_COVERAGE_MODULATION_MODE_RGBA_NV - VK_COVERAGE_MODULATION_MODE_NONE_NV + 1),
+ VK_COVERAGE_MODULATION_MODE_MAX_ENUM_NV = 0x7FFFFFFF
+} VkCoverageModulationModeNV;
+
+typedef VkFlags VkPipelineCoverageModulationStateCreateFlagsNV;
+
+typedef struct VkPipelineCoverageModulationStateCreateInfoNV {
+ VkStructureType sType;
+ const void* pNext;
+ VkPipelineCoverageModulationStateCreateFlagsNV flags;
+ VkCoverageModulationModeNV coverageModulationMode;
+ VkBool32 coverageModulationTableEnable;
+ uint32_t coverageModulationTableCount;
+ const float* pCoverageModulationTable;
+} VkPipelineCoverageModulationStateCreateInfoNV;
+
+
+
+#define VK_NV_fill_rectangle 1
+#define VK_NV_FILL_RECTANGLE_SPEC_VERSION 1
+#define VK_NV_FILL_RECTANGLE_EXTENSION_NAME "VK_NV_fill_rectangle"
+
+
+#define VK_EXT_post_depth_coverage 1
+#define VK_EXT_POST_DEPTH_COVERAGE_SPEC_VERSION 1
+#define VK_EXT_POST_DEPTH_COVERAGE_EXTENSION_NAME "VK_EXT_post_depth_coverage"
+
+
+#define VK_EXT_validation_cache 1
+VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkValidationCacheEXT)
+
+#define VK_EXT_VALIDATION_CACHE_SPEC_VERSION 1
+#define VK_EXT_VALIDATION_CACHE_EXTENSION_NAME "VK_EXT_validation_cache"
+
+
+typedef enum VkValidationCacheHeaderVersionEXT {
+ VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT = 1,
+ VK_VALIDATION_CACHE_HEADER_VERSION_BEGIN_RANGE_EXT = VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT,
+ VK_VALIDATION_CACHE_HEADER_VERSION_END_RANGE_EXT = VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT,
+ VK_VALIDATION_CACHE_HEADER_VERSION_RANGE_SIZE_EXT = (VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT - VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT + 1),
+ VK_VALIDATION_CACHE_HEADER_VERSION_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkValidationCacheHeaderVersionEXT;
+
+typedef VkFlags VkValidationCacheCreateFlagsEXT;
+
+typedef struct VkValidationCacheCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkValidationCacheCreateFlagsEXT flags;
+ size_t initialDataSize;
+ const void* pInitialData;
+} VkValidationCacheCreateInfoEXT;
+
+typedef struct VkShaderModuleValidationCacheCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkValidationCacheEXT validationCache;
+} VkShaderModuleValidationCacheCreateInfoEXT;
+
+
+typedef VkResult (VKAPI_PTR *PFN_vkCreateValidationCacheEXT)(VkDevice device, const VkValidationCacheCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkValidationCacheEXT* pValidationCache);
+typedef void (VKAPI_PTR *PFN_vkDestroyValidationCacheEXT)(VkDevice device, VkValidationCacheEXT validationCache, const VkAllocationCallbacks* pAllocator);
+typedef VkResult (VKAPI_PTR *PFN_vkMergeValidationCachesEXT)(VkDevice device, VkValidationCacheEXT dstCache, uint32_t srcCacheCount, const VkValidationCacheEXT* pSrcCaches);
+typedef VkResult (VKAPI_PTR *PFN_vkGetValidationCacheDataEXT)(VkDevice device, VkValidationCacheEXT validationCache, size_t* pDataSize, void* pData);
+
+#ifndef VK_NO_PROTOTYPES
+VKAPI_ATTR VkResult VKAPI_CALL vkCreateValidationCacheEXT(
+ VkDevice device,
+ const VkValidationCacheCreateInfoEXT* pCreateInfo,
+ const VkAllocationCallbacks* pAllocator,
+ VkValidationCacheEXT* pValidationCache);
+
+VKAPI_ATTR void VKAPI_CALL vkDestroyValidationCacheEXT(
+ VkDevice device,
+ VkValidationCacheEXT validationCache,
+ const VkAllocationCallbacks* pAllocator);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkMergeValidationCachesEXT(
+ VkDevice device,
+ VkValidationCacheEXT dstCache,
+ uint32_t srcCacheCount,
+ const VkValidationCacheEXT* pSrcCaches);
+
+VKAPI_ATTR VkResult VKAPI_CALL vkGetValidationCacheDataEXT(
+ VkDevice device,
+ VkValidationCacheEXT validationCache,
+ size_t* pDataSize,
+ void* pData);
+#endif
+
+#define VK_EXT_shader_viewport_index_layer 1
+#define VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_SPEC_VERSION 1
+#define VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME "VK_EXT_shader_viewport_index_layer"
+
+
+#define VK_EXT_global_priority 1
+#define VK_EXT_GLOBAL_PRIORITY_SPEC_VERSION 1
+#define VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME "VK_EXT_global_priority"
+
+
+typedef enum VkQueueGlobalPriorityEXT {
+ VK_QUEUE_GLOBAL_PRIORITY_LOW = 128,
+ VK_QUEUE_GLOBAL_PRIORITY_MEDIUM = 256,
+ VK_QUEUE_GLOBAL_PRIORITY_HIGH = 512,
+ VK_QUEUE_GLOBAL_PRIORITY_REALTIME = 1024,
+ VK_QUEUE_GLOBAL_PRIORITY_BEGIN_RANGE_EXT = VK_QUEUE_GLOBAL_PRIORITY_LOW,
+ VK_QUEUE_GLOBAL_PRIORITY_END_RANGE_EXT = VK_QUEUE_GLOBAL_PRIORITY_REALTIME,
+ VK_QUEUE_GLOBAL_PRIORITY_RANGE_SIZE_EXT = (VK_QUEUE_GLOBAL_PRIORITY_REALTIME - VK_QUEUE_GLOBAL_PRIORITY_LOW + 1),
+ VK_QUEUE_GLOBAL_PRIORITY_MAX_ENUM_EXT = 0x7FFFFFFF
+} VkQueueGlobalPriorityEXT;
+
+typedef struct VkDeviceQueueGlobalPriorityCreateInfoEXT {
+ VkStructureType sType;
+ const void* pNext;
+ VkQueueGlobalPriorityEXT globalPriority;
+} VkDeviceQueueGlobalPriorityCreateInfoEXT;
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif